diff --git a/components/esp_driver_gpio/include/driver/rtc_io.h b/components/esp_driver_gpio/include/driver/rtc_io.h index 27a161d655..b26cf20f14 100644 --- a/components/esp_driver_gpio/include/driver/rtc_io.h +++ b/components/esp_driver_gpio/include/driver/rtc_io.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -11,17 +11,17 @@ #include "esp_err.h" #include "soc/soc_caps.h" #include "hal/rtc_io_types.h" -#include "driver/gpio.h" +#include "hal/gpio_types.h" #ifdef __cplusplus extern "C" { #endif /** - * @brief Determine if the specified GPIO is a valid RTC GPIO. + * @brief Determine if the specified IO is a valid RTC GPIO. * * @param gpio_num GPIO number - * @return true if GPIO is valid for RTC GPIO use. false otherwise. + * @return true if the IO is valid for RTC GPIO use. false otherwise. */ bool rtc_gpio_is_valid_gpio(gpio_num_t gpio_num); @@ -29,36 +29,34 @@ bool rtc_gpio_is_valid_gpio(gpio_num_t gpio_num); #if SOC_RTCIO_PIN_COUNT > 0 /** - * @brief Get RTC IO index number by gpio number. + * @brief Get RTC IO index number by GPIO number. * * @param gpio_num GPIO number * @return - * >=0: Index of rtcio. - * -1 : The gpio is not rtcio. + * >=0: Index of RTC IO. + * -1 : The IO is not an RTC IO. */ int rtc_io_number_get(gpio_num_t gpio_num); /** - * @brief Init a GPIO as RTC GPIO - * - * This function must be called when initializing a pad for an analog function. + * @brief Init an IO to be an RTC GPIO, route to RTC IO MUX * * @param gpio_num GPIO number (e.g. GPIO_NUM_12) * * @return - * - ESP_OK success - * - ESP_ERR_INVALID_ARG GPIO is not an RTC IO + * - ESP_OK Success + * - ESP_ERR_INVALID_ARG The IO is not an RTC IO */ esp_err_t rtc_gpio_init(gpio_num_t gpio_num); /** - * @brief Init a GPIO as digital GPIO + * @brief Deinit an IO as an RTC GPIO, route back to IO MUX * * @param gpio_num GPIO number (e.g. GPIO_NUM_12) * * @return - * - ESP_OK success - * - ESP_ERR_INVALID_ARG GPIO is not an RTC IO + * - ESP_OK Success + * - ESP_ERR_INVALID_ARG The IO is not an RTC IO */ esp_err_t rtc_gpio_deinit(gpio_num_t gpio_num); @@ -71,7 +69,7 @@ esp_err_t rtc_gpio_deinit(gpio_num_t gpio_num); * @return * - 1 High level * - 0 Low level - * - ESP_ERR_INVALID_ARG GPIO is not an RTC IO + * - ESP_ERR_INVALID_ARG The IO is not an RTC IO */ uint32_t rtc_gpio_get_level(gpio_num_t gpio_num); @@ -83,7 +81,7 @@ uint32_t rtc_gpio_get_level(gpio_num_t gpio_num); * * @return * - ESP_OK Success - * - ESP_ERR_INVALID_ARG GPIO is not an RTC IO + * - ESP_ERR_INVALID_ARG The IO is not an RTC IO */ esp_err_t rtc_gpio_set_level(gpio_num_t gpio_num, uint32_t level); @@ -94,11 +92,11 @@ esp_err_t rtc_gpio_set_level(gpio_num_t gpio_num, uint32_t level); * output and input. * * @param gpio_num GPIO number (e.g. GPIO_NUM_12) - * @param mode GPIO direction + * @param mode RTC GPIO direction * * @return * - ESP_OK Success - * - ESP_ERR_INVALID_ARG GPIO is not an RTC IO + * - ESP_ERR_INVALID_ARG The IO is not an RTC IO */ esp_err_t rtc_gpio_set_direction(gpio_num_t gpio_num, rtc_gpio_mode_t mode); @@ -110,11 +108,11 @@ esp_err_t rtc_gpio_set_direction(gpio_num_t gpio_num, rtc_gpio_mode_t mode); * The rest targets support INPUT_ONLY, OUTPUT_ONLY, INPUT_OUTPUT mode. * * @param gpio_num GPIO number (e.g. GPIO_NUM_12) - * @param mode GPIO direction + * @param mode RTC GPIO direction * * @return * - ESP_OK Success - * - ESP_ERR_INVALID_ARG GPIO is not an RTC IO + * - ESP_ERR_INVALID_ARG The IO is not an RTC IO */ esp_err_t rtc_gpio_set_direction_in_sleep(gpio_num_t gpio_num, rtc_gpio_mode_t mode); @@ -128,7 +126,7 @@ esp_err_t rtc_gpio_set_direction_in_sleep(gpio_num_t gpio_num, rtc_gpio_mode_t m * * @return * - ESP_OK Success - * - ESP_ERR_INVALID_ARG GPIO is not an RTC IO + * - ESP_ERR_INVALID_ARG The IO is not an RTC IO */ esp_err_t rtc_gpio_pullup_en(gpio_num_t gpio_num); @@ -142,7 +140,7 @@ esp_err_t rtc_gpio_pullup_en(gpio_num_t gpio_num); * * @return * - ESP_OK Success - * - ESP_ERR_INVALID_ARG GPIO is not an RTC IO + * - ESP_ERR_INVALID_ARG The IO is not an RTC IO */ esp_err_t rtc_gpio_pulldown_en(gpio_num_t gpio_num); @@ -156,7 +154,7 @@ esp_err_t rtc_gpio_pulldown_en(gpio_num_t gpio_num); * * @return * - ESP_OK Success - * - ESP_ERR_INVALID_ARG GPIO is not an RTC IO + * - ESP_ERR_INVALID_ARG The IO is not an RTC IO */ esp_err_t rtc_gpio_pullup_dis(gpio_num_t gpio_num); @@ -170,7 +168,7 @@ esp_err_t rtc_gpio_pullup_dis(gpio_num_t gpio_num); * * @return * - ESP_OK Success - * - ESP_ERR_INVALID_ARG GPIO is not an RTC IO + * - ESP_ERR_INVALID_ARG The IO is not an RTC IO */ esp_err_t rtc_gpio_pulldown_dis(gpio_num_t gpio_num); @@ -225,7 +223,7 @@ esp_err_t rtc_gpio_iomux_func_sel(gpio_num_t gpio_num, int func); * @param gpio_num GPIO number (e.g. GPIO_NUM_12) * @return * - ESP_OK Success - * - ESP_ERR_INVALID_ARG GPIO is not an RTC IO + * - ESP_ERR_INVALID_ARG The IO is not an RTC IO */ esp_err_t rtc_gpio_hold_en(gpio_num_t gpio_num); @@ -239,7 +237,7 @@ esp_err_t rtc_gpio_hold_en(gpio_num_t gpio_num); * @param gpio_num GPIO number (e.g. GPIO_NUM_12) * @return * - ESP_OK Success - * - ESP_ERR_INVALID_ARG GPIO is not an RTC IO + * - ESP_ERR_INVALID_ARG The IO is not an RTC IO */ esp_err_t rtc_gpio_hold_dis(gpio_num_t gpio_num); @@ -275,8 +273,8 @@ esp_err_t rtc_gpio_force_hold_dis_all(void); * * @param gpio_num GPIO number (e.g. GPIO_NUM_12). * @return - * - ESP_OK on success - * - ESP_ERR_INVALID_ARG if GPIO is not an RTC IO + * - ESP_OK Success + * - ESP_ERR_INVALID_ARG The IO is not an RTC IO */ esp_err_t rtc_gpio_isolate(gpio_num_t gpio_num); #endif // SOC_RTCIO_HOLD_SUPPORTED && SOC_RTCIO_INPUT_OUTPUT_SUPPORTED @@ -289,8 +287,8 @@ esp_err_t rtc_gpio_isolate(gpio_num_t gpio_num); * @param intr_type Wakeup on high level (GPIO_INTR_HIGH_LEVEL) or low level * (GPIO_INTR_LOW_LEVEL) * @return - * - ESP_OK on success - * - ESP_ERR_INVALID_ARG if gpio_num is not an RTC IO, or intr_type is not + * - ESP_OK Success + * - ESP_ERR_INVALID_ARG The IO is not an RTC IO, or intr_type is not * one of GPIO_INTR_HIGH_LEVEL, GPIO_INTR_LOW_LEVEL. */ esp_err_t rtc_gpio_wakeup_enable(gpio_num_t gpio_num, gpio_int_type_t intr_type); @@ -299,8 +297,8 @@ esp_err_t rtc_gpio_wakeup_enable(gpio_num_t gpio_num, gpio_int_type_t intr_type) * @brief Disable wakeup from sleep mode using specific GPIO * @param gpio_num GPIO number * @return - * - ESP_OK on success - * - ESP_ERR_INVALID_ARG if gpio_num is not an RTC IO + * - ESP_OK Success + * - ESP_ERR_INVALID_ARG The IO is not an RTC IO */ esp_err_t rtc_gpio_wakeup_disable(gpio_num_t gpio_num); diff --git a/components/esp_driver_gpio/src/rtc_io.c b/components/esp_driver_gpio/src/rtc_io.c index d6bd9a6b7e..65ee7b9f17 100644 --- a/components/esp_driver_gpio/src/rtc_io.c +++ b/components/esp_driver_gpio/src/rtc_io.c @@ -11,8 +11,6 @@ #include "esp_private/periph_ctrl.h" #include "esp_private/io_mux.h" #include "freertos/FreeRTOS.h" -#include "freertos/semphr.h" -#include "freertos/timers.h" #include "driver/rtc_io.h" #include "driver/lp_io.h" #include "hal/rtc_io_hal.h" diff --git a/components/esp_hw_support/sleep_modes.c b/components/esp_hw_support/sleep_modes.c index b09f995536..0972844e05 100644 --- a/components/esp_hw_support/sleep_modes.c +++ b/components/esp_hw_support/sleep_modes.c @@ -31,6 +31,7 @@ #include "soc/spi_pins.h" #include "soc/chip_revision.h" #include "driver/rtc_io.h" +#include "driver/gpio.h" #include "hal/efuse_hal.h" #include "hal/rtc_io_hal.h" #include "hal/clk_tree_hal.h" @@ -1938,7 +1939,7 @@ static void ext1_wakeup_prepare(void) { // Configure all RTC IOs selected as ext1 wakeup inputs uint32_t rtc_gpio_mask = s_config.ext1_rtc_gpio_mask; - for (int gpio = 0; gpio < GPIO_PIN_COUNT && rtc_gpio_mask != 0; ++gpio) { + for (int gpio = 0; gpio < SOC_GPIO_PIN_COUNT && rtc_gpio_mask != 0; ++gpio) { int rtc_pin = rtc_io_number_get(gpio); if ((rtc_gpio_mask & BIT(rtc_pin)) == 0) { continue; @@ -1987,7 +1988,7 @@ uint64_t esp_sleep_get_ext1_wakeup_status(void) uint32_t status = rtc_hal_ext1_get_wakeup_status(); // Translate bit map of RTC IO numbers into the bit map of GPIO numbers uint64_t gpio_mask = 0; - for (int gpio = 0; gpio < GPIO_PIN_COUNT; ++gpio) { + for (int gpio = 0; gpio < SOC_GPIO_PIN_COUNT; ++gpio) { if (!esp_sleep_is_valid_wakeup_gpio(gpio)) { continue; } diff --git a/components/esp_system/test_apps/esp_system_unity_tests/main/test_sleep.c b/components/esp_system/test_apps/esp_system_unity_tests/main/test_sleep.c index 4dda52f60f..8dd7d9e733 100644 --- a/components/esp_system/test_apps/esp_system_unity_tests/main/test_sleep.c +++ b/components/esp_system/test_apps/esp_system_unity_tests/main/test_sleep.c @@ -9,7 +9,6 @@ #include #include "esp_sleep.h" #include "esp_private/esp_sleep_internal.h" -#include "driver/rtc_io.h" #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "freertos/semphr.h" @@ -17,6 +16,8 @@ #include "hal/uart_types.h" #include "hal/uart_ll.h" #include "driver/uart.h" +#include "driver/rtc_io.h" +#include "driver/gpio.h" #include "soc/rtc.h" // for wakeup trigger defines #include "soc/rtc_periph.h" // for read rtc registers directly (cause) #include "soc/soc.h" // for direct register read macros diff --git a/examples/bluetooth/nimble/throughput_app/blecent_throughput/components/cmd_system/cmd_system.c b/examples/bluetooth/nimble/throughput_app/blecent_throughput/components/cmd_system/cmd_system.c index b39ba53ff6..d67108acd8 100644 --- a/examples/bluetooth/nimble/throughput_app/blecent_throughput/components/cmd_system/cmd_system.c +++ b/examples/bluetooth/nimble/throughput_app/blecent_throughput/components/cmd_system/cmd_system.c @@ -13,6 +13,7 @@ #include "esp_sleep.h" #include "esp_flash.h" #include "driver/rtc_io.h" +#include "driver/gpio.h" #include "driver/uart.h" #include "argtable3/argtable3.h" #include "freertos/FreeRTOS.h" diff --git a/examples/system/console/advanced/components/cmd_system/cmd_system_sleep.c b/examples/system/console/advanced/components/cmd_system/cmd_system_sleep.c index 4aad14d6f3..4dc434b041 100644 --- a/examples/system/console/advanced/components/cmd_system/cmd_system_sleep.c +++ b/examples/system/console/advanced/components/cmd_system/cmd_system_sleep.c @@ -22,6 +22,7 @@ #include "esp_chip_info.h" #include "esp_sleep.h" #include "driver/rtc_io.h" +#include "driver/gpio.h" #include "driver/uart.h" #include "argtable3/argtable3.h" #include "cmd_system.h"