WL_Config.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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_Config_H_
  14. #define _WL_Config_H_
  15. #include "Flash_Access.h"
  16. /**
  17. * @brief This class is used as a structure to configure wear levelling module
  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_(16) WL_Config_s { /*!< Size of wl_config_t structure should be divided by 16 for encryption*/
  28. size_t start_addr; /*!< start address in the flash*/
  29. uint32_t full_mem_size; /*!< Amount of memory used to store data in bytes*/
  30. 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.*/
  31. uint32_t sector_size; /*!< size of flash memory sector that will be erased and stored at once (erase)*/
  32. uint32_t updaterate; /*!< Amount of accesses before block will be moved*/
  33. uint32_t wr_size; /*!< Minimum amount of bytes per one block at write operation: 1...*/
  34. uint32_t version; /*!< A version of current implementatioon. To erase and reallocate complete memory this ID must be different from id before.*/
  35. 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.*/
  36. uint32_t crc; /*!< CRC for this config*/
  37. } wl_config_t;
  38. #ifndef _MSC_VER // MSVS has different format for this define
  39. static_assert(sizeof(wl_config_t) % 16 == 0, "Size of wl_config_t structure should be compatible with flash encryption");
  40. #endif // _MSC_VER
  41. #endif // _WL_Config_H_