Skip to content

Commit 5cbb194

Browse files
committed
Structure size alligned by compiler.
1 parent 743969f commit 5cbb194

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

components/wear_levelling/private_include/WL_Config.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,25 +20,25 @@
2020
* @brief This class is used as a structure to configure wear levelling module
2121
*
2222
*/
23-
#ifndef wl_config_t_size
24-
#define wl_config_t_size (int)((48 - (2*sizeof(size_t) + 7*sizeof(uint32_t)) + sizeof(uint32_t) - 1)/sizeof(uint32_t))
25-
#endif // wl_config_t_size
26-
typedef struct WL_Config_s {
27-
size_t start_addr; /*!< start address in the flash*/
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*/
2834
uint32_t full_mem_size; /*!< Amount of memory used to store data in bytes*/
2935
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.*/
3036
uint32_t sector_size; /*!< size of flash memory sector that will be erased and stored at once (erase)*/
3137
uint32_t updaterate; /*!< Amount of accesses before block will be moved*/
3238
uint32_t wr_size; /*!< Minimum amount of bytes per one block at write operation: 1...*/
3339
uint32_t version; /*!< A version of current implementatioon. To erase and reallocate complete memory this ID must be different from id before.*/
3440
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.*/
35-
uint32_t reserved[wl_config_t_size]; /*!< dummy array to make wl_config_t size compatible with flash encryption (divided by 16)*/
3641
uint32_t crc; /*!< CRC for this config*/
37-
public:
38-
WL_Config_s()
39-
{
40-
for (int i=0 ; i< wl_config_t_size ; i++) this->reserved[i] = 0;
41-
}
4242
} wl_config_t;
4343

4444
#ifndef _MSC_VER // MSVS has different format for this define

0 commit comments

Comments
 (0)