diff --git a/components/driver/include/driver/dedic_gpio.h b/components/driver/include/driver/dedic_gpio.h index f7d9b4a6cc..f381e2c64b 100644 --- a/components/driver/include/driver/dedic_gpio.h +++ b/components/driver/include/driver/dedic_gpio.h @@ -20,6 +20,8 @@ #include "esp_attr.h" #include "soc/soc_caps.h" +#if SOC_DEDICATED_GPIO_SUPPORTED + #ifdef __cplusplus extern "C" { #endif @@ -171,3 +173,5 @@ esp_err_t dedic_gpio_bundle_set_interrupt_and_callback(dedic_gpio_bundle_handle_ #ifdef __cplusplus } #endif + +#endif //SOC_DEDICATED_GPIO_SUPPORTED diff --git a/components/driver/include/driver/gpio.h b/components/driver/include/driver/gpio.h index 91dbde2a4d..2d8b481fda 100644 --- a/components/driver/include/driver/gpio.h +++ b/components/driver/include/driver/gpio.h @@ -3,7 +3,7 @@ // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // 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 @@ -492,28 +492,6 @@ esp_err_t gpio_sleep_set_direction(gpio_num_t gpio_num, gpio_mode_t mode); * - ESP_ERR_INVALID_ARG : Parameter error */ esp_err_t gpio_sleep_set_pull_mode(gpio_num_t gpio_num, gpio_pull_mode_t pull); - -#if CONFIG_GPIO_ESP32_SUPPORT_SWITCH_SLP_PULL -/** - * @brief Emulate ESP32S2 behaviour to backup FUN_PU, FUN_PD information - * - * @note Need to be called before sleep. - * - * @return - * - ESP_OK Success - */ -esp_err_t gpio_sleep_pupd_config_apply(gpio_num_t gpio_num); - -/** - * @brief Emulate ESP32S2 behaviour to restore FUN_PU, FUN_PD information - * - * @note Need to be called after sleep. - * - * @return - * - ESP_OK Success - */ -esp_err_t gpio_sleep_pupd_config_unapply(gpio_num_t gpio_num); -#endif #endif #if SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP diff --git a/components/driver/include/driver/rtc_io.h b/components/driver/include/driver/rtc_io.h index ea8878223c..4cdcf74ba4 100644 --- a/components/driver/include/driver/rtc_io.h +++ b/components/driver/include/driver/rtc_io.h @@ -17,10 +17,12 @@ #include #include "esp_err.h" -#include "driver/gpio.h" #include "soc/soc_caps.h" #include "soc/rtc_io_periph.h" #include "hal/rtc_io_types.h" +#include "driver/gpio.h" + + #ifdef __cplusplus extern "C" { #endif @@ -42,6 +44,7 @@ static inline bool rtc_gpio_is_valid_gpio(gpio_num_t gpio_num) #define RTC_GPIO_IS_VALID_GPIO(gpio_num) rtc_gpio_is_valid_gpio(gpio_num) // Deprecated, use rtc_gpio_is_valid_gpio() +#if SOC_RTCIO_INPUT_OUTPUT_SUPPORTED /** * @brief Get RTC IO index number by gpio number. * @@ -52,15 +55,9 @@ static inline bool rtc_gpio_is_valid_gpio(gpio_num_t gpio_num) */ static inline int rtc_io_number_get(gpio_num_t gpio_num) { -#if SOC_RTCIO_INPUT_OUTPUT_SUPPORTED return rtc_io_num_map[gpio_num]; -#else - return gpio_num; -#endif } -#if SOC_RTCIO_INPUT_OUTPUT_SUPPORTED - /** * @brief Init a GPIO as RTC GPIO * diff --git a/components/driver/include/esp_private/gpio.h b/components/driver/include/esp_private/gpio.h new file mode 100644 index 0000000000..1c4811393c --- /dev/null +++ b/components/driver/include/esp_private/gpio.h @@ -0,0 +1,45 @@ +// Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// 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. + +#pragma once + +#include "sdkconfig.h" +#include + +#include "soc/soc_caps.h" +#include "driver/gpio.h" + +#if SOC_GPIO_SUPPORT_SLP_SWITCH +#if CONFIG_GPIO_ESP32_SUPPORT_SWITCH_SLP_PULL +/** + * @brief Emulate ESP32S2 behaviour to backup FUN_PU, FUN_PD information + * + * @note Need to be called before sleep. + * + * @return + * - ESP_OK Success + */ +esp_err_t gpio_sleep_pupd_config_apply(gpio_num_t gpio_num); + +/** + * @brief Emulate ESP32S2 behaviour to restore FUN_PU, FUN_PD information + * + * @note Need to be called after sleep. + * + * @return + * - ESP_OK Success + */ +esp_err_t gpio_sleep_pupd_config_unapply(gpio_num_t gpio_num); +#endif +#endif diff --git a/components/esp_system/sleep_modes.c b/components/esp_system/sleep_modes.c index 510e483b77..362d5c592f 100644 --- a/components/esp_system/sleep_modes.c +++ b/components/esp_system/sleep_modes.c @@ -53,14 +53,14 @@ #include "esp32/rom/cache.h" #include "esp32/clk.h" #include "esp32/rom/rtc.h" -#include "driver/gpio.h" +#include "esp_private/gpio.h" #elif CONFIG_IDF_TARGET_ESP32S2 #include "esp32s2/clk.h" #include "esp32s2/rom/cache.h" #include "esp32s2/rom/rtc.h" #include "esp32s2/brownout.h" #include "soc/extmem_reg.h" -#include "driver/gpio.h" +#include "esp_private/gpio.h" #elif CONFIG_IDF_TARGET_ESP32S3 #include "esp32s3/clk.h" #include "esp32s3/rom/cache.h" diff --git a/components/soc/esp32c3/include/soc/gpio_caps.h b/components/soc/esp32c3/include/soc/gpio_caps.h index 770b7b2ad1..8da8d2194a 100644 --- a/components/soc/esp32c3/include/soc/gpio_caps.h +++ b/components/soc/esp32c3/include/soc/gpio_caps.h @@ -30,11 +30,6 @@ extern "C" { // GPIO0~5 on ESP32C3 can support chip deep sleep wakeup #define SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP (1) -#define GPIO_MODE_DEF_DISABLE (0) -#define GPIO_MODE_DEF_INPUT (BIT0) -#define GPIO_MODE_DEF_OUTPUT (BIT1) -#define GPIO_MODE_DEF_OD (BIT2) - #define SOC_GPIO_VALID_GPIO_MASK ((1U<