micro_climate/App/Inc/inflash.h

37 lines
1.2 KiB
C

#ifndef _INFLASH_H_
#define _INFLASH_H_
#include "comm_types.h"
/* 内部flash存储空间 */
/* page 511,one page 2k, 0x800F800-0x0800FFFF*/
#define STM32_INFLASH_PAGE_SIZE 2048
#define STM32_INFLASH_BASE 0x8000000 /* STM32 FLASH内部起始地址 */
#define STM32_INFLASH_SAVE_ADDR_BEGIN (STM32_INFLASH_BASE+STM32_INFLASH_PAGE_SIZE*511)
#define STM32_INFLASH_SAVE_ADDR_END (STM32_INFLASH_BASE+STM32_INFLASH_PAGE_SIZE*512-1)
#define STM32_INFLASH_SAVE_PAGE 511
typedef enum{
FLAG_SAVE_INFLASH_HEAD = 0x55,
FLAG_SAVE_INFLASH_END = 0x16,
}FlagInFlashType_e;
#pragma pack(push,1)
typedef struct _config_info{
u_int8_t flag_head;
u_int8_t addr;
u_int16_t uart_baud; /* 串口波特率 */
u_int16_t speed_average_time;
u_int16_t temp_hum_update_time;
u_int8_t flag_end;
}config_info;
#pragma pack(pop)
extern config_info g_stConfigInfo;
void InFlash_Erase_Pages(u_int16_t PageBeginNum, u_int16_t NbPages);
void InFlash_Write(u_int32_t addr, u_int64_t *pBuffer,u_int32_t NumToWrite);
void save_config_info(config_info save_config_info);
void delete_config_info();
BOOL read_config_info();
#endif //_INFLASH_H_