micro_climate/App/Inc/inflash.h

53 lines
2.6 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_int16_t transducer_cfg_1R5; /* 换能器参数 */
u_int16_t transducer_cfg_4R5; /* 换能器参数 */
u_int16_t transducer_cfg_8R0; /* 换能器参数 */
u_int16_t RSSI_range; /* RSSI有效范围 */
u_int16_t transducer_distace; /* 换能器表面距离 */
u_int16_t linear_point_1_x; /* 线性插值点1X */
u_int16_t linear_point_1_y; /* 线性插值点1Y */
u_int16_t linear_point_2_x; /* 线性插值点2X */
u_int16_t linear_point_2_y; /* 线性插值点2Y */
u_int16_t linear_point_3_x; /* 线性插值点3X */
u_int16_t linear_point_3_y; /* 线性插值点3Y */
u_int16_t linear_point_4_x; /* 线性插值点4X */
u_int16_t linear_point_4_y; /* 线性插值点4Y */
u_int16_t linear_point_5_x; /* 线性插值点5X */
u_int16_t linear_point_5_y; /* 线性插值点5Y */
u_int16_t linear_enable; /* 线性插值使能 */
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_