Преглед изворни кода

修复spi的myRadioSpi_rwByte超时操作i

dropLin пре 4 недеља
родитељ
комит
9ea5fbc19c
1 измењених фајлова са 4 додато и 4 уклоњено
  1. 4 4
      radio/myRadio_gpio.c

+ 4 - 4
radio/myRadio_gpio.c

@@ -275,13 +275,13 @@ void myRadio_gpio_init(RADIO_GPIO_CALLBACK cb)
 }
 uint8_t myRadioSpi_rwByte(uint8_t byteToWrite)
 {
-    uint8_t i, temp;
-    temp = 0;   
+    uint16_t i = 0; 
+    uint8_t temp = 0;   
 #if defined(SPI_HARD)
 	while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_TXE) == RESET) //检查指定的SPI标志位设置与否:发送缓存空标志位
     {
         i++;
-        if(i > 200)return 0;
+        if(i > 2000)return 0;
     }			  
 	SPI_I2S_SendData(SPI1, byteToWrite); //通过外设SPIx发送一个数据
 	i=0;
@@ -289,7 +289,7 @@ uint8_t myRadioSpi_rwByte(uint8_t byteToWrite)
 	while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_RXNE) == RESET)//检查指定的SPI标志位设置与否:接受缓存非空标志位
     {
         i++;
-        if(i > 200)return 0;
+        if(i > 2000)return 0;
     }
     /*!< Return the byte read from the SPI bus */
     temp = SPI_I2S_ReceiveData(SPI1);