Răsfoiți Sursa

优化射频操作

dropLin 2 zile în urmă
părinte
comite
581fd1aa84
2 a modificat fișierele cu 17 adăugiri și 5 ștergeri
  1. 13 1
      radio/myRadio.c
  2. 4 4
      radio/myRadio_gpio.c

+ 13 - 1
radio/myRadio.c

@@ -430,6 +430,10 @@ void myRadio_process(void)
     {
         return;
     }
+    if ((Radio.GetOpMode() != MODE_TX) || (Radio.GetOpMode() != MODE_RX) || (Radio.GetOpMode() != MODE_CAD))
+    {
+        return;
+    }
     SX1280ProcessIrqs(); 
 }
 /**
@@ -577,7 +581,15 @@ uint8_t myRadio_getChipType(void)
 }
 int16_t myRadio_getRssi(void)
 {
-    return Radio.GetRssiInst();;
+    if (Radio.GetOpMode() == MODE_RX)
+    {        
+        return Radio.GetRssiInst();
+    }
+    else
+    {
+        return -127;
+    }
+    
 }
 /**
  * @brief 无线发送数据包

+ 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);