mirror of
https://github.com/pascallanger/DIY-Multiprotocol-TX-Module.git
synced 2025-07-12 17:57:53 +00:00
Add skeleton for V2x2 receiver
This commit is contained in:
parent
bff68f482e
commit
10d3147b03
@ -20,6 +20,7 @@ const char STR_HUBSAN[] ="Hubsan";
|
||||
const char STR_FRSKYD[] ="FrSky D";
|
||||
const char STR_HISKY[] ="Hisky";
|
||||
const char STR_V2X2[] ="V2x2";
|
||||
const char STR_V2X2_RX[] ="V2x2 RX";
|
||||
const char STR_DSM[] ="DSM";
|
||||
const char STR_DSM_RX[] ="DSM_RX";
|
||||
const char STR_DEVO[] ="Devo";
|
||||
@ -344,6 +345,9 @@ const mm_protocol_definition multi_protocols[] = {
|
||||
#if defined(V2X2_NRF24L01_INO)
|
||||
{PROTO_V2X2, STR_V2X2, 2, STR_SUBTYPE_V2X2, OPTION_NONE },
|
||||
#endif
|
||||
#if defined(V2X2_RX_NRF24L01_INO)
|
||||
{PROTO_V2X2_RX, STR_V2X2_RX, 0, NO_SUBTYPE, OPTION_NONE },
|
||||
#endif
|
||||
#if defined(V761_NRF24L01_INO)
|
||||
{PROTO_V761, STR_V761, 0, NO_SUBTYPE, OPTION_NONE },
|
||||
#endif
|
||||
|
@ -99,6 +99,7 @@ enum PROTOCOLS
|
||||
PROTO_DSM_RX = 70, // =>CYRF6936
|
||||
PROTO_JJRC345 = 71, // =>NRF24L01
|
||||
PROTO_Q90C = 72, // =>NRF24L01 or CC2500
|
||||
PROTO_V2X2_RX = 73, // =>NRF24L01
|
||||
|
||||
PROTO_TEST = 127, // =>CC2500
|
||||
};
|
||||
@ -693,7 +694,8 @@ enum {
|
||||
#define FRSKYX_CLONE_EEPROM_OFFSET 822 // (1) format + (3) TX ID + (47) channels, 51 bytes, end is 873
|
||||
#define FRSKYX2_CLONE_EEPROM_OFFSET 873 // (1) format + (3) TX ID, 4 bytes, end is 877
|
||||
#define DSM_RX_EEPROM_OFFSET 877 // (4) TX ID + format, 5 bytes, end is 882
|
||||
//#define CONFIG_EEPROM_OFFSET 882 // Current configuration of the multimodule
|
||||
#define V2X2_RX_EEPROM_OFFSET 882 // (3) TX ID, 3 bytes, end is 885
|
||||
//#define CONFIG_EEPROM_OFFSET 885 // Current configuration of the multimodule
|
||||
|
||||
//****************************************
|
||||
//*** MULTI protocol serial definition ***
|
||||
@ -784,6 +786,7 @@ Serial: 100000 Baud 8e2 _ xxxx xxxx p --
|
||||
DSM_RX 70
|
||||
JJRC345 71
|
||||
Q90C 72
|
||||
V2X2_RX 73
|
||||
BindBit=> 0x80 1=Bind/0=No
|
||||
AutoBindBit=> 0x40 1=Yes /0=No
|
||||
RangeCheck=> 0x20 1=Yes /0=No
|
||||
|
@ -1554,6 +1554,14 @@ static void protocol_init()
|
||||
remote_callback = Q90C_callback;
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if defined(V2X2_RX_NRF24L01_INO)
|
||||
case PROTO_V2X2_RX:
|
||||
next_callback=initV2X2_Rx();
|
||||
remote_callback = V2X2_Rx_callback;
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if defined(TEST_CC2500_INO)
|
||||
case PROTO_TEST:
|
||||
next_callback=initTEST();
|
||||
|
@ -267,7 +267,7 @@ static void multi_send_status()
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined (FRSKY_RX_TELEMETRY) || defined (AFHDS2A_RX_TELEMETRY) || defined (BAYANG_RX_TELEMETRY) || defined (DSM_RX_CYRF6936_INO)
|
||||
#if defined (FRSKY_RX_TELEMETRY) || defined (AFHDS2A_RX_TELEMETRY) || defined (BAYANG_RX_TELEMETRY) || defined (DSM_RX_CYRF6936_INO) || defined (V2X2_RX_TELEMETRY)
|
||||
void receiver_channels_frame()
|
||||
{
|
||||
uint16_t len = packet_in[3] * 11; // 11 bit per channel
|
||||
@ -939,8 +939,8 @@ void TelemetryUpdate()
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined (FRSKY_RX_TELEMETRY) || defined(AFHDS2A_RX_TELEMETRY) || defined (BAYANG_RX_TELEMETRY) || defined (DSM_RX_CYRF6936_INO)
|
||||
if ((telemetry_link & 1) && (protocol == PROTO_FRSKY_RX || protocol == PROTO_AFHDS2A_RX || protocol == PROTO_BAYANG_RX || protocol == PROTO_DSM_RX) )
|
||||
#if defined (FRSKY_RX_TELEMETRY) || defined(AFHDS2A_RX_TELEMETRY) || defined (BAYANG_RX_TELEMETRY) || defined (DSM_RX_CYRF6936_INO) || defined (V2X2_RX_TELEMETRY)
|
||||
if ((telemetry_link & 1) && (protocol == PROTO_FRSKY_RX || protocol == PROTO_AFHDS2A_RX || protocol == PROTO_BAYANG_RX || protocol == PROTO_DSM_RX) || protocol == PROTO_V2X2_RX )
|
||||
{
|
||||
receiver_channels_frame();
|
||||
telemetry_link &= ~1;
|
||||
|
80
Multiprotocol/V2X2_Rx_nrf24l01.ino
Normal file
80
Multiprotocol/V2X2_Rx_nrf24l01.ino
Normal file
@ -0,0 +1,80 @@
|
||||
/*
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#if defined(V2X2_RX_NRF24L01_INO)
|
||||
|
||||
#define V2X2_RX_PACKET_SIZE 16
|
||||
#define V2X2_RX_RF_BIND_CHANNEL 0x08
|
||||
#define V2X2_RX_RF_NUM_CHANNELS 5
|
||||
|
||||
enum {
|
||||
V2X2_RX_BIND,
|
||||
V2X2_RX_DATA
|
||||
};
|
||||
|
||||
static void __attribute__((unused)) V2X2_Rx_init_nrf24l01()
|
||||
{
|
||||
NRF24L01_Initialize();
|
||||
NRF24L01_WriteReg(NRF24L01_03_SETUP_AW, 0x03); // 5-byte RX/TX address
|
||||
NRF24L01_WriteRegisterMulti(NRF24L01_0B_RX_ADDR_P1, (uint8_t*)"\x66\x88\x68\x68\x68", 5);
|
||||
NRF24L01_FlushRx();
|
||||
NRF24L01_WriteReg(NRF24L01_07_STATUS, 0x70); // Clear data ready, data sent, and retransmit
|
||||
NRF24L01_WriteReg(NRF24L01_01_EN_AA, 0x00); // No Auto Acknowldgement on all data pipes
|
||||
NRF24L01_WriteReg(NRF24L01_02_EN_RXADDR, 0x3F); // Enable all data pipes
|
||||
NRF24L01_WriteReg(NRF24L01_12_RX_PW_P1, V2X2_RX_PACKET_SIZE);
|
||||
NRF24L01_WriteReg(NRF24L01_05_RF_CH, BAYANG_RX_RF_BIND_CHANNEL);
|
||||
NRF24L01_SetBitrate(NRF24L01_BR_1M); // 1Mbps
|
||||
NRF24L01_WriteReg(NRF24L01_07_STATUS, 0x70); // reset registers status
|
||||
NRF24L01_SetTxRxMode(TXRX_OFF);
|
||||
NRF24L01_SetTxRxMode(RX_EN);
|
||||
// switch to RX mode
|
||||
NRF24L01_WriteReg(NRF24L01_00_CONFIG, _BV(NRF24L01_00_EN_CRC) | _BV(NRF24L01_00_CRCO) | _BV(NRF24L01_00_PWR_UP) | _BV(NRF24L01_00_PRIM_RX));
|
||||
}
|
||||
|
||||
static uint8_t __attribute__((unused)) V2X2_Rx_check_validity()
|
||||
{
|
||||
// check transmitter id
|
||||
|
||||
// checksum
|
||||
|
||||
}
|
||||
|
||||
static void __attribute__((unused)) V2X2_Rx_build_telemetry_packet()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
uint16_t initV2X2_Rx()
|
||||
{
|
||||
V2X2_Rx_init_nrf24l01();
|
||||
|
||||
phase = V2X2_RX_BIND;
|
||||
return 1000;
|
||||
}
|
||||
|
||||
uint16_t V2X2_Rx_callback()
|
||||
{
|
||||
switch (phase) {
|
||||
case V2X2_RX_BIND:
|
||||
// V2X2_set_tx_id();
|
||||
break;
|
||||
case V2X2_RX_DATA:
|
||||
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
52
Multiprotocol/V2X2_common.ino
Normal file
52
Multiprotocol/V2X2_common.ino
Normal file
@ -0,0 +1,52 @@
|
||||
/*
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#if defined(V2X2_NRF24L01_INO) || defined(V2X2_RX_NRF24L01_INO)
|
||||
|
||||
// This is frequency hopping table for V202 protocol
|
||||
// The table is the first 4 rows of 32 frequency hopping
|
||||
// patterns, all other rows are derived from the first 4.
|
||||
// For some reason the protocol avoids channels, dividing
|
||||
// by 16 and replaces them by subtracting 3 from the channel
|
||||
// number in this case.
|
||||
// The pattern is defined by 5 least significant bits of
|
||||
// sum of 3 bytes comprising TX id
|
||||
const uint8_t PROGMEM v2x2_freq_hopping[][16] = {
|
||||
{ 0x27, 0x1B, 0x39, 0x28, 0x24, 0x22, 0x2E, 0x36,
|
||||
0x19, 0x21, 0x29, 0x14, 0x1E, 0x12, 0x2D, 0x18 }, // 00
|
||||
{ 0x2E, 0x33, 0x25, 0x38, 0x19, 0x12, 0x18, 0x16,
|
||||
0x2A, 0x1C, 0x1F, 0x37, 0x2F, 0x23, 0x34, 0x10 }, // 01
|
||||
{ 0x11, 0x1A, 0x35, 0x24, 0x28, 0x18, 0x25, 0x2A,
|
||||
0x32, 0x2C, 0x14, 0x27, 0x36, 0x34, 0x1C, 0x17 }, // 02
|
||||
{ 0x22, 0x27, 0x17, 0x39, 0x34, 0x28, 0x2B, 0x1D,
|
||||
0x18, 0x2A, 0x21, 0x38, 0x10, 0x26, 0x20, 0x1F } // 03
|
||||
};
|
||||
|
||||
static void __attribute__((unused)) V2X2_set_tx_id(void)
|
||||
{
|
||||
uint8_t sum;
|
||||
sum = rx_tx_addr[1] + rx_tx_addr[2] + rx_tx_addr[3];
|
||||
// Higher 3 bits define increment to corresponding row
|
||||
uint8_t increment = (sum & 0x1e) >> 2;
|
||||
// Base row is defined by lowest 2 bits
|
||||
sum &= 0x03;
|
||||
for (uint8_t i = 0; i < 16; ++i) {
|
||||
uint8_t val = pgm_read_byte_near(&v2x2_freq_hopping[sum][i]) + increment;
|
||||
// Strange avoidance of channels divisible by 16
|
||||
hopping_frequency[i] = (val & 0x0f) ? val : val - 3;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -59,25 +59,6 @@ enum {
|
||||
V202_DATA//4
|
||||
};
|
||||
|
||||
// This is frequency hopping table for V202 protocol
|
||||
// The table is the first 4 rows of 32 frequency hopping
|
||||
// patterns, all other rows are derived from the first 4.
|
||||
// For some reason the protocol avoids channels, dividing
|
||||
// by 16 and replaces them by subtracting 3 from the channel
|
||||
// number in this case.
|
||||
// The pattern is defined by 5 least significant bits of
|
||||
// sum of 3 bytes comprising TX id
|
||||
const uint8_t PROGMEM freq_hopping[][16] = {
|
||||
{ 0x27, 0x1B, 0x39, 0x28, 0x24, 0x22, 0x2E, 0x36,
|
||||
0x19, 0x21, 0x29, 0x14, 0x1E, 0x12, 0x2D, 0x18 }, // 00
|
||||
{ 0x2E, 0x33, 0x25, 0x38, 0x19, 0x12, 0x18, 0x16,
|
||||
0x2A, 0x1C, 0x1F, 0x37, 0x2F, 0x23, 0x34, 0x10 }, // 01
|
||||
{ 0x11, 0x1A, 0x35, 0x24, 0x28, 0x18, 0x25, 0x2A,
|
||||
0x32, 0x2C, 0x14, 0x27, 0x36, 0x34, 0x1C, 0x17 }, // 02
|
||||
{ 0x22, 0x27, 0x17, 0x39, 0x34, 0x28, 0x2B, 0x1D,
|
||||
0x18, 0x2A, 0x21, 0x38, 0x10, 0x26, 0x20, 0x1F } // 03
|
||||
};
|
||||
|
||||
static void __attribute__((unused)) v202_init()
|
||||
{
|
||||
NRF24L01_Initialize();
|
||||
@ -122,21 +103,6 @@ static void __attribute__((unused)) V202_init2()
|
||||
//Done by TX_EN??? => NRF24L01_WriteReg(NRF24L01_00_CONFIG, _BV(NRF24L01_00_EN_CRC) | _BV(NRF24L01_00_CRCO) | _BV(NRF24L01_00_PWR_UP));
|
||||
}
|
||||
|
||||
static void __attribute__((unused)) V2X2_set_tx_id(void)
|
||||
{
|
||||
uint8_t sum;
|
||||
sum = rx_tx_addr[1] + rx_tx_addr[2] + rx_tx_addr[3];
|
||||
// Higher 3 bits define increment to corresponding row
|
||||
uint8_t increment = (sum & 0x1e) >> 2;
|
||||
// Base row is defined by lowest 2 bits
|
||||
sum &=0x03;
|
||||
for (uint8_t i = 0; i < 16; ++i) {
|
||||
uint8_t val = pgm_read_byte_near(&freq_hopping[sum][i]) + increment;
|
||||
// Strange avoidance of channels divisible by 16
|
||||
hopping_frequency[i] = (val & 0x0f) ? val : val - 3;
|
||||
}
|
||||
}
|
||||
|
||||
static void __attribute__((unused)) V2X2_add_pkt_checksum()
|
||||
{
|
||||
uint8_t sum = 0;
|
||||
|
@ -263,6 +263,7 @@
|
||||
#undef SYMAX_NRF24L01_INO
|
||||
#undef TIGER_NRF24L01_INO
|
||||
#undef V2X2_NRF24L01_INO
|
||||
#undef V2X2_RX_NRF24L01_INO
|
||||
#undef V761_NRF24L01_INO
|
||||
#undef V911S_NRF24L01_INO
|
||||
#undef XK_NRF24L01_INO
|
||||
@ -311,6 +312,8 @@
|
||||
#undef BAYANG_RX_NRF24L01_INO
|
||||
#undef DEVO_HUB_TELEMETRY
|
||||
#undef DSM_RX_CYRF6936_INO
|
||||
#undef V2X2_RX_TELEMETRY
|
||||
#undef V2X2_RX_NRF24L01_INO
|
||||
#else
|
||||
#if defined(MULTI_TELEMETRY) && defined(MULTI_STATUS)
|
||||
#error You should choose either MULTI_TELEMETRY or MULTI_STATUS but not both.
|
||||
@ -331,6 +334,10 @@
|
||||
#undef BAYANG_RX_TELEMETRY
|
||||
#undef BAYANG_RX_NRF24L01_INO
|
||||
#endif
|
||||
#if not defined(V2X2_RX_NRF24L01_INO) || not defined(V2X2_RX_TELEMETRY)
|
||||
#undef V2X2_RX_TELEMETRY
|
||||
#undef V2X2_RX_NRF24L01_INO
|
||||
#endif
|
||||
#if not defined(BAYANG_NRF24L01_INO)
|
||||
#undef BAYANG_HUB_TELEMETRY
|
||||
#endif
|
||||
@ -373,7 +380,7 @@
|
||||
#if not defined(HOTT_CC2500_INO)
|
||||
#undef HOTT_FW_TELEMETRY
|
||||
#endif
|
||||
#if not defined(HOTT_FW_TELEMETRY) && not defined(DSM_TELEMETRY) && not defined(SPORT_TELEMETRY) && not defined(HUB_TELEMETRY) && not defined(HUBSAN_HUB_TELEMETRY) && not defined(BUGS_HUB_TELEMETRY) && not defined(NCC1701_HUB_TELEMETRY) && not defined(BAYANG_HUB_TELEMETRY) && not defined(CABELL_HUB_TELEMETRY) && not defined(AFHDS2A_HUB_TELEMETRY) && not defined(AFHDS2A_FW_TELEMETRY) && not defined(MULTI_TELEMETRY) && not defined(MULTI_STATUS) && not defined(HITEC_HUB_TELEMETRY) && not defined(HITEC_FW_TELEMETRY) && not defined(SCANNER_TELEMETRY) && not defined(FRSKY_RX_TELEMETRY) && not defined(AFHDS2A_RX_TELEMETRY) && not defined(BAYANG_RX_TELEMETRY) && not defined(DEVO_HUB_TELEMETRY)
|
||||
#if not defined(HOTT_FW_TELEMETRY) && not defined(DSM_TELEMETRY) && not defined(SPORT_TELEMETRY) && not defined(HUB_TELEMETRY) && not defined(HUBSAN_HUB_TELEMETRY) && not defined(BUGS_HUB_TELEMETRY) && not defined(NCC1701_HUB_TELEMETRY) && not defined(BAYANG_HUB_TELEMETRY) && not defined(CABELL_HUB_TELEMETRY) && not defined(AFHDS2A_HUB_TELEMETRY) && not defined(AFHDS2A_FW_TELEMETRY) && not defined(MULTI_TELEMETRY) && not defined(MULTI_STATUS) && not defined(HITEC_HUB_TELEMETRY) && not defined(HITEC_FW_TELEMETRY) && not defined(SCANNER_TELEMETRY) && not defined(FRSKY_RX_TELEMETRY) && not defined(AFHDS2A_RX_TELEMETRY) && not defined(BAYANG_RX_TELEMETRY) && not defined(DEVO_HUB_TELEMETRY) && not defined(V2X2_RX_TELEMETRY)
|
||||
#undef TELEMETRY
|
||||
#undef INVERT_TELEMETRY
|
||||
#undef MULTI_TELEMETRY
|
||||
|
@ -227,6 +227,7 @@
|
||||
#define SYMAX_NRF24L01_INO
|
||||
#define TIGER_NRF24L01_INO
|
||||
#define V2X2_NRF24L01_INO
|
||||
#define V2X2_RX_NRF24L01_INO
|
||||
#define V761_NRF24L01_INO
|
||||
#define V911S_NRF24L01_INO
|
||||
#define XK_NRF24L01_INO
|
||||
@ -313,6 +314,7 @@
|
||||
#define AFHDS2A_RX_TELEMETRY // Forward channels data to TX
|
||||
#define HOTT_FW_TELEMETRY // Forward received telemetry packets to be decoded by erskyTX and OpenTX
|
||||
#define BAYANG_RX_TELEMETRY // Forward channels data to TX
|
||||
#define V2X2_RX_TELEMETRY // Forward channels data to TX
|
||||
|
||||
/****************************/
|
||||
/*** SERIAL MODE SETTINGS ***/
|
||||
@ -707,6 +709,8 @@ const PPM_Parameters PPM_prot[14*NBR_BANKS]= {
|
||||
PROTO_V2X2
|
||||
V2X2
|
||||
JXD506
|
||||
PROTO_V2X2_RX
|
||||
NONE
|
||||
PROTO_V761
|
||||
NONE
|
||||
PROTO_V911S
|
||||
|
Loading…
x
Reference in New Issue
Block a user