forked from espressif/esp-idf
hal: Fix systimer counter value bit field
This commit fixes the systimer_counter_value_t by adding a resreved field so that the type fills 64-bits. Without the reserved field, when compiling with -O0 optimization, the unoccupied high bits would not be initalized by the compiler, leading to systimer_hal_get_counter_value() returning a garbage value.
This commit is contained in:
@ -30,6 +30,9 @@ typedef struct {
|
|||||||
struct {
|
struct {
|
||||||
uint64_t lo : SOC_SYSTIMER_BIT_WIDTH_LO; /*!< Low part of counter value */
|
uint64_t lo : SOC_SYSTIMER_BIT_WIDTH_LO; /*!< Low part of counter value */
|
||||||
uint64_t hi : SOC_SYSTIMER_BIT_WIDTH_HI; /*!< High part of counter value */
|
uint64_t hi : SOC_SYSTIMER_BIT_WIDTH_HI; /*!< High part of counter value */
|
||||||
|
#if (SOC_SYSTIMER_BIT_WIDTH_LO + SOC_SYSTIMER_BIT_WIDTH_HI) < 64
|
||||||
|
uint64_t reserved: (64 - (SOC_SYSTIMER_BIT_WIDTH_LO + SOC_SYSTIMER_BIT_WIDTH_HI));
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
uint64_t val; /*!< counter value */
|
uint64_t val; /*!< counter value */
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user