本帖最后由 咚了个咚 于 2025-7-24 23:22 编辑
我让STM32F4在一定时间后从从机模式切换为主机模式,作为主机发送消息,然后再切换回从机模式。如果将SPI配置为slave_rxonly并启用SPI,当我将设备重新配置为主机时,会意外地立即发送时钟信号。而我此时并没有发送任何数据。 这是我的主循环。 while (1) { /* USER CODE END WHILE */ /* USER CODE BEGIN 3 */ MX_SPI1_Init(); /* This configures master */ HAL_Delay(10); sendHelloWorld(); configSlave(); /* Configures slave mode */ __HAL_SPI_ENABLE(&hspi1); /* Enabling the device in this mode generates a continous clock during master init */ HAL_Delay(100); HAL_SPI_DeInit(&hspi1); /* Disables SPI and de-initializes the peripheral */ }
|