/** * @brief Issue chip reset command. * @param None * @retval uint8_t : 0(Ok) or CC2500_TIMEOUT_ERROR */ uint8_t CC2500_SRES_CMD(void) { CC2500Timeout = CC2500_FLAG_TIMEOUT; CC2500_WriteCommand(CC2500_COMMAND_SRES, 0); while (GPIO_ReadInputDataBit(CC2500_SPI_MISO_GPIO_PORT, CC2500_SPI_MISO_PIN) == (uint8_t) Bit_SET) { if((CC2500Timeout--) == 0) { return CC2500_TIMEOUT_UserCallback(); } } return 0; }
/** * @brief no operation, used to get chip status. * @param uint8_t ReadWriteFIFOFlag: 1: return RX FIFO available bytes; 0: return TX FIFO available bytes * @retval uint8_t : chip status */ uint8_t CC2500_SNOP_CMD(uint8_t ReadWriteFIFOFlag) { return CC2500_WriteCommand(CC2500_COMMAND_SNOP, ReadWriteFIFOFlag); }
inline void setRF_Main() { char error = 0; char TX = 0; char RX = 0; int command = 0; if (RF1.Enable == true) { //delay time if (RF1.debounce == true) { RF1.Count++; if (RF1.Count >= (RF1.RunTime / Main_Time)) { RF1.Count = (RF1.RunTime / Main_Time); RF1.Count = 0; RF1.debounce = false; } } else { command = RF_getCommand(); switch (command) { case 0: //exit break; case 1: //RX if (RF1.RxStatus == false) { RF1.RxStatus = true; CC2500_WriteCommand(CC2500_SIDLE); // idle CC2500_WriteCommand(CC2500_SFRX); // clear RXFIFO data CC2500_WriteCommand(CC2500_SRX); // set receive mode } else { CC2500_RxData(); if (RF1.ReceiveGO == true) { RF1.ReceiveGO = false; RF1.RxStatus = false; getRxData(); RF1.debounce = true; } } break; case 2: //TX if (RF1.TransceiveGO == true) { RF1.RxStatus = false; // RF1.CorrectionCounter = 0; // RF_RxDisable(); setData(); CC2500_TxData(); RF1.debounce = true; if(RF1.again == false){ RF1.again = true; }else{ RF1.again = false; RF1.TransceiveGO = false; } } break; }; } // if (getBuz_GO() == 0) { // //#if Switch_use == 1 // command = RF_getCommand(); //#else // KeyPress = 0; //#endif // // if (command == 0) { // // if (RF1.TransceiveGO == true) { // // if (RF1.Learn == false) { // RF1.Count++; // if (RF1.Count >= (RF1.RunTime / Main_Time)) { // RF1.Count = (RF1.RunTime / Main_Time); // // RF1.TransceiveGO = false; // RF1.CorrectionCounter = 0; // RF_RxDisable(); // setData(); // CC2500_TxData(); // // // ErrLED = ErrLED == true ? false : true; // // } // } else { // RF1.Count = 0; // RF1.TransceiveGO = false; // } // } else { // if (RF1.RxStatus == true) { //#if Rx_Enable == 1 // CC2500_RxData(); //#endif // if (RF1.ReceiveGO == true) { // RF1.ReceiveGO = false; // RF1.CorrectionCounter = 0; //#if I2C_use == 1 // I2C_SetData(1); // //LED2=~LED2; //#elif UART_use == 1 // //UART_SetData(); // //LED2=~LED2; //#else // getRxData(); // // ErrLED = ErrLED == true ? false : true; //#endif // } // } else { // RF1.Count++; // if (RF1.Count >= (RF1.RunTime / Main_Time)) { // RF1.Count = 0; //#if Rx_Enable == 1 // RF1.RxStatus = true; // CC2500_WriteCommand(CC2500_SIDLE); // idle // CC2500_WriteCommand(CC2500_SFRX); // clear RXFIFO data // CC2500_WriteCommand(CC2500_SRX); // set receive mode //#endif // } // } // } // } // } // RF1.CorrectionCounter++; // if (RF1.CorrectionCounter > (60000 / Main_Time)) { // RF1.CorrectionCounter = 0; // // RF1.RxStatus = false; // RF1.ReceiveGO = false; // CC2500_WriteCommand(CC2500_SIDLE); // idle // // CC2500_WriteCommand(CC2500_SFRX); // clear RXFIFO data // } // // if (RF1.Timeout == true) { // RF1.Timeout = false; // CC2500_PowerOnInitial(); // } } else { if (myMain.PowerON == true) { RF1.Enable = true; RF_Initialization(); CC2500_PowerOnInitial(); } } }