#include "SX1231.h" // ======== static fucntion ======== // static void InitMCU (void); /*===================================================== main =====================================================*/ void main (void) { unsigned char rc; InitMCU(); InitSX1212(); #if 1 // to test SPI SpiWriteCfg(REG_SYNCBYTE4, 0x55); if(SpiReadCfg(REG_SYNCBYTE4) != 0x55) { while(1); // something wrong with SPI } SpiWriteCfg(REG_SYNCBYTE4, 0xAA); if(SpiReadCfg(REG_SYNCBYTE4) != 0xAA) { while(1); // something wrong with SPI } SpiWriteCfg(REG_SYNCBYTE4, SYNC_WORD4); if(SpiReadCfg(REG_SYNCBYTE4) != SYNC_WORD4) { while(1); // something wrong with SPI } #endif //..... BuildPacket(0x12); SendRfFrame((unsigned char *)(&RF_Pkt), sizeof(RF_Pkt)); while(1) { ReceiveRfFrame((unsigned char *)(&RF_Pkt), sizeof(RF_Pkt), &rc); if(rc == OK) { //got packet // ... } //... } } /*===================================================== InitMCU =====================================================*/ static void InitMCU (void) { // .... /* Initiate MCU here including clock, IO, ..... */ }