mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 03:00:34 +03:00
refactor(lpperi): improve compatibility solution
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user