1 // Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // http://www.apache.org/licenses/LICENSE-2.0 7 // 8 // Unless required by applicable law or agreed to in writing, software 9 // distributed under the License is distributed on an "AS IS" BASIS, 10 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 // See the License for the specific language governing permissions and 12 // limitations under the License. 13 14 #ifndef _WL_Config_H_ 15 #define _WL_Config_H_ 16 17 #include "Flash_Access.h" 18 19 /** 20 * @brief This class is used as a structure to configure wear levelling module 21 * 22 */ 23 24 #if defined(_MSC_VER) 25 #define ALIGNED_(x) __declspec(align(x)) 26 #else 27 #if defined(__GNUC__) 28 #define ALIGNED_(x) __attribute__ ((aligned(x))) 29 #endif 30 #endif 31 32 typedef struct ALIGNED_(16) WL_Config_s { /*!< Size of wl_config_t structure should be divided by 16 for encryption*/ 33 size_t start_addr; /*!< start address in the flash*/ 34 uint32_t full_mem_size; /*!< Amount of memory used to store data in bytes*/ 35 uint32_t page_size; /*!< One page size in bytes. Page could be more then memory block. This parameter must be page_size >= N*block_size.*/ 36 uint32_t sector_size; /*!< size of flash memory sector that will be erased and stored at once (erase)*/ 37 uint32_t updaterate; /*!< Amount of accesses before block will be moved*/ 38 uint32_t wr_size; /*!< Minimum amount of bytes per one block at write operation: 1...*/ 39 uint32_t version; /*!< A version of current implementatioon. To erase and reallocate complete memory this ID must be different from id before.*/ 40 size_t temp_buff_size; /*!< Size of temporary allocated buffer to copy from one flash area to another. The best way, if this value will be equal to sector size.*/ 41 uint32_t crc; /*!< CRC for this config*/ 42 } wl_config_t; 43 44 #ifndef _MSC_VER // MSVS has different format for this define 45 static_assert(sizeof(wl_config_t) % 16 == 0, "Size of wl_config_t structure should be compatible with flash encryption"); 46 #endif // _MSC_VER 47 48 #endif // _WL_Config_H_ 49