From a1737eab46c0a9712e8d74af758616fc9f8c6791 Mon Sep 17 00:00:00 2001 From: pascallanger Date: Thu, 30 Nov 2023 09:46:18 +0100 Subject: [PATCH 01/10] PELIKAN: new hopping tables --- Multiprotocol/Pelikan_a7105.ino | 45 ++++++++++++++++++++------------- Protocols_Details.md | 2 +- 2 files changed, 28 insertions(+), 19 deletions(-) diff --git a/Multiprotocol/Pelikan_a7105.ino b/Multiprotocol/Pelikan_a7105.ino index 5006cdd..10e0b1e 100644 --- a/Multiprotocol/Pelikan_a7105.ino +++ b/Multiprotocol/Pelikan_a7105.ino @@ -291,9 +291,10 @@ const uint8_t PROGMEM pelikan_lite_hopp[][PELIKAN_NUM_RF_CHAN] = { #endif #ifdef PELIKAN_SCX24_FORCE_HOP const uint8_t PROGMEM pelikan_scx24_hopp[][PELIKAN_NUM_RF_CHAN] = { - { 0x1E,0x32,0x46,0x5A,0x44,0x58,0x2E,0x42,0x56,0x2C,0x40,0x54,0x2A,0x3E,0x52,0x28,0x3C,0x50,0x26,0x3A,0x4E,0x24,0x38,0x4C,0x22,0x36,0x4A,0x20,0x1A }, - { 0x2C,0x44,0x1E,0x52,0x56,0x22,0x3A,0x3E,0x34,0x4C,0x26,0x5A,0x50,0x2A,0x42,0x38,0x2E,0x46,0x20,0x54,0x4A,0x24,0x3C,0x32,0x28,0x40,0x58,0x1B,0x4E }, - { 0x3C,0x4C,0x1E,0x4A,0x5A,0x2C,0x58,0x2A,0x3A,0x56,0x28,0x38,0x26,0x36,0x46,0x34,0x44,0x54,0x42,0x52,0x24,0x50,0x22,0x32,0x4E,0x20,0x40,0x3E,0x17 } +/*TX1*/ { 0x1E,0x32,0x46,0x5A,0x44,0x58,0x2E,0x42,0x56,0x2C,0x40,0x54,0x2A,0x3E,0x52,0x28,0x3C,0x50,0x26,0x3A,0x4E,0x24,0x38,0x4C,0x22,0x36,0x4A,0x20,0x1A }, +/*TX2*/ { 0x2C,0x44,0x1E,0x52,0x56,0x22,0x3A,0x3E,0x34,0x4C,0x26,0x5A,0x50,0x2A,0x42,0x38,0x2E,0x46,0x20,0x54,0x4A,0x24,0x3C,0x32,0x28,0x40,0x58,0x1B,0x4E }, +/*TX3*/ { 0x3C,0x4C,0x1E,0x4A,0x5A,0x2C,0x58,0x2A,0x3A,0x56,0x28,0x38,0x26,0x36,0x46,0x34,0x44,0x54,0x42,0x52,0x24,0x50,0x22,0x32,0x4E,0x20,0x40,0x3E,0x17 }, +/*TX4*/ { 0x46,0x32,0x1E,0x58,0x44,0x5A,0x56,0x42,0x2E,0x54,0x40,0x2C,0x52,0x3E,0x2A,0x50,0x3C,0x28,0x4E,0x3A,0x26,0x4C,0x38,0x24,0x4A,0x36,0x22,0x20,0x1A } }; #endif @@ -346,21 +347,25 @@ void PELIKAN_init() { #if defined(PELIKAN_SCX24_FORCE_HOP) // Hop frequency table - uint8_t num=rx_tx_addr[3] % 0x03; - if(num==1) - {//1 - rx_tx_addr[0]=0x10; // hopping freq TX2 - rx_tx_addr[1]=0x63; // hopping freq TX2 - } - else if(num==2) - {//2 - rx_tx_addr[0]=0x81; // hopping freq Ben - rx_tx_addr[1]=0x63; // hopping freq Ben - } - else - {//0 - rx_tx_addr[0]=0x12; // hopping freq TX1 - rx_tx_addr[1]=0x46; // hopping freq TX1 + uint8_t num=rx_tx_addr[3] & 0x03; + switch(num) + { + case 1: + rx_tx_addr[0]=0x10; // hopping freq TX2 + rx_tx_addr[1]=0x63; // hopping freq TX2 + break; + case 2: + rx_tx_addr[0]=0x81; // hopping freq TX3 + rx_tx_addr[1]=0x63; // hopping freq TX3 + break; + case 3: + rx_tx_addr[0]=0x36; // hopping freq TX4 + rx_tx_addr[1]=0x5C; // hopping freq TX4 + break; + default: + rx_tx_addr[0]=0x12; // hopping freq TX1 + rx_tx_addr[1]=0x46; // hopping freq TX1 + break; } for(uint8_t i=0;i Date: Thu, 30 Nov 2023 09:47:28 +0100 Subject: [PATCH 02/10] Update Losi_cyrf6936.ino --- Multiprotocol/Losi_cyrf6936.ino | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Multiprotocol/Losi_cyrf6936.ino b/Multiprotocol/Losi_cyrf6936.ino index 22aa47a..bb8a4aa 100644 --- a/Multiprotocol/Losi_cyrf6936.ino +++ b/Multiprotocol/Losi_cyrf6936.ino @@ -19,10 +19,6 @@ #define LOSI_FORCE_ID -//const uint8_t PROGMEM LOSI_bind_sop_code[] = {0x62, 0xdf, 0xc1, 0x49, 0xdf, 0xb1, 0xc0, 0x49}; -const uint8_t LOSI_bind_data_code[8] = - { 0xD7, 0xA1, 0x54, 0xB1, 0x5E, 0x89, 0xAE, 0x86 } ; - const uint8_t LOSI_data_code[][8] = { //(Freq-1)%5=0 { 0x83, 0xF7, 0xA8, 0x2D, 0x7A, 0x44, 0x64, 0xD3 }, @@ -69,6 +65,8 @@ const uint8_t LOSI_data_code[][8] = { { 0x07, 0xBD, 0x9F, 0x26, 0xC8, 0x31, 0x0F, 0xB8 }, { 0xEF, 0x03, 0x95, 0x89, 0xB4, 0x71, 0x61, 0x9D }, { 0x40, 0xBA, 0x97, 0xD5, 0x86, 0x4F, 0xCC, 0xD1 } + //Bind + { 0xD7, 0xA1, 0x54, 0xB1, 0x5E, 0x89, 0xAE, 0x86 } ; }; static uint16_t __attribute__((unused)) LOSI_check(uint16_t val) @@ -139,7 +137,7 @@ static void __attribute__((unused)) LOSI_cyrf_init() CYRF_WriteRegister(CYRF_1F_TX_OVERRIDE, 0x04); // No CRC //CYRF_WriteRegister(CYRF_1E_RX_OVERRIDE, 0x14); //CYRF_WriteRegister(CYRF_14_EOP_CTRL, 0x02); - CYRF_ConfigDataCode(LOSI_bind_data_code, 16); // Load bind data code by default + CYRF_ConfigDataCode(&LOSI_data_code[40], 16); // Load bind data code by default } uint16_t LOSI_callback() From 2b69c1184ee3b04327d310ca2efe0e0f3e5608ed Mon Sep 17 00:00:00 2001 From: pascallanger Date: Thu, 30 Nov 2023 12:10:17 +0100 Subject: [PATCH 03/10] Update Losi_cyrf6936.ino --- Multiprotocol/Losi_cyrf6936.ino | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Multiprotocol/Losi_cyrf6936.ino b/Multiprotocol/Losi_cyrf6936.ino index bb8a4aa..7c3abdc 100644 --- a/Multiprotocol/Losi_cyrf6936.ino +++ b/Multiprotocol/Losi_cyrf6936.ino @@ -64,9 +64,9 @@ const uint8_t LOSI_data_code[][8] = { { 0x8C, 0xFA, 0x47, 0x9B, 0x83, 0xA5, 0x66, 0xD0 }, { 0x07, 0xBD, 0x9F, 0x26, 0xC8, 0x31, 0x0F, 0xB8 }, { 0xEF, 0x03, 0x95, 0x89, 0xB4, 0x71, 0x61, 0x9D }, - { 0x40, 0xBA, 0x97, 0xD5, 0x86, 0x4F, 0xCC, 0xD1 } + { 0x40, 0xBA, 0x97, 0xD5, 0x86, 0x4F, 0xCC, 0xD1 }, //Bind - { 0xD7, 0xA1, 0x54, 0xB1, 0x5E, 0x89, 0xAE, 0x86 } ; + { 0xD7, 0xA1, 0x54, 0xB1, 0x5E, 0x89, 0xAE, 0x86 } }; static uint16_t __attribute__((unused)) LOSI_check(uint16_t val) From d419e2b34408de851eeb370d2d6bbc76786ff251 Mon Sep 17 00:00:00 2001 From: pascallanger Date: Thu, 30 Nov 2023 12:15:02 +0100 Subject: [PATCH 04/10] Update Losi_cyrf6936.ino --- Multiprotocol/Losi_cyrf6936.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Multiprotocol/Losi_cyrf6936.ino b/Multiprotocol/Losi_cyrf6936.ino index 7c3abdc..b1f38cf 100644 --- a/Multiprotocol/Losi_cyrf6936.ino +++ b/Multiprotocol/Losi_cyrf6936.ino @@ -137,7 +137,7 @@ static void __attribute__((unused)) LOSI_cyrf_init() CYRF_WriteRegister(CYRF_1F_TX_OVERRIDE, 0x04); // No CRC //CYRF_WriteRegister(CYRF_1E_RX_OVERRIDE, 0x14); //CYRF_WriteRegister(CYRF_14_EOP_CTRL, 0x02); - CYRF_ConfigDataCode(&LOSI_data_code[40], 16); // Load bind data code by default + CYRF_ConfigDataCode(LOSI_data_code[40], 16); // Load bind data code by default } uint16_t LOSI_callback() From 11db967b8a2861bebee39d257b2df0f1e30bcfea Mon Sep 17 00:00:00 2001 From: pascallanger Date: Thu, 30 Nov 2023 16:02:58 +0100 Subject: [PATCH 05/10] LOSI multi ID --- Multiprotocol/Losi_cyrf6936.ino | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Multiprotocol/Losi_cyrf6936.ino b/Multiprotocol/Losi_cyrf6936.ino index b1f38cf..cd9c8a0 100644 --- a/Multiprotocol/Losi_cyrf6936.ino +++ b/Multiprotocol/Losi_cyrf6936.ino @@ -17,7 +17,7 @@ #include "iface_cyrf6936.h" -#define LOSI_FORCE_ID +//#define LOSI_FORCE_ID const uint8_t LOSI_data_code[][8] = { //(Freq-1)%5=0 @@ -152,7 +152,7 @@ uint16_t LOSI_callback() { BIND_DONE; // Load normal data code - CYRF_ConfigDataCode(LOSI_data_code[(((hopping_frequency[0] - 1) % 5) << 3) + num_ch], 16); + CYRF_ConfigDataCode(LOSI_data_code[(((hopping_frequency[0] - 1) % 5) << 3) + ((rx_tx_addr[0] + rx_tx_addr[1] + rx_tx_addr[2]) % 8)], 16); packet_period = 19738; } } @@ -167,6 +167,14 @@ void LOSI_init() CYRF_FindBestChannels(hopping_frequency, 1, 0, 0x07, 0x4F); // 0x07 and 0x4F are unknown limits, this routine resets the CRC Seed to 0 hopping_frequency[0] |= 1; // Only odd channels are used, integrated in CYRF code... + rx_tx_addr[0] = 0x56; + rx_tx_addr[1] = 0x52; + rx_tx_addr[2] = 0x23; + rx_tx_addr[3] = 0x8A; + + crc8 = 0; + crc8 = (uint16_t)LOSI_check(((rx_tx_addr[2]&0x0F) << 8) + rx_tx_addr[3]) >> 12; + #ifdef LOSI_FORCE_ID /* rx_tx_addr[0] = 0x47; @@ -196,6 +204,8 @@ void LOSI_init() //{ 0xC3, 0x0E, 0x01, 0x16, 0x0E, 0x32, 0x06, 0xBA, 0xE0, 0x83, 0x01, 0xFA, 0xAB, 0x3E, 0x8F, 0xAC } // Note: crc8=00..0F and num_ch=00..07 + // num_ch = ((rx_tx_addr[0] + rx_tx_addr[1] + rx_tx_addr[2]) % 8); + // crc8 = (uint16_t)LOSI_check(((rx_tx_addr[2]&0x0F) << 8) + rx_tx_addr[3]) >> 12; #endif CYRF_ConfigRFChannel(hopping_frequency[0]); From 23af33e2149bf8f32bce8d4ca6ff5e2da5aaa359 Mon Sep 17 00:00:00 2001 From: pascallanger Date: Thu, 30 Nov 2023 16:04:43 +0100 Subject: [PATCH 06/10] LOSI multi IDs --- Multiprotocol/Losi_cyrf6936.ino | 5 ----- Multiprotocol/Multiprotocol.h | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/Multiprotocol/Losi_cyrf6936.ino b/Multiprotocol/Losi_cyrf6936.ino index cd9c8a0..2fdb91f 100644 --- a/Multiprotocol/Losi_cyrf6936.ino +++ b/Multiprotocol/Losi_cyrf6936.ino @@ -167,11 +167,6 @@ void LOSI_init() CYRF_FindBestChannels(hopping_frequency, 1, 0, 0x07, 0x4F); // 0x07 and 0x4F are unknown limits, this routine resets the CRC Seed to 0 hopping_frequency[0] |= 1; // Only odd channels are used, integrated in CYRF code... - rx_tx_addr[0] = 0x56; - rx_tx_addr[1] = 0x52; - rx_tx_addr[2] = 0x23; - rx_tx_addr[3] = 0x8A; - crc8 = 0; crc8 = (uint16_t)LOSI_check(((rx_tx_addr[2]&0x0F) << 8) + rx_tx_addr[3]) >> 12; diff --git a/Multiprotocol/Multiprotocol.h b/Multiprotocol/Multiprotocol.h index 8e96fcd..39ccf9f 100644 --- a/Multiprotocol/Multiprotocol.h +++ b/Multiprotocol/Multiprotocol.h @@ -19,7 +19,7 @@ #define VERSION_MAJOR 1 #define VERSION_MINOR 3 #define VERSION_REVISION 3 -#define VERSION_PATCH_LEVEL 39 +#define VERSION_PATCH_LEVEL 40 #define MODE_SERIAL 0 From 61cbe45ce2c1379ea9eba029f9b7235f0adb4f6f Mon Sep 17 00:00:00 2001 From: Ben Lye Date: Thu, 30 Nov 2023 15:17:21 +0000 Subject: [PATCH 07/10] Disabled protocols in Atmega CYRF builds (#911) --- buildroot/bin/build_release_avr_noboot | 1 + buildroot/bin/build_release_avr_optiboot | 1 + 2 files changed, 2 insertions(+) diff --git a/buildroot/bin/build_release_avr_noboot b/buildroot/bin/build_release_avr_noboot index 201db3d..30ea235 100644 --- a/buildroot/bin/build_release_avr_noboot +++ b/buildroot/bin/build_release_avr_noboot @@ -22,6 +22,7 @@ mv build/Multiprotocol.ino.bin ./binaries/mm-avr-usbasp-aetr-CC2500-inv-v$MULTI_ printf "\e[33;1mBuilding mm-avr-usbasp-aetr-CYRF6936-inv-v$MULTI_VERSION.bin\e[0m\n"; opt_disable $ALL_PROTOCOLS; opt_enable $CYRF6936_PROTOCOLS; +opt_disable E01X_CYRF6936_INO LOSI_CYRF6936_INO buildMulti; exitcode=$((exitcode+$?)); mv build/Multiprotocol.ino.bin ./binaries/mm-avr-usbasp-aetr-CYRF6936-inv-v$MULTI_VERSION.bin; diff --git a/buildroot/bin/build_release_avr_optiboot b/buildroot/bin/build_release_avr_optiboot index 039478b..c30804b 100644 --- a/buildroot/bin/build_release_avr_optiboot +++ b/buildroot/bin/build_release_avr_optiboot @@ -22,6 +22,7 @@ mv build/Multiprotocol.ino.bin ./binaries/mm-avr-txflash-aetr-CC2500-inv-v$MULTI printf "\e[33;1mBuilding mm-avr-txflash-aetr-CYRF6936-inv-v$MULTI_VERSION.bin\e[0m\n"; opt_disable $ALL_PROTOCOLS; opt_enable $CYRF6936_PROTOCOLS; +opt_disable E01X_CYRF6936_INO LOSI_CYRF6936_INO buildMulti; exitcode=$((exitcode+$?)); mv build/Multiprotocol.ino.bin ./binaries/mm-avr-txflash-aetr-CYRF6936-inv-v$MULTI_VERSION.bin; From 7da6d52a846608fdf17eedced8c1f8afc479151b Mon Sep 17 00:00:00 2001 From: pascallanger Date: Fri, 1 Dec 2023 10:58:56 +0100 Subject: [PATCH 08/10] CYRF data codes are always 16 Removed useless function argument LOSI now points to the DSM data codes = dependency on DSM --- Multiprotocol/CYRF6936_SPI.ino | 6 +++--- Multiprotocol/DSM.ino | 10 +++++----- Multiprotocol/DSM_Rx_cyrf6936.ino | 6 +++--- Multiprotocol/DSM_cyrf6936.ino | 8 ++++---- Multiprotocol/J6Pro_cyrf6936.ino | 2 +- Multiprotocol/Losi_cyrf6936.ino | 17 +++++++++++------ Multiprotocol/MLINK_cyrf6936.ino | 4 ++-- Multiprotocol/Multiprotocol.h | 2 +- Multiprotocol/Validate.h | 3 +++ Multiprotocol/_Config.h | 2 +- Multiprotocol/iface_cyrf6936.h | 2 +- Protocols_Details.md | 2 -- 12 files changed, 35 insertions(+), 29 deletions(-) diff --git a/Multiprotocol/CYRF6936_SPI.ino b/Multiprotocol/CYRF6936_SPI.ino index 722c787..abef608 100644 --- a/Multiprotocol/CYRF6936_SPI.ino +++ b/Multiprotocol/CYRF6936_SPI.ino @@ -195,11 +195,11 @@ void CYRF_ConfigSOPCode(const uint8_t *sopcodes) CYRF_WriteRegisterMulti(CYRF_22_SOP_CODE, sopcodes, 8); } -void CYRF_ConfigDataCode(const uint8_t *datacodes, uint8_t len) +void CYRF_ConfigDataCode(const uint8_t *datacodes) { //NOTE: This can also be implemented as: - //for(i = 0; i < len; i++) WriteRegister)0x23, datacodes[i]; - CYRF_WriteRegisterMulti(CYRF_23_DATA_CODE, datacodes, len); + //for(i = 0; i < 16; i++) WriteRegister)0x23, datacodes[i]; + CYRF_WriteRegisterMulti(CYRF_23_DATA_CODE, datacodes, 16); } void CYRF_WritePreamble(uint32_t preamble) diff --git a/Multiprotocol/DSM.ino b/Multiprotocol/DSM.ino index 1902ef1..a6edad7 100644 --- a/Multiprotocol/DSM.ino +++ b/Multiprotocol/DSM.ino @@ -65,7 +65,7 @@ const uint8_t PROGMEM DSM_pncodes[5][9][8] = { }, }; -static void __attribute__((unused)) DSM_read_code(uint8_t *buf, uint8_t row, uint8_t col, uint8_t len) +static void __attribute__((unused)) DSM_read_code(uint8_t *buf, uint8_t row, uint8_t col) { for(uint8_t i=0;i> 12; #endif diff --git a/Multiprotocol/MLINK_cyrf6936.ino b/Multiprotocol/MLINK_cyrf6936.ino index cf833e2..3f0d0ef 100644 --- a/Multiprotocol/MLINK_cyrf6936.ino +++ b/Multiprotocol/MLINK_cyrf6936.ino @@ -421,7 +421,7 @@ uint16_t MLINK_callback() case MLINK_PREP_DATA: - CYRF_ConfigDataCode(MLINK_Data_Code,16); + CYRF_ConfigDataCode(MLINK_Data_Code); MLINK_CRC_Init += 0xED; hopping_frequency_no = 0x00; CYRF_ConfigRFChannel(hopping_frequency[hopping_frequency_no]); @@ -597,7 +597,7 @@ void MLINK_init() { packet_count = 0; bind_counter = MLINK_BIND_COUNT; - CYRF_ConfigDataCode((uint8_t*)"\x6F\xBE\x32\x01\xDB\xF1\x2B\x01\xE3\x5C\xFA\x02\x97\x93\xF9\x02",16); //Bind data code + CYRF_ConfigDataCode((uint8_t*)"\x6F\xBE\x32\x01\xDB\xF1\x2B\x01\xE3\x5C\xFA\x02\x97\x93\xF9\x02"); //Bind data code CYRF_ConfigRFChannel(MLINK_BIND_CHANNEL); phase = MLINK_BIND_TX; } diff --git a/Multiprotocol/Multiprotocol.h b/Multiprotocol/Multiprotocol.h index 39ccf9f..4d0dcbf 100644 --- a/Multiprotocol/Multiprotocol.h +++ b/Multiprotocol/Multiprotocol.h @@ -19,7 +19,7 @@ #define VERSION_MAJOR 1 #define VERSION_MINOR 3 #define VERSION_REVISION 3 -#define VERSION_PATCH_LEVEL 40 +#define VERSION_PATCH_LEVEL 41 #define MODE_SERIAL 0 diff --git a/Multiprotocol/Validate.h b/Multiprotocol/Validate.h index 8cc99e2..4c34331 100644 --- a/Multiprotocol/Validate.h +++ b/Multiprotocol/Validate.h @@ -352,6 +352,9 @@ #undef V911S_CCNRF_INO #undef XK_CCNRF_INO #endif +#if not defined(DSM_CYRF6936_INO) + #undef LOSI_CYRF6936_INO +#endif #if not defined(STM32_BOARD) //RF2500 emulation does not work on atmega... #undef E010R5_CYRF6936_INO diff --git a/Multiprotocol/_Config.h b/Multiprotocol/_Config.h index bbf619f..e70c12d 100644 --- a/Multiprotocol/_Config.h +++ b/Multiprotocol/_Config.h @@ -191,7 +191,7 @@ //#define E01X_CYRF6936_INO #define E129_CYRF6936_INO #define J6PRO_CYRF6936_INO -//#define LOSI_CYRF6936_INO +#define LOSI_CYRF6936_INO //Need DSM to be enabled #define MLINK_CYRF6936_INO #define SCORPIO_CYRF6936_INO #define TRAXXAS_CYRF6936_INO diff --git a/Multiprotocol/iface_cyrf6936.h b/Multiprotocol/iface_cyrf6936.h index cf96f2c..433548a 100644 --- a/Multiprotocol/iface_cyrf6936.h +++ b/Multiprotocol/iface_cyrf6936.h @@ -85,7 +85,7 @@ void CYRF_SetPower(u8 power); void CYRF_ConfigCRCSeed(u16 crc); static void CYRF_StartReceive(); void CYRF_ConfigSOPCode(const u8 *sopcodes); -void CYRF_ConfigDataCode(const u8 *datacodes, u8 len); +void CYRF_ConfigDataCode(const u8 *datacodes); static u8 CYRF_ReadRSSI(u32 dodummyread); static void CYRF_ReadDataPacket(u8 dpbuffer[]); void CYRF_WriteDataPacket(const u8 dpbuffer[]); diff --git a/Protocols_Details.md b/Protocols_Details.md index a8f5559..a5f92e0 100644 --- a/Protocols_Details.md +++ b/Protocols_Details.md @@ -640,8 +640,6 @@ A|E|T|R|CH5|CH6|CH7|CH8|CH9|CH10|CH11|CH12 ## Losi - *89* TX: LSR-3000 -**Only 1 ID available**. More IDs can be added if you dump your original TX. - Extended limits supported CH1|CH2|CH3 From 785edde659d69d70e47405a737f840d5afba892c Mon Sep 17 00:00:00 2001 From: pascallanger Date: Fri, 1 Dec 2023 18:29:23 +0100 Subject: [PATCH 09/10] Update DSM.ino --- Multiprotocol/DSM.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Multiprotocol/DSM.ino b/Multiprotocol/DSM.ino index a6edad7..278bbae 100644 --- a/Multiprotocol/DSM.ino +++ b/Multiprotocol/DSM.ino @@ -67,7 +67,7 @@ const uint8_t PROGMEM DSM_pncodes[5][9][8] = { static void __attribute__((unused)) DSM_read_code(uint8_t *buf, uint8_t row, uint8_t col) { - for(uint8_t i=0;i Date: Fri, 1 Dec 2023 19:06:15 +0100 Subject: [PATCH 10/10] DSM.ino: Saved a few bytes --- Multiprotocol/DSM.ino | 98 ++++++++++++++++++++----------------------- 1 file changed, 45 insertions(+), 53 deletions(-) diff --git a/Multiprotocol/DSM.ino b/Multiprotocol/DSM.ino index 278bbae..09ad1bf 100644 --- a/Multiprotocol/DSM.ino +++ b/Multiprotocol/DSM.ino @@ -4,9 +4,45 @@ uint8_t sop_col; -const uint8_t PROGMEM DSM_pncodes[5][9][8] = { +const uint8_t PROGMEM DSM_pncodes[][8] = { /* Note these are in order transmitted (LSB 1st) */ - { /* Row 0 */ + /* Row 1 */ + /* Col 0 */ {0x83, 0xF7, 0xA8, 0x2D, 0x7A, 0x44, 0x64, 0xD3}, + /* Col 1 */ {0x3F, 0x2C, 0x4E, 0xAA, 0x71, 0x48, 0x7A, 0xC9}, + /* Col 2 */ {0x17, 0xFF, 0x9E, 0x21, 0x36, 0x90, 0xC7, 0x82}, + /* Col 3 */ {0xBC, 0x5D, 0x9A, 0x5B, 0xEE, 0x7F, 0x42, 0xEB}, + /* Col 4 */ {0x24, 0xF5, 0xDD, 0xF8, 0x7A, 0x77, 0x74, 0xE7}, + /* Col 5 */ {0x3D, 0x70, 0x7C, 0x94, 0xDC, 0x84, 0xAD, 0x95}, + /* Col 6 */ {0x1E, 0x6A, 0xF0, 0x37, 0x52, 0x7B, 0x11, 0xD4}, + /* Col 7 */ {0x62, 0xF5, 0x2B, 0xAA, 0xFC, 0x33, 0xBF, 0xAF}, + /* Row 2 */ + /* Col 0 */ {0x40, 0x56, 0x32, 0xD9, 0x0F, 0xD9, 0x5D, 0x97}, + /* Col 1 */ {0x8E, 0x4A, 0xD0, 0xA9, 0xA7, 0xFF, 0x20, 0xCA}, + /* Col 2 */ {0x4C, 0x97, 0x9D, 0xBF, 0xB8, 0x3D, 0xB5, 0xBE}, + /* Col 3 */ {0x0C, 0x5D, 0x24, 0x30, 0x9F, 0xCA, 0x6D, 0xBD}, + /* Col 4 */ {0x50, 0x14, 0x33, 0xDE, 0xF1, 0x78, 0x95, 0xAD}, + /* Col 5 */ {0x0C, 0x3C, 0xFA, 0xF9, 0xF0, 0xF2, 0x10, 0xC9}, + /* Col 6 */ {0xF4, 0xDA, 0x06, 0xDB, 0xBF, 0x4E, 0x6F, 0xB3}, + /* Col 7 */ {0x9E, 0x08, 0xD1, 0xAE, 0x59, 0x5E, 0xE8, 0xF0}, + /* Row 3 */ + /* Col 0 */ {0xC0, 0x90, 0x8F, 0xBB, 0x7C, 0x8E, 0x2B, 0x8E}, + /* Col 1 */ {0x80, 0x69, 0x26, 0x80, 0x08, 0xF8, 0x49, 0xE7}, + /* Col 2 */ {0x7D, 0x2D, 0x49, 0x54, 0xD0, 0x80, 0x40, 0xC1}, + /* Col 3 */ {0xB6, 0xF2, 0xE6, 0x1B, 0x80, 0x5A, 0x36, 0xB4}, + /* Col 4 */ {0x42, 0xAE, 0x9C, 0x1C, 0xDA, 0x67, 0x05, 0xF6}, + /* Col 5 */ {0x9B, 0x75, 0xF7, 0xE0, 0x14, 0x8D, 0xB5, 0x80}, + /* Col 6 */ {0xBF, 0x54, 0x98, 0xB9, 0xB7, 0x30, 0x5A, 0x88}, + /* Col 7 */ {0x35, 0xD1, 0xFC, 0x97, 0x23, 0xD4, 0xC9, 0x88}, + /* Row 4 */ + /* Col 0 */ {0xE1, 0xD6, 0x31, 0x26, 0x5F, 0xBD, 0x40, 0x93}, // Wrong values used by Orange TX/RX Col 8 */ {0x88, 0xE1, 0xD6, 0x31, 0x26, 0x5F, 0xBD, 0x40} + /* Col 1 */ {0xDC, 0x68, 0x08, 0x99, 0x97, 0xAE, 0xAF, 0x8C}, + /* Col 2 */ {0xC3, 0x0E, 0x01, 0x16, 0x0E, 0x32, 0x06, 0xBA}, + /* Col 3 */ {0xE0, 0x83, 0x01, 0xFA, 0xAB, 0x3E, 0x8F, 0xAC}, + /* Col 4 */ {0x5C, 0xD5, 0x9C, 0xB8, 0x46, 0x9C, 0x7D, 0x84}, + /* Col 5 */ {0xF1, 0xC6, 0xFE, 0x5C, 0x9D, 0xA5, 0x4F, 0xB7}, + /* Col 6 */ {0x58, 0xB5, 0xB3, 0xDD, 0x0E, 0x28, 0xF1, 0xB0}, + /* Col 7 */ {0x5F, 0x30, 0x3B, 0x56, 0x96, 0x45, 0xF4, 0xA1}, + /* Row 0 */ /* Col 0 */ {0x03, 0xBC, 0x6E, 0x8A, 0xEF, 0xBD, 0xFE, 0xF8}, /* Col 1 */ {0x88, 0x17, 0x13, 0x3B, 0x2D, 0xBF, 0x06, 0xD6}, /* Col 2 */ {0xF1, 0x94, 0x30, 0x21, 0xA1, 0x1C, 0x88, 0xA9}, @@ -16,59 +52,15 @@ const uint8_t PROGMEM DSM_pncodes[5][9][8] = { /* Col 6 */ {0xEF, 0x03, 0x95, 0x89, 0xB4, 0x71, 0x61, 0x9D}, /* Col 7 */ {0x40, 0xBA, 0x97, 0xD5, 0x86, 0x4F, 0xCC, 0xD1}, /* Col 8 */ {0xD7, 0xA1, 0x54, 0xB1, 0x5E, 0x89, 0xAE, 0x86} - }, - { /* Row 1 */ - /* Col 0 */ {0x83, 0xF7, 0xA8, 0x2D, 0x7A, 0x44, 0x64, 0xD3}, - /* Col 1 */ {0x3F, 0x2C, 0x4E, 0xAA, 0x71, 0x48, 0x7A, 0xC9}, - /* Col 2 */ {0x17, 0xFF, 0x9E, 0x21, 0x36, 0x90, 0xC7, 0x82}, - /* Col 3 */ {0xBC, 0x5D, 0x9A, 0x5B, 0xEE, 0x7F, 0x42, 0xEB}, - /* Col 4 */ {0x24, 0xF5, 0xDD, 0xF8, 0x7A, 0x77, 0x74, 0xE7}, - /* Col 5 */ {0x3D, 0x70, 0x7C, 0x94, 0xDC, 0x84, 0xAD, 0x95}, - /* Col 6 */ {0x1E, 0x6A, 0xF0, 0x37, 0x52, 0x7B, 0x11, 0xD4}, - /* Col 7 */ {0x62, 0xF5, 0x2B, 0xAA, 0xFC, 0x33, 0xBF, 0xAF}, - /* Col 8 */ {0x40, 0x56, 0x32, 0xD9, 0x0F, 0xD9, 0x5D, 0x97} - }, - { /* Row 2 */ - /* Col 0 */ {0x40, 0x56, 0x32, 0xD9, 0x0F, 0xD9, 0x5D, 0x97}, - /* Col 1 */ {0x8E, 0x4A, 0xD0, 0xA9, 0xA7, 0xFF, 0x20, 0xCA}, - /* Col 2 */ {0x4C, 0x97, 0x9D, 0xBF, 0xB8, 0x3D, 0xB5, 0xBE}, - /* Col 3 */ {0x0C, 0x5D, 0x24, 0x30, 0x9F, 0xCA, 0x6D, 0xBD}, - /* Col 4 */ {0x50, 0x14, 0x33, 0xDE, 0xF1, 0x78, 0x95, 0xAD}, - /* Col 5 */ {0x0C, 0x3C, 0xFA, 0xF9, 0xF0, 0xF2, 0x10, 0xC9}, - /* Col 6 */ {0xF4, 0xDA, 0x06, 0xDB, 0xBF, 0x4E, 0x6F, 0xB3}, - /* Col 7 */ {0x9E, 0x08, 0xD1, 0xAE, 0x59, 0x5E, 0xE8, 0xF0}, - /* Col 8 */ {0xC0, 0x90, 0x8F, 0xBB, 0x7C, 0x8E, 0x2B, 0x8E} - }, - { /* Row 3 */ - /* Col 0 */ {0xC0, 0x90, 0x8F, 0xBB, 0x7C, 0x8E, 0x2B, 0x8E}, - /* Col 1 */ {0x80, 0x69, 0x26, 0x80, 0x08, 0xF8, 0x49, 0xE7}, - /* Col 2 */ {0x7D, 0x2D, 0x49, 0x54, 0xD0, 0x80, 0x40, 0xC1}, - /* Col 3 */ {0xB6, 0xF2, 0xE6, 0x1B, 0x80, 0x5A, 0x36, 0xB4}, - /* Col 4 */ {0x42, 0xAE, 0x9C, 0x1C, 0xDA, 0x67, 0x05, 0xF6}, - /* Col 5 */ {0x9B, 0x75, 0xF7, 0xE0, 0x14, 0x8D, 0xB5, 0x80}, - /* Col 6 */ {0xBF, 0x54, 0x98, 0xB9, 0xB7, 0x30, 0x5A, 0x88}, - /* Col 7 */ {0x35, 0xD1, 0xFC, 0x97, 0x23, 0xD4, 0xC9, 0x88}, - /* Col 8 */ {0xE1, 0xD6, 0x31, 0x26, 0x5F, 0xBD, 0x40, 0x93} -// Wrong values used by Orange TX/RX -// /* Col 8 */ {0x88, 0xE1, 0xD6, 0x31, 0x26, 0x5F, 0xBD, 0x40} - }, - { /* Row 4 */ - /* Col 0 */ {0xE1, 0xD6, 0x31, 0x26, 0x5F, 0xBD, 0x40, 0x93}, - /* Col 1 */ {0xDC, 0x68, 0x08, 0x99, 0x97, 0xAE, 0xAF, 0x8C}, - /* Col 2 */ {0xC3, 0x0E, 0x01, 0x16, 0x0E, 0x32, 0x06, 0xBA}, - /* Col 3 */ {0xE0, 0x83, 0x01, 0xFA, 0xAB, 0x3E, 0x8F, 0xAC}, - /* Col 4 */ {0x5C, 0xD5, 0x9C, 0xB8, 0x46, 0x9C, 0x7D, 0x84}, - /* Col 5 */ {0xF1, 0xC6, 0xFE, 0x5C, 0x9D, 0xA5, 0x4F, 0xB7}, - /* Col 6 */ {0x58, 0xB5, 0xB3, 0xDD, 0x0E, 0x28, 0xF1, 0xB0}, - /* Col 7 */ {0x5F, 0x30, 0x3B, 0x56, 0x96, 0x45, 0xF4, 0xA1}, - /* Col 8 */ {0x03, 0xBC, 0x6E, 0x8A, 0xEF, 0xBD, 0xFE, 0xF8} - }, }; static void __attribute__((unused)) DSM_read_code(uint8_t *buf, uint8_t row, uint8_t col) { + row--; + if(row>4) + row = 4; for(uint8_t i=0;i<8;i++) - buf[i]=pgm_read_byte_near( &DSM_pncodes[row][col][i] ); + buf[i]=pgm_read_byte_near( &DSM_pncodes[row*8+col][i] ); } const uint8_t PROGMEM DSM_init_vals[][2] = { @@ -137,10 +129,10 @@ static void __attribute__((unused)) DSM_set_sop_data_crc(bool ch2, bool dsmx) debug_time(); debug(" crc:%04X,row:%d,col:%d,rf:%02X",(~seed)&0xffff,pn_row,sop_col,hopping_frequency[hopping_frequency_no]); #endif - DSM_read_code(code,pn_row,sop_col); // pn_row between 0 and 4, sop_col between 1 and 7 + DSM_read_code(code,pn_row,sop_col); // pn_row between 0 and 4, sop_col between 0 and 7 CYRF_ConfigSOPCode(code); - DSM_read_code(code,pn_row,7 - sop_col); // 7-sop_col between 0 and 6 - DSM_read_code(code+8,pn_row,7 - sop_col + 1); // 7-sop_col+1 between 1 and 7 + DSM_read_code(code,pn_row,7 - sop_col); // 7-sop_col between 0 and 7 + DSM_read_code(code+8,pn_row,7 - sop_col + 1); // 7-sop_col+1 between 1 and 8 CYRF_ConfigDataCode(code); CYRF_ConfigRFChannel(hopping_frequency[hopping_frequency_no]);