diff --git a/BootLoaders/Boards/boards.txt b/BootLoaders/Boards/boards.txt index 4abfa94..6735147 100644 --- a/BootLoaders/Boards/boards.txt +++ b/BootLoaders/Boards/boards.txt @@ -20,6 +20,7 @@ multiatmega328p.build.f_cpu=16000000L multiatmega328p.build.core=arduino:arduino multiatmega328p.build.variant=arduino:eightanaloginputs multiatmega328p.build.extra_flags=-Wl,--relax +multiatmega328p.build.board=MULTI_AVR multiatmega328p.bootloader.tool=arduino:avrdude multiatmega328p.bootloader.low_fuses=0xFF @@ -29,12 +30,14 @@ multiatmega328p.bootloader.lock_bits=0x0F multiatmega328p.menu.bootloader.none=No bootloader multiatmega328p.menu.bootloader.none.build.board=MULTI_NO_BOOT + multiatmega328p.menu.bootloader.none.upload.maximum_size=32768 multiatmega328p.menu.bootloader.none.bootloader.file=Multi4in1/AtmegaMultiEmpty.hex multiatmega328p.menu.bootloader.none.bootloader.high_fuses=0xD7 multiatmega328p.menu.bootloader.optiboot=Flash from TX multiatmega328p.menu.bootloader.optiboot.build.board=MULTI_FLASH_FROM_TX + multiatmega328p.menu.bootloader.optiboot.upload.maximum_size=32512 multiatmega328p.menu.bootloader.optiboot.bootloader.file=Multi4in1/AtmegaMultiBoot.hex multiatmega328p.menu.bootloader.optiboot.bootloader.high_fuses=0xD6 diff --git a/BootLoaders/package_multi_4in1_board_index.json b/BootLoaders/package_multi_4in1_board_index.json index 7b352c3..1d5b725 100644 --- a/BootLoaders/package_multi_4in1_board_index.json +++ b/BootLoaders/package_multi_4in1_board_index.json @@ -19,8 +19,8 @@ }, "url": "https://github.com/pascallanger/DIY-Multiprotocol-TX-Module/raw/master/BootLoaders/package_multi_4in1_board_v1.0.0.zip", "archiveFileName": "package_multi_4in1_board_v1.0.0.zip", - "checksum": "SHA-256:7B8A93E4EDFA8EF63884A6B152C0DAFF24E067FA4F779A52AE77BFC8F23DCB72", - "size": "3135", + "checksum": "SHA-256:F5CF6502AB15B2BEC5F47CE0258DB9A1682CA3A4F2A4E490EA76F54961072483", + "size": "3161", "boards": [ {"name": "Multi 4-in-1 (Atmega328p, 3.3V, 16MHz)"} ], diff --git a/BootLoaders/package_multi_4in1_board_v1.0.0.zip b/BootLoaders/package_multi_4in1_board_v1.0.0.zip index bb22be9..af0bf24 100644 Binary files a/BootLoaders/package_multi_4in1_board_v1.0.0.zip and b/BootLoaders/package_multi_4in1_board_v1.0.0.zip differ diff --git a/Multiprotocol/Multiprotocol.h b/Multiprotocol/Multiprotocol.h index 30e1a80..7969787 100644 --- a/Multiprotocol/Multiprotocol.h +++ b/Multiprotocol/Multiprotocol.h @@ -19,7 +19,7 @@ #define VERSION_MAJOR 1 #define VERSION_MINOR 1 #define VERSION_REVISION 6 -#define VERSION_PATCH_LEVEL 25 +#define VERSION_PATCH_LEVEL 26 //****************** // Protocols //****************** diff --git a/Multiprotocol/Multiprotocol.ino b/Multiprotocol/Multiprotocol.ino index 02623e7..8c32ebc 100644 --- a/Multiprotocol/Multiprotocol.ino +++ b/Multiprotocol/Multiprotocol.ino @@ -22,7 +22,7 @@ */ #include //#define DEBUG_TX -//#define USE_MY_CONFIG +#define USE_MY_CONFIG #ifdef ARDUINO_AVR_XMEGA32D4 #include "MultiOrange.h" #endif diff --git a/Multiprotocol/SFHSS_cc2500.ino b/Multiprotocol/SFHSS_cc2500.ino index edc6190..6f995f8 100644 --- a/Multiprotocol/SFHSS_cc2500.ino +++ b/Multiprotocol/SFHSS_cc2500.ino @@ -127,25 +127,42 @@ static void __attribute__((unused)) SFHSS_calc_next_chan() // Values grow down and to the right. static void __attribute__((unused)) SFHSS_build_data_packet() { + uint16_t ch1,ch2,ch3,ch4; // command.bit0 is the packet number indicator: =0 -> SFHSS_DATA1, =1 -> SFHSS_DATA2 // command.bit1 is unknown but seems to be linked to the payload[0].bit0 but more dumps are needed: payload[0]=0x82 -> =0, payload[0]=0x81 -> =1 // command.bit2 is the failsafe transmission indicator: =0 -> normal data, =1->failsafe data // command.bit3 is the channels indicator: =0 -> CH1-4, =1 -> CH5-8 + + //Coding below matches the Futaba T8J transmission scheme DATA1->CH1-4, DATA2->CH5-8, DATA1->CH5-8, DATA2->CH1-4,... + // XK, T10J and TM-FH are different with a classic DATA1->CH1-4, DATA2->CH5-8,... + //Failsafe is sent twice every couple of seconds (unknown but >5s) + uint8_t command= (phase == SFHSS_DATA1) ? 0 : 1; // Building packet for Data1 or Data2 counter+=command; - if(counter&1) command|=0x08; // Transmit lower and upper channels twice in a row - if((counter&0x3FE)==0x3FE) - { - command|=0x04; // Transmit failsafe data every 7s - counter&=0x3FF; // Reset counter + if( (counter&0x3FC) == 0x3FC ) + { // Transmit failsafe data twice every 7s + if( ((counter&1)^(command&1)) == 0 ) + command|=0x04; // Failsafe } else command|=0x02; // Assuming packet[0] == 0x81 - uint8_t ch_offset = ((command&0x08) >> 1) + ((command&0x04)<<1); // CH1..CH8 when failsafe is off, CH9..CH16 when failsafe is on - uint16_t ch1 = convert_channel_16b_nolim(CH_AETR[ch_offset+0],2020,1020); - uint16_t ch2 = convert_channel_16b_nolim(CH_AETR[ch_offset+1],2020,1020); - uint16_t ch3 = convert_channel_16b_nolim(CH_AETR[ch_offset+2],2020,1020); - uint16_t ch4 = convert_channel_16b_nolim(CH_AETR[ch_offset+3],2020,1020); + counter&=0x3FF; // Reset failsafe counter + if(counter&1) command|=0x08; // Transmit lower and upper channels twice in a row + if(command&0x04) + {//Failsafe data + ch1=0x400; // Centered + ch2=0x400; // Centered + ch3=(command&0x08)?0x400:0xC00; // Centered or zero if throttle channel + ch4=0x400; // Centered + } + else + {//Normal data + uint8_t ch_offset = (command&0x08) >> 1; // CH1..CH4 or CH5..CH8 + ch1 = convert_channel_16b_nolim(CH_AETR[ch_offset+0],2020,1020); + ch2 = convert_channel_16b_nolim(CH_AETR[ch_offset+1],2020,1020); + ch3 = convert_channel_16b_nolim(CH_AETR[ch_offset+2],2020,1020); + ch4 = convert_channel_16b_nolim(CH_AETR[ch_offset+3],2020,1020); + } // XK [0]=0x81 [3]=0x00 [4]=0x00 // T8J [0]=0x81 [3]=0x42 [4]=0x07 diff --git a/Multiprotocol/_MyConfig.h b/Multiprotocol/_MyConfig.h new file mode 100644 index 0000000..1ab7c1f --- /dev/null +++ b/Multiprotocol/_MyConfig.h @@ -0,0 +1,23 @@ +//#define FORCE_GLOBAL_ID 0x12345678 + +#if not defined STM32_BOARD + // #undef AFHDS2A_A7105_INO + + // #undef DEVO_CYRF6936_INO + // #undef J6PRO_CYRF6936_INO + // #undef WK2x01_CYRF6936_INO + + // #undef FRSKYV_CC2500_INO + // #undef FRSKYX_CC2500_INO + + // #undef KN_NRF24L01_INO + // #undef SLT_NRF24L01_INO + + // #undef FY326_NRF24L01_INO + // #undef FQ777_NRF24L01_INO + // #undef ASSAN_NRF24L01_INO + // #undef HONTAI_NRF24L01_INO + // #undef Q303_NRF24L01_INO + // #undef GW008_NRF24L01_INO + // #undef DM002_NRF24L01_INO +#endif