WL_State.h 2.0 KB

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