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(NANORF_NRF24L01_INO)
18 #include "iface_nrf24l01.h"
20 #define NANORF_PACKET_PERIOD 40000
21 #define NANORF_INITIAL_WAIT 500
22 #define NANORF_RF_CHANNEL 40
23 #define NANORF_PAYLOADSIZE 7
25 static void __attribute__((unused)) NANORF_send_packet()
27 packet[0] = convert_channel_8b(AILERON);
28 packet[1] = convert_channel_8b(ELEVATOR);
29 packet[2] = convert_channel_8b(THROTTLE);
30 packet[3] = convert_channel_8b(RUDDER);
31 packet[4] = convert_channel_8b(CH5);
32 packet[5] = convert_channel_8b(CH6);
34 for (uint8_t i=0; i < NANORF_PAYLOADSIZE-1; i++)
35 packet[6] += packet[i];
38 // clear packet status bits and TX FIFO
39 NRF24L01_WriteReg(NRF24L01_07_STATUS, 0x70);
41 NRF24L01_WritePayload(packet, NANORF_PAYLOADSIZE);
45 static void __attribute__((unused)) NANORF_RF_init()
47 NRF24L01_Initialize();
49 NRF24L01_WriteRegisterMulti(NRF24L01_10_TX_ADDR , (uint8_t *)"Nano1",5);
50 NRF24L01_WriteReg(NRF24L01_05_RF_CH, NANORF_RF_CHANNEL);
53 uint16_t NANORF_callback()
56 return NANORF_PACKET_PERIOD;