mirror of
https://github.com/espressif/esp-idf.git
synced 2025-07-30 18:57:19 +02:00
fix(gpio): fix 8/16-bit gpio, rtc/lp_io register access
This commit is contained in:
@ -21,6 +21,7 @@
|
|||||||
#include "soc/rtc_cntl_reg.h"
|
#include "soc/rtc_cntl_reg.h"
|
||||||
#include "hal/gpio_types.h"
|
#include "hal/gpio_types.h"
|
||||||
#include "hal/assert.h"
|
#include "hal/assert.h"
|
||||||
|
#include "hal/misc.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@ -60,7 +61,7 @@ static inline void gpio_ll_get_io_config(gpio_dev_t *hw, uint32_t gpio_num,
|
|||||||
*od = hw->pin[gpio_num].pad_driver;
|
*od = hw->pin[gpio_num].pad_driver;
|
||||||
*drv = (iomux_reg_val & FUN_DRV_M) >> FUN_DRV_S;
|
*drv = (iomux_reg_val & FUN_DRV_M) >> FUN_DRV_S;
|
||||||
*fun_sel = (iomux_reg_val & MCU_SEL_M) >> MCU_SEL_S;
|
*fun_sel = (iomux_reg_val & MCU_SEL_M) >> MCU_SEL_S;
|
||||||
*sig_out = hw->func_out_sel_cfg[gpio_num].func_sel;
|
*sig_out = HAL_FORCE_READ_U32_REG_FIELD(hw->func_out_sel_cfg[gpio_num], out_sel);
|
||||||
*slp_sel = (iomux_reg_val & SLP_SEL_M) >> SLP_SEL_S;
|
*slp_sel = (iomux_reg_val & SLP_SEL_M) >> SLP_SEL_S;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -534,7 +535,7 @@ static inline int gpio_ll_get_in_signal_connected_io(gpio_dev_t *hw, uint32_t in
|
|||||||
{
|
{
|
||||||
gpio_func_in_sel_cfg_reg_t reg;
|
gpio_func_in_sel_cfg_reg_t reg;
|
||||||
reg.val = hw->func_in_sel_cfg[in_sig_idx].val;
|
reg.val = hw->func_in_sel_cfg[in_sig_idx].val;
|
||||||
return (reg.sig_in_sel ? reg.func_sel : -1);
|
return (reg.sig_in_sel ? reg.in_sel : -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include "soc/usb_serial_jtag_reg.h"
|
#include "soc/usb_serial_jtag_reg.h"
|
||||||
#include "hal/gpio_types.h"
|
#include "hal/gpio_types.h"
|
||||||
#include "hal/assert.h"
|
#include "hal/assert.h"
|
||||||
|
#include "hal/misc.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@ -528,7 +529,7 @@ static inline int gpio_ll_get_in_signal_connected_io(gpio_dev_t *hw, uint32_t in
|
|||||||
{
|
{
|
||||||
typeof(hw->func_in_sel_cfg[in_sig_idx]) reg;
|
typeof(hw->func_in_sel_cfg[in_sig_idx]) reg;
|
||||||
reg.val = hw->func_in_sel_cfg[in_sig_idx].val;
|
reg.val = hw->func_in_sel_cfg[in_sig_idx].val;
|
||||||
return (reg.sig_in_sel ? reg.func_sel : -1);
|
return (reg.sig_in_sel ? reg.in_sel : -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -740,7 +741,7 @@ static inline void gpio_ll_get_io_config(gpio_dev_t *hw, uint32_t gpio_num,
|
|||||||
*od = hw->pin[gpio_num].pad_driver;
|
*od = hw->pin[gpio_num].pad_driver;
|
||||||
gpio_ll_get_drive_capability(hw, gpio_num, (gpio_drive_cap_t *)drv); // specific workaround in the LL
|
gpio_ll_get_drive_capability(hw, gpio_num, (gpio_drive_cap_t *)drv); // specific workaround in the LL
|
||||||
*fun_sel = (iomux_reg_val & MCU_SEL_M) >> MCU_SEL_S;
|
*fun_sel = (iomux_reg_val & MCU_SEL_M) >> MCU_SEL_S;
|
||||||
*sig_out = hw->func_out_sel_cfg[gpio_num].func_sel;
|
*sig_out = HAL_FORCE_READ_U32_REG_FIELD(hw->func_out_sel_cfg[gpio_num], out_sel);
|
||||||
*slp_sel = (iomux_reg_val & SLP_SEL_M) >> SLP_SEL_S;
|
*slp_sel = (iomux_reg_val & SLP_SEL_M) >> SLP_SEL_S;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
#include "soc/gpio_periph.h"
|
#include "soc/gpio_periph.h"
|
||||||
#include "soc/gpio_struct.h"
|
#include "soc/gpio_struct.h"
|
||||||
#include "soc/lp_aon_struct.h"
|
#include "soc/lp_aon_struct.h"
|
||||||
#include "soc/lp_io_struct.h"
|
|
||||||
#include "soc/pmu_struct.h"
|
#include "soc/pmu_struct.h"
|
||||||
#include "soc/usb_serial_jtag_reg.h"
|
#include "soc/usb_serial_jtag_reg.h"
|
||||||
#include "soc/pcr_struct.h"
|
#include "soc/pcr_struct.h"
|
||||||
@ -28,6 +27,7 @@
|
|||||||
#include "hal/gpio_types.h"
|
#include "hal/gpio_types.h"
|
||||||
#include "hal/misc.h"
|
#include "hal/misc.h"
|
||||||
#include "hal/assert.h"
|
#include "hal/assert.h"
|
||||||
|
#include "hal/misc.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@ -67,7 +67,7 @@ static inline void gpio_ll_get_io_config(gpio_dev_t *hw, uint32_t gpio_num,
|
|||||||
*od = hw->pin[gpio_num].pad_driver;
|
*od = hw->pin[gpio_num].pad_driver;
|
||||||
*drv = (iomux_reg_val & FUN_DRV_M) >> FUN_DRV_S;
|
*drv = (iomux_reg_val & FUN_DRV_M) >> FUN_DRV_S;
|
||||||
*fun_sel = (iomux_reg_val & MCU_SEL_M) >> MCU_SEL_S;
|
*fun_sel = (iomux_reg_val & MCU_SEL_M) >> MCU_SEL_S;
|
||||||
*sig_out = hw->func_out_sel_cfg[gpio_num].out_sel;
|
*sig_out = HAL_FORCE_READ_U32_REG_FIELD(hw->func_out_sel_cfg[gpio_num], out_sel);
|
||||||
*slp_sel = (iomux_reg_val & SLP_SEL_M) >> SLP_SEL_S;
|
*slp_sel = (iomux_reg_val & SLP_SEL_M) >> SLP_SEL_S;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,9 +111,9 @@ static inline void rtcio_ll_output_disable(int rtcio_num)
|
|||||||
static inline void rtcio_ll_set_level(int rtcio_num, uint32_t level)
|
static inline void rtcio_ll_set_level(int rtcio_num, uint32_t level)
|
||||||
{
|
{
|
||||||
if (level) {
|
if (level) {
|
||||||
HAL_FORCE_MODIFY_U32_REG_FIELD(LP_IO.out_data_w1ts, out_data_w1ts, BIT(rtcio_num));
|
HAL_FORCE_MODIFY_U32_REG_FIELD(LP_IO.out_data_w1ts, out_w1ts, BIT(rtcio_num));
|
||||||
} else {
|
} else {
|
||||||
HAL_FORCE_MODIFY_U32_REG_FIELD(LP_IO.out_data_w1tc, out_data_w1tc, BIT(rtcio_num));
|
HAL_FORCE_MODIFY_U32_REG_FIELD(LP_IO.out_data_w1tc, out_w1tc, BIT(rtcio_num));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -406,7 +406,7 @@ static inline uint32_t rtcio_ll_get_interrupt_status(void)
|
|||||||
*/
|
*/
|
||||||
static inline void rtcio_ll_clear_interrupt_status(void)
|
static inline void rtcio_ll_clear_interrupt_status(void)
|
||||||
{
|
{
|
||||||
HAL_FORCE_MODIFY_U32_REG_FIELD(LP_IO.status_w1tc, status_w1tc, 0xff);
|
HAL_FORCE_MODIFY_U32_REG_FIELD(LP_IO.status_w1tc, status_intr_w1tc, 0xff);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -66,7 +66,7 @@ static inline void gpio_ll_get_io_config(gpio_dev_t *hw, uint32_t gpio_num,
|
|||||||
*od = hw->pin[gpio_num].pad_driver;
|
*od = hw->pin[gpio_num].pad_driver;
|
||||||
*drv = (iomux_reg_val & FUN_DRV_M) >> FUN_DRV_S;
|
*drv = (iomux_reg_val & FUN_DRV_M) >> FUN_DRV_S;
|
||||||
*fun_sel = (iomux_reg_val & MCU_SEL_M) >> MCU_SEL_S;
|
*fun_sel = (iomux_reg_val & MCU_SEL_M) >> MCU_SEL_S;
|
||||||
*sig_out = hw->func_out_sel_cfg[gpio_num].out_sel;
|
*sig_out = HAL_FORCE_READ_U32_REG_FIELD(hw->func_out_sel_cfg[gpio_num], out_sel);
|
||||||
*slp_sel = (iomux_reg_val & SLP_SEL_M) >> SLP_SEL_S;
|
*slp_sel = (iomux_reg_val & SLP_SEL_M) >> SLP_SEL_S;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -283,7 +283,9 @@ static inline void gpio_ll_pin_input_hysteresis_enable(gpio_dev_t *hw, uint32_t
|
|||||||
uint64_t bit_mask = 1ULL << gpio_num;
|
uint64_t bit_mask = 1ULL << gpio_num;
|
||||||
if (!(bit_mask & SOC_GPIO_VALID_DIGITAL_IO_PAD_MASK)) {
|
if (!(bit_mask & SOC_GPIO_VALID_DIGITAL_IO_PAD_MASK)) {
|
||||||
// GPIO0-15
|
// GPIO0-15
|
||||||
LP_IOMUX.lp_pad_hys.reg_lp_gpio_hys |= bit_mask;
|
uint32_t hys_mask = HAL_FORCE_READ_U32_REG_FIELD(LP_IOMUX.lp_pad_hys, reg_lp_gpio_hys);
|
||||||
|
hys_mask |= bit_mask;
|
||||||
|
HAL_FORCE_MODIFY_U32_REG_FIELD(LP_IOMUX.lp_pad_hys, reg_lp_gpio_hys, hys_mask);
|
||||||
} else {
|
} else {
|
||||||
if (gpio_num < 32 + SOC_RTCIO_PIN_COUNT) {
|
if (gpio_num < 32 + SOC_RTCIO_PIN_COUNT) {
|
||||||
// GPIO 16-47
|
// GPIO 16-47
|
||||||
@ -306,7 +308,9 @@ static inline void gpio_ll_pin_input_hysteresis_disable(gpio_dev_t *hw, uint32_t
|
|||||||
uint64_t bit_mask = 1ULL << gpio_num;
|
uint64_t bit_mask = 1ULL << gpio_num;
|
||||||
if (!(bit_mask & SOC_GPIO_VALID_DIGITAL_IO_PAD_MASK)) {
|
if (!(bit_mask & SOC_GPIO_VALID_DIGITAL_IO_PAD_MASK)) {
|
||||||
// GPIO0-15
|
// GPIO0-15
|
||||||
LP_IOMUX.lp_pad_hys.reg_lp_gpio_hys &= ~bit_mask;
|
uint32_t hys_mask = HAL_FORCE_READ_U32_REG_FIELD(LP_IOMUX.lp_pad_hys, reg_lp_gpio_hys);
|
||||||
|
hys_mask &= ~bit_mask;
|
||||||
|
HAL_FORCE_MODIFY_U32_REG_FIELD(LP_IOMUX.lp_pad_hys, reg_lp_gpio_hys, hys_mask);
|
||||||
} else {
|
} else {
|
||||||
if (gpio_num < 32 + SOC_RTCIO_PIN_COUNT) {
|
if (gpio_num < 32 + SOC_RTCIO_PIN_COUNT) {
|
||||||
// GPIO 16-47
|
// GPIO 16-47
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
#include "soc/soc.h"
|
#include "soc/soc.h"
|
||||||
#include "soc/gpio_periph.h"
|
#include "soc/gpio_periph.h"
|
||||||
#include "soc/rtc_cntl_reg.h"
|
#include "soc/rtc_cntl_reg.h"
|
||||||
#include "soc/rtc_io_reg.h"
|
|
||||||
#include "soc/gpio_struct.h"
|
#include "soc/gpio_struct.h"
|
||||||
#include "hal/gpio_types.h"
|
#include "hal/gpio_types.h"
|
||||||
#include "hal/assert.h"
|
#include "hal/assert.h"
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
#include "soc/soc.h"
|
#include "soc/soc.h"
|
||||||
#include "soc/gpio_periph.h"
|
#include "soc/gpio_periph.h"
|
||||||
#include "soc/rtc_cntl_reg.h"
|
#include "soc/rtc_cntl_reg.h"
|
||||||
#include "soc/rtc_io_reg.h"
|
|
||||||
#include "soc/usb_serial_jtag_reg.h"
|
#include "soc/usb_serial_jtag_reg.h"
|
||||||
#include "hal/gpio_types.h"
|
#include "hal/gpio_types.h"
|
||||||
#include "soc/gpio_struct.h"
|
#include "soc/gpio_struct.h"
|
||||||
|
@ -301,7 +301,7 @@ typedef union {
|
|||||||
* set this value: s=0-53: connect GPIO[s] to this port. s=0x38: set this port always
|
* set this value: s=0-53: connect GPIO[s] to this port. s=0x38: set this port always
|
||||||
* high level. s=0x3C: set this port always low level.
|
* high level. s=0x3C: set this port always low level.
|
||||||
*/
|
*/
|
||||||
uint32_t func_sel:5;
|
uint32_t in_sel:5;
|
||||||
/** in_inv_sel : R/W; bitpos: [5]; default: 0;
|
/** in_inv_sel : R/W; bitpos: [5]; default: 0;
|
||||||
* set this bit to invert input signal. 1:invert. 0:not invert.
|
* set this bit to invert input signal. 1:invert. 0:not invert.
|
||||||
*/
|
*/
|
||||||
@ -325,7 +325,7 @@ typedef union {
|
|||||||
* output of GPIO[n] equals input of peripheral[s]. s=256: output of GPIO[n] equals
|
* output of GPIO[n] equals input of peripheral[s]. s=256: output of GPIO[n] equals
|
||||||
* GPIO_OUT_REG[n].
|
* GPIO_OUT_REG[n].
|
||||||
*/
|
*/
|
||||||
uint32_t func_sel:8;
|
uint32_t out_sel:8;
|
||||||
/** out_inv_sel : R/W; bitpos: [8]; default: 0;
|
/** out_inv_sel : R/W; bitpos: [8]; default: 0;
|
||||||
* set this bit to invert output signal.1:invert.0:not invert.
|
* set this bit to invert output signal.1:invert.0:not invert.
|
||||||
*/
|
*/
|
||||||
|
@ -1,16 +1,8 @@
|
|||||||
// Copyright 2020 Espressif Systems (Shanghai) PTE LTD
|
/*
|
||||||
//
|
* SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
*
|
||||||
// you may not use this file except in compliance with the License.
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
// You may obtain a copy of the License at
|
*/
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
#ifndef _SOC_GPIO_STRUCT_H_
|
#ifndef _SOC_GPIO_STRUCT_H_
|
||||||
#define _SOC_GPIO_STRUCT_H_
|
#define _SOC_GPIO_STRUCT_H_
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
@ -190,7 +182,7 @@ typedef volatile struct gpio_dev_s {
|
|||||||
uint32_t reserved_150;
|
uint32_t reserved_150;
|
||||||
union {
|
union {
|
||||||
struct {
|
struct {
|
||||||
uint32_t func_sel: 5;
|
uint32_t in_sel: 5;
|
||||||
uint32_t sig_in_inv: 1;
|
uint32_t sig_in_inv: 1;
|
||||||
uint32_t sig_in_sel: 1;
|
uint32_t sig_in_sel: 1;
|
||||||
uint32_t reserved7: 25;
|
uint32_t reserved7: 25;
|
||||||
@ -327,7 +319,7 @@ typedef volatile struct gpio_dev_s {
|
|||||||
uint32_t reserved_550;
|
uint32_t reserved_550;
|
||||||
union {
|
union {
|
||||||
struct {
|
struct {
|
||||||
uint32_t func_sel: 8;
|
uint32_t out_sel: 8;
|
||||||
uint32_t inv_sel: 1;
|
uint32_t inv_sel: 1;
|
||||||
uint32_t oen_sel: 1;
|
uint32_t oen_sel: 1;
|
||||||
uint32_t oen_inv_sel: 1;
|
uint32_t oen_inv_sel: 1;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@ -30,10 +30,10 @@ typedef union {
|
|||||||
*/
|
*/
|
||||||
typedef union {
|
typedef union {
|
||||||
struct {
|
struct {
|
||||||
/** out_data_w1ts : WT; bitpos: [7:0]; default: 0;
|
/** out_w1ts : WT; bitpos: [7:0]; default: 0;
|
||||||
* set one time output data
|
* set one time output data
|
||||||
*/
|
*/
|
||||||
uint32_t out_data_w1ts:8;
|
uint32_t out_w1ts:8;
|
||||||
uint32_t reserved_8:24;
|
uint32_t reserved_8:24;
|
||||||
};
|
};
|
||||||
uint32_t val;
|
uint32_t val;
|
||||||
@ -44,10 +44,10 @@ typedef union {
|
|||||||
*/
|
*/
|
||||||
typedef union {
|
typedef union {
|
||||||
struct {
|
struct {
|
||||||
/** out_data_w1tc : WT; bitpos: [7:0]; default: 0;
|
/** out_w1tc : WT; bitpos: [7:0]; default: 0;
|
||||||
* clear one time output data
|
* clear one time output data
|
||||||
*/
|
*/
|
||||||
uint32_t out_data_w1tc:8;
|
uint32_t out_w1tc:8;
|
||||||
uint32_t reserved_8:24;
|
uint32_t reserved_8:24;
|
||||||
};
|
};
|
||||||
uint32_t val;
|
uint32_t val;
|
||||||
@ -114,10 +114,10 @@ typedef union {
|
|||||||
*/
|
*/
|
||||||
typedef union {
|
typedef union {
|
||||||
struct {
|
struct {
|
||||||
/** status_w1ts : WT; bitpos: [7:0]; default: 0;
|
/** status_intr_w1ts : WT; bitpos: [7:0]; default: 0;
|
||||||
* set one time output data
|
* set one time output data
|
||||||
*/
|
*/
|
||||||
uint32_t status_w1ts:8;
|
uint32_t status_intr_w1ts:8;
|
||||||
uint32_t reserved_8:24;
|
uint32_t reserved_8:24;
|
||||||
};
|
};
|
||||||
uint32_t val;
|
uint32_t val;
|
||||||
@ -128,10 +128,10 @@ typedef union {
|
|||||||
*/
|
*/
|
||||||
typedef union {
|
typedef union {
|
||||||
struct {
|
struct {
|
||||||
/** status_w1tc : WT; bitpos: [7:0]; default: 0;
|
/** status_intr_w1tc : WT; bitpos: [7:0]; default: 0;
|
||||||
* clear one time output data
|
* clear one time output data
|
||||||
*/
|
*/
|
||||||
uint32_t status_w1tc:8;
|
uint32_t status_intr_w1tc:8;
|
||||||
uint32_t reserved_8:24;
|
uint32_t reserved_8:24;
|
||||||
};
|
};
|
||||||
uint32_t val;
|
uint32_t val;
|
||||||
|
@ -654,7 +654,6 @@ components/soc/esp32c3/include/soc/boot_mode.h
|
|||||||
components/soc/esp32c3/include/soc/extmem_reg.h
|
components/soc/esp32c3/include/soc/extmem_reg.h
|
||||||
components/soc/esp32c3/include/soc/fe_reg.h
|
components/soc/esp32c3/include/soc/fe_reg.h
|
||||||
components/soc/esp32c3/include/soc/gpio_reg.h
|
components/soc/esp32c3/include/soc/gpio_reg.h
|
||||||
components/soc/esp32c3/include/soc/gpio_struct.h
|
|
||||||
components/soc/esp32c3/include/soc/i2c_reg.h
|
components/soc/esp32c3/include/soc/i2c_reg.h
|
||||||
components/soc/esp32c3/include/soc/interrupt_core0_reg.h
|
components/soc/esp32c3/include/soc/interrupt_core0_reg.h
|
||||||
components/soc/esp32c3/include/soc/ledc_reg.h
|
components/soc/esp32c3/include/soc/ledc_reg.h
|
||||||
|
Reference in New Issue
Block a user