pressure_sensor_system/Software/master/PressureSensorBoardMaster/BSP/flash.h

33 lines
779 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 FLASH_H
#define FLASH_H
#include "stm32f1xx_hal.h"
#include <stdint.h> // 提供 int8_t 定义
#define HOST_MAC_FLASH_ADDR 0x0800F400
#define MAGIC_NUMBER 0xA5A5A5A5 // 自定义签名
typedef struct {
uint32_t magic; // 签名,例如 0xA5A5A5A5
char mac[13]; // MAC 地址字符串12字符 + '\0'
// 可以扩展其他字段...
} FlashData_t;
/**
* @brief 保存 MAC 字符串到 Flash使用固定地址 HOST_MAC_FLASH_ADDR
* @param mac_str MAC 字符串长度不超过12
* @retval 0 成功,-1 失败
*/
uint8_t Save_MAC_To_Flash(char *mac_str);
/**
* @brief 从 Flash 加载 MAC 字符串(使用固定地址 HOST_MAC_FLASH_ADDR
* @param mac_out 输出缓冲区至少13字节
* @retval 0 成功,-1 无有效数据
*/
uint8_t Load_MAC_From_Flash(char *mac_out);
#endif