96 lines
1.9 KiB
C
96 lines
1.9 KiB
C
#pragma once
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/* Includes ----------------------------------------------------------------- */
|
|
#include <stdint.h>
|
|
#include <stdbool.h>
|
|
|
|
#include "device/sx1281_driver/sx1281.h"
|
|
/* USER INCLUDE BEGIN */
|
|
|
|
/* USER INCLUDE END */
|
|
|
|
/* Exported constants ------------------------------------------------------- */
|
|
/* Exported macro ----------------------------------------------------------- */
|
|
/* USER DEFINE BEGIN */
|
|
|
|
/* USER DEFINE END */
|
|
|
|
/* Exported types ----------------------------------------------------------- */
|
|
|
|
|
|
|
|
typedef enum {
|
|
MR16_MODE_NONE,
|
|
MR16_MODE_RFUART,
|
|
MR16_MODE_RC,
|
|
MR16_MODE_SETTING
|
|
}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
|
|
}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 {
|
|
uint8_t header1;
|
|
uint8_t header2;
|
|
|
|
|
|
uint16_t crc;
|
|
}MR16_TXBuffer_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 {
|
|
MR16_Param_t *param;
|
|
MR16_Data_t *data;
|
|
|
|
/*
|
|
[0]header1(TXID_highbyte)
|
|
[1]header2(TXID_lowbyte)
|
|
[2]datalength(<=122)
|
|
[...]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,MR16_Mode_t mr16Mode, SX1281_RadioMode_t radioMode);
|
|
int8_t MR16_Main(MR16_t *mr16, uint8_t data[],uint8_t data_length);
|
|
/* USER FUNCTION BEGIN */
|
|
|
|
/* USER FUNCTION END */
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif |