CM_DOG/User/device/n100.h
2025-06-26 05:11:10 +08:00

64 lines
1.5 KiB
C

/*
N100 陀螺仪数据
*/
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ----------------------------------------------------------------- */
#include <cmsis_os2.h>
#include <stdbool.h>
#include <stdint.h>
#include "component/ahrs.h"
/* Exported constants ------------------------------------------------------- */
/* Exported macro ----------------------------------------------------------- */
/* Exported types ----------------------------------------------------------- */
typedef struct {
struct {
uint8_t head;
uint8_t cmd;
uint8_t len;
uint8_t count;
uint8_t crc8;
} header; /* 数据包头部 */
struct {
uint16_t crc16;
AHRS_Gyro_t gyro; /* 陀螺仪数据 */
AHRS_Eulr_t eulr; /* 欧拉角数据 */
AHRS_Quaternion_t quat; /* 四元数数据 */
int64_t time; /* 时间戳 */
} data; /* 数据包内容 */
uint8_t end;
} N100_AHRS_t;
typedef struct {
osThreadId_t thread_alert;
N100_AHRS_t rx_raw;
AHRS_Gyro_t gyro; /* 陀螺仪数据 */
AHRS_Eulr_t eulr; /* 欧拉角数据 */
AHRS_Quaternion_t quat; /* 四元数数据 */
} N100_t;
/* Exported functions prototypes -------------------------------------------- */
int8_t N100_Init(N100_t *n100);
int8_t N100_Restart(void);
int8_t N100_StartReceiving(N100_t *n100);
bool N100_WaitDmaCplt(void);
int8_t N100_ParseData (N100_t *n100);
int8_t N100_HandleOffline(N100_t *n100);
#ifdef __cplusplus
}
#endif