mirror of
https://github.com/pascallanger/DIY-Multiprotocol-TX-Module.git
synced 2026-01-16 07:13:14 +00:00
More code optimization
This commit is contained in:
@@ -127,10 +127,8 @@ static void __attribute__((unused)) YD717_RF_init()
|
||||
NRF24L01_WriteReg(NRF24L01_04_SETUP_RETR, 0x1A); // 500uS retransmit t/o, 10 tries
|
||||
NRF24L01_WriteReg(NRF24L01_05_RF_CH, YD717_RF_CHANNEL); // Channel 3C
|
||||
|
||||
NRF24L01_Activate(0x73); // Activate feature register
|
||||
NRF24L01_WriteReg(NRF24L01_1C_DYNPD, 0x3F); // Enable dynamic payload length on all pipes
|
||||
NRF24L01_WriteReg(NRF24L01_1D_FEATURE, 0x07); // Set feature bits on
|
||||
NRF24L01_Activate(0x73);
|
||||
|
||||
// for bind packets set address to prearranged value known to receiver
|
||||
uint8_t bind_rx_tx_addr[5];
|
||||
@@ -144,26 +142,24 @@ static void __attribute__((unused)) YD717_RF_init()
|
||||
bind_rx_tx_addr[i] = 0x60 + offset;
|
||||
NRF24L01_WriteRegisterMulti(NRF24L01_10_TX_ADDR, bind_rx_tx_addr, 5);
|
||||
NRF24L01_WriteRegisterMulti(NRF24L01_0A_RX_ADDR_P0, bind_rx_tx_addr, 5);
|
||||
|
||||
NRF24L01_WriteReg(NRF24L01_00_CONFIG, _BV(NRF24L01_00_EN_CRC) | _BV(NRF24L01_00_PWR_UP));
|
||||
}
|
||||
|
||||
uint16_t YD717_callback()
|
||||
{
|
||||
#ifdef MULTI_SYNC
|
||||
telemetry_set_input_sync(YD717_PACKET_PERIOD);
|
||||
#endif
|
||||
if (bind_counter)
|
||||
{
|
||||
bind_counter--;
|
||||
if(bind_counter==0)
|
||||
if(--bind_counter==0)
|
||||
{
|
||||
NRF24L01_WriteRegisterMulti(NRF24L01_10_TX_ADDR, rx_tx_addr, 5); // set address
|
||||
NRF24L01_WriteRegisterMulti(NRF24L01_0A_RX_ADDR_P0, rx_tx_addr, 5);
|
||||
BIND_DONE; // bind complete
|
||||
}
|
||||
}
|
||||
else
|
||||
#ifdef MULTI_SYNC
|
||||
telemetry_set_input_sync(YD717_PACKET_PERIOD);
|
||||
#endif
|
||||
YD717_send_packet();
|
||||
return YD717_PACKET_PERIOD; // Packet every 8ms
|
||||
return YD717_PACKET_PERIOD; // Packet every 8ms
|
||||
}
|
||||
|
||||
void YD717_init()
|
||||
|
||||
Reference in New Issue
Block a user