From d29461607b84a463b496eb0ad1bcd4475ff6e442 Mon Sep 17 00:00:00 2001 From: pascallanger Date: Tue, 29 Oct 2019 00:36:57 +0100 Subject: [PATCH] Tweakes --- Multiprotocol/FrSkyX_cc2500.ino | 4 ++-- Multiprotocol/Multiprotocol.h | 12 ++++++------ Multiprotocol/Multiprotocol.ino | 22 +++++++++++++--------- Multiprotocol/Scanner_cc2500.ino | 2 +- Multiprotocol/Telemetry.ino | 5 +++++ 5 files changed, 27 insertions(+), 18 deletions(-) diff --git a/Multiprotocol/FrSkyX_cc2500.ino b/Multiprotocol/FrSkyX_cc2500.ino index 06adf4c..33fce64 100644 --- a/Multiprotocol/FrSkyX_cc2500.ino +++ b/Multiprotocol/FrSkyX_cc2500.ino @@ -232,7 +232,7 @@ static void __attribute__((unused)) FrSkyX_build_packet() if(nbr_bytes) {//Check the buffer status uint8_t used = SportTail; - if ( SportHead >= SportTail ) + if ( SportHead > SportTail ) used += MAX_SPORT_BUFFER - SportHead ; else used -= SportHead ; @@ -353,7 +353,7 @@ uint16_t ReadFrSkyX() case FRSKY_DATA3: uint8_t rssi; rssi = CC2500_ReadReg(CC2500_34_RSSI | CC2500_READ_BURST); // 0.5 db/count, RSSI value read from the RSSI status register is a 2's complement number - if ((sub_protocol & 2) && rssi > 72 && rssi < 128) //LBT and RSSI between -36 to -8.5 dBm + if ((sub_protocol & 2) && rssi < 128) //LBT and RSSI between -73 to -8.5 dBm (-36dBm=72) { transmit=false; debugln("Busy %d %d",hopping_frequency_no,rssi); diff --git a/Multiprotocol/Multiprotocol.h b/Multiprotocol/Multiprotocol.h index 5e4b13c..31be1c9 100644 --- a/Multiprotocol/Multiprotocol.h +++ b/Multiprotocol/Multiprotocol.h @@ -19,7 +19,7 @@ #define VERSION_MAJOR 1 #define VERSION_MINOR 3 #define VERSION_REVISION 0 -#define VERSION_PATCH_LEVEL 25 +#define VERSION_PATCH_LEVEL 26 //****************** // Protocols @@ -299,11 +299,11 @@ enum TRAXXAS struct PPM_Parameters { - uint8_t protocol : 6; - uint8_t sub_proto : 3; - uint8_t rx_num : 4; - uint8_t power : 1; - uint8_t autobind : 1; + uint8_t protocol; + uint8_t sub_proto : 3; + uint8_t rx_num : 6; + uint8_t power : 1; + uint8_t autobind : 1; int8_t option; uint32_t chan_order; }; diff --git a/Multiprotocol/Multiprotocol.ino b/Multiprotocol/Multiprotocol.ino index 1347e94..6df2c9b 100644 --- a/Multiprotocol/Multiprotocol.ino +++ b/Multiprotocol/Multiprotocol.ino @@ -1712,9 +1712,12 @@ void update_serial_data() #endif if(IS_RX_MISSED_BUFF_on) // If the buffer is still valid { - rx_len=rx_idx; - memcpy((void*)rx_ok_buff,(const void*)rx_buff,rx_len);// Duplicate the buffer - RX_FLAG_on; // data to be processed next time... + if(rx_idx>=26 && rx_idxCCR2=TIMER2_BASE->CNT + 360; // Next byte should show up within 18??s=1.5 byte + TIMER2_BASE->CCR2=TIMER2_BASE->CNT + 500; // Next byte should show up within 250us (1 byte = 120us) TIMER2_BASE->SR = 0x1E5F & ~TIMER_SR_CC2IF; // Clear Timer2/Comp2 interrupt flag TIMER2_BASE->DIER |= TIMER_DIER_CC2IE; // Enable Timer2/Comp2 interrupt #else TX_RX_PAUSE_on; tx_pause(); cli(); // Disable global int due to RW of 16 bits registers - OCR1B = TCNT1 + 360; // Next byte should show up within 18??s=1.5 byte + OCR1B = TCNT1 + 500; // Next byte should show up within 250us (1 byte = 120us) sei(); // Enable global int TIFR1 = OCF1B_bm ; // clear OCR1B match flag SET_TIMSK1_OCIE1B ; // enable interrupt on compare B match @@ -2111,10 +2114,10 @@ static uint32_t random_id(uint16_t address, uint8_t create_new) { rx_buff[rx_idx++]=UDR0; // Store received byte #if defined STM32_BOARD - TIMER2_BASE->CCR2=TIMER2_BASE->CNT + 360; // Next byte should show up within 18??s=1.5 byte + TIMER2_BASE->CCR2=TIMER2_BASE->CNT + 500; // Next byte should show up within 250us (1 byte = 120us) #else cli(); // Disable global int due to RW of 16 bits registers - OCR1B = TCNT1 + 360; // Next byte should show up within 18??s=1.5 byte + OCR1B = TCNT1 + 500; // Next byte should show up within 250us (1 byte = 120us) sei(); // Enable global int #endif } @@ -2149,11 +2152,12 @@ static uint32_t random_id(uint16_t address, uint8_t create_new) #elif defined STM32_BOARD void ISR_COMPB() #else - ISR(TIMER1_COMPB_vect, ISR_NOBLOCK ) + ISR(TIMER1_COMPB_vect) #endif { // Timer1 compare B interrupt - if(rx_idx>=26) + if(rx_idx>=26 && rx_idx