启动CAD的代码如下所示:
/**
* @brief Set LoRa to CAD mode.
* @note The period of CAD is about 800 us.
* @param wTimeout: the unit is millisecond, 0=don't care.
* @retval Result of invoked.
* -1=Error that radio is busy; 0=Set CAD OK.
*/
int8_t SX1278SetCAD(uint16_t wTimeout)
{
if (RF_IDLE != s_tRadioState)
{
return -1; /* Error: radio is busy! */
}
SX1278SetSwPin2Rx(); /* CAD needs receive signal */
CAD检测完毕后,中断服务程序代码如下:
/**
* @brief Handler for IRQ of DIO_0.
* @note Insure callback functions are SMALL, FAST and SAFE that would been invoked by ISR.
* @param None
* @retval None
*/
void SX1278Dio0IrqHandler(void)
{
uint8_t byRegVal;