mirror of
				https://github.com/espressif/esp-idf.git
				synced 2025-11-04 06:11:06 +00:00 
			
		
		
		
	feat(gpio): add a dump API to dump IO configurations
Closes https://github.com/espressif/esp-idf/issues/12176
This commit is contained in:
		@@ -38,6 +38,39 @@ extern "C" {
 | 
			
		||||
 | 
			
		||||
#define GPIO_LL_PRO_CPU_INTR_ENA      (BIT(0))
 | 
			
		||||
#define GPIO_LL_PRO_CPU_NMI_INTR_ENA  (BIT(1))
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief Get the configuration for an IO
 | 
			
		||||
 *
 | 
			
		||||
 * @param hw Peripheral GPIO hardware instance address.
 | 
			
		||||
 * @param gpio_num GPIO number
 | 
			
		||||
 * @param pu Pull-up enabled or not
 | 
			
		||||
 * @param pd Pull-down enabled or not
 | 
			
		||||
 * @param ie Input enabled or not
 | 
			
		||||
 * @param oe Output enabled or not
 | 
			
		||||
 * @param od Open-drain enabled or not
 | 
			
		||||
 * @param drv Drive strength value
 | 
			
		||||
 * @param fun_sel IOMUX function selection value
 | 
			
		||||
 * @param sig_out Outputting peripheral signal index
 | 
			
		||||
 * @param slp_sel Pin sleep mode enabled or not
 | 
			
		||||
 */
 | 
			
		||||
static inline void gpio_ll_get_io_config(gpio_dev_t *hw, uint32_t gpio_num,
 | 
			
		||||
                                         bool *pu, bool *pd, bool *ie, bool *oe, bool *od, uint32_t *drv,
 | 
			
		||||
                                         uint32_t *fun_sel, uint32_t *sig_out, bool *slp_sel)
 | 
			
		||||
{
 | 
			
		||||
    uint32_t bit_mask = 1 << gpio_num;
 | 
			
		||||
    uint32_t iomux_reg_val = REG_READ(GPIO_PIN_MUX_REG[gpio_num]);
 | 
			
		||||
    *pu = (iomux_reg_val & FUN_PU_M) >> FUN_PU_S;
 | 
			
		||||
    *pd = (iomux_reg_val & FUN_PD_M) >> FUN_PD_S;
 | 
			
		||||
    *ie = (iomux_reg_val & FUN_IE_M) >> FUN_IE_S;
 | 
			
		||||
    *oe = (hw->enable.val & bit_mask) >> gpio_num;
 | 
			
		||||
    *od = hw->pin[gpio_num].pad_driver;
 | 
			
		||||
    *drv = (iomux_reg_val & FUN_DRV_M) >> FUN_DRV_S;
 | 
			
		||||
    *fun_sel = (iomux_reg_val & MCU_SEL_M) >> MCU_SEL_S;
 | 
			
		||||
    *sig_out = hw->func_out_sel_cfg[gpio_num].out_sel;
 | 
			
		||||
    *slp_sel = (iomux_reg_val & SLP_SEL_M) >> SLP_SEL_S;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief Enable pull-up on GPIO.
 | 
			
		||||
  *
 | 
			
		||||
@@ -478,6 +511,23 @@ static inline void gpio_ll_iomux_set_clk_src(soc_module_clk_t src)
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief Get the GPIO number that is routed to the input peripheral signal through GPIO matrix.
 | 
			
		||||
 *
 | 
			
		||||
 * @param hw Peripheral GPIO hardware instance address.
 | 
			
		||||
 * @param in_sig_idx Peripheral signal index (tagged as input attribute).
 | 
			
		||||
 *
 | 
			
		||||
 * @return
 | 
			
		||||
 *    - -1     Signal bypassed GPIO matrix
 | 
			
		||||
 *    - Others GPIO number
 | 
			
		||||
 */
 | 
			
		||||
static inline int gpio_ll_get_in_signal_connected_io(gpio_dev_t *hw, uint32_t in_sig_idx)
 | 
			
		||||
{
 | 
			
		||||
    gpio_func_in_sel_cfg_reg_t reg;
 | 
			
		||||
    reg.val = hw->func_in_sel_cfg[in_sig_idx].val;
 | 
			
		||||
    return (reg.sig_in_sel ? reg.in_sel : -1);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief Force hold digital io pad.
 | 
			
		||||
  * @note GPIO force hold, whether the chip in sleep mode or wakeup mode.
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user