Fixed xn297 scramble mode affecting cx-10a and probably other xn297 based protocols...

This commit is contained in:
pascallanger 2016-04-18 19:43:12 +02:00
parent 4486582006
commit 6d752acb28
2 changed files with 6 additions and 12 deletions

View File

@ -25,7 +25,6 @@
#define Q282_PACKET_SIZE 21 #define Q282_PACKET_SIZE 21
#define CX10_PACKET_PERIOD 1316 // Timeout for callback in uSec #define CX10_PACKET_PERIOD 1316 // Timeout for callback in uSec
#define CX10A_PACKET_PERIOD 6000 #define CX10A_PACKET_PERIOD 6000
#define CX10A_BIND_COUNT 400 // 2 seconds
#define CX10_INITIAL_WAIT 500 #define CX10_INITIAL_WAIT 500
@ -198,12 +197,6 @@ uint16_t CX10_callback()
} }
break; break;
case CX10_BIND2: case CX10_BIND2:
bind_counter--;
if(bind_counter==0)
{ // Needed for some CX-10A to properly finish the bind
CX10_init();
bind_counter=CX10A_BIND_COUNT;
}
if( NRF24L01_ReadReg(NRF24L01_07_STATUS) & BV(NRF24L01_07_RX_DR)) if( NRF24L01_ReadReg(NRF24L01_07_STATUS) & BV(NRF24L01_07_RX_DR))
{ // RX fifo data ready { // RX fifo data ready
XN297_ReadPayload(packet, packet_length); XN297_ReadPayload(packet, packet_length);
@ -211,16 +204,18 @@ uint16_t CX10_callback()
NRF24L01_SetTxRxMode(TX_EN); NRF24L01_SetTxRxMode(TX_EN);
if(packet[9] == 1) if(packet[9] == 1)
{ {
phase = CX10_BIND1; BIND_DONE;
bind_counter=0; phase = CX10_DATA;
} }
} }
else else
{ {
// switch to TX mode
NRF24L01_SetTxRxMode(TXRX_OFF); NRF24L01_SetTxRxMode(TXRX_OFF);
NRF24L01_FlushTx();
NRF24L01_SetTxRxMode(TX_EN); NRF24L01_SetTxRxMode(TX_EN);
CX10_Write_Packet(1); CX10_Write_Packet(1);
_delay_us(1000); _delay_us(400);
// switch to RX mode // switch to RX mode
NRF24L01_SetTxRxMode(TXRX_OFF); NRF24L01_SetTxRxMode(TXRX_OFF);
NRF24L01_FlushRx(); NRF24L01_FlushRx();
@ -270,7 +265,6 @@ uint16_t initCX10(void)
packet_period = CX10A_PACKET_PERIOD; packet_period = CX10A_PACKET_PERIOD;
phase = CX10_BIND2; phase = CX10_BIND2;
bind_counter=CX10A_BIND_COUNT;
for(uint8_t i=0; i<4; i++) for(uint8_t i=0; i<4; i++)
packet[5+i] = 0xff; // clear aircraft id packet[5+i] = 0xff; // clear aircraft id

View File

@ -258,7 +258,7 @@ uint8_t NRF24L01_packet_ack()
/////////////// ///////////////
// XN297 emulation layer // XN297 emulation layer
uint8_t xn297_scramble_enabled; uint8_t xn297_scramble_enabled=1; //enabled by default
uint8_t xn297_addr_len; uint8_t xn297_addr_len;
uint8_t xn297_tx_addr[5]; uint8_t xn297_tx_addr[5];
uint8_t xn297_rx_addr[5]; uint8_t xn297_rx_addr[5];