mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-01 18:50:34 +03:00
Merge branch 'doces/add_pcnt_pull_migreation_guide_v6.1' into 'release/v6.1'
docs(pcnt): add gpio pull mode migration guide (v6.1) See merge request espressif/esp-idf!51118
This commit is contained in:
@@ -33,25 +33,28 @@ B +-----+ +-----+ +-----+
|
||||
|
||||
* An ESP development board
|
||||
* EC11 rotary encoder (or other encoders which can produce quadrature waveforms)
|
||||
* Pull-up resistors for the A and B signal lines. It is recommended to provide external pull-up resistors on the PCB.
|
||||
|
||||
Connection :
|
||||
|
||||
```text
|
||||
+--------+ +---------------------------------+
|
||||
| | | |
|
||||
| A +--------------+ GPIO_A (internal pull up) |
|
||||
| A +--------------+ GPIO_A (external pull up) |
|
||||
| | | |
|
||||
+-------+ | | |
|
||||
| | | GND +--------------+ GND |
|
||||
+-------+ | | |
|
||||
| | | |
|
||||
| B +--------------+ GPIO_B (internal pull up) |
|
||||
| B +--------------+ GPIO_B (external pull up) |
|
||||
| | | |
|
||||
+--------+ +---------------------------------+
|
||||
```
|
||||
|
||||
The GPIO used by the example can be changed according to your board by `EXAMPLE_EC11_GPIO_A` and `EXAMPLE_EC11_GPIO_B` in [source file](main/rotary_encoder_example_main.c).
|
||||
|
||||
The PCNT driver does not configure internal pull-up or pull-down resistors for the input GPIOs. If your board does not have external pull-up resistors for the EC11 A/B signal lines, enable `EXAMPLE_ENABLE_INTERNAL_PULL_UPS` from `menuconfig`, or call GPIO APIs such as `gpio_pullup_en()` or `gpio_set_pull_mode()` in your application.
|
||||
|
||||
### Build and Flash
|
||||
|
||||
By configuring one of the EC11 GPIO (e.g. `EXAMPLE_EC11_GPIO_A`) as a wake up source, you can make the rotary encoder wake the system from light sleep. This example can illustrate this feature if you enable the `EXAMPLE_WAKE_UP_LIGHT_SLEEP` from the menuconfig.
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
menu "Example Configuration"
|
||||
config EXAMPLE_ENABLE_INTERNAL_PULL_UPS
|
||||
bool "Enable internal pull-up resistors"
|
||||
default "n"
|
||||
help
|
||||
Enable the internal pull-up resistors for the EC11 A/B signal GPIOs.
|
||||
It is recommended to provide external pull-up resistors on the PCB.
|
||||
Enable this option only when external pull-up resistors are not available.
|
||||
|
||||
config EXAMPLE_WAKE_UP_LIGHT_SLEEP
|
||||
bool "Configure the EC11 to wake up light sleep"
|
||||
default "n"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2010-2022 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2010-2026 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: CC0-1.0
|
||||
*/
|
||||
@@ -46,6 +46,12 @@ void app_main(void)
|
||||
};
|
||||
ESP_ERROR_CHECK(pcnt_unit_set_glitch_filter(pcnt_unit, &filter_config));
|
||||
|
||||
#if CONFIG_EXAMPLE_ENABLE_INTERNAL_PULL_UPS
|
||||
ESP_LOGI(TAG, "enable internal pull-up resistors");
|
||||
ESP_ERROR_CHECK(gpio_pullup_en(EXAMPLE_EC11_GPIO_A));
|
||||
ESP_ERROR_CHECK(gpio_pullup_en(EXAMPLE_EC11_GPIO_B));
|
||||
#endif
|
||||
|
||||
ESP_LOGI(TAG, "install pcnt channels");
|
||||
pcnt_chan_config_t chan_a_config = {
|
||||
.edge_gpio_num = EXAMPLE_EC11_GPIO_A,
|
||||
|
||||
Reference in New Issue
Block a user