Files
ASER/App/IMU/hwt101.h
2026-03-31 23:30:33 +08:00

41 lines
1.2 KiB
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#ifndef HWT101_H
#define HWT101_H
#include <stdint.h>
#include "main.h"
#define HWT101_DMA_BUF_SIZE 256 // 必须是 32 的整数倍
typedef enum {
HWT101_RATE_10HZ = 0x06,
HWT101_RATE_50HZ = 0x08,
HWT101_RATE_100HZ = 0x09, // 推荐100Hz
HWT101_RATE_200HZ = 0x0B
} HWT101_Rate_t;
typedef enum {
HWT101_BAUD_9600 = 0x02,
HWT101_BAUD_115200 = 0x06,
HWT101_BAUD_230400 = 0x07
} HWT101_Baud_t;
typedef struct {
float yaw; // 原始偏航角 (deg),范围 [-180, +180),跨界时跳变
float yaw_continuous; // unwrap 后的连续偏航角 (deg),无跳变,可直接做差计算转角
float wz; // Z 轴角速度 (deg/s)
uint32_t last_update;
uint8_t online;
} HWT101_Data_t;
/* API 函数声明 */
void HWT101_Init(UART_HandleTypeDef *huart);
void HWT101_Process(void);
// 【升级 2】改为传入指针安全拷贝数据防止数据撕裂
void HWT101_GetData(HWT101_Data_t *out_data);
// 在末尾 API 声明处加上这句
void HWT101_ErrorRecovery(UART_HandleTypeDef *huart);
HAL_StatusTypeDef HWT101_Config(HWT101_Rate_t rate, HWT101_Baud_t baud);
HAL_StatusTypeDef HWT101_ZeroYaw(void);
#endif /* HWT101_H */