This is an automated email from the ASF dual-hosted git repository. simbit18 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit e148048ac261ee1916c80281478f1e482b01eea7 Author: Eren Terzioglu <eren.terzio...@espressif.com> AuthorDate: Fri Aug 8 19:28:00 2025 +0200 arch/risc-v/esp32c6: Add RTC GPIO support for esp32c6 Add RTC GPIO support for esp32c6 Signed-off-by: Eren Terzioglu <eren.terzio...@espressif.com> --- arch/risc-v/src/common/espressif/esp_rtc_gpio.c | 75 +++++++++++++++++++++++++ arch/risc-v/src/common/espressif/esp_rtc_gpio.h | 62 ++++++++++++++++++++ 2 files changed, 137 insertions(+) diff --git a/arch/risc-v/src/common/espressif/esp_rtc_gpio.c b/arch/risc-v/src/common/espressif/esp_rtc_gpio.c index 5fa8cc498dc..3fa13175643 100644 --- a/arch/risc-v/src/common/espressif/esp_rtc_gpio.c +++ b/arch/risc-v/src/common/espressif/esp_rtc_gpio.c @@ -43,6 +43,12 @@ #include "hal/rtc_io_hal.h" #include "soc/rtc_cntl_periph.h" #include "soc/periph_defs.h" +#ifdef CONFIG_ARCH_CHIP_ESP32C6 +#include "driver/rtc_io.h" +#include "hal/rtc_io_ll.h" +#include "hal/rtc_io_hal.h" +#include "io_mux.h" +#endif /**************************************************************************** * Pre-processor Definitions @@ -264,3 +270,72 @@ void esp_rtcioirqdisable(int irq) } #endif /* CONFIG_ESPRESSIF_RTCIO_IRQ */ #endif /* CONFIG_ARCH_CHIP_ESP32C3_GENERIC */ + +#ifdef CONFIG_ARCH_CHIP_ESP32C6 +/**************************************************************************** + * Name: esp_rtcio_config_gpio + * + * Description: + * Configure a RTC GPIO pin based on encoded pin attributes + * + * Input Parameters: + * pin - RTC GPIO pin to be configured. + * mode - Attributes to be configured for the selected RTC GPIO pin. + * + * Returned Value: + * Zero (OK) on success, or -1 (ERROR) in case of failure. + * + ****************************************************************************/ + +int esp_rtcio_config_gpio(int pin, enum esp_rtc_gpio_mode_e mode) +{ + int ret = rtc_gpio_init(pin); + if (ret != OK) + { + return ret; + } + + ret = rtc_gpio_set_direction(pin, mode); + + return ret; +} + +/**************************************************************************** + * Name: esp_rtcio_read + * + * Description: + * Read one or zero from the selected RTC GPIO pin + * + * Input Parameters: + * pin - RTC GPIO pin to be read. + * + * Returned Value: + * The boolean representation of the input value (true/false). + * + ****************************************************************************/ + +int esp_rtcio_read(int pin) +{ + return rtc_gpio_get_level(pin); +} + +/**************************************************************************** + * Name: esp_rtcio_write + * + * Description: + * Write one or zero to the selected RTC GPIO pin + * + * Input Parameters: + * pin - GPIO pin to be modified. + * value - The value to be written (0 or 1). + * + * Returned Value: + * None + * + ****************************************************************************/ + +void esp_rtcio_write(int pin, bool value) +{ + rtc_gpio_set_level(pin, value); +} +#endif /* CONFIG_ARCH_CHIP_ESP32C6 */ diff --git a/arch/risc-v/src/common/espressif/esp_rtc_gpio.h b/arch/risc-v/src/common/espressif/esp_rtc_gpio.h index 7790c91fada..52837e9dceb 100644 --- a/arch/risc-v/src/common/espressif/esp_rtc_gpio.h +++ b/arch/risc-v/src/common/espressif/esp_rtc_gpio.h @@ -40,6 +40,16 @@ * Public Types ****************************************************************************/ +typedef enum esp_rtc_gpio_mode_e +{ + ESP_RTC_GPIO_MODE_INPUT, + ESP_RTC_GPIO_MODE_OUTPUT, + ESP_RTC_GPIO_MODE_INPUT_OUTPUT, + ESP_RTC_GPIO_MODE_DISABLED, + ESP_RTC_GPIO_MODE_OUTPUT_OD, + ESP_RTC_GPIO_MODE_INPUT_OUTPUT_OD +} esp_rtc_gpio_mode_t; + #ifndef __ASSEMBLY__ /**************************************************************************** @@ -111,5 +121,57 @@ void esp_rtcioirqdisable(int irq); # define esp_rtcioirqdisable(irq) #endif +#ifdef CONFIG_ARCH_CHIP_ESP32C6 +/**************************************************************************** + * Name: esp_rtcio_config_gpio + * + * Description: + * Configure a RTC GPIO pin based on encoded pin attributes + * + * Input Parameters: + * pin - RTC GPIO pin to be configured. + * mode - Attributes to be configured for the selected RTC GPIO pin. + * + * Returned Value: + * Zero (OK) on success, or -1 (ERROR) in case of failure. + * + ****************************************************************************/ + +int esp_rtcio_config_gpio(int pin, enum esp_rtc_gpio_mode_e mode); + +/**************************************************************************** + * Name: esp_rtcio_read + * + * Description: + * Read one or zero from the selected RTC GPIO pin + * + * Input Parameters: + * pin - RTC GPIO pin to be read. + * + * Returned Value: + * The boolean representation of the input value (true/false). + * + ****************************************************************************/ + +int esp_rtcio_read(int pin); + +/**************************************************************************** + * Name: esp_rtcio_write + * + * Description: + * Write one or zero to the selected RTC GPIO pin + * + * Input Parameters: + * pin - GPIO pin to be modified. + * value - The value to be written (0 or 1). + * + * Returned Value: + * None + * + ****************************************************************************/ + +void esp_rtcio_write(int pin, bool value); +#endif /* CONFIG_ARCH_CHIP_ESP32C6 */ + #endif /* __ASSEMBLY__ */ #endif /* __ARCH_RISC_V_SRC_COMMON_ESPRESSIF_ESP_RTC_GPIO_H */