85 lines
1.7 KiB
C
85 lines
1.7 KiB
C
#ifndef RC_h
|
|
#define RC_h
|
|
|
|
/* Includes ----------------------------------------------------------------- */
|
|
#include <cmsis_os2.h>
|
|
#include "bsp_usart.h"
|
|
#include "cmd.h"
|
|
#include "user_math.h"
|
|
#include "device.h"
|
|
|
|
/* Exported constants ------------------------------------------------------- */
|
|
/* Exported macro ----------------------------------------------------------- */
|
|
/* Exported types ----------------------------------------------------------- */
|
|
typedef __packed struct
|
|
{
|
|
uint16_t ch_r_x : 11;
|
|
uint16_t ch_r_y : 11;
|
|
uint16_t ch_l_x : 11;
|
|
uint16_t ch_l_y : 11;
|
|
uint8_t sw_r : 2;
|
|
uint8_t sw_l : 2;
|
|
int16_t x;
|
|
int16_t y;
|
|
int16_t z;
|
|
uint8_t press_l;
|
|
uint8_t press_r;
|
|
uint16_t key;
|
|
uint16_t res;
|
|
} DR16_Data_t;
|
|
|
|
typedef struct {
|
|
DR16_Data_t data;
|
|
} DR16_t;
|
|
|
|
/*原始数据*/
|
|
typedef __packed struct
|
|
{
|
|
fp32 map_ch[4];
|
|
int16_t ch[4];
|
|
int16_t sw[8];
|
|
|
|
} LD_raw_t;
|
|
|
|
|
|
typedef __packed struct
|
|
{
|
|
fp32 ch_r_x ;
|
|
fp32 ch_r_y ;
|
|
fp32 ch_l_x ;
|
|
fp32 ch_l_y ;
|
|
int16_t key_A ;
|
|
// int16_t key_B ;//无
|
|
int16_t key_C ;
|
|
// int16_t key_D ;//无
|
|
int16_t key_E ;
|
|
int16_t key_F;
|
|
int16_t key_G ;
|
|
int16_t key_H ;
|
|
|
|
int16_t knob_left;//左旋钮
|
|
int16_t knob_right;//右旋钮
|
|
|
|
} LD_Data_t;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int8_t RC_SBUS_Init(void );
|
|
static void RC_SBUS_RxCpltCallback(void) ;
|
|
int8_t RC_SBUS_Restart(void) ;
|
|
int8_t RC_SBUS_StartDmaRecv(void) ;
|
|
bool RC_SBUS_WaitDmaCplt(uint32_t timeout) ;
|
|
int8_t LD_ParseRaw( LD_raw_t *raw, LD_Data_t *LD);
|
|
static bool DR16_DataCorrupted(const DR16_t *dr16) ;
|
|
int8_t DR16_ParseRaw(DR16_t *dr16);
|
|
int8_t RC_ParseRC( DR16_t *dr16,LD_raw_t *LD_raw, LD_Data_t *LD, CMD_RC_t *rc) ;
|
|
int8_t DR16_HandleOffline(const DR16_t *dr16, CMD_RC_t *rc) ;
|
|
int8_t LD_HandleOffline(const LD_Data_t *LD, CMD_RC_t *rc) ;
|
|
|
|
#endif
|
|
|