forked from espressif/esp-idf
refactor(rtcio): update comments for rtc_io header file
Closes https://github.com/espressif/esp-idf/issues/13735
This commit is contained in:
@@ -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
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@@ -11,17 +11,17 @@
|
|||||||
#include "esp_err.h"
|
#include "esp_err.h"
|
||||||
#include "soc/soc_caps.h"
|
#include "soc/soc_caps.h"
|
||||||
#include "hal/rtc_io_types.h"
|
#include "hal/rtc_io_types.h"
|
||||||
#include "driver/gpio.h"
|
#include "hal/gpio_types.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#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
|
* @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);
|
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
|
#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
|
* @param gpio_num GPIO number
|
||||||
* @return
|
* @return
|
||||||
* >=0: Index of rtcio.
|
* >=0: Index of RTC IO.
|
||||||
* -1 : The gpio is not rtcio.
|
* -1 : The IO is not an RTC IO.
|
||||||
*/
|
*/
|
||||||
int rtc_io_number_get(gpio_num_t gpio_num);
|
int rtc_io_number_get(gpio_num_t gpio_num);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Init a GPIO as RTC GPIO
|
* @brief Init an IO to be an RTC GPIO, route to RTC IO MUX
|
||||||
*
|
|
||||||
* This function must be called when initializing a pad for an analog function.
|
|
||||||
*
|
*
|
||||||
* @param gpio_num GPIO number (e.g. GPIO_NUM_12)
|
* @param gpio_num GPIO number (e.g. GPIO_NUM_12)
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
* - ESP_OK success
|
* - 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_init(gpio_num_t gpio_num);
|
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)
|
* @param gpio_num GPIO number (e.g. GPIO_NUM_12)
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
* - ESP_OK success
|
* - 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_deinit(gpio_num_t gpio_num);
|
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
|
* @return
|
||||||
* - 1 High level
|
* - 1 High level
|
||||||
* - 0 Low 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);
|
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
|
* @return
|
||||||
* - ESP_OK Success
|
* - 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);
|
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.
|
* output and input.
|
||||||
*
|
*
|
||||||
* @param gpio_num GPIO number (e.g. GPIO_NUM_12)
|
* @param gpio_num GPIO number (e.g. GPIO_NUM_12)
|
||||||
* @param mode GPIO direction
|
* @param mode RTC GPIO direction
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
* - ESP_OK Success
|
* - 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);
|
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.
|
* The rest targets support INPUT_ONLY, OUTPUT_ONLY, INPUT_OUTPUT mode.
|
||||||
*
|
*
|
||||||
* @param gpio_num GPIO number (e.g. GPIO_NUM_12)
|
* @param gpio_num GPIO number (e.g. GPIO_NUM_12)
|
||||||
* @param mode GPIO direction
|
* @param mode RTC GPIO direction
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
* - ESP_OK Success
|
* - 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);
|
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
|
* @return
|
||||||
* - ESP_OK Success
|
* - 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);
|
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
|
* @return
|
||||||
* - ESP_OK Success
|
* - 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);
|
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
|
* @return
|
||||||
* - ESP_OK Success
|
* - 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);
|
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
|
* @return
|
||||||
* - ESP_OK Success
|
* - 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);
|
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)
|
* @param gpio_num GPIO number (e.g. GPIO_NUM_12)
|
||||||
* @return
|
* @return
|
||||||
* - ESP_OK Success
|
* - 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);
|
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)
|
* @param gpio_num GPIO number (e.g. GPIO_NUM_12)
|
||||||
* @return
|
* @return
|
||||||
* - ESP_OK Success
|
* - 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);
|
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).
|
* @param gpio_num GPIO number (e.g. GPIO_NUM_12).
|
||||||
* @return
|
* @return
|
||||||
* - ESP_OK on success
|
* - ESP_OK Success
|
||||||
* - ESP_ERR_INVALID_ARG if GPIO is not an RTC IO
|
* - ESP_ERR_INVALID_ARG The IO is not an RTC IO
|
||||||
*/
|
*/
|
||||||
esp_err_t rtc_gpio_isolate(gpio_num_t gpio_num);
|
esp_err_t rtc_gpio_isolate(gpio_num_t gpio_num);
|
||||||
#endif // SOC_RTCIO_HOLD_SUPPORTED && SOC_RTCIO_INPUT_OUTPUT_SUPPORTED
|
#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
|
* @param intr_type Wakeup on high level (GPIO_INTR_HIGH_LEVEL) or low level
|
||||||
* (GPIO_INTR_LOW_LEVEL)
|
* (GPIO_INTR_LOW_LEVEL)
|
||||||
* @return
|
* @return
|
||||||
* - ESP_OK on success
|
* - ESP_OK Success
|
||||||
* - ESP_ERR_INVALID_ARG if gpio_num is not an RTC IO, or intr_type is not
|
* - 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.
|
* 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);
|
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
|
* @brief Disable wakeup from sleep mode using specific GPIO
|
||||||
* @param gpio_num GPIO number
|
* @param gpio_num GPIO number
|
||||||
* @return
|
* @return
|
||||||
* - ESP_OK on success
|
* - ESP_OK Success
|
||||||
* - ESP_ERR_INVALID_ARG if gpio_num is not an RTC IO
|
* - ESP_ERR_INVALID_ARG The IO is not an RTC IO
|
||||||
*/
|
*/
|
||||||
esp_err_t rtc_gpio_wakeup_disable(gpio_num_t gpio_num);
|
esp_err_t rtc_gpio_wakeup_disable(gpio_num_t gpio_num);
|
||||||
|
|
||||||
|
@@ -11,8 +11,6 @@
|
|||||||
#include "esp_private/periph_ctrl.h"
|
#include "esp_private/periph_ctrl.h"
|
||||||
#include "esp_private/io_mux.h"
|
#include "esp_private/io_mux.h"
|
||||||
#include "freertos/FreeRTOS.h"
|
#include "freertos/FreeRTOS.h"
|
||||||
#include "freertos/semphr.h"
|
|
||||||
#include "freertos/timers.h"
|
|
||||||
#include "driver/rtc_io.h"
|
#include "driver/rtc_io.h"
|
||||||
#include "driver/lp_io.h"
|
#include "driver/lp_io.h"
|
||||||
#include "hal/rtc_io_hal.h"
|
#include "hal/rtc_io_hal.h"
|
||||||
|
@@ -31,6 +31,7 @@
|
|||||||
#include "soc/spi_pins.h"
|
#include "soc/spi_pins.h"
|
||||||
#include "soc/chip_revision.h"
|
#include "soc/chip_revision.h"
|
||||||
#include "driver/rtc_io.h"
|
#include "driver/rtc_io.h"
|
||||||
|
#include "driver/gpio.h"
|
||||||
#include "hal/efuse_hal.h"
|
#include "hal/efuse_hal.h"
|
||||||
#include "hal/rtc_io_hal.h"
|
#include "hal/rtc_io_hal.h"
|
||||||
#include "hal/clk_tree_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
|
// Configure all RTC IOs selected as ext1 wakeup inputs
|
||||||
uint32_t rtc_gpio_mask = s_config.ext1_rtc_gpio_mask;
|
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);
|
int rtc_pin = rtc_io_number_get(gpio);
|
||||||
if ((rtc_gpio_mask & BIT(rtc_pin)) == 0) {
|
if ((rtc_gpio_mask & BIT(rtc_pin)) == 0) {
|
||||||
continue;
|
continue;
|
||||||
@@ -1987,7 +1988,7 @@ uint64_t esp_sleep_get_ext1_wakeup_status(void)
|
|||||||
uint32_t status = rtc_hal_ext1_get_wakeup_status();
|
uint32_t status = rtc_hal_ext1_get_wakeup_status();
|
||||||
// Translate bit map of RTC IO numbers into the bit map of GPIO numbers
|
// Translate bit map of RTC IO numbers into the bit map of GPIO numbers
|
||||||
uint64_t gpio_mask = 0;
|
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)) {
|
if (!esp_sleep_is_valid_wakeup_gpio(gpio)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@@ -9,7 +9,6 @@
|
|||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include "esp_sleep.h"
|
#include "esp_sleep.h"
|
||||||
#include "esp_private/esp_sleep_internal.h"
|
#include "esp_private/esp_sleep_internal.h"
|
||||||
#include "driver/rtc_io.h"
|
|
||||||
#include "freertos/FreeRTOS.h"
|
#include "freertos/FreeRTOS.h"
|
||||||
#include "freertos/task.h"
|
#include "freertos/task.h"
|
||||||
#include "freertos/semphr.h"
|
#include "freertos/semphr.h"
|
||||||
@@ -17,6 +16,8 @@
|
|||||||
#include "hal/uart_types.h"
|
#include "hal/uart_types.h"
|
||||||
#include "hal/uart_ll.h"
|
#include "hal/uart_ll.h"
|
||||||
#include "driver/uart.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.h" // for wakeup trigger defines
|
||||||
#include "soc/rtc_periph.h" // for read rtc registers directly (cause)
|
#include "soc/rtc_periph.h" // for read rtc registers directly (cause)
|
||||||
#include "soc/soc.h" // for direct register read macros
|
#include "soc/soc.h" // for direct register read macros
|
||||||
|
@@ -13,6 +13,7 @@
|
|||||||
#include "esp_sleep.h"
|
#include "esp_sleep.h"
|
||||||
#include "esp_flash.h"
|
#include "esp_flash.h"
|
||||||
#include "driver/rtc_io.h"
|
#include "driver/rtc_io.h"
|
||||||
|
#include "driver/gpio.h"
|
||||||
#include "driver/uart.h"
|
#include "driver/uart.h"
|
||||||
#include "argtable3/argtable3.h"
|
#include "argtable3/argtable3.h"
|
||||||
#include "freertos/FreeRTOS.h"
|
#include "freertos/FreeRTOS.h"
|
||||||
|
@@ -22,6 +22,7 @@
|
|||||||
#include "esp_chip_info.h"
|
#include "esp_chip_info.h"
|
||||||
#include "esp_sleep.h"
|
#include "esp_sleep.h"
|
||||||
#include "driver/rtc_io.h"
|
#include "driver/rtc_io.h"
|
||||||
|
#include "driver/gpio.h"
|
||||||
#include "driver/uart.h"
|
#include "driver/uart.h"
|
||||||
#include "argtable3/argtable3.h"
|
#include "argtable3/argtable3.h"
|
||||||
#include "cmd_system.h"
|
#include "cmd_system.h"
|
||||||
|
Reference in New Issue
Block a user