2 This project is free software: you can redistribute it and/or modify
3 it under the terms of the GNU General Public License as published by
4 the Free Software Foundation, either version 3 of the License, or
5 (at your option) any later version.
7 Multiprotocol is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 GNU General Public License for more details.
12 You should have received a copy of the GNU General Public License
13 along with Multiprotocol. If not, see <http://www.gnu.org/licenses/>.
16 #if defined(SHENQI_NRF24L01_INO)
18 #include "iface_nrf24l01.h"
20 const uint8_t PROGMEM SHENQI_Freq[] = {
34 NRF24L01_Initialize();
36 LT8900_Config(4, 8, _BV(LT8900_CRC_ON)|_BV(LT8900_PACKET_LENGTH_EN), 0xAA);
38 LT8900_SetAddress((uint8_t *)"\x9A\x9A\x9A\x9A",4);
39 LT8900_SetTxRxMode(RX_EN);
42 void SHENQI_send_packet()
48 bind_addr[0]=rx_tx_addr[0];
49 bind_addr[1]=rx_tx_addr[1];
52 LT8900_SetAddress(bind_addr,4);
54 packet[1]=rx_tx_addr[2];
55 packet[2]=rx_tx_addr[3];
62 telemetry_set_input_sync(3000+2508+6*1750);
64 LT8900_SetAddress(rx_tx_addr,4);
65 packet[1]=255-convert_channel_8b(RUDDER);
66 packet[2]=255-convert_channel_16b_limit(THROTTLE,0x60,0xA0);
67 uint8_t freq=pgm_read_byte_near(&SHENQI_Freq[hopping_frequency_no])+(rx_tx_addr[2]&0x0F);
68 LT8900_SetChannel(freq);
69 hopping_frequency_no++;
70 if(hopping_frequency_no==60)
71 hopping_frequency_no=0;
74 // Send packet + 1 retransmit - not sure why but needed (not present on original TX...)
75 LT8900_WritePayload(packet,3);
76 while(NRF24L01_packet_ack()!=PKT_ACKED);
77 LT8900_WritePayload(packet,3);
89 uint16_t SHENQI_callback()
97 if( NRF24L01_ReadReg(NRF24L01_07_STATUS) & _BV(NRF24L01_07_RX_DR))
99 if(LT8900_ReadPayload(packet, 3))
102 rx_tx_addr[0]=packet[1];
103 rx_tx_addr[1]=packet[2];
104 LT8900_SetTxRxMode(TX_EN);
110 return packet_period;
115 BIND_IN_PROGRESS; // autobind protocol
117 hopping_frequency_no = 0;