Files

30 lines
1.8 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 __FLASH_H
#define __FLASH_H
#include "boot_main.h"
#include "ota_config.h"
/* ════════════════════════════════════════════════════════════════
* Flash 布局与 OTA 状态机 — 统一由 ota_config.h 配置(唯一入口)
* (布局宏 OTA_RUN_ADDR_BASE / OTA_BAK_ADDR_BASE / OTA_SLOT_MAX_SIZE
* 及状态结构 ota_param_t / OTA_STATE_* 均在 ota_config.h 中定义)
* ════════════════════════════════════════════════════════════════ */
#define SYS_BOOTLOADER_ADDR_BASE 0x08000000UL /* Bootloader17KB */
#define FLASH_END_ADDR 0x08020000UL /* 128KB 边界 */
#define RAM_BASE_ADDR 0x20000000UL
#define RAM_END_ADDR 0x20004000UL /* 16KB RAM */
/* ════════════════════════════════════════════════════════════════
* Flash 操作 API
* ════════════════════════════════════════════════════════════════ */
void APP_FlashWrite(uint32_t PageAddress, uint8_t *Data, uint32_t DataSize);
void APP_FlashRead(uint32_t PageAddress, uint8_t *Data, uint32_t DataSize);
void APP_FlashEraseWithCheck(uint32_t PageAddress, uint32_t DataSize);
/* OTA 状态区读写(AB:4 页轮换磨损均衡;SINGLE:固定页 0 直写) */
void ota_param_load(ota_param_t *p);
void ota_param_store(const ota_param_t *p);
#endif