Files
GD32E230_VL53L4CD/Inc/calib_store.h
T

38 lines
1.3 KiB
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.
/**
* @file calib_store.h
* @brief VL53L4CD 校准数据 Flash 持久化存储接口
* @details 利用主 Flash 最后一页(1KB,地址按运行时检测到的 Flash 容量计算)
* 保存偏移校准与串扰校准结果,掉电不丢失。
* 注意:链接脚本已将代码区缩小 1KB,为 16K 容量器件保留该页。
*/
#ifndef CALIB_STORE_H
#define CALIB_STORE_H
#include <stdbool.h>
#include <stdint.h>
/**
* @brief 从 Flash 读取校准数据
* @param[out] offset_mm: 返回保存的偏移量,单位 mm
* @param[out] xtalk_kcps: 返回保存的串扰值,单位 kcps
* @retval true: 校准数据有效; false: 无数据、版本不匹配或校验失败
*/
bool calib_store_load(int16_t *offset_mm, uint16_t *xtalk_kcps);
/**
* @brief 保存校准数据到 Flash(整页擦除后写入)
* @details 操作期间会短暂暂停串口接收中断,耗时约几十毫秒
* @param[in] offset_mm: 偏移量,单位 mm
* @param[in] xtalk_kcps: 串扰值,单位 kcps0..127
* @retval true: 保存成功; false: Flash 操作失败
*/
bool calib_store_save(int16_t offset_mm, uint16_t xtalk_kcps);
/**
* @brief 擦除 Flash 中的校准数据页
* @retval true: 擦除成功; false: Flash 操作失败
*/
bool calib_store_erase(void);
#endif /* CALIB_STORE_H */