Small tweaks

This commit is contained in:
pascallanger 2019-11-01 15:11:31 +01:00
parent 9b499ab7d1
commit 5cf2bf2cf5
5 changed files with 24 additions and 20 deletions

View File

@ -132,7 +132,7 @@ static void __attribute__((unused)) FrSkyX_build_packet()
failsafe_chan = 0; failsafe_chan = 0;
} else if (FS_flag & 0x10 && failsafe_chan < (sub_protocol & 0x01 ? 8-1:16-1)) } else if (FS_flag & 0x10 && failsafe_chan < (sub_protocol & 0x01 ? 8-1:16-1))
{ {
FS_flag = 0x10 | ((FS_flag + 2) & 0x0F); //10, 12, 14, 16, 18, 1A, 1C, 1E - failsafe packet FS_flag = 0x10 | ((FS_flag + 2) & 0x0F); //10, 12, 14, 16, 18, 1A, 1C, 1E - failsafe packet
failsafe_chan ++; failsafe_chan ++;
} else if (FS_flag & 0x10) } else if (FS_flag & 0x10)
{ {
@ -142,7 +142,7 @@ static void __attribute__((unused)) FrSkyX_build_packet()
failsafe_count++; failsafe_count++;
#endif #endif
packet[0] = (sub_protocol & 0x02 ) ? 0x20 : 0x1D ; // LBT or FCC packet[0] = (sub_protocol & 0x02 ) ? 0x20 : 0x1D ; // LBT or FCC
packet[1] = rx_tx_addr[3]; packet[1] = rx_tx_addr[3];
packet[2] = rx_tx_addr[2]; packet[2] = rx_tx_addr[2];
packet[3] = 0x02; packet[3] = 0x02;
@ -179,11 +179,11 @@ static void __attribute__((unused)) FrSkyX_build_packet()
chan_1 = FrSkyX_scaleForPXX(startChan); chan_1 = FrSkyX_scaleForPXX(startChan);
startChan++; startChan++;
// //
packet[9+i] = lowByte(chan_0); //3 bytes*4 packet[9+i] = lowByte(chan_0); //3 bytes*4
packet[9+i+1]=(((chan_0>>8) & 0x0F)|(chan_1 << 4)); packet[9+i+1]=(((chan_0>>8) & 0x0F)|(chan_1 << 4));
packet[9+i+2]=chan_1>>4; packet[9+i+2]=chan_1>>4;
} }
if(sub_protocol & 0x01 ) // in X8 mode send only 8ch every 9ms if(sub_protocol & 0x01 ) //In X8 mode send only 8ch every 9ms
chan_offset = 0 ; chan_offset = 0 ;
else else
chan_offset^=0x08; chan_offset^=0x08;
@ -192,7 +192,7 @@ static void __attribute__((unused)) FrSkyX_build_packet()
uint8_t limit = (sub_protocol & 2 ) ? 31 : 28 ; uint8_t limit = (sub_protocol & 2 ) ? 31 : 28 ;
for (uint8_t i=22;i<limit;i++) for (uint8_t i=22;i<limit;i++)
packet[i]=0; packet[i]=0;
packet[21] = FrSkyX_RX_Seq << 4;//TX=8 at startup packet[21] = FrSkyX_RX_Seq << 4; //TX=8 at startup
#ifdef SPORT_SEND #ifdef SPORT_SEND
if (FrSkyX_TX_IN_Seq!=0xFF) if (FrSkyX_TX_IN_Seq!=0xFF)
{//RX has replied at least once {//RX has replied at least once
@ -201,7 +201,7 @@ static void __attribute__((unused)) FrSkyX_build_packet()
//debugln("Init"); //debugln("Init");
FrSkyX_TX_Seq = 0 ; FrSkyX_TX_Seq = 0 ;
for(uint8_t i=0;i<4;i++) for(uint8_t i=0;i<4;i++)
FrSkyX_TX_Frames[i].count=0; // discard frames in current output buffer FrSkyX_TX_Frames[i].count=0; //Discard frames in current output buffer
} }
else if (FrSkyX_TX_IN_Seq & 0x04) else if (FrSkyX_TX_IN_Seq & 0x04)
{//Retransmit the requested packet {//Retransmit the requested packet
@ -242,7 +242,7 @@ static void __attribute__((unused)) FrSkyX_build_packet()
debugln("Ok buf:%d",used); debugln("Ok buf:%d",used);
} }
} }
FrSkyX_TX_Seq = ( FrSkyX_TX_Seq + 1 ) & 0x03 ; // Next iteration send next packet FrSkyX_TX_Seq = ( FrSkyX_TX_Seq + 1 ) & 0x03 ; //Next iteration send next packet
} }
else else
{//Not in sequence somehow, transmit what the receiver wants but why not asking for retransmit... {//Not in sequence somehow, transmit what the receiver wants but why not asking for retransmit...
@ -254,7 +254,7 @@ static void __attribute__((unused)) FrSkyX_build_packet()
} }
} }
else else
packet[21] |= 0x08 ; //FrSkyX_TX_Seq=8 at startup packet[21] |= 0x08 ; //FrSkyX_TX_Seq=8 at startup
} }
if(packet[22]) if(packet[22])
{//Debug {//Debug
@ -266,7 +266,7 @@ static void __attribute__((unused)) FrSkyX_build_packet()
#else #else
packet[21] |= FrSkyX_TX_Seq ;//TX=8 at startup packet[21] |= FrSkyX_TX_Seq ;//TX=8 at startup
if ( !(FrSkyX_TX_IN_Seq & 0xF8) ) if ( !(FrSkyX_TX_IN_Seq & 0xF8) )
FrSkyX_TX_Seq = ( FrSkyX_TX_Seq + 1 ) & 0x03 ; // Next iteration send next packet FrSkyX_TX_Seq = ( FrSkyX_TX_Seq + 1 ) & 0x03 ; // Next iteration send next packet
#endif // SPORT_SEND #endif // SPORT_SEND
uint16_t lcrc = FrSkyX_crc(&packet[3], limit-3); uint16_t lcrc = FrSkyX_crc(&packet[3], limit-3);
@ -316,21 +316,22 @@ uint16_t ReadFrSkyX()
else else
{ {
packet_count++; packet_count++;
//debugln("M %d",packet_count);
// restart sequence on missed packet - might need count or timeout instead of one missed // restart sequence on missed packet - might need count or timeout instead of one missed
if(packet_count>100) if(packet_count>100)
{//~1sec {//~1sec
FrSkyX_TX_Seq = 0x08 ; // Request init FrSkyX_TX_Seq = 0x08 ; //Request init
FrSkyX_TX_IN_Seq = 0xFF ; // No sequence received yet FrSkyX_TX_IN_Seq = 0xFF ; //No sequence received yet
#ifdef SPORT_SEND #ifdef SPORT_SEND
for(uint8_t i=0;i<4;i++) for(uint8_t i=0;i<4;i++)
FrSkyX_TX_Frames[i].count=0; // discard frames in current output buffer FrSkyX_TX_Frames[i].count=0; //Discard frames in current output buffer
#endif #endif
packet_count=0; packet_count=0;
#if defined TELEMETRY #if defined TELEMETRY
telemetry_lost=1; telemetry_lost=1;
#endif #endif
} }
CC2500_Strobe(CC2500_SFRX); //flush the RXFIFO CC2500_Strobe(CC2500_SFRX); //Flush the RXFIFO
} }
FrSkyX_build_packet(); FrSkyX_build_packet();
state = FRSKY_DATA1; state = FRSKY_DATA1;

View File

@ -19,7 +19,7 @@
#define VERSION_MAJOR 1 #define VERSION_MAJOR 1
#define VERSION_MINOR 3 #define VERSION_MINOR 3
#define VERSION_REVISION 0 #define VERSION_REVISION 0
#define VERSION_PATCH_LEVEL 27 #define VERSION_PATCH_LEVEL 28
//****************** //******************
// Protocols // Protocols

View File

@ -609,7 +609,7 @@ void loop()
{ //If at least 1ms is available update values { //If at least 1ms is available update values
count=0; count=0;
Update_All(); Update_All();
#if defined(STM32_BOARD) && defined(DEBUG_SERIAL) #ifdef DEBUG_SERIAL
if(TIMER2_BASE->SR & TIMER_SR_CC1IF ) if(TIMER2_BASE->SR & TIMER_SR_CC1IF )
debugln("Long update"); debugln("Long update");
#endif #endif
@ -2161,8 +2161,10 @@ static uint32_t random_id(uint16_t address, uint8_t create_new)
else else
RX_MISSED_BUFF_on; // Notify that rx_buff is good RX_MISSED_BUFF_on; // Notify that rx_buff is good
} }
else #ifdef DEBUG_SERIAL
debugln("RX frame too short"); else
debugln("RX frame too short");
#endif
discard_frame=true; discard_frame=true;
#ifdef STM32_BOARD #ifdef STM32_BOARD
TIMER2_BASE->DIER &= ~TIMER_DIER_CC2IE; // Disable Timer2/Comp2 interrupt TIMER2_BASE->DIER &= ~TIMER_DIER_CC2IE; // Disable Timer2/Comp2 interrupt

View File

@ -80,7 +80,7 @@ static void multi_send_header(uint8_t type, uint8_t len)
Serial_write(len); Serial_write(len);
} }
inline void telemetry_set_input_sync(uint16_t refreshRate) static void telemetry_set_input_sync(uint16_t refreshRate)
{ {
#ifdef MULTI_SYNC #ifdef MULTI_SYNC
#if defined(STM32_BOARD) && defined(DEBUG_PIN) #if defined(STM32_BOARD) && defined(DEBUG_PIN)

View File

@ -225,7 +225,7 @@
//FrSkyX specific setting //FrSkyX specific setting
//----------------------- //-----------------------
//EU LBT setting: if commented the TX will not check if a channel is busy before transmitting. //EU LBT setting: if commented the TX will not check if a channel is busy before transmitting.
//!!!Work in progress!!! it's currently known to cause telemerty issues. Enable only if you know what you are doing. //!!! Work in progress !!! it's currently known to cause telemerty issues. Enable only if you know what you are doing.
//#define FRSKYX_LBT //#define FRSKYX_LBT
//DSM specific settings //DSM specific settings
@ -283,7 +283,8 @@
//Send to OpenTX the current protocol and subprotocol names. Comment to disable. //Send to OpenTX the current protocol and subprotocol names. Comment to disable.
#define MULTI_NAMES #define MULTI_NAMES
//Sync OpenTX frames with the current protocol timing. This feature is only available on the STM32 module. Comment to disable. //Sync OpenTX frames with the current protocol timing. This feature is only available on the STM32 module. Comment to disable.
#define MULTI_SYNC //!!! Work in progress !!! Do not enable for internal module
//#define MULTI_SYNC
//Comment a line to disable a specific protocol telemetry //Comment a line to disable a specific protocol telemetry
#define DSM_TELEMETRY // Forward received telemetry packet directly to TX to be decoded by er9x, erskyTX and OpenTX #define DSM_TELEMETRY // Forward received telemetry packet directly to TX to be decoded by er9x, erskyTX and OpenTX