Skip to content

Commit 282ff11

Browse files
committed
Merge branch 'feature/add_knob_ext1_wakeup' into 'master'
feat: add knob ext1_wakeup mode See merge request ae_group/esp-iot-solution!1094
2 parents 6f426e5 + efad11e commit 282ff11

File tree

3 files changed

+45
-9
lines changed

3 files changed

+45
-9
lines changed

components/knob/CHANGELOG.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
# ChangeLog
22

3+
## v1.0.0 - 2024-9-26
4+
5+
* Add ext1_wakeup mode for Knob when define CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP=y
6+
37
## v0.1.5 - 2024-7-3
48

5-
### Enhancements:
9+
### Enhancements:
10+
611
* Support power save mode
712

813
## v0.1.4 - 2023-11-23
@@ -11,7 +16,7 @@
1116

1217
## v0.1.3 - 2023-6-2
1318

14-
### Enhancements:
19+
### Enhancements:
1520

1621
* Add power on knob position detection to avoid logical inversion caused by knob position
1722
* Change test to test_apps project
@@ -34,10 +39,9 @@
3439
### Enhancements:
3540

3641
* Initial version
37-
3842
* The following types of events are supported
3943

40-
| EVENT | 描述 |
44+
| EVENT | 描述 |
4145
| ---------- | -------------------------------------- |
4246
| KNOB_LEFT | EVENT: Rotate to the left |
4347
| KNOB_RIGHT | EVENT: Rotate to the right |
@@ -46,5 +50,4 @@
4650
| KNOB_ZERO | EVENT: Count back to 0 |
4751

4852
* Support for defining multiple knobs
49-
50-
* Support binding callback functions for each event and adding user-data
53+
* Support binding callback functions for each event and adding user-data

components/knob/idf_component.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
version: "0.1.5"
2-
description: Knob driver implemented through software quadrature decoding.
1+
version: "1.0.0"
2+
description: Knob driver implemented through software pcnt
33
url: https://github.com/espressif/esp-iot-solution/tree/master/components/knob
44
documentation: https://docs.espressif.com/projects/esp-iot-solution/en/latest/input_device/knob.html
55
issues: https://github.com/espressif/esp-iot-solution/issues

components/knob/knob_gpio.c

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,20 +66,53 @@ esp_err_t knob_gpio_wake_up_control(uint32_t gpio_num, uint8_t wake_up_level, bo
6666
{
6767
esp_err_t ret;
6868
if (enable) {
69+
#if CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP
70+
#if SOC_PM_SUPPORT_EXT1_WAKEUP
71+
ret = esp_sleep_enable_ext1_wakeup_io((1ULL << gpio_num), wake_up_level == 0 ? ESP_EXT1_WAKEUP_ANY_LOW : ESP_EXT1_WAKEUP_ANY_HIGH);
72+
#else
73+
/*!< Not support etc: esp32c2, esp32c3. Target must support ext1 wakeup */
74+
ret = ESP_FAIL;
75+
ESP_RETURN_ON_FALSE(ret == ESP_OK, ESP_FAIL, TAG, "Target must support ext1 wakeup");
76+
#endif
77+
#endif
78+
/* Enable wake up from GPIO */
6979
ret = gpio_wakeup_enable(gpio_num, wake_up_level == 0 ? GPIO_INTR_LOW_LEVEL : GPIO_INTR_HIGH_LEVEL);
7080
} else {
81+
#if CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP
82+
#if SOC_PM_SUPPORT_EXT1_WAKEUP
83+
ret = esp_sleep_disable_ext1_wakeup_io(1ULL << gpio_num);
84+
#endif
85+
#endif
7186
ret = gpio_wakeup_disable(gpio_num);
7287
}
7388
return ret;
7489
}
7590

7691
esp_err_t knob_gpio_wake_up_init(uint32_t gpio_num, uint8_t wake_up_level)
7792
{
93+
#if CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP
94+
if (!esp_sleep_is_valid_wakeup_gpio(gpio_num)) {
95+
ESP_LOGE(TAG, "GPIO %ld is not a valid wakeup source under CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP",
96+
gpio_num);
97+
return ESP_FAIL;
98+
}
99+
gpio_hold_en(gpio_num);
100+
#endif
78101
/* Enable wake up from GPIO */
79102
esp_err_t ret = gpio_wakeup_enable(gpio_num, wake_up_level == 0 ? GPIO_INTR_LOW_LEVEL : GPIO_INTR_HIGH_LEVEL);
80103
ESP_RETURN_ON_FALSE(ret == ESP_OK, ESP_FAIL, TAG, "Enable gpio wakeup failed");
104+
105+
#if CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP
106+
#if SOC_PM_SUPPORT_EXT1_WAKEUP
107+
ret = esp_sleep_enable_ext1_wakeup_io((1ULL << gpio_num), wake_up_level == 0 ? ESP_EXT1_WAKEUP_ANY_LOW : ESP_EXT1_WAKEUP_ANY_HIGH);
108+
#else
109+
/*!< Not support etc: esp32c2, esp32c3. Target must support ext1 wakeup */
110+
ret = ESP_FAIL;
111+
ESP_RETURN_ON_FALSE(ret == ESP_OK, ESP_FAIL, TAG, "Target must support ext1 wakeup");
112+
#endif
113+
#else
81114
ret = esp_sleep_enable_gpio_wakeup();
82115
ESP_RETURN_ON_FALSE(ret == ESP_OK, ESP_FAIL, TAG, "esp sleep enable gpio wakeup failed");
83-
116+
#endif
84117
return ESP_OK;
85118
}

0 commit comments

Comments
 (0)