STM_ATEM/User/optic_mag_driver.h
zhoujie bc37e14fba feat(optic_mag): 集成光泵磁力仪驱动并重构数据包架构
- 新增光泵磁力仪驱动模块,通过 USART2 中断接收 BCD 编码数据,采样率 115200bps
- 重构数据包架构:引入标准包与扩展包(含光泵数据)两种类型,通过帧头魔数区分
- 新增 DataPacketWithOptic_t、CorrectedDataPacketWithOptic_t 两种扩展数据包类型
- 数据存储改为通用字节流写入(方案Y),支持任意包类型混流存储
- 将编译期配置集中到 app_config.h,包括 UART 输出、SD 存储、GPS 位置等开关
- 移除 ADC_SYNC GPIO 引脚配置,释放 PA2 用于 USART2_TX
- 主循环 ProcessAdcData 改为按需选择数据包类型,光泵数据快照在 ADC 中断前完成
- 新增 USART2 错误回调处理,支持接收异常时自动恢复
2026-06-07 22:50:54 +08:00

21 lines
591 B
C
Raw 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 OPTIC_MAG_DRIVER_H
#define OPTIC_MAG_DRIVER_H
#include "main.h"
#include <stdint.h>
#define OPTIC_MAG_FRAME_START 0x5A
#define OPTIC_MAG_FRAME_END 0xA5
#define OPTIC_MAG_DATA_BYTES 10
// 单位 0.0001 nT忽略末位BCD数字取前9位
// 例如 123456789 表示 12345.6789 nT
extern volatile uint32_t g_optic_mag_value;
extern volatile uint8_t g_optic_mag_fresh;
void OpticMag_Init(UART_HandleTypeDef *huart);
void OpticMag_UART_RxCpltCallback(UART_HandleTypeDef *huart);
void OpticMag_UART_ErrorCallback(UART_HandleTypeDef *huart);
#endif // OPTIC_MAG_DRIVER_H