mirror of
https://github.com/pascallanger/DIY-Multiprotocol-TX-Module.git
synced 2025-02-04 18:38:13 +00:00
New _Config.h file, MJXQ fix, 16 bit regs
This commit is contained in:
parent
988d28f2fd
commit
061c97caca
@ -62,10 +62,9 @@ uint8_t A7105_ReadReg(uint8_t address) {
|
||||
|
||||
uint8_t A7105_Read(void)
|
||||
{
|
||||
uint8_t result;
|
||||
uint8_t i;
|
||||
uint8_t result=0;
|
||||
SDI_SET_INPUT;
|
||||
for(i=0;i<8;i++)
|
||||
for(uint8_t i=0;i<8;i++)
|
||||
{
|
||||
result=result<<1;
|
||||
if(SDI_1) ///if SDIO =1
|
||||
|
@ -74,17 +74,17 @@ uint16_t ASSAN_callback()
|
||||
NRF24L01_SetTxRxMode(RX_EN);
|
||||
phase++;
|
||||
case ASSAN_BIND1:
|
||||
//Wait for RX to send the frames
|
||||
//Wait for receiver to send the frames
|
||||
if( NRF24L01_ReadReg(NRF24L01_07_STATUS) & BV(NRF24L01_07_RX_DR))
|
||||
{ //Something has been received
|
||||
NRF24L01_ReadPayload(packet, ASSAN_PACKET_SIZE);
|
||||
if(packet[19]==0x13)
|
||||
{ //Last packet received
|
||||
{ //Last frame received
|
||||
phase++;
|
||||
//Switch to TX
|
||||
NRF24L01_SetTxRxMode(TXRX_OFF);
|
||||
NRF24L01_SetTxRxMode(TX_EN);
|
||||
//Prepare packet
|
||||
//Prepare bind packet
|
||||
memset(packet,0x05,ASSAN_PACKET_SIZE-5);
|
||||
packet[15]=0x99;
|
||||
for(uint8_t i=0;i<4;i++)
|
||||
|
@ -108,7 +108,6 @@ static void __attribute__((unused)) read_code(uint8_t *buf, uint8_t row, uint8_t
|
||||
//
|
||||
uint8_t sop_col;
|
||||
uint8_t data_col;
|
||||
uint16_t cyrf_state;
|
||||
uint8_t binding;
|
||||
|
||||
static void __attribute__((unused)) build_bind_packet()
|
||||
@ -146,7 +145,7 @@ static void __attribute__((unused)) build_bind_packet()
|
||||
|
||||
static uint8_t __attribute__((unused)) PROTOCOL_SticksMoved(uint8_t init)
|
||||
{
|
||||
#define STICK_MOVEMENT 15*(PPM_MAX-PPM_MIN)/100 // defines when the bind dialog should be interrupted (stick movement STICK_MOVEMENT %)
|
||||
#define STICK_MOVEMENT 15*(servo_max_125-servo_min_125)/100 // defines when the bind dialog should be interrupted (stick movement STICK_MOVEMENT %)
|
||||
static uint16_t ele_start, ail_start;
|
||||
uint16_t ele = Servo_data[ELEVATOR];//CHAN_ReadInput(MIXER_MapChannel(INP_ELEVATOR));
|
||||
uint16_t ail = Servo_data[AILERON];//CHAN_ReadInput(MIXER_MapChannel(INP_AILERON));
|
||||
@ -263,7 +262,7 @@ static void __attribute__((unused)) build_data_packet(uint8_t upper)//
|
||||
value=Servo_data[AUX8];
|
||||
break;
|
||||
}
|
||||
value=map(value,PPM_MIN,PPM_MAX,0,max-1);
|
||||
value=map(value,servo_min_125,servo_max_125,0,max-1);
|
||||
}
|
||||
value |= (upper && i == 0 ? 0x8000 : 0) | (idx << bits);
|
||||
}
|
||||
@ -416,12 +415,12 @@ uint16_t ReadDsm2()
|
||||
#define DSM_READ_DELAY 600 // Time before write to check read state, and switch channels. Was 400 but 500 seems what the 328p needs to read a packet
|
||||
uint16_t start;
|
||||
|
||||
switch(cyrf_state)
|
||||
switch(state)
|
||||
{
|
||||
default:
|
||||
//Binding
|
||||
cyrf_state++;
|
||||
if(cyrf_state & 1)
|
||||
state++;
|
||||
if(state & 1)
|
||||
{
|
||||
//Send packet on even states
|
||||
//Note state has already incremented, so this is actually 'even' state
|
||||
@ -441,17 +440,17 @@ uint16_t ReadDsm2()
|
||||
cyrf_configdata();
|
||||
CYRF_SetTxRxMode(TX_EN);
|
||||
hopping_frequency_no = 0;
|
||||
cyrf_state = DSM2_CH1_WRITE_A; // in fact cyrf_state++
|
||||
state = DSM2_CH1_WRITE_A; // in fact state++
|
||||
set_sop_data_crc();
|
||||
return 10000;
|
||||
case DSM2_CH1_WRITE_A:
|
||||
case DSM2_CH1_WRITE_B:
|
||||
case DSM2_CH2_WRITE_A:
|
||||
case DSM2_CH2_WRITE_B:
|
||||
build_data_packet(cyrf_state == DSM2_CH1_WRITE_B);// build lower or upper channels
|
||||
build_data_packet(state == DSM2_CH1_WRITE_B);// build lower or upper channels
|
||||
CYRF_ReadRegister(CYRF_04_TX_IRQ_STATUS); // clear IRQ flags
|
||||
CYRF_WriteDataPacket(packet);
|
||||
cyrf_state++; // change from WRITE to CHECK mode
|
||||
state++; // change from WRITE to CHECK mode
|
||||
return DSM_WRITE_DELAY;
|
||||
case DSM2_CH1_CHECK_A:
|
||||
case DSM2_CH1_CHECK_B:
|
||||
@ -460,7 +459,7 @@ uint16_t ReadDsm2()
|
||||
if(CYRF_ReadRegister(CYRF_04_TX_IRQ_STATUS) & 0x02)
|
||||
break;
|
||||
set_sop_data_crc();
|
||||
cyrf_state++; // change from CH1_CHECK to CH2_WRITE
|
||||
state++; // change from CH1_CHECK to CH2_WRITE
|
||||
return DSM_CH1_CH2_DELAY - DSM_WRITE_DELAY;
|
||||
case DSM2_CH2_CHECK_A:
|
||||
case DSM2_CH2_CHECK_B:
|
||||
@ -468,10 +467,10 @@ uint16_t ReadDsm2()
|
||||
while ((uint16_t)micros()-start < 500) // Wait max 500µs
|
||||
if(CYRF_ReadRegister(CYRF_04_TX_IRQ_STATUS) & 0x02)
|
||||
break;
|
||||
if (cyrf_state == DSM2_CH2_CHECK_A)
|
||||
if (state == DSM2_CH2_CHECK_A)
|
||||
CYRF_SetPower(0x28); //Keep transmit power in sync
|
||||
#if defined DSM_TELEMETRY
|
||||
cyrf_state++; // change from CH2_CHECK to CH2_READ
|
||||
state++; // change from CH2_CHECK to CH2_READ
|
||||
if(option<=3 || option>7)
|
||||
{ // disable telemetry for option between 4 and 7 ie 4,5,6,7 channels @11ms since it does not work...
|
||||
CYRF_SetTxRxMode(RX_EN); //Receive mode
|
||||
@ -494,7 +493,7 @@ uint16_t ReadDsm2()
|
||||
pkt[0]=CYRF_ReadRegister(CYRF_13_RSSI)&0x1F; // store RSSI of the received telemetry signal
|
||||
telemetry_link=1;
|
||||
}
|
||||
if (cyrf_state == DSM2_CH2_READ_A && option <= 3) // normal 22ms mode if option<=3 ie 4,5,6,7 channels @22ms
|
||||
if (state == DSM2_CH2_READ_A && option <= 3) // normal 22ms mode if option<=3 ie 4,5,6,7 channels @22ms
|
||||
{
|
||||
//Force end read state
|
||||
CYRF_WriteRegister(CYRF_0F_XACT_CFG, (CYRF_ReadRegister(CYRF_0F_XACT_CFG) | 0x20)); // Force end state
|
||||
@ -502,35 +501,35 @@ uint16_t ReadDsm2()
|
||||
while ((uint16_t)micros()-start < 100) // Wait max 100 µs
|
||||
if((CYRF_ReadRegister(CYRF_0F_XACT_CFG) & 0x20) == 0)
|
||||
break;
|
||||
cyrf_state = DSM2_CH2_READ_B;
|
||||
state = DSM2_CH2_READ_B;
|
||||
CYRF_WriteRegister(CYRF_05_RX_CTRL, 0x87); //0x80??? //Prepare to receive
|
||||
return 11000;
|
||||
}
|
||||
if (cyrf_state == DSM2_CH2_READ_A && option>7)
|
||||
cyrf_state = DSM2_CH1_WRITE_B; //Transmit upper
|
||||
if (state == DSM2_CH2_READ_A && option>7)
|
||||
state = DSM2_CH1_WRITE_B; //Transmit upper
|
||||
else
|
||||
cyrf_state = DSM2_CH1_WRITE_A; //Force 11ms if option>3 ie 4,5,6,7 channels @11ms
|
||||
state = DSM2_CH1_WRITE_A; //Force 11ms if option>3 ie 4,5,6,7 channels @11ms
|
||||
CYRF_SetTxRxMode(TX_EN); //Write mode
|
||||
set_sop_data_crc();
|
||||
return DSM_READ_DELAY;
|
||||
#else
|
||||
// No telemetry
|
||||
set_sop_data_crc();
|
||||
if (cyrf_state == DSM2_CH2_CHECK_A)
|
||||
if (state == DSM2_CH2_CHECK_A)
|
||||
{
|
||||
if(option < 8)
|
||||
{
|
||||
cyrf_state = DSM2_CH1_WRITE_A; // change from CH2_CHECK_A to CH1_WRITE_A (ie no upper)
|
||||
state = DSM2_CH1_WRITE_A; // change from CH2_CHECK_A to CH1_WRITE_A (ie no upper)
|
||||
if(option>3)
|
||||
return 11000 - DSM_CH1_CH2_DELAY - DSM_WRITE_DELAY ; // force 11ms if option>3 ie 4,5,6,7 channels @11ms
|
||||
else
|
||||
return 22000 - DSM_CH1_CH2_DELAY - DSM_WRITE_DELAY ; // normal 22ms mode if option<=3 ie 4,5,6,7 channels @22ms
|
||||
}
|
||||
else
|
||||
cyrf_state = DSM2_CH1_WRITE_B; // change from CH2_CHECK_A to CH1_WRITE_A (to transmit upper)
|
||||
state = DSM2_CH1_WRITE_B; // change from CH2_CHECK_A to CH1_WRITE_A (to transmit upper)
|
||||
}
|
||||
else
|
||||
cyrf_state = DSM2_CH1_WRITE_A; // change from CH2_CHECK_B to CH1_WRITE_A (upper already transmitted so transmit lower)
|
||||
state = DSM2_CH1_WRITE_A; // change from CH2_CHECK_B to CH1_WRITE_A (upper already transmitted so transmit lower)
|
||||
return 11000 - DSM_CH1_CH2_DELAY - DSM_WRITE_DELAY;
|
||||
#endif
|
||||
}
|
||||
@ -581,14 +580,14 @@ uint16_t initDsm2()
|
||||
//
|
||||
if(IS_AUTOBIND_FLAG_on)
|
||||
{
|
||||
cyrf_state = DSM2_BIND;
|
||||
state = DSM2_BIND;
|
||||
PROTOCOL_SticksMoved(1); //Initialize Stick position
|
||||
initialize_bind_state();
|
||||
binding = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
cyrf_state = DSM2_CHANSEL;//
|
||||
state = DSM2_CHANSEL;//
|
||||
binding = 0;
|
||||
}
|
||||
return 10000;
|
||||
|
@ -148,7 +148,7 @@ static void __attribute__((unused)) build_data_pkt()
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
//
|
||||
int16_t value= map(Servo_data[ch_idx * 4 + i],PPM_MIN,PPM_MAX,-1600,1600);//range -1600...+1600
|
||||
int16_t value= map(Servo_data[ch_idx * 4 + i],servo_min_125,servo_max_125,-1600,1600);//range -1600...+1600
|
||||
//s32 value = (s32)Channels[ch_idx * 4 + i] * 0x640 / CHAN_MAX_VALUE;//10000
|
||||
if(value < 0)
|
||||
{
|
||||
|
@ -145,7 +145,7 @@ static uint16_t __attribute__((unused)) crc_x(uint8_t *data, uint8_t len)
|
||||
|
||||
static uint16_t __attribute__((unused)) scaleForPXX( uint8_t i )
|
||||
{ //mapped 860,2140(125%) range to 64,1984(PXX values);
|
||||
return (uint16_t)(((Servo_data[i]-PPM_MIN)*3)>>1)+64;
|
||||
return (uint16_t)(((Servo_data[i]-servo_min_125)*3)>>1)+64;
|
||||
}
|
||||
|
||||
static void __attribute__((unused)) frskyX_build_bind_packet()
|
||||
|
@ -122,7 +122,7 @@ static void __attribute__((unused)) build_ch_data()
|
||||
uint8_t i,j;
|
||||
for (i = 0; i< 8; i++) {
|
||||
j=CH_AETR[i];
|
||||
temp=map(limit_channel_100(j),PPM_MIN_100,PPM_MAX_100,0,1000);
|
||||
temp=map(limit_channel_100(j),servo_min_100,servo_max_100,0,1000);
|
||||
if (j == THROTTLE) // It is clear that hisky's throttle stick is made reversely, so I adjust it here on purpose
|
||||
temp = 1000 -temp;
|
||||
if (j == AUX3)
|
||||
|
@ -26,6 +26,17 @@
|
||||
#define MJXQ_RF_NUM_CHANNELS 4
|
||||
#define MJXQ_ADDRESS_LENGTH 5
|
||||
|
||||
// haven't figured out txid<-->rf channel mapping for MJX models
|
||||
const uint8_t PROGMEM MJXQ_map_rfchan[][4] = {
|
||||
{0x0A, 0x46, 0x3A, 0x42},
|
||||
{0x0A, 0x3C, 0x36, 0x3F},
|
||||
{0x0A, 0x43, 0x36, 0x3F} };
|
||||
const uint8_t PROGMEM MJXQ_map_txid[][3] = {
|
||||
{0xF8, 0x4F, 0x1C},
|
||||
{0xC8, 0x6E, 0x02},
|
||||
{0x48, 0x6A, 0x40} };
|
||||
|
||||
|
||||
#define MJXQ_PAN_TILT_COUNT 16 // for H26D - match stock tx timing
|
||||
#define MJXQ_PAN_DOWN 0x08
|
||||
#define MJXQ_PAN_UP 0x04
|
||||
@ -39,14 +50,14 @@ static uint8_t __attribute__((unused)) MJXQ_pan_tilt_value()
|
||||
packet_count++;
|
||||
if(packet_count & MJXQ_PAN_TILT_COUNT)
|
||||
{
|
||||
if(Servo_AUX8)
|
||||
if(Servo_data[AUX8]>PPM_MAX_COMMAND)
|
||||
pan=MJXQ_PAN_UP;
|
||||
if(Servo_data[AUX8]<PPM_MIN_COMMAND)
|
||||
pan=MJXQ_PAN_DOWN;
|
||||
if(Servo_data[AUX9]>PPM_MIN_COMMAND)
|
||||
pan=MJXQ_TILT_UP;
|
||||
if(Servo_data[AUX9]>PPM_MAX_COMMAND)
|
||||
pan+=MJXQ_TILT_UP;
|
||||
if(Servo_data[AUX9]<PPM_MIN_COMMAND)
|
||||
pan=MJXQ_TILT_DOWN;
|
||||
pan+=MJXQ_TILT_DOWN;
|
||||
}
|
||||
return pan;
|
||||
}
|
||||
@ -188,29 +199,21 @@ static void __attribute__((unused)) MJXQ_init()
|
||||
|
||||
static void __attribute__((unused)) MJXQ_init2()
|
||||
{
|
||||
// haven't figured out txid<-->rf channel mapping for MJX models
|
||||
static const uint8_t rf_map[][4] = {
|
||||
{0x0A, 0x46, 0x3A, 0x42},
|
||||
{0x0A, 0x3C, 0x36, 0x3F},
|
||||
{0x0A, 0x43, 0x36, 0x3F} };
|
||||
if (sub_protocol == H26D)
|
||||
memcpy(hopping_frequency, "\x32\x3e\x42\x4e", MJXQ_RF_NUM_CHANNELS);
|
||||
else
|
||||
if (sub_protocol == WLH08)
|
||||
memcpy(hopping_frequency, rf_map[rx_tx_addr[0]%3], MJXQ_RF_NUM_CHANNELS);
|
||||
for(uint8_t i=0;i<MJXQ_RF_NUM_CHANNELS;i++)
|
||||
hopping_frequency[i]=pgm_read_byte_near( &MJXQ_map_rfchan[rx_tx_addr[4]%3][i] );
|
||||
}
|
||||
|
||||
static void __attribute__((unused)) MJXQ_initialize_txid()
|
||||
{
|
||||
// haven't figured out txid<-->rf channel mapping for MJX models
|
||||
static const uint8_t tx_map[][3]={
|
||||
{0xF8, 0x4F, 0x1C},
|
||||
{0xC8, 0x6E, 0x02},
|
||||
{0x48, 0x6A, 0x40} };
|
||||
if (sub_protocol == WLH08)
|
||||
rx_tx_addr[0]&=0xF8; // txid must be multiple of 8
|
||||
else
|
||||
memcpy(rx_tx_addr,tx_map[rx_tx_addr[0]%3],3);
|
||||
for(uint8_t i=0;i<3;i++)
|
||||
rx_tx_addr[i]=pgm_read_byte_near( &MJXQ_map_txid[rx_tx_addr[4]%3][i] );
|
||||
}
|
||||
|
||||
uint16_t MJXQ_callback()
|
||||
|
@ -35,7 +35,7 @@ enum PROTOCOLS
|
||||
MODE_HISKY = 4, // =>NRF24L01
|
||||
MODE_V2X2 = 5, // =>NRF24L01
|
||||
MODE_DSM2 = 6, // =>CYRF6936
|
||||
MODE_DEVO =7, // =>CYRF6936
|
||||
MODE_DEVO = 7, // =>CYRF6936
|
||||
MODE_YD717 = 8, // =>NRF24L01
|
||||
MODE_KN = 9, // =>NRF24L01
|
||||
MODE_SYMAX = 10, // =>NRF24L01
|
||||
@ -45,60 +45,61 @@ enum PROTOCOLS
|
||||
MODE_BAYANG = 14, // =>NRF24L01
|
||||
MODE_FRSKYX = 15, // =>CC2500
|
||||
MODE_ESKY = 16, // =>NRF24L01
|
||||
MODE_MT99XX=17, // =>NRF24L01
|
||||
MODE_MJXQ=18, // =>NRF24L01
|
||||
MODE_SHENQI=19, // =>NRF24L01
|
||||
MODE_FY326=20, // =>NRF24L01
|
||||
MODE_SFHSS=21, // =>CC2500
|
||||
MODE_J6PRO=22, // =>CYRF6936
|
||||
MODE_FQ777=23, // =>NRF24L01
|
||||
MODE_ASSAN=24 // =>NRF24L01
|
||||
MODE_MT99XX = 17, // =>NRF24L01
|
||||
MODE_MJXQ = 18, // =>NRF24L01
|
||||
MODE_SHENQI = 19, // =>NRF24L01
|
||||
MODE_FY326 = 20, // =>NRF24L01
|
||||
MODE_SFHSS = 21, // =>CC2500
|
||||
MODE_J6PRO = 22, // =>CYRF6936
|
||||
MODE_FQ777 = 23, // =>NRF24L01
|
||||
MODE_ASSAN = 24 // =>NRF24L01
|
||||
};
|
||||
|
||||
enum Flysky
|
||||
{
|
||||
Flysky=0,
|
||||
V9X9=1,
|
||||
V6X6=2,
|
||||
V912=3
|
||||
Flysky = 0,
|
||||
V9X9 = 1,
|
||||
V6X6 = 2,
|
||||
V912 = 3
|
||||
};
|
||||
enum Hisky
|
||||
{
|
||||
Hisky=0,
|
||||
HK310=1
|
||||
Hisky = 0,
|
||||
HK310 = 1
|
||||
};
|
||||
enum DSM2{
|
||||
DSM2=0,
|
||||
DSMX=1
|
||||
enum DSM2
|
||||
{
|
||||
DSM2 = 0,
|
||||
DSMX = 1
|
||||
};
|
||||
enum YD717
|
||||
{
|
||||
YD717=0,
|
||||
SKYWLKR=1,
|
||||
SYMAX4=2,
|
||||
XINXUN=3,
|
||||
NIHUI=4
|
||||
YD717 = 0,
|
||||
SKYWLKR = 1,
|
||||
SYMAX4 = 2,
|
||||
XINXUN = 3,
|
||||
NIHUI = 4
|
||||
};
|
||||
enum KN
|
||||
{
|
||||
WLTOYS=0,
|
||||
FEILUN=1
|
||||
WLTOYS = 0,
|
||||
FEILUN = 1
|
||||
};
|
||||
enum SYMAX
|
||||
{
|
||||
SYMAX=0,
|
||||
SYMAX5C=1
|
||||
SYMAX = 0,
|
||||
SYMAX5C = 1
|
||||
};
|
||||
enum CX10
|
||||
{
|
||||
CX10_GREEN = 0,
|
||||
CX10_BLUE=1, // also compatible with CX10-A, CX12
|
||||
DM007=2,
|
||||
Q282=3,
|
||||
JC3015_1=4,
|
||||
JC3015_2=5,
|
||||
MK33041=6,
|
||||
Q242=7
|
||||
CX10_BLUE = 1, // also compatible with CX10-A, CX12
|
||||
DM007 = 2,
|
||||
Q282 = 3,
|
||||
JC3015_1 = 4,
|
||||
JC3015_2 = 5,
|
||||
MK33041 = 6,
|
||||
Q242 = 7
|
||||
};
|
||||
enum CG023
|
||||
{
|
||||
@ -146,126 +147,118 @@ struct PPM_Parameters
|
||||
//*******************
|
||||
//*** Pinouts ***
|
||||
//*******************
|
||||
//#define BIND_pin 13
|
||||
#define LED_pin 13 //Promini original led on B5
|
||||
//
|
||||
#define PPM_pin 3 //PPM -D3
|
||||
#define PPM_pin 3 //PPM-D3
|
||||
#ifdef XMEGA
|
||||
#define SDI_pin 6 //SDIO-D6
|
||||
#define SDI_pin 6 //SDIO-D6
|
||||
#else
|
||||
#define SDI_pin 5 //SDIO-D5
|
||||
#define SDI_pin 5 //SDIO-D5
|
||||
#endif
|
||||
#define SCLK_pin 4 //SCK-D4
|
||||
#define CS_pin 2 //CS-D2
|
||||
#define SDO_pin 6 //D6
|
||||
//
|
||||
#define CC25_CSN_pin 7
|
||||
#define NRF_CSN_pin 8
|
||||
#define CYRF_CSN_pin 9
|
||||
#define CTRL1 1 //C1 (A1)
|
||||
#define CTRL2 2 //C2 (A2)
|
||||
//
|
||||
#ifdef XMEGA
|
||||
#define CTRL1_on
|
||||
#define CTRL1_off
|
||||
//
|
||||
#define CTRL2_on
|
||||
#define CTRL2_off
|
||||
#define CTRL1_on
|
||||
#define CTRL1_off
|
||||
#define CTRL2_on
|
||||
#define CTRL2_off
|
||||
#else
|
||||
#define CTRL1_on PORTC |= _BV(1)
|
||||
#define CTRL1_off PORTC &= ~_BV(1)
|
||||
//
|
||||
#define CTRL2_on PORTC |= _BV(2)
|
||||
#define CTRL2_off PORTC &= ~_BV(2)
|
||||
#define CTRL1_on PORTC |= _BV(1)
|
||||
#define CTRL1_off PORTC &= ~_BV(1)
|
||||
#define CTRL2_on PORTC |= _BV(2)
|
||||
#define CTRL2_off PORTC &= ~_BV(2)
|
||||
#endif
|
||||
//
|
||||
#ifdef XMEGA
|
||||
#define CS_on PORTD.OUTSET = _BV(4) //D4
|
||||
#define CS_off PORTD.OUTCLR = _BV(4) //D4
|
||||
#define CS_on PORTD.OUTSET = _BV(4) //D4
|
||||
#define CS_off PORTD.OUTCLR = _BV(4) //D4
|
||||
#else
|
||||
#define CS_on PORTD |= _BV(2) //D2
|
||||
#define CS_off PORTD &= ~_BV(2) //D2
|
||||
#define CS_on PORTD |= _BV(2) //D2
|
||||
#define CS_off PORTD &= ~_BV(2) //D2
|
||||
#endif
|
||||
//
|
||||
#ifdef XMEGA
|
||||
#define SCK_on PORTD.OUTSET = _BV(7) //D7
|
||||
#define SCK_off PORTD.OUTCLR = _BV(7) //D7
|
||||
#define SCK_on PORTD.OUTSET = _BV(7) //D7
|
||||
#define SCK_off PORTD.OUTCLR = _BV(7) //D7
|
||||
#else
|
||||
#define SCK_on PORTD |= _BV(4) //D4
|
||||
#define SCK_off PORTD &= ~_BV(4) //D4
|
||||
#define SCK_on PORTD |= _BV(4) //D4
|
||||
#define SCK_off PORTD &= ~_BV(4) //D4
|
||||
#endif
|
||||
//
|
||||
#ifdef XMEGA
|
||||
#define SDI_on PORTD.OUTSET = _BV(5) //D5
|
||||
#define SDI_off PORTD.OUTCLR = _BV(5) //D5
|
||||
#define SDI_on PORTD.OUTSET = _BV(5) //D5
|
||||
#define SDI_off PORTD.OUTCLR = _BV(5) //D5
|
||||
#else
|
||||
#define SDI_on PORTD |= _BV(5) //D5
|
||||
#define SDI_off PORTD &= ~_BV(5) //D5
|
||||
#define SDI_on PORTD |= _BV(5) //D5
|
||||
#define SDI_off PORTD &= ~_BV(5) //D5
|
||||
#endif
|
||||
|
||||
//
|
||||
#ifdef XMEGA
|
||||
#define SDI_1 (PORTD.IN & (1<<SDI_pin)) == (1<<SDI_pin) //D5
|
||||
#define SDI_0 (PORTD.IN & (1<<SDI_pin)) == 0x00 //D5
|
||||
#define SDI_1 (PORTD.IN & (1<<SDI_pin)) == (1<<SDI_pin) //D5
|
||||
#define SDI_0 (PORTD.IN & (1<<SDI_pin)) == 0x00 //D5
|
||||
#else
|
||||
#define SDI_1 (PIND & (1<<SDI_pin)) == (1<<SDI_pin) //D5
|
||||
#define SDI_0 (PIND & (1<<SDI_pin)) == 0x00 //D5
|
||||
#define SDI_1 (PIND & (1<<SDI_pin)) == (1<<SDI_pin) //D5
|
||||
#define SDI_0 (PIND & (1<<SDI_pin)) == 0x00 //D5
|
||||
#endif
|
||||
//
|
||||
#define SDI_SET_INPUT DDRD &= ~_BV(5) //D5
|
||||
#define SDI_SET_OUTPUT DDRD |= _BV(5) //D5
|
||||
//Hisky /CC2500/CYRF aditional pinout
|
||||
#define CC25_CSN_pin 7
|
||||
#define NRF_CSN_pin 8
|
||||
#define CYRF_CSN_pin 9
|
||||
//
|
||||
#define CYRF_RST_pin A5 //reset pin
|
||||
//
|
||||
#ifdef XMEGA
|
||||
#define CC25_CSN_on PORTD.OUTSET = _BV(7) //D7
|
||||
#define CC25_CSN_off PORTD.OUTCLR = _BV(7) //D7
|
||||
#define CC25_CSN_on PORTD.OUTSET = _BV(7) //D7
|
||||
#define CC25_CSN_off PORTD.OUTCLR = _BV(7) //D7
|
||||
#else
|
||||
#define CC25_CSN_on PORTD |= _BV(7) //D7
|
||||
#define CC25_CSN_off PORTD &= ~_BV(7) //D7
|
||||
#define CC25_CSN_on PORTD |= _BV(7) //D7
|
||||
#define CC25_CSN_off PORTD &= ~_BV(7) //D7
|
||||
#endif
|
||||
//
|
||||
#ifdef XMEGA
|
||||
#define NRF_CSN_on
|
||||
#define NRF_CSN_off
|
||||
#define NRF_CSN_on
|
||||
#define NRF_CSN_off
|
||||
#else
|
||||
#define NRF_CSN_on PORTB |= _BV(0) //D8
|
||||
#define NRF_CSN_off PORTB &= ~_BV(0) //D8
|
||||
#define NRF_CSN_on PORTB |= _BV(0) //D8
|
||||
#define NRF_CSN_off PORTB &= ~_BV(0) //D8
|
||||
#endif
|
||||
//
|
||||
#ifdef XMEGA
|
||||
#define CYRF_CSN_on PORTD.OUTSET = _BV(4) //D9
|
||||
#define CYRF_CSN_off PORTD.OUTCLR = _BV(4) //D9
|
||||
#define CYRF_CSN_on PORTD.OUTSET = _BV(4)
|
||||
#define CYRF_CSN_off PORTD.OUTCLR = _BV(4)
|
||||
#else
|
||||
#define CYRF_CSN_on PORTB |= _BV(1) //D9
|
||||
#define CYRF_CSN_off PORTB &= ~_BV(1) //D9
|
||||
#define CYRF_RST_HI PORTC|= _BV(5) //reset cyrf
|
||||
#define CYRF_RST_LO PORTC&=~_BV(5) //
|
||||
#define CYRF_CSN_on PORTB |= _BV(1) //D9
|
||||
#define CYRF_CSN_off PORTB &= ~_BV(1) //D9
|
||||
#define CYRF_RST_HI PORTC |= _BV(5) //A5
|
||||
#define CYRF_RST_LO PORTC &= ~_BV(5) //A5
|
||||
#endif
|
||||
//
|
||||
#ifdef XMEGA
|
||||
#define SDO_1 (PORTD.IN & (1<<SDO_pin)) == (1<<SDO_pin) //D6
|
||||
#define SDO_0 (PORTD.IN & (1<<SDO_pin)) == 0x00 //D6
|
||||
#define SDO_1 (PORTD.IN & (1<<SDO_pin)) == (1<<SDO_pin) //D6
|
||||
#define SDO_0 (PORTD.IN & (1<<SDO_pin)) == 0x00 //D6
|
||||
#else
|
||||
#define SDO_1 (PIND & (1<<SDO_pin)) == (1<<SDO_pin) //D6
|
||||
#define SDO_0 (PIND & (1<<SDO_pin)) == 0x00 //D6
|
||||
#define SDO_1 (PIND & (1<<SDO_pin)) == (1<<SDO_pin) //D6
|
||||
#define SDO_0 (PIND & (1<<SDO_pin)) == 0x00 //D6
|
||||
#endif
|
||||
//
|
||||
//
|
||||
|
||||
// LED
|
||||
#ifdef XMEGA
|
||||
#define LED_ON PORTD.OUTCLR = _BV(1)
|
||||
#define LED_OFF PORTD.OUTSET = _BV(1)
|
||||
#define LED_TOGGLE PORTD.OUTTGL = _BV(1)
|
||||
#define LED_SET_OUTPUT PORTD.DIRSET = _BV(1)
|
||||
#define IS_LED_on ( (PORTD.OUT & _BV(1)) != 0x00 )
|
||||
#define LED_ON PORTD.OUTCLR = _BV(1)
|
||||
#define LED_OFF PORTD.OUTSET = _BV(1)
|
||||
#define LED_TOGGLE PORTD.OUTTGL = _BV(1)
|
||||
#define LED_SET_OUTPUT PORTD.DIRSET = _BV(1)
|
||||
#define IS_LED_on ( (PORTD.OUT & _BV(1)) != 0x00 )
|
||||
#else
|
||||
#define LED_ON PORTB |= _BV(5)
|
||||
#define LED_OFF PORTB &= ~_BV(5)
|
||||
#define LED_TOGGLE PORTB ^= _BV(5)
|
||||
#define LED_SET_OUTPUT DDRB |= _BV(5)
|
||||
#define IS_LED_on ( (PORTB & _BV(5)) != 0x00 )
|
||||
#define LED_ON PORTB |= _BV(5)
|
||||
#define LED_OFF PORTB &= ~_BV(5)
|
||||
#define LED_TOGGLE PORTB ^= _BV(5)
|
||||
#define LED_SET_OUTPUT DDRB |= _BV(5)
|
||||
#define IS_LED_on ( (PORTB & _BV(5)) != 0x00 )
|
||||
#endif
|
||||
|
||||
// TX
|
||||
|
@ -28,6 +28,7 @@
|
||||
|
||||
//Multiprotocol module configuration file
|
||||
#include "_Config.h"
|
||||
#include "TX_Def.h"
|
||||
|
||||
//Global constants/variables
|
||||
uint32_t MProtocol_id;//tx id,
|
||||
@ -47,6 +48,7 @@ uint8_t packet[40];
|
||||
// Servo data
|
||||
uint16_t Servo_data[NUM_CHN];
|
||||
uint8_t Servo_AUX;
|
||||
uint16_t servo_max_100,servo_min_100,servo_max_125,servo_min_125;
|
||||
|
||||
// Protocol variables
|
||||
uint8_t rx_tx_addr[5];
|
||||
@ -195,8 +197,10 @@ void setup()
|
||||
// Set servos positions
|
||||
for(uint8_t i=0;i<NUM_CHN;i++)
|
||||
Servo_data[i]=1500;
|
||||
Servo_data[THROTTLE]=PPM_MIN_100;
|
||||
Servo_data[THROTTLE]=servo_min_100;
|
||||
#ifdef ENABLE_PPM
|
||||
memcpy((void *)PPM_data,Servo_data, sizeof(Servo_data));
|
||||
#endif
|
||||
|
||||
//Wait for every component to start
|
||||
delayMilliseconds(100);
|
||||
@ -217,9 +221,6 @@ void setup()
|
||||
#else
|
||||
mode_select=0x0F - ( ( (PINB>>2)&0x07 ) | ( (PINC<<3)&0x08) );//encoder dip switches 1,2,4,8=>B2,B3,B4,C0
|
||||
#endif
|
||||
//**********************************
|
||||
//mode_select=1; // here to test PPM
|
||||
//**********************************
|
||||
|
||||
// Update LED
|
||||
LED_OFF;
|
||||
@ -242,6 +243,7 @@ void setup()
|
||||
NRF24L01_Reset();
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_PPM
|
||||
//Protocol and interrupts initialization
|
||||
if(mode_select != MODE_SERIAL)
|
||||
{ // PPM
|
||||
@ -254,6 +256,8 @@ void setup()
|
||||
if(PPM_prot[mode_select].power) POWER_FLAG_on;
|
||||
if(PPM_prot[mode_select].autobind) AUTOBIND_FLAG_on;
|
||||
mode_select++;
|
||||
servo_max_100=PPM_MAX_100; servo_min_100=PPM_MIN_100;
|
||||
servo_max_125=PPM_MAX_125; servo_min_125=PPM_MIN_125;
|
||||
|
||||
protocol_init();
|
||||
|
||||
@ -268,17 +272,23 @@ void setup()
|
||||
#endif
|
||||
}
|
||||
else
|
||||
#endif //ENABLE_PPM
|
||||
{ // Serial
|
||||
#ifdef ENABLE_SERIAL
|
||||
cur_protocol[0]=0;
|
||||
cur_protocol[1]=0;
|
||||
prev_protocol=0;
|
||||
servo_max_100=SERIAL_MAX_100; servo_min_100=SERIAL_MIN_100;
|
||||
servo_max_125=SERIAL_MAX_125; servo_min_125=SERIAL_MIN_125;
|
||||
Mprotocol_serial_init(); // Configure serial and enable RX interrupt
|
||||
#endif //ENABLE_SERIAL
|
||||
}
|
||||
}
|
||||
|
||||
// Main
|
||||
void loop()
|
||||
{
|
||||
#ifdef ENABLE_SERIAL
|
||||
if(mode_select==MODE_SERIAL && IS_RX_FLAG_on) // Serial mode and something has been received
|
||||
{
|
||||
update_serial_data(); // Update protocol and data
|
||||
@ -291,6 +301,8 @@ void loop()
|
||||
CHANGE_PROTOCOL_FLAG_off; //done
|
||||
}
|
||||
}
|
||||
#endif //ENABLE_SERIAL
|
||||
#ifdef ENABLE_PPM
|
||||
if(mode_select!=MODE_SERIAL && IS_PPM_FLAG_on) // PPM mode and a full frame has been received
|
||||
{
|
||||
for(uint8_t i=0;i<NUM_CHN;i++)
|
||||
@ -299,11 +311,14 @@ void loop()
|
||||
cli(); // disable global int
|
||||
temp_ppm = PPM_data[i] ;
|
||||
sei(); // enable global int
|
||||
if(temp_ppm<PPM_MIN_125) temp_ppm=PPM_MIN_125;
|
||||
else if(temp_ppm>PPM_MAX_125) temp_ppm=PPM_MAX_125;
|
||||
Servo_data[i]= temp_ppm ;
|
||||
}
|
||||
update_aux_flags();
|
||||
PPM_FLAG_off; // wait for next frame before update
|
||||
}
|
||||
#endif //ENABLE_PPM
|
||||
update_led_status();
|
||||
#if defined(TELEMETRY)
|
||||
if( ((cur_protocol[0]&0x1F)==MODE_FRSKY) || ((cur_protocol[0]&0x1F)==MODE_HUBSAN) || ((cur_protocol[0]&0x1F)==MODE_FRSKYX) || ((cur_protocol[0]&0x1F)==MODE_DSM2) )
|
||||
@ -362,10 +377,8 @@ static void CheckTimer(uint16_t (*cb)(void))
|
||||
#else
|
||||
if( (TIFR1 & (1<<OCF1A)) != 0)
|
||||
{
|
||||
uint16_t temp ;
|
||||
temp = TCNT1 ;
|
||||
cli(); // disable global int
|
||||
OCR1A=temp; // Callback should already have been called... Use "now" as new sync point.
|
||||
OCR1A=TCNT1; // Callback should already have been called... Use "now" as new sync point.
|
||||
sei(); // enable global int
|
||||
}
|
||||
else
|
||||
@ -384,10 +397,8 @@ static void CheckTimer(uint16_t (*cb)(void))
|
||||
sei(); // enable global int
|
||||
while((TCC1.INTFLAGS & TC1_CCAIF_bm) == 0); // wait 2ms...
|
||||
#else
|
||||
uint16_t temp ;
|
||||
temp = OCR1A + 2000*2 ;
|
||||
cli(); // disable global int
|
||||
OCR1A = temp ; // set compare A for callback
|
||||
OCR1A = OCR1A + 2000*2 ; // set compare A for callback
|
||||
TIFR1=(1<<OCF1A); // clear compare A=callback flag
|
||||
sei(); // enable global int
|
||||
while((TIFR1 & (1<<OCF1A)) == 0); // wait 2ms...
|
||||
@ -595,7 +606,7 @@ static void protocol_init()
|
||||
|
||||
if(next_callback>32000)
|
||||
{ // next_callback should not be more than 32767 so we will wait here...
|
||||
uint16_t temp=next_callback>>10-2;
|
||||
uint16_t temp=(next_callback>>10)-2;
|
||||
delayMilliseconds(temp);
|
||||
next_callback-=temp<<10; // between 2-3ms left at this stage
|
||||
}
|
||||
@ -612,7 +623,7 @@ static void protocol_init()
|
||||
BIND_BUTTON_FLAG_off; // do not bind/reset id anymore even if protocol change
|
||||
}
|
||||
|
||||
static void update_serial_data()
|
||||
void update_serial_data()
|
||||
{
|
||||
if(rx_ok_buff[0]&0x20) //check range
|
||||
RANGE_FLAG_on;
|
||||
@ -660,7 +671,7 @@ static void update_serial_data()
|
||||
RX_FLAG_off; //data has been processed
|
||||
}
|
||||
|
||||
static void module_reset()
|
||||
void module_reset()
|
||||
{
|
||||
if(remote_callback)
|
||||
{ // previous protocol loaded
|
||||
@ -703,13 +714,13 @@ int16_t map( int16_t x, int16_t in_min, int16_t in_max, int16_t out_min, int16_t
|
||||
// Channel value is converted to 8bit values full scale
|
||||
uint8_t convert_channel_8b(uint8_t num)
|
||||
{
|
||||
return (uint8_t) (map(limit_channel_100(num),PPM_MIN_100,PPM_MAX_100,0,255));
|
||||
return (uint8_t) (map(limit_channel_100(num),servo_min_100,servo_max_100,0,255));
|
||||
}
|
||||
|
||||
// Channel value is converted to 8bit values to provided values scale
|
||||
uint8_t convert_channel_8b_scale(uint8_t num,uint8_t min,uint8_t max)
|
||||
{
|
||||
return (uint8_t) (map(limit_channel_100(num),PPM_MIN_100,PPM_MAX_100,min,max));
|
||||
return (uint8_t) (map(limit_channel_100(num),servo_min_100,servo_max_100,min,max));
|
||||
}
|
||||
|
||||
// Channel value is converted sign + magnitude 8bit values
|
||||
@ -723,7 +734,7 @@ uint8_t convert_channel_s8b(uint8_t num)
|
||||
// Channel value is converted to 10bit values
|
||||
uint16_t convert_channel_10b(uint8_t num)
|
||||
{
|
||||
return (uint16_t) (map(limit_channel_100(num),PPM_MIN_100,PPM_MAX_100,1,1023));
|
||||
return (uint16_t) (map(limit_channel_100(num),servo_min_100,servo_max_100,1,1023));
|
||||
}
|
||||
|
||||
// Channel value is multiplied by 1.5
|
||||
@ -743,15 +754,15 @@ void convert_channel_HK310(uint8_t num, uint8_t *low, uint8_t *high)
|
||||
// Channel value is limited to PPM_100
|
||||
uint16_t limit_channel_100(uint8_t ch)
|
||||
{
|
||||
if(Servo_data[ch]>PPM_MAX_100)
|
||||
return PPM_MAX_100;
|
||||
if(Servo_data[ch]>servo_max_100)
|
||||
return servo_max_100;
|
||||
else
|
||||
if (Servo_data[ch]<PPM_MIN_100)
|
||||
return PPM_MIN_100;
|
||||
if (Servo_data[ch]<servo_min_100)
|
||||
return servo_min_100;
|
||||
return Servo_data[ch];
|
||||
}
|
||||
|
||||
static void Mprotocol_serial_init()
|
||||
void Mprotocol_serial_init()
|
||||
{
|
||||
#ifdef XMEGA
|
||||
|
||||
@ -787,7 +798,7 @@ static void Mprotocol_serial_init()
|
||||
}
|
||||
|
||||
#if defined(TELEMETRY)
|
||||
static void PPM_Telemetry_serial_init()
|
||||
void PPM_Telemetry_serial_init()
|
||||
{
|
||||
initTXSerial( SPEED_9600 ) ;
|
||||
}
|
||||
@ -843,6 +854,7 @@ void SPI_Write(uint8_t command)
|
||||
SDI_on;
|
||||
else
|
||||
SDI_off;
|
||||
NOP();
|
||||
SCK_on;
|
||||
NOP();
|
||||
command = command << 1;
|
||||
@ -982,6 +994,7 @@ void init()
|
||||
/**************************/
|
||||
|
||||
//PPM
|
||||
#ifdef ENABLE_PPM
|
||||
#ifdef XMEGA
|
||||
ISR(PORTD_INT0_vect)
|
||||
#else
|
||||
@ -1008,17 +1021,16 @@ ISR(INT1_vect, ISR_NOBLOCK)
|
||||
else
|
||||
if(chan!=-1) // need to wait for start of frame
|
||||
{ //servo values between 500us and 2420us will end up here
|
||||
uint16_t temp = Cur_TCNT1>>1;
|
||||
if(temp<PPM_MIN) temp=PPM_MIN;
|
||||
else if(temp>PPM_MAX) temp=PPM_MAX;
|
||||
PPM_data[chan]=temp;
|
||||
PPM_data[chan]= Cur_TCNT1>>1;;
|
||||
if(chan++>=NUM_CHN)
|
||||
chan=-1; // don't accept any new channels
|
||||
}
|
||||
Prev_TCNT1+=Cur_TCNT1;
|
||||
}
|
||||
#endif //ENABLE_PPM
|
||||
|
||||
//Serial RX
|
||||
#ifdef ENABLE_SERIAL
|
||||
#ifdef XMEGA
|
||||
ISR(USARTC0_RXC_vect)
|
||||
#else
|
||||
@ -1071,8 +1083,7 @@ ISR(USART_RX_vect)
|
||||
#endif
|
||||
if(!IS_RX_FLAG_on)
|
||||
{ //Good frame received and main has finished with previous buffer
|
||||
uint8_t i ;
|
||||
for(i=0;i<RXBUFFER_SIZE;i++)
|
||||
for(uint8_t i=0;i<RXBUFFER_SIZE;i++)
|
||||
rx_ok_buff[i]=rx_buff[i]; // Duplicate the buffer
|
||||
RX_FLAG_on; // flag for main to process servo data
|
||||
}
|
||||
@ -1106,4 +1117,4 @@ ISR(TIMER1_COMPB_vect, ISR_NOBLOCK )
|
||||
{ // Timer1 compare B interrupt
|
||||
idx=0;
|
||||
}
|
||||
|
||||
#endif //ENABLE_SERIAL
|
@ -127,7 +127,7 @@ static void __attribute__((unused)) SFHSS_calc_next_chan()
|
||||
// Values grow down and to the right, so we just revert every channel.
|
||||
static uint16_t __attribute__((unused)) SFHSS_convert_channel(uint8_t num)
|
||||
{
|
||||
return (uint16_t) (map(limit_channel_100(num),PPM_MIN_100,PPM_MAX_100,906,86));
|
||||
return (uint16_t) (map(limit_channel_100(num),servo_min_100,servo_max_100,906,86));
|
||||
}
|
||||
|
||||
static void __attribute__((unused)) SFHSS_build_data_packet()
|
||||
|
255
Multiprotocol/TX_Def.h
Normal file
255
Multiprotocol/TX_Def.h
Normal file
@ -0,0 +1,255 @@
|
||||
// Turnigy PPM and channels
|
||||
#if defined(TX_ER9X)
|
||||
#define PPM_MAX_100 2012 // 100%
|
||||
#define PPM_MIN_100 988 // 100%
|
||||
#define PPM_MAX_125 2140 // 125%
|
||||
#define PPM_MIN_125 860 // 125%
|
||||
#endif
|
||||
|
||||
// Devo PPM and channels
|
||||
#if defined(TX_DEVO7)
|
||||
#define PPM_MAX_100 1920 // 100%
|
||||
#define PPM_MIN_100 1120 // 100%
|
||||
#define PPM_MAX_125 2100 // 125%
|
||||
#define PPM_MIN_125 900 // 125%
|
||||
#endif
|
||||
|
||||
// SPEKTRUM PPM and channels
|
||||
#if defined(TX_SPEKTRUM)
|
||||
#define PPM_MAX_100 1900 // 100%
|
||||
#define PPM_MIN_100 1100 // 100%
|
||||
#define PPM_MAX_125 2000 // 125%
|
||||
#define PPM_MIN_125 1000 // 125%
|
||||
#endif
|
||||
|
||||
// HISKY
|
||||
#if defined(TX_HISKY)
|
||||
#define PPM_MAX_125 2000 // 125%
|
||||
#define PPM_MIN_125 1000 // 125%
|
||||
#define PPM_MAX_100 1900 // 100%
|
||||
#define PPM_MIN_100 1100 // 100%
|
||||
#define PPM_MAX_125 2000 // 125%
|
||||
#define PPM_MIN_125 1000 // 125%
|
||||
#endif
|
||||
|
||||
//Serial MIN MAX values
|
||||
#define SERIAL_MAX_100 2012 // 100%
|
||||
#define SERIAL_MIN_100 988 // 100%
|
||||
#define SERIAL_MAX_125 2140 // 125%
|
||||
#define SERIAL_MIN_125 860 // 125%
|
||||
|
||||
//PPM values used to compare
|
||||
#define PPM_MIN_COMMAND 1250
|
||||
#define PPM_SWITCH 1550
|
||||
#define PPM_MAX_COMMAND 1750
|
||||
|
||||
//Channel definitions
|
||||
#ifdef AETR
|
||||
enum {
|
||||
AILERON =0,
|
||||
ELEVATOR,
|
||||
THROTTLE,
|
||||
RUDDER,
|
||||
};
|
||||
#endif
|
||||
#ifdef AERT
|
||||
enum {
|
||||
AILERON =0,
|
||||
ELEVATOR,
|
||||
RUDDER,
|
||||
THROTTLE,
|
||||
};
|
||||
#endif
|
||||
#ifdef ARET
|
||||
enum {
|
||||
AILERON =0,
|
||||
RUDDER,
|
||||
ELEVATOR,
|
||||
THROTTLE,
|
||||
};
|
||||
#endif
|
||||
#ifdef ARTE
|
||||
enum {
|
||||
AILERON =0,
|
||||
RUDDER,
|
||||
THROTTLE,
|
||||
ELEVATOR,
|
||||
};
|
||||
#endif
|
||||
#ifdef ATRE
|
||||
enum {
|
||||
AILERON =0,
|
||||
THROTTLE,
|
||||
RUDDER,
|
||||
ELEVATOR,
|
||||
};
|
||||
#endif
|
||||
#ifdef ATER
|
||||
enum {
|
||||
AILERON =0,
|
||||
THROTTLE,
|
||||
ELEVATOR,
|
||||
RUDDER,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef EATR
|
||||
enum {
|
||||
ELEVATOR =0,
|
||||
AILERON,
|
||||
THROTTLE,
|
||||
RUDDER,
|
||||
};
|
||||
#endif
|
||||
#ifdef EART
|
||||
enum {
|
||||
ELEVATOR =0,
|
||||
AILERON,
|
||||
RUDDER,
|
||||
THROTTLE,
|
||||
};
|
||||
#endif
|
||||
#ifdef ERAT
|
||||
enum {
|
||||
ELEVATOR =0,
|
||||
RUDDER,
|
||||
AILERON,
|
||||
THROTTLE,
|
||||
};
|
||||
#endif
|
||||
#ifdef ERTA
|
||||
enum {
|
||||
ELEVATOR =0,
|
||||
RUDDER,
|
||||
THROTTLE,
|
||||
AILERON,
|
||||
};
|
||||
#endif
|
||||
#ifdef ETRA
|
||||
enum {
|
||||
ELEVATOR =0,
|
||||
THROTTLE,
|
||||
RUDDER,
|
||||
AILERON,
|
||||
};
|
||||
#endif
|
||||
#ifdef ETAR
|
||||
enum {
|
||||
ELEVATOR =0,
|
||||
THROTTLE,
|
||||
AILERON,
|
||||
RUDDER,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef TEAR
|
||||
enum {
|
||||
THROTTLE =0,
|
||||
ELEVATOR,
|
||||
AILERON,
|
||||
RUDDER,
|
||||
};
|
||||
#endif
|
||||
#ifdef TERA
|
||||
enum {
|
||||
THROTTLE =0,
|
||||
ELEVATOR,
|
||||
RUDDER,
|
||||
AILERON,
|
||||
};
|
||||
#endif
|
||||
#ifdef TREA
|
||||
enum {
|
||||
THROTTLE =0,
|
||||
RUDDER,
|
||||
ELEVATOR,
|
||||
AILERON,
|
||||
};
|
||||
#endif
|
||||
#ifdef TRAE
|
||||
enum {
|
||||
THROTTLE =0,
|
||||
RUDDER,
|
||||
AILERON,
|
||||
ELEVATOR,
|
||||
};
|
||||
#endif
|
||||
#ifdef TARE
|
||||
enum {
|
||||
THROTTLE =0,
|
||||
AILERON,
|
||||
RUDDER,
|
||||
ELEVATOR,
|
||||
};
|
||||
#endif
|
||||
#ifdef TAER
|
||||
enum {
|
||||
THROTTLE =0,
|
||||
AILERON,
|
||||
ELEVATOR,
|
||||
RUDDER,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef RETA
|
||||
enum {
|
||||
RUDDER =0,
|
||||
ELEVATOR,
|
||||
THROTTLE,
|
||||
AILERON,
|
||||
};
|
||||
#endif
|
||||
#ifdef REAT
|
||||
enum {
|
||||
RUDDER =0,
|
||||
ELEVATOR,
|
||||
AILERON,
|
||||
THROTTLE,
|
||||
};
|
||||
#endif
|
||||
#ifdef RAET
|
||||
enum {
|
||||
RUDDER =0,
|
||||
AILERON,
|
||||
ELEVATOR,
|
||||
THROTTLE,
|
||||
};
|
||||
#endif
|
||||
#ifdef RATE
|
||||
enum {
|
||||
RUDDER =0,
|
||||
AILERON,
|
||||
THROTTLE,
|
||||
ELEVATOR,
|
||||
};
|
||||
#endif
|
||||
#ifdef RTAE
|
||||
enum {
|
||||
RUDDER =0,
|
||||
THROTTLE,
|
||||
AILERON,
|
||||
ELEVATOR,
|
||||
};
|
||||
#endif
|
||||
#ifdef RTEA
|
||||
enum {
|
||||
RUDDER =0,
|
||||
THROTTLE,
|
||||
ELEVATOR,
|
||||
AILERON,
|
||||
};
|
||||
#endif
|
||||
|
||||
#define AUX1 4
|
||||
#define AUX2 5
|
||||
#define AUX3 6
|
||||
#define AUX4 7
|
||||
#define AUX5 8
|
||||
#define AUX6 9
|
||||
#define AUX7 10
|
||||
#define AUX8 11
|
||||
#define AUX9 12
|
||||
#define AUX10 13
|
||||
#define AUX11 14
|
||||
#define AUX12 15
|
||||
#define AUX13 16
|
@ -133,7 +133,8 @@ void frsky_link_frame()
|
||||
#if defined HUB_TELEMETRY
|
||||
void frsky_user_frame()
|
||||
{
|
||||
uint8_t indexx = 0, c=0, j=8, n=0, i;
|
||||
uint8_t indexx = 0, j=8, i;
|
||||
//uint8_t c=0, n=0;
|
||||
|
||||
if(pktt[6]>0 && pktt[6]<=10)
|
||||
{//only valid hub frames
|
||||
|
@ -13,28 +13,32 @@
|
||||
along with Multiprotocol. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**********************************************/
|
||||
/** Multiprotocol module configuration file ***/
|
||||
/**********************************************/
|
||||
|
||||
/*******************/
|
||||
/*** TX SETTINGS ***/
|
||||
/*******************/
|
||||
//Uncomment your TX type
|
||||
#define TX_ER9X_AETR //ER9X AETR (988<->2012µs)
|
||||
//#define TX_ER9X_TAER //ER9X TAER (988<->2012µs)
|
||||
//#define TX_DEVO7 //DEVO7 EATR (1120<->1920µs)
|
||||
//#define TX_SPEKTRUM //Spektrum TAER (1100<->1900µs)
|
||||
//#define TX_HISKY //HISKY AETR (1100<->1900µs)
|
||||
//Modify the channel order based on your TX: AETR, TAER, RETA...
|
||||
//For example a JR/Spektrum radio is TAER. Default is AETR.
|
||||
#define AETR
|
||||
|
||||
|
||||
/****************************/
|
||||
/*** PROTOCOLS TO INCLUDE ***/
|
||||
/****************************/
|
||||
//Comment if a module is not installed
|
||||
//In this section select the protocols you want to be accessible when using the module.
|
||||
//All the protocols will not fit in the module so you need to pick and choose.
|
||||
|
||||
//There are 4 RF components supported. If one of them is not installed you must comment it using "//".
|
||||
//This is also a quick way to reduce the number of protocols and save Flash space.
|
||||
#define A7105_INSTALLED
|
||||
#define CYRF6936_INSTALLED
|
||||
#define CC2500_INSTALLED
|
||||
#define NFR24L01_INSTALLED
|
||||
|
||||
//Comment a protocol to exclude it from compilation
|
||||
//Bellow is the list of all available protocols. Comment the protocols you are not using with "//" to save Flash space.
|
||||
#ifdef A7105_INSTALLED
|
||||
#define FLYSKY_A7105_INO
|
||||
#define HUBSAN_A7105_INO
|
||||
@ -68,16 +72,20 @@
|
||||
#define ASSAN_NRF24L01_INO
|
||||
#endif
|
||||
|
||||
|
||||
/**************************/
|
||||
/*** TELEMETRY SETTINGS ***/
|
||||
/**************************/
|
||||
//Uncomment to enable telemetry
|
||||
//In this section you can configure the telemetry.
|
||||
|
||||
//If you do not plan using the telemetry comment this global setting using "//" and skip to the next section.
|
||||
#define TELEMETRY
|
||||
|
||||
//Uncomment to invert the telemetry serial signal, this is usefull for OpenTX on Taranis as an example
|
||||
//Uncomment to invert the polarity of the telemetry serial signal.
|
||||
//For ER9X and ERSKY9X it must be commented. For OpenTX it must be uncommented.
|
||||
//#define INVERT_TELEMETRY 1
|
||||
|
||||
//Comment to disable a specific telemetry
|
||||
//Comment a line to disable a protocol telemetry
|
||||
#if defined(TELEMETRY)
|
||||
#if defined DSM2_CYRF6936_INO
|
||||
#define DSM_TELEMETRY
|
||||
@ -90,18 +98,59 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/********************/
|
||||
/*** PPM SETTINGS ***/
|
||||
/********************/
|
||||
//Update this table to set which protocol and all associated settings are called for the corresponding dial number
|
||||
|
||||
/****************************/
|
||||
/*** SERIAL MODE SETTINGS ***/
|
||||
/****************************/
|
||||
//In this section you can configure the serial mode.
|
||||
//The serial mode enables full editing of all the parameters in the GUI of the radio.
|
||||
//This is available natively for ER9X and ERSKY9X. It is available for OpenTX on Taranis with a special version.
|
||||
|
||||
//If you do not plan to use the Serial mode comment this line using "//" to save Flash space
|
||||
#define ENABLE_SERIAL
|
||||
|
||||
|
||||
/*************************/
|
||||
/*** PPM MODE SETTINGS ***/
|
||||
/*************************/
|
||||
//In this section you can configure all details about PPM.
|
||||
//If you do not plan to use the PPM mode comment this line using "//" to save Flash space, you don't need to configure anything below in this case
|
||||
#define ENABLE_PPM
|
||||
|
||||
/*** TX END POINTS ***/
|
||||
//It is important for the module to know the endpoints of your radio.
|
||||
//Below are some standard transmitters already preconfigured.
|
||||
//Uncomment only the one which matches your transmitter.
|
||||
#define TX_ER9X //ER9X/ERSKY9X/OpenTX ( 988<->2012µs)
|
||||
//#define TX_DEVO7 //DEVO (1120<->1920µs)
|
||||
//#define TX_SPEKTRUM //Spektrum (1100<->1900µs)
|
||||
//#define TX_HISKY //HISKY (1100<->1900µs)
|
||||
//#define TX_CUSTOM //Custom
|
||||
|
||||
// The lines below are used to set the end points in microseconds (µs) if you have selected TX_CUSTOM.
|
||||
// A few things to considered:
|
||||
// - If you put too big values compared to your TX you won't be able to reach the extremes which is bad for throttle as an example
|
||||
// - If you put too low values you won't be able to use your full stick range, it will be maxed out before reaching the end
|
||||
// - Centered stick value is usually 1500. It should match the middle between MIN and MAX, ie Center=(MAX-MIN)/2+MIN. If your TX is not centered you can adjust the value MIN or MAX.
|
||||
// - 100% is the value when the model is by default, 125% is the value when you extend the servo travel which is only used by some protocols
|
||||
#if defined(TX_CUSTOM)
|
||||
#define PPM_MAX_100 1900 // 100%
|
||||
#define PPM_MIN_100 1100 // 100%
|
||||
#define PPM_MAX_125 2000 // 125%
|
||||
#define PPM_MIN_125 1000 // 125%
|
||||
#endif
|
||||
|
||||
//The table below indicates which protocol to run when a specific position on the dial has been selected.
|
||||
//All fields and values are explained below. Everything is configurable from here like in the Serial mode.
|
||||
//Example: You can associate multiple times the same protocol to different dial positions to take advantage of the model match (RX_Num)
|
||||
const PPM_Parameters PPM_prot[15]= {
|
||||
// Dial Protocol Sub protocol RX_Num Power Auto Bind Option
|
||||
/* 1 */ {MODE_FLYSKY, Flysky , 0 , P_HIGH , NO_AUTOBIND , 0 },
|
||||
/* 2 */ {MODE_HUBSAN, 0 , 0 , P_HIGH , NO_AUTOBIND , 0 },
|
||||
/* 3 */ {MODE_FRSKY , 0 , 0 , P_HIGH , NO_AUTOBIND , 0xD7 }, // D7 fine tuning
|
||||
/* 3 */ {MODE_FRSKY , 0 , 0 , P_HIGH , NO_AUTOBIND , 0 }, // option=fine freq tuning
|
||||
/* 4 */ {MODE_HISKY , Hisky , 0 , P_HIGH , NO_AUTOBIND , 0 },
|
||||
/* 5 */ {MODE_V2X2 , 0 , 0 , P_HIGH , NO_AUTOBIND , 0 },
|
||||
/* 6 */ {MODE_DSM2 , DSM2 , 0 , P_HIGH , NO_AUTOBIND , 6 }, // 6 channels @ 11ms
|
||||
/* 6 */ {MODE_DSM2 , DSM2 , 0 , P_HIGH , NO_AUTOBIND , 2 }, // option=2=6 channels @ 22ms
|
||||
/* 7 */ {MODE_DEVO , 0 , 0 , P_HIGH , NO_AUTOBIND , 0 },
|
||||
/* 8 */ {MODE_YD717 , YD717 , 0 , P_HIGH , NO_AUTOBIND , 0 },
|
||||
/* 9 */ {MODE_KN , WLTOYS , 0 , P_HIGH , NO_AUTOBIND , 0 },
|
||||
@ -112,7 +161,7 @@ const PPM_Parameters PPM_prot[15]= {
|
||||
/* 14 */ {MODE_BAYANG, 0 , 0 , P_HIGH , NO_AUTOBIND , 0 },
|
||||
/* 15 */ {MODE_SYMAX , SYMAX5C , 0 , P_HIGH , NO_AUTOBIND , 0 }
|
||||
};
|
||||
/* Available protocols and associated sub protocols:
|
||||
/* Available protocols and associated sub protocols to pick and choose from
|
||||
MODE_FLYSKY
|
||||
Flysky
|
||||
V9X9
|
||||
@ -188,134 +237,17 @@ const PPM_Parameters PPM_prot[15]= {
|
||||
NONE
|
||||
MODE_ASSAN
|
||||
NONE
|
||||
|
||||
RX_Num value between 0 and 15
|
||||
|
||||
Power P_HIGH or P_LOW
|
||||
|
||||
Auto Bind AUTOBIND or NO_AUTOBIND
|
||||
|
||||
Option value between 0 and 255. 0xD7 or 0x00 for Frsky fine tuning.
|
||||
*/
|
||||
|
||||
/*******************/
|
||||
/*** TX SETTINGS ***/
|
||||
/*******************/
|
||||
// Turnigy PPM and channels
|
||||
#if defined(TX_ER9X_AETR)
|
||||
#define PPM_MAX 2140 // 125%
|
||||
#define PPM_MIN 860 // 125%
|
||||
#define PPM_MAX_100 2012 // 100%
|
||||
#define PPM_MIN_100 988 // 100%
|
||||
enum chan_order{
|
||||
AILERON =0,
|
||||
ELEVATOR,
|
||||
THROTTLE,
|
||||
RUDDER,
|
||||
AUX1,
|
||||
AUX2,
|
||||
AUX3,
|
||||
AUX4,
|
||||
AUX5,
|
||||
AUX6,
|
||||
AUX7,
|
||||
AUX8,
|
||||
AUX9
|
||||
};
|
||||
#endif
|
||||
// RX_Num is used for model match. Using RX_Num values different for each receiver will prevent starting a model with the false config loaded...
|
||||
// RX_Num value is between 0 and 15.
|
||||
|
||||
// Turnigy PPM and channels
|
||||
#if defined(TX_ER9X_TAER)
|
||||
#define PPM_MAX 2140 // 125%
|
||||
#define PPM_MIN 860 // 125%
|
||||
#define PPM_MAX_100 2012 // 100%
|
||||
#define PPM_MIN_100 988 // 100%
|
||||
enum chan_order{
|
||||
THROTTLE =0,
|
||||
AILERON,
|
||||
ELEVATOR,
|
||||
RUDDER,
|
||||
AUX1,
|
||||
AUX2,
|
||||
AUX3,
|
||||
AUX4,
|
||||
AUX5,
|
||||
AUX6,
|
||||
AUX7,
|
||||
AUX8,
|
||||
AUX9
|
||||
};
|
||||
#endif
|
||||
// Power P_HIGH or P_LOW: High or low power setting for the transmission.
|
||||
// For indoor P_LOW is more than enough.
|
||||
|
||||
// Devo PPM and channels
|
||||
#if defined(TX_DEVO7)
|
||||
#define PPM_MAX 2100 // 125%
|
||||
#define PPM_MIN 900 // 125%
|
||||
#define PPM_MAX_100 1920 // 100%
|
||||
#define PPM_MIN_100 1120 // 100%
|
||||
enum chan_order{
|
||||
ELEVATOR=0,
|
||||
AILERON,
|
||||
THROTTLE,
|
||||
RUDDER,
|
||||
AUX1,
|
||||
AUX2,
|
||||
AUX3,
|
||||
AUX4,
|
||||
AUX5,
|
||||
AUX6,
|
||||
AUX7,
|
||||
AUX8,
|
||||
AUX9
|
||||
};
|
||||
#endif
|
||||
// Auto Bind AUTOBIND or NO_AUTOBIND
|
||||
// For protocols which does not require binding at each power up (like Flysky, FrSky...), you might still want a bind to be initiated each time you power up the TX.
|
||||
// As an exxample, it's usefull for the WLTOYS F929/F939/F949/F959 (all using the Flysky protocol) which requires a bind at each power up.
|
||||
|
||||
// SPEKTRUM PPM and channels
|
||||
#if defined(TX_SPEKTRUM)
|
||||
#define PPM_MAX 2000 // 125%
|
||||
#define PPM_MIN 1000 // 125%
|
||||
#define PPM_MAX_100 1900 // 100%
|
||||
#define PPM_MIN_100 1100 // 100%
|
||||
enum chan_order{
|
||||
THROTTLE=0,
|
||||
AILERON,
|
||||
ELEVATOR,
|
||||
RUDDER,
|
||||
AUX1,
|
||||
AUX2,
|
||||
AUX3,
|
||||
AUX4,
|
||||
AUX5,
|
||||
AUX6,
|
||||
AUX7,
|
||||
AUX8,
|
||||
AUX9
|
||||
};
|
||||
#endif
|
||||
|
||||
// HISKY
|
||||
#if defined(TX_HISKY)
|
||||
#define PPM_MAX 2000 // 125%
|
||||
#define PPM_MIN 1000 // 125%
|
||||
#define PPM_MAX_100 1900 // 100%
|
||||
#define PPM_MIN_100 1100 // 100%
|
||||
enum chan_order{
|
||||
AILERON =0,
|
||||
ELEVATOR,
|
||||
THROTTLE,
|
||||
RUDDER,
|
||||
AUX1,
|
||||
AUX2,
|
||||
AUX3,
|
||||
AUX4,
|
||||
AUX5,
|
||||
AUX6,
|
||||
AUX7,
|
||||
AUX8,
|
||||
AUX9
|
||||
};
|
||||
#endif
|
||||
|
||||
#define PPM_MIN_COMMAND 1250
|
||||
#define PPM_SWITCH 1550
|
||||
#define PPM_MAX_COMMAND 1750
|
||||
// Option: the value is between -127 and +127.
|
||||
// The option value is only valid for some protocols, read this page for more information: https://github.com/pascallanger/DIY-Multiprotocol-TX-Module/blob/master/Protocols_Details.md
|
Loading…
x
Reference in New Issue
Block a user