Merge branch 'refactor/improve_the_compatible_method_on_h2_v5.4' into 'release/v5.4'

refactor(lpperi): improve compatibility solution (v5.4)

See merge request espressif/esp-idf!36422
This commit is contained in:
morris
2025-01-17 16:56:56 +08:00
10 changed files with 25 additions and 93 deletions
@@ -4,7 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
/* For compatibility of ECO0 and ECO5 */
/* This is a wrapper for revisions compatibility */
#pragma once
@@ -17,31 +17,33 @@ extern "C" {
#endif
/**
* @brief Compatible lpperi struct for ECO0-ECO4 and ECO5
* @brief Compatible lpperi struct wrapper
*
*/
typedef struct {
volatile lpperi_clk_en_reg_t *clk_en;
volatile lpperi_reset_en_reg_t *reset_en;
volatile lpperi_rng_cfg_reg_t *rng_cfg;
volatile lpperi_rng_data_reg_t *rng_data;
volatile lpperi_cpu_reg_t *cpu;
volatile lpperi_bus_timeout_reg_t *bus_timeout;
volatile lpperi_bus_timeout_addr_reg_t *bus_timeout_addr;
volatile lpperi_bus_timeout_uid_reg_t *bus_timeout_uid;
volatile lpperi_mem_ctrl_reg_t *mem_ctrl;
volatile lpperi_interrupt_source_reg_t *interrupt_source;
volatile lpperi_debug_sel0_reg_t *debug_sel0;
volatile lpperi_debug_sel1_reg_t *debug_sel1;
volatile lpperi_date_reg_t *date;
typedef union {
volatile lpperi_rev0_0_dev_t rev0_0; /* Struct for LPPERI v0.0 < rev < v1.2 */
volatile lpperi_rev1_2_dev_t rev1_2; /* Struct for LPPERI rev >= v1.2*/
} lpperi_dev_t;
extern lpperi_dev_t LPPERI; // Compatible instance that achieved in 'lpperi_struct.c'
extern lpperi_dev_t LPPERI;
/** The LPPERI date version of chip revision 1.2*/
#define LPPERI_REV1_2_DATE (0x2308030)
/**
* @brief Initialize the LP_PERI register address according to the register version
* @brief Set the register value compatibly
* @param reg The register to set (can carry the field, like clk_en.lp_io_ck_en)
* @param val The value to set
*/
void lpperi_compatible_reg_addr_init(void);
#define LPPERI_REG_SET(reg, val) (LPPERI.rev1_2.date.lpperi_date >= LPPERI_REV1_2_DATE ? \
(LPPERI.rev1_2.reg = (val)) : (LPPERI.rev0_0.reg = (val)))
/**
* @brief Get the register value compatibly
* @param reg The register to get (can carry the field, like clk_en.lp_io_ck_en)
*/
#define LPPERI_REG_GET(reg) (LPPERI.rev1_2.date.lpperi_date >= LPPERI_REV1_2_DATE ? \
(LPPERI.rev1_2.reg) : (LPPERI.rev0_0.reg))
#ifdef __cplusplus
}