esp32/esp32-c3: Adds two helpers to extract and include a field value

This commit is contained in:
Sara Souza 2021-04-28 08:36:13 -03:00 committed by Xiang Xiao
parent cce42d5f74
commit 50daf24242
2 changed files with 16 additions and 0 deletions

View File

@ -257,4 +257,12 @@
#define BIT(nr) (1UL << (nr))
/* Extract the field from the register and shift it to avoid wrong reading */
#define REG_MASK(_reg, _field) (((_reg) & (_field##_M)) >> (_field##_S))
/* Helper to place a value in a field */
#define VALUE_TO_FIELD(_value, _field) (((_value) << (_field##_S)) & (_field##_M))
#endif /* __ARCH_RISCV_SRC_ESP32C3_HARDWARE_ESP32C3_SOC_H */

View File

@ -183,6 +183,14 @@
#define GET_PERI_REG_BITS2(reg, mask,shift) ((READ_PERI_REG(reg)>>(shift))&(mask))
/* Extract the field from the register and shift it to avoid wrong reading */
#define REG_MASK(_reg, _field) (((_reg) & (_field##_M)) >> (_field##_S))
/* Helper to place a value in a field */
#define VALUE_TO_FIELD(_value, _field) (((_value) << (_field##_S)) & (_field##_M))
/* Periheral Clock */
#define APB_CLK_FREQ_ROM 26 * 1000000