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_State_H_ 15 #define _WL_State_H_ 16 #include "esp_err.h" 17 18 /** 19 * @brief This structure is used to store current state of flash access 20 * 21 */ 22 #if defined(_MSC_VER) 23 #define ALIGNED_(x) __declspec(align(x)) 24 #else 25 #if defined(__GNUC__) 26 #define ALIGNED_(x) __attribute__ ((aligned(x))) 27 #endif 28 #endif 29 30 typedef struct ALIGNED_(32) WL_State_s { 31 public: 32 uint32_t pos; /*!< current dummy block position*/ 33 uint32_t max_pos; /*!< maximum amount of positions*/ 34 uint32_t move_count; /*!< total amount of move counts. Used to calculate the address*/ 35 uint32_t access_count; /*!< current access count*/ 36 uint32_t max_count; /*!< max access count when block will be moved*/ 37 uint32_t block_size; /*!< size of move block*/ 38 uint32_t version; /*!< state id used to identify the version of current libary implementaion*/ 39 uint32_t device_id; /*!< ID of current WL instance*/ 40 uint32_t reserved[7]; /*!< Reserved space for future use*/ 41 uint32_t crc; /*!< CRC of structure*/ 42 } wl_state_t; 43 44 #ifndef _MSC_VER // MSVS has different format for this define 45 static_assert(sizeof(wl_state_t) % 16 == 0, "Size of wl_state_t structure should be compatible with flash encryption"); 46 #endif // _MSC_VER 47 48 #define WL_STATE_CRC_LEN_V1 offsetof(wl_state_t, device_id) 49 #define WL_STATE_CRC_LEN_V2 offsetof(wl_state_t, crc) 50 51 #endif // _WL_State_H_ 52