#pragma once #ifdef __cplusplus extern "C" { #endif /* Includes ----------------------------------------------------------------- */ #include #include #include "device/sx1281_driver/sx1281.h" /* USER INCLUDE BEGIN */ /* USER INCLUDE END */ /* Exported constants ------------------------------------------------------- */ /* Exported macro ----------------------------------------------------------- */ #define MR16_RC_Data_Len 14 // RC模式下缓冲区数据长度(含ID和CRC) /* USER DEFINE BEGIN */ /* USER DEFINE END */ /* Exported types ----------------------------------------------------------- */ typedef enum { MR16_MODE_NONE, MR16_MODE_RFUART, MR16_MODE_RC, MR16_MODE_NUM }MR16_Mode_t; typedef struct { uint16_t ch_l_x; uint16_t ch_l_y; uint16_t ch_r_x; uint16_t ch_r_y; bool sw[16];//二值按键 bool threePosLever[8];//三值按键 uint16_t res1;//保留位1 uint16_t res2;//保留位2 uint16_t res3;//保留位3 uint16_t res4;//保留位4 }MR16_RCData_t; typedef struct { uint8_t header1; uint8_t header2; union { MR16_RCData_t rc; }data; uint16_t crc; }MR16_Data_t; typedef struct { SX1281_Params_t radioParams; MR16_Mode_t mode; uint16_t TX_ID; uint16_t RX_ID[3];//最多识别三台设备的信号 }MR16_Param_t; typedef struct { float now; /* 当前时间,单位秒 */ uint64_t last_wakeup; /* 上次唤醒时间,单位微秒 */ float dt; /* 两次唤醒间隔时间,单位秒 */ float lastUIupdata; }MR16_Timer_t; typedef struct { MR16_Param_t *param; MR16_Data_t *data; MR16_Timer_t timer; /* [0]header1(TXID_highbyte) [1]header2(TXID_lowbyte) [...]data [2+datalength+1]crc_highbyte [2+datalength+2]crc_lowbyte */ uint8_t txbuffer[127]; uint32_t packetCount[3]; }MR16_t; /* Exported functions prototypes -------------------------------------------- */ int8_t MR16_Init(MR16_t *mr16,MR16_Param_t *param); int8_t MR16_Main(MR16_t *mr16); /* RC Mode Functions */ int8_t MR16_RC_PackTxBuffer(MR16_t *mr16, const uint8_t *rcData, uint16_t dataLen); /* UI Functions */ int8_t MR16_UI_PowerON(void); int8_t MR16_UI_Home(MR16_t *mr16); int8_t MR16_UI_UpdateStatus(MR16_t *mr16); /* USER FUNCTION BEGIN */ /* USER FUNCTION END */ #ifdef __cplusplus } #endif