mirror of
https://github.com/pascallanger/DIY-Multiprotocol-TX-Module.git
synced 2025-02-09 22:48:12 +00:00
S-FHSS failsafe
This commit is contained in:
parent
2ffa2d7b73
commit
76e9002995
@ -20,6 +20,7 @@ multiatmega328p.build.f_cpu=16000000L
|
|||||||
multiatmega328p.build.core=arduino:arduino
|
multiatmega328p.build.core=arduino:arduino
|
||||||
multiatmega328p.build.variant=arduino:eightanaloginputs
|
multiatmega328p.build.variant=arduino:eightanaloginputs
|
||||||
multiatmega328p.build.extra_flags=-Wl,--relax
|
multiatmega328p.build.extra_flags=-Wl,--relax
|
||||||
|
multiatmega328p.build.board=MULTI_AVR
|
||||||
|
|
||||||
multiatmega328p.bootloader.tool=arduino:avrdude
|
multiatmega328p.bootloader.tool=arduino:avrdude
|
||||||
multiatmega328p.bootloader.low_fuses=0xFF
|
multiatmega328p.bootloader.low_fuses=0xFF
|
||||||
@ -29,12 +30,14 @@ multiatmega328p.bootloader.lock_bits=0x0F
|
|||||||
|
|
||||||
multiatmega328p.menu.bootloader.none=No bootloader
|
multiatmega328p.menu.bootloader.none=No bootloader
|
||||||
multiatmega328p.menu.bootloader.none.build.board=MULTI_NO_BOOT
|
multiatmega328p.menu.bootloader.none.build.board=MULTI_NO_BOOT
|
||||||
|
|
||||||
multiatmega328p.menu.bootloader.none.upload.maximum_size=32768
|
multiatmega328p.menu.bootloader.none.upload.maximum_size=32768
|
||||||
multiatmega328p.menu.bootloader.none.bootloader.file=Multi4in1/AtmegaMultiEmpty.hex
|
multiatmega328p.menu.bootloader.none.bootloader.file=Multi4in1/AtmegaMultiEmpty.hex
|
||||||
multiatmega328p.menu.bootloader.none.bootloader.high_fuses=0xD7
|
multiatmega328p.menu.bootloader.none.bootloader.high_fuses=0xD7
|
||||||
|
|
||||||
multiatmega328p.menu.bootloader.optiboot=Flash from TX
|
multiatmega328p.menu.bootloader.optiboot=Flash from TX
|
||||||
multiatmega328p.menu.bootloader.optiboot.build.board=MULTI_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.upload.maximum_size=32512
|
||||||
multiatmega328p.menu.bootloader.optiboot.bootloader.file=Multi4in1/AtmegaMultiBoot.hex
|
multiatmega328p.menu.bootloader.optiboot.bootloader.file=Multi4in1/AtmegaMultiBoot.hex
|
||||||
multiatmega328p.menu.bootloader.optiboot.bootloader.high_fuses=0xD6
|
multiatmega328p.menu.bootloader.optiboot.bootloader.high_fuses=0xD6
|
||||||
|
@ -19,8 +19,8 @@
|
|||||||
},
|
},
|
||||||
"url": "https://github.com/pascallanger/DIY-Multiprotocol-TX-Module/raw/master/BootLoaders/package_multi_4in1_board_v1.0.0.zip",
|
"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",
|
"archiveFileName": "package_multi_4in1_board_v1.0.0.zip",
|
||||||
"checksum": "SHA-256:7B8A93E4EDFA8EF63884A6B152C0DAFF24E067FA4F779A52AE77BFC8F23DCB72",
|
"checksum": "SHA-256:F5CF6502AB15B2BEC5F47CE0258DB9A1682CA3A4F2A4E490EA76F54961072483",
|
||||||
"size": "3135",
|
"size": "3161",
|
||||||
"boards": [
|
"boards": [
|
||||||
{"name": "Multi 4-in-1 (Atmega328p, 3.3V, 16MHz)"}
|
{"name": "Multi 4-in-1 (Atmega328p, 3.3V, 16MHz)"}
|
||||||
],
|
],
|
||||||
|
Binary file not shown.
@ -19,7 +19,7 @@
|
|||||||
#define VERSION_MAJOR 1
|
#define VERSION_MAJOR 1
|
||||||
#define VERSION_MINOR 1
|
#define VERSION_MINOR 1
|
||||||
#define VERSION_REVISION 6
|
#define VERSION_REVISION 6
|
||||||
#define VERSION_PATCH_LEVEL 25
|
#define VERSION_PATCH_LEVEL 26
|
||||||
//******************
|
//******************
|
||||||
// Protocols
|
// Protocols
|
||||||
//******************
|
//******************
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
*/
|
*/
|
||||||
#include <avr/pgmspace.h>
|
#include <avr/pgmspace.h>
|
||||||
//#define DEBUG_TX
|
//#define DEBUG_TX
|
||||||
//#define USE_MY_CONFIG
|
#define USE_MY_CONFIG
|
||||||
#ifdef ARDUINO_AVR_XMEGA32D4
|
#ifdef ARDUINO_AVR_XMEGA32D4
|
||||||
#include "MultiOrange.h"
|
#include "MultiOrange.h"
|
||||||
#endif
|
#endif
|
||||||
|
@ -127,25 +127,42 @@ static void __attribute__((unused)) SFHSS_calc_next_chan()
|
|||||||
// Values grow down and to the right.
|
// Values grow down and to the right.
|
||||||
static void __attribute__((unused)) SFHSS_build_data_packet()
|
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.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.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.bit2 is the failsafe transmission indicator: =0 -> normal data, =1->failsafe data
|
||||||
// command.bit3 is the channels indicator: =0 -> CH1-4, =1 -> CH5-8
|
// 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
|
uint8_t command= (phase == SFHSS_DATA1) ? 0 : 1; // Building packet for Data1 or Data2
|
||||||
counter+=command;
|
counter+=command;
|
||||||
if(counter&1) command|=0x08; // Transmit lower and upper channels twice in a row
|
if( (counter&0x3FC) == 0x3FC )
|
||||||
if((counter&0x3FE)==0x3FE)
|
{ // Transmit failsafe data twice every 7s
|
||||||
{
|
if( ((counter&1)^(command&1)) == 0 )
|
||||||
command|=0x04; // Transmit failsafe data every 7s
|
command|=0x04; // Failsafe
|
||||||
counter&=0x3FF; // Reset counter
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
command|=0x02; // Assuming packet[0] == 0x81
|
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
|
counter&=0x3FF; // Reset failsafe counter
|
||||||
uint16_t ch1 = convert_channel_16b_nolim(CH_AETR[ch_offset+0],2020,1020);
|
if(counter&1) command|=0x08; // Transmit lower and upper channels twice in a row
|
||||||
uint16_t ch2 = convert_channel_16b_nolim(CH_AETR[ch_offset+1],2020,1020);
|
if(command&0x04)
|
||||||
uint16_t ch3 = convert_channel_16b_nolim(CH_AETR[ch_offset+2],2020,1020);
|
{//Failsafe data
|
||||||
uint16_t ch4 = convert_channel_16b_nolim(CH_AETR[ch_offset+3],2020,1020);
|
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
|
// XK [0]=0x81 [3]=0x00 [4]=0x00
|
||||||
// T8J [0]=0x81 [3]=0x42 [4]=0x07
|
// T8J [0]=0x81 [3]=0x42 [4]=0x07
|
||||||
|
23
Multiprotocol/_MyConfig.h
Normal file
23
Multiprotocol/_MyConfig.h
Normal file
@ -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
|
Loading…
x
Reference in New Issue
Block a user