20 #include "sensepi_store_config.h" 22 #include "hal_nop_delay.h" 26 #include "nrf_assert.h" 27 #include "common_util.h" 32 #define LAST_APP_PAGE_ADDR 0x27000 34 #define CONFIG_SIZE_TO_POINTER 5 36 #define NO_OF_CONFIGS 204 40 #define LAST_CONFIG_END_ADDR (LAST_APP_PAGE_ADDR+NO_OF_CONFIGS*CONFIG_SIZE_TO_POINTER\ 44 #define CONFIG_FW_VER_LOC LAST_CONFIG_END_ADDR+0x2 46 #define MEM_RESET_VALUE 0xFFFFFFFF 48 #define MEM_FULL LAST_CONFIG_END_ADDR 58 static uint32_t get_next_location (
void);
65 static void clear_all_config (
void);
70 static void update_fw_ver (
void);
72 static uint32_t get_next_location (
void)
74 log_printf(
"%s\n",__func__);
75 uint32_t * p_mem_loc = (uint32_t *) LAST_APP_PAGE_ADDR;
76 while(p_mem_loc < (uint32_t *)LAST_CONFIG_END_ADDR)
78 if(*(p_mem_loc) == MEM_RESET_VALUE)
80 return (uint32_t)p_mem_loc;
82 p_mem_loc += CONFIG_SIZE_TO_POINTER;
90 log_printf(
"%s\n",__func__);
91 if(get_next_location () == LAST_APP_PAGE_ADDR)
103 log_printf(
"%s\n",__func__);
104 uint32_t * p_mem_loc = (uint32_t *) get_next_location();
105 if(p_mem_loc == (uint32_t *)MEM_FULL)
108 p_mem_loc = (uint32_t *) get_next_location();
110 hal_nvmc_write_data(p_mem_loc, latest_config,
sizeof(sensepi_config_t));
116 log_printf(
"%s\n",__func__);
117 uint32_t * p_mem_loc = (uint32_t*)get_next_location();
118 if(p_mem_loc != (uint32_t*)LAST_APP_PAGE_ADDR)
120 p_mem_loc -= CONFIG_SIZE_TO_POINTER;
122 return (sensepi_config_t*) p_mem_loc;
125 static void clear_all_config (
void)
127 log_printf(
"%s\n",__func__);
128 hal_nvmc_erase_page (LAST_APP_PAGE_ADDR);
133 log_printf(
"%s\n",__func__);
134 uint32_t * p_mem_loc = (uint32_t *) CONFIG_FW_VER_LOC;
135 uint32_t local_major_num = *p_mem_loc/10000;
136 if(*p_mem_loc == MEM_RESET_VALUE)
140 else if(local_major_num != (FW_VER/10000))
147 static void update_fw_ver ()
149 log_printf(
"%s\n",__func__);
150 uint32_t * p_mem_loc = (uint32_t *) CONFIG_FW_VER_LOC;
151 uint32_t local_fw_ver = FW_VER;
152 hal_nvmc_write_data (p_mem_loc, &local_fw_ver,
sizeof(uint32_t));
bool sensepi_store_config_is_memory_empty(void)
void sensepi_store_config_check_fw_ver()
Function to check the major number of firmware if latest major number \ firmware version is greater t...
sensepi_config_t * sensepi_store_config_get_last_config()
void sensepi_store_config_write(sensepi_config_t *latest_config)
Function to write the sensepi_config_t at address location received from get_next_location().