2 * This file is part of Cleanflight and Betaflight.
4 * Cleanflight and Betaflight are free software. You can redistribute
5 * this software and/or modify this software under the terms of the
6 * GNU General Public License as published by the Free Software
7 * Foundation, either version 3 of the License, or (at your option)
10 * Cleanflight and Betaflight are distributed in the hope that they
11 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
12 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 * See the GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this software.
18 * If not, see <http://www.gnu.org/licenses/>.
21 // expresslrs packet header types
22 // 00 -> standard 4 channel data packet
23 // 01 -> switch data packet
25 // 10 -> sync packet with hop data
27 ELRS_RC_DATA_PACKET
= 0x00,
28 ELRS_MSP_DATA_PACKET
= 0x01,
29 ELRS_SYNC_PACKET
= 0x02,
30 ELRS_TLM_PACKET
= 0x03,
37 ELRS_DIO_RX_AND_TX_DONE
= 3,
44 ELRS_DISCONNECT_PENDING
// used on modelmatch change to drop the connection
48 ELRS_TIM_DISCONNECTED
= 0,
49 ELRS_TIM_TENTATIVE
= 1,
53 typedef struct elrsReceiver_s
{
61 volatile uint8_t nonceRX
; // nonce that we THINK we are up to.
63 elrsModSettings_t
*modParams
;
64 elrsRfPerfParams_t
*rfPerfParams
;
75 bool alreadyTelemResp
;
79 timerState_e timerState
;
80 connectionState_e connectionState
;
82 uint8_t rfModeCycleMultiplier
;
83 uint16_t cycleIntervalMs
;
84 uint32_t rfModeCycledAtMs
;
86 uint8_t nextRateIndex
;
88 uint32_t gotConnectionMs
;
89 uint32_t lastSyncPacketMs
;
90 uint32_t lastValidPacketMs
;
92 uint32_t configCheckedAtMs
;
96 volatile bool initializeReceiverPending
;
97 volatile bool fhssRequired
;
98 volatile bool didFhss
;
100 uint32_t statsUpdatedAtMs
;
102 elrsRxInitFnPtr init
;
103 elrsRxConfigFnPtr config
;
104 elrsRxStartReceivingFnPtr startReceiving
;
105 elrsRxISRFnPtr rxISR
;
106 elrsRxHandleFromTockFnPtr rxHandleFromTock
;
107 elrsRxBusyTimeoutFnPtr rxHandleFromTick
;
108 elrsRxgetRfLinkInfoFnPtr getRfLinkInfo
;
109 elrsRxSetFrequencyFnPtr setFrequency
;
110 elrsRxHandleFreqCorrectionFnPtr handleFreqCorrection
;
112 timerOvrHandlerRec_t timerUpdateCb
;