mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-02 04:04:31 +02:00
esp32c3: Add new esp_sleep_is_valid_wakeup_gpio() function
This commit is contained in:
@@ -140,6 +140,17 @@ esp_err_t esp_sleep_enable_touchpad_wakeup(void);
|
|||||||
*/
|
*/
|
||||||
touch_pad_t esp_sleep_get_touchpad_wakeup_status(void);
|
touch_pad_t esp_sleep_get_touchpad_wakeup_status(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Returns true if a GPIO number is valid for use as wakeup source.
|
||||||
|
*
|
||||||
|
* @note For SoCs with RTC IO capability, this can be any valid RTC IO input pin.
|
||||||
|
*
|
||||||
|
* @param gpio_num Number of the GPIO to test for wakeup source capability
|
||||||
|
*
|
||||||
|
* @return True if this GPIO number will be accepted as a sleep wakeup source.
|
||||||
|
*/
|
||||||
|
bool esp_sleep_is_valid_wakeup_gpio(gpio_num_t gpio_num);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Enable wakeup using a pin
|
* @brief Enable wakeup using a pin
|
||||||
*
|
*
|
||||||
|
@@ -652,12 +652,21 @@ touch_pad_t esp_sleep_get_touchpad_wakeup_status(void)
|
|||||||
return pad_num;
|
return pad_num;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool esp_sleep_is_valid_wakeup_gpio(gpio_num_t gpio_num)
|
||||||
|
{
|
||||||
|
#if SOC_RTCIO_INPUT_OUTPUT_SUPPORTED
|
||||||
|
return RTC_GPIO_IS_VALID_GPIO(gpio_num);
|
||||||
|
#else
|
||||||
|
return GPIO_IS_VALID_GPIO(gpio_num);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
esp_err_t esp_sleep_enable_ext0_wakeup(gpio_num_t gpio_num, int level)
|
esp_err_t esp_sleep_enable_ext0_wakeup(gpio_num_t gpio_num, int level)
|
||||||
{
|
{
|
||||||
if (level < 0 || level > 1) {
|
if (level < 0 || level > 1) {
|
||||||
return ESP_ERR_INVALID_ARG;
|
return ESP_ERR_INVALID_ARG;
|
||||||
}
|
}
|
||||||
if (!RTC_GPIO_IS_VALID_GPIO(gpio_num)) {
|
if (!esp_sleep_is_valid_wakeup_gpio(gpio_num)) {
|
||||||
return ESP_ERR_INVALID_ARG;
|
return ESP_ERR_INVALID_ARG;
|
||||||
}
|
}
|
||||||
if (s_config.wakeup_triggers & (RTC_TOUCH_TRIG_EN | RTC_ULP_TRIG_EN)) {
|
if (s_config.wakeup_triggers & (RTC_TOUCH_TRIG_EN | RTC_ULP_TRIG_EN)) {
|
||||||
@@ -689,7 +698,7 @@ esp_err_t esp_sleep_enable_ext1_wakeup(uint64_t mask, esp_sleep_ext1_wakeup_mode
|
|||||||
if ((mask & 1) == 0) {
|
if ((mask & 1) == 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!RTC_GPIO_IS_VALID_GPIO(gpio)) {
|
if (!esp_sleep_is_valid_wakeup_gpio(gpio)) {
|
||||||
ESP_LOGE(TAG, "Not an RTC IO: GPIO%d", gpio);
|
ESP_LOGE(TAG, "Not an RTC IO: GPIO%d", gpio);
|
||||||
return ESP_ERR_INVALID_ARG;
|
return ESP_ERR_INVALID_ARG;
|
||||||
}
|
}
|
||||||
@@ -747,7 +756,7 @@ uint64_t esp_sleep_get_ext1_wakeup_status(void)
|
|||||||
// 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 < GPIO_PIN_COUNT; ++gpio) {
|
||||||
if (!RTC_GPIO_IS_VALID_GPIO(gpio)) {
|
if (!esp_sleep_is_valid_wakeup_gpio(gpio)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int rtc_pin = rtc_io_number_get(gpio);
|
int rtc_pin = rtc_io_number_get(gpio);
|
||||||
|
@@ -210,7 +210,7 @@ static int deep_sleep(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
if (deep_sleep_args.wakeup_gpio_num->count) {
|
if (deep_sleep_args.wakeup_gpio_num->count) {
|
||||||
int io_num = deep_sleep_args.wakeup_gpio_num->ival[0];
|
int io_num = deep_sleep_args.wakeup_gpio_num->ival[0];
|
||||||
if (!rtc_gpio_is_valid_gpio(io_num)) {
|
if (!esp_sleep_is_valid_wakeup_gpio(io_num)) {
|
||||||
ESP_LOGE(TAG, "GPIO %d is not an RTC IO", io_num);
|
ESP_LOGE(TAG, "GPIO %d is not an RTC IO", io_num);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user