void rx_init() { uint8_t bbcal[6] = { 0x3f , 0x4c , 0x84 , 0x6F , 0x9c , 0x20 }; writeregs( bbcal , sizeof(bbcal) ); uint8_t rfcal[8] = { 0x3e , 0xc9 , 0x9a , 0x80 , 0x61 , 0xbb , 0xab , 0x9c }; writeregs( rfcal , sizeof(rfcal) ); uint8_t demodcal[6] = { 0x39 , 0x0b , 0xdf , 0xc4 , 0xa7 , 0x03}; writeregs( demodcal , sizeof(demodcal) ); int rxaddress[5] = { 0 , 0 , 0 , 0 , 0 }; xn_writerxaddress( rxaddress); xn_writereg( EN_AA , 0 ); // aa disabled xn_writereg( EN_RXADDR , 1 ); // pipe 0 only xn_writereg( RF_SETUP , B00000001); // lna high current on ( better performance ) xn_writereg( RX_PW_P0 , 15 ); // payload size xn_writereg( SETUP_RETR , 0 ); // no retransmissions ( redundant?) xn_writereg( SETUP_AW , 3 ); // address size (5 bits) xn_command( FLUSH_RX); xn_writereg( RF_CH , 0 ); // bind on channel 0 xn_writereg( 0 , B00001111 ); // power up, crc enabled #ifdef RADIO_CHECK void check_radio(void); check_radio(); #endif }
void rx_init() { // always on (CH_ON) channel set 1 aux[AUXNUMBER - 2] = 1; // always off (CH_OFF) channel set 0 aux[AUXNUMBER - 1] = 0; #ifdef AUX1_START_ON aux[CH_AUX1] = 1; #endif #ifdef RADIO_XN297L #define XN_TO_RX B10001111 #define XN_TO_TX B10000010 #define XN_POWER B00111111 #endif #ifdef RADIO_XN297 static uint8_t bbcal[6] = { 0x3f , 0x4c , 0x84 , 0x6F , 0x9c , 0x20 }; writeregs( bbcal , sizeof(bbcal) ); // new values static uint8_t rfcal[8] = { 0x3e , 0xc9 , 0x9a , 0xA0 , 0x61 , 0xbb , 0xab , 0x9c }; writeregs( rfcal , sizeof(rfcal) ); static uint8_t demodcal[6] = { 0x39 , 0x0b , 0xdf , 0xc4 , 0xa7 , 0x03}; writeregs( demodcal , sizeof(demodcal) ); #define XN_TO_RX B00001111 #define XN_TO_TX B00000010 #define XN_POWER B00000111 #endif bleinit(); delay(100); int rxaddress[5] = { 0 , 0 , 0 , 0 , 0 }; xn_writerxaddress( rxaddress); xn_writereg( EN_AA , 0 ); // aa disabled xn_writereg( EN_RXADDR , 1 ); // pipe 0 only xn_writereg( RF_SETUP , XN_POWER); // lna high current on ( better performance ) xn_writereg( RX_PW_P0 , 15 ); // payload size xn_writereg( SETUP_RETR , 0 ); // no retransmissions ( redundant?) xn_writereg( SETUP_AW , 3 ); // address size (5 bits) xn_command( FLUSH_RX); xn_writereg( RF_CH , 0 ); // bind on channel 0 // set above // xn_writereg( 29 , 32); // feture reg , CE mode (software controlled) #ifdef RADIO_XN297L xn_writereg( 0x1d, B00111000 ); // 64 bit payload , software ce spi_cson(); spi_sendbyte( 0xFD); // internal CE high command spi_sendbyte( 0); // required for above spi_csoff(); #endif #ifdef RADIO_XN297 xn_writereg( 0x1d, B00011000 ); // 64 bit payload , software ce #endif xn_writereg( 0 , XN_TO_RX ); // power up, crc enabled, rx mode #ifdef RADIO_CHECK void check_radio(void); check_radio(); #endif }