2024-07-05 03:52:43 +00:00
|
|
|
#ifndef _INFLASH_H_
|
|
|
|
#define _INFLASH_H_
|
|
|
|
#include "comm_types.h"
|
|
|
|
|
|
|
|
|
|
|
|
/* 内部flash存储空间 */
|
2024-11-08 08:31:22 +00:00
|
|
|
/* page 511,one page 2k, 0x800F800-0x0800FFFF*/
|
2024-07-05 03:52:43 +00:00
|
|
|
#define STM32_INFLASH_PAGE_SIZE 2048
|
|
|
|
#define STM32_INFLASH_BASE 0x8000000 /* STM32 FLASH内部起始地址 */
|
2024-11-27 10:05:09 +00:00
|
|
|
|
|
|
|
//用户配置存储位置
|
|
|
|
#define STM32_INFLASH_SAVE_PAGE_1 511
|
|
|
|
#define STM32_INFLASH_SAVE_ADDR_1_BEGIN (STM32_INFLASH_BASE+STM32_INFLASH_PAGE_SIZE*STM32_INFLASH_SAVE_PAGE_1)
|
|
|
|
#define STM32_INFLASH_SAVE_ADDR_1_END (STM32_INFLASH_BASE+STM32_INFLASH_PAGE_SIZE*(STM32_INFLASH_SAVE_PAGE_1+1)-1)
|
|
|
|
|
|
|
|
//出厂配置存储位置
|
|
|
|
#define STM32_INFLASH_SAVE_PAGE_2 510
|
|
|
|
#define STM32_INFLASH_SAVE_ADDR_2_BEGIN (STM32_INFLASH_BASE+STM32_INFLASH_PAGE_SIZE*STM32_INFLASH_SAVE_PAGE_2)
|
|
|
|
#define STM32_INFLASH_SAVE_ADDR_2_END (STM32_INFLASH_BASE+STM32_INFLASH_PAGE_SIZE*(STM32_INFLASH_SAVE_PAGE_2+1)-1)
|
2024-07-05 03:52:43 +00:00
|
|
|
|
|
|
|
typedef enum{
|
|
|
|
FLAG_SAVE_INFLASH_HEAD = 0x55,
|
|
|
|
FLAG_SAVE_INFLASH_END = 0x16,
|
|
|
|
}FlagInFlashType_e;
|
|
|
|
|
|
|
|
#pragma pack(push,1)
|
2024-11-27 10:05:09 +00:00
|
|
|
//用户可更改参数
|
|
|
|
typedef struct _usr_config_info{
|
2024-07-05 03:52:43 +00:00
|
|
|
u_int8_t flag_head;
|
2024-11-23 10:00:43 +00:00
|
|
|
u_int8_t addr; /* 设备地址 */
|
|
|
|
u_int16_t uart_baud; /* 串口波特率 */
|
|
|
|
u_int16_t speed_average_time; /* 风速平均时间 */
|
|
|
|
u_int16_t temp_hum_update_time; /* 温湿度平均时间 */
|
2024-11-27 10:05:09 +00:00
|
|
|
u_int8_t flag_end;
|
|
|
|
}usr_config_info;
|
|
|
|
|
|
|
|
//出厂配置参数
|
|
|
|
typedef struct _factory_config_info{
|
|
|
|
u_int8_t flag_head;
|
2024-11-23 10:00:43 +00:00
|
|
|
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; /* 线性插值使能 */
|
2024-07-05 03:52:43 +00:00
|
|
|
u_int8_t flag_end;
|
2024-11-27 10:05:09 +00:00
|
|
|
}factory_config_info;
|
2024-07-05 03:52:43 +00:00
|
|
|
#pragma pack(pop)
|
|
|
|
|
2024-11-27 10:05:09 +00:00
|
|
|
extern usr_config_info g_usrConfigInfo;
|
|
|
|
extern factory_config_info g_stConfigInfo;
|
2024-07-05 03:52:43 +00:00
|
|
|
|
|
|
|
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);
|
2024-11-27 10:05:09 +00:00
|
|
|
void save_usr_config_info(usr_config_info save_config_info);
|
|
|
|
void save_factory_config_info(factory_config_info save_config_info);
|
|
|
|
BOOL read_usr_config_info();
|
|
|
|
BOOL read_factory_config_info();
|
2024-07-05 03:52:43 +00:00
|
|
|
BOOL read_config_info();
|
2024-11-27 10:05:09 +00:00
|
|
|
void delete_config_info();
|
2024-07-05 03:52:43 +00:00
|
|
|
#endif //_INFLASH_H_
|