diff --git a/Multiprotocol/Multi_Names.ino b/Multiprotocol/Multi_Names.ino index 601d866..87e0477 100644 --- a/Multiprotocol/Multi_Names.ino +++ b/Multiprotocol/Multi_Names.ino @@ -91,7 +91,7 @@ const char STR_RLINK[] ="RadLink"; const char STR_REALACC[] ="Realacc"; const char STR_OMP[] ="OMP"; const char STR_TEST[] ="Test"; -const char STR_FAKE[] ="Fake"; +const char STR_NANORF[] ="NanoRF"; const char STR_SUBTYPE_FLYSKY[] = "\x04""Std\0""V9x9""V6x6""V912""CX20"; const char STR_SUBTYPE_HUBSAN[] = "\x04""H107""H301""H501"; @@ -112,7 +112,7 @@ const char STR_SUBTYPE_MT99[] = "\x06""MT99\0 ""H7\0 ""YZ\0 ""LS\0 " const char STR_SUBTYPE_MJXQ[] = "\x07""WLH08\0 ""X600\0 ""X800\0 ""H26D\0 ""E010\0 ""H26WH\0 ""Phoenix"; const char STR_SUBTYPE_FY326[] = "\x05""Std\0 ""FY319"; const char STR_SUBTYPE_HONTAI[] = "\x07""Std\0 ""JJRC X1""X5C1\0 ""FQ_951"; -const char STR_SUBTYPE_AFHDS2A[] = "\x08""PWM,IBUS""PPM,IBUS""PWM,SBUS""PPM,SBUS""PWM,IB16""PPM,IB16";"PWM,SB16""PPM,SB16" +const char STR_SUBTYPE_AFHDS2A[] = "\x08""PWM,IBUS""PPM,IBUS""PWM,SBUS""PPM,SBUS""PWM,IB16""PPM,IB16""PWM,SB16""PPM,SB16"; const char STR_SUBTYPE_Q2X2[] = "\x04""Q222""Q242""Q282"; const char STR_SUBTYPE_WK2x01[] = "\x06""WK2801""WK2401""W6_5_1""W6_6_1""W6_HeL""W6_HeI"; const char STR_SUBTYPE_Q303[] = "\x06""Std\0 ""CX35\0 ""CX10D\0""CX10WD"; @@ -392,8 +392,8 @@ const mm_protocol_definition multi_protocols[] = { #if defined(TEST_CC2500_INO) {PROTO_TEST, STR_TEST, 0, NO_SUBTYPE, OPTION_RFTUNE }, #endif - #if defined(FAKE_NRF24L01_INO) - {PROTO_FAKE, STR_FAKE, 0, NO_SUBTYPE, OPTION_NONE }, + #if defined(NANORF_NRF24L01_INO) + {PROTO_NANORF, STR_NANORF, 0, NO_SUBTYPE, OPTION_NONE }, #endif {0x00, nullptr, 0, nullptr, 0 } }; diff --git a/Multiprotocol/Multiprotocol.h b/Multiprotocol/Multiprotocol.h index efde24e..b5ed659 100644 --- a/Multiprotocol/Multiprotocol.h +++ b/Multiprotocol/Multiprotocol.h @@ -19,7 +19,7 @@ #define VERSION_MAJOR 1 #define VERSION_MINOR 3 #define VERSION_REVISION 1 -#define VERSION_PATCH_LEVEL 62 +#define VERSION_PATCH_LEVEL 63 //****************** // Protocols @@ -104,7 +104,7 @@ enum PROTOCOLS PROTO_REALACC = 76, // =>NRF24L01 PROTO_OMP = 77, // =>NRF24L01 - PROTO_FAKE = 126, // =>CC2500+NRF24L01 + PROTO_NANORF = 126, // =>NRF24L01 PROTO_TEST = 127, // =>CC2500 }; diff --git a/Multiprotocol/Multiprotocol.ino b/Multiprotocol/Multiprotocol.ino index 793d058..8f6ab06 100644 --- a/Multiprotocol/Multiprotocol.ino +++ b/Multiprotocol/Multiprotocol.ino @@ -1651,10 +1651,10 @@ static void protocol_init() remote_callback = TEST_callback; break; #endif - #if defined(FAKE_NRF24L01_INO) - case PROTO_FAKE: - next_callback=initFAKE(); - remote_callback = FAKE_callback; + #if defined(NANORF_NRF24L01_INO) + case PROTO_NANORF: + next_callback=initNANORF(); + remote_callback = NANORF_callback; break; #endif #endif diff --git a/Multiprotocol/NanoRF_nrf24l01.ino b/Multiprotocol/NanoRF_nrf24l01.ino new file mode 100644 index 0000000..4005a9f --- /dev/null +++ b/Multiprotocol/NanoRF_nrf24l01.ino @@ -0,0 +1,73 @@ +/* + This project is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Multiprotocol is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Multiprotocol. If not, see . + */ + +#if defined(NANORF_NRF24L01_INO) + +#include "iface_nrf24l01.h" + +#define NANORF_PACKET_PERIOD 40000 +#define NANORF_INITIAL_WAIT 500 +#define NANORF_RF_CHANNEL 40 +#define NANORF_PAYLOADSIZE 7 + +static void __attribute__((unused)) NANORF_send_packet() +{ + packet[0] = convert_channel_8b(AILERON); + packet[1] = convert_channel_8b(ELEVATOR); + packet[2] = convert_channel_8b(THROTTLE); + packet[3] = convert_channel_8b(RUDDER); + packet[4] = convert_channel_8b(CH5); + packet[5] = convert_channel_8b(CH6); + packet[6] = 0; + for (uint8_t i=0; i < NANORF_PAYLOADSIZE-1; i++) + packet[6] += packet[i]; + packet[6] += 0x55; + + // clear packet status bits and TX FIFO + NRF24L01_WriteReg(NRF24L01_07_STATUS, 0x70); + NRF24L01_FlushTx(); + NRF24L01_WritePayload(packet, NANORF_PAYLOADSIZE); + +} + +static void __attribute__((unused)) NANORF_init() +{ + NRF24L01_Initialize(); + NRF24L01_SetTxRxMode(TX_EN); + NRF24L01_WriteRegisterMulti(NRF24L01_10_TX_ADDR , (uint8_t *)"Nano1",5); + NRF24L01_WriteReg(NRF24L01_01_EN_AA, 0x00); // No Auto Acknoledgement + NRF24L01_WriteReg(NRF24L01_02_EN_RXADDR, 0x01); // Enable all data pipes (even though not used?) + NRF24L01_WriteReg(NRF24L01_03_SETUP_AW, 0x03); // 5-byte RX/TX address + NRF24L01_WriteReg(NRF24L01_04_SETUP_RETR, 0x00); // 4mS retransmit t/o, 15 tries (retries w/o AA?) + NRF24L01_WriteReg(NRF24L01_05_RF_CH, NANORF_RF_CHANNEL); + NRF24L01_SetBitrate(NRF24L01_BR_1M); + NRF24L01_SetPower(); // Set tx_power + NRF24L01_WriteReg(NRF24L01_00_CONFIG, _BV(NRF24L01_00_EN_CRC) | _BV(NRF24L01_00_CRCO) | _BV(NRF24L01_00_PWR_UP)); // +} + +uint16_t NANORF_callback() +{ + NANORF_send_packet(); + return NANORF_PACKET_PERIOD; +} + +uint16_t initNANORF() +{ + BIND_DONE; + NANORF_init(); + return NANORF_INITIAL_WAIT; +} + +#endif