#pragma once #include static constexpr uint16_t JOY_MIN = 172, JOY_MID =992, JOY_MAX= 1811; static constexpr float JOY_VAL = (JOY_MAX - JOY_MIN) / 1e3; #define CRSF_FRAME_SIZE_MAX 30 // the actual maximum length is 64, but we're only interested in RC channels and want to minimize buffer size #define CRSF_PAYLOAD_SIZE_MAX (CRSF_FRAME_SIZE_MAX-4) #define CRSF_BAUDRATE 420000 struct CRSF_Data // FlySky { uint16_t X, Y, Z, W; uint16_t SWA, SWB, SWC, SWD; uint16_t VRA, VRB; uint16_t OTHER[8]; bool FrameLost; bool FailSafe; }; void CRSF_Init(void); bool CRSF_Update(CRSF_Data& data, bool& off); bool crsf_parse(const uint8_t *frame, unsigned len, uint16_t *values, uint16_t *num_values, uint16_t max_channels);