micropython-esp32-ulp
micropython-esp32-ulp copied to clipboard
Request for Clarification of ULP GPIO example
https://github.com/micropython/micropython-esp32-ulp/blob/7eb2a8034d7fd4eb3c588fc2fd3171780083ee8e/examples/readgpio.py#L40
Can I ask for a clarification on this line of the gpio example? What's got me confused here is that it references bit 13 of this register:
Bit 13 is reserved. I don't know if the intent here really was to write an input enable, like this:
What am I missing?
I have found that the documentation and code (ESP-IDF) don't always match 100%. In such cases, I tend to trust the code in the ESP-IDF, as that is what's actually running on devices. Then again, I have seen a case where the code was incorrect (https://github.com/espressif/binutils-esp32ulp/pull/18) and the Technical Manual was actually correct.
In this case, the example follows the approach used by Espressif's own example: https://github.com/espressif/esp-idf/blob/v4.4.1/examples/system/ulp_fsm/ulp/main/ulp_example_main.c#L72, where the rtc_gpio_set_direction
function calls rtcio_ll_input_enable
(here), which in turn sets the input enable on the RTC_IO_TOUCH_PADx_REG
using the RTC_IO_TOUCH_PADx_FUN_IE_M
mask (here). That last code uses a lookup table to find the correct register REG
for the rtc pin and then the corresponding input-enable IE
mask. And since the mask is always 1 bit wide, in our example, we're simply using it as a low-bit number with a bit-width of 1.
(Note, I have also found that with ESP32 low level code, there are often multiple ways of achieving something and the naming used everywhere is not always intuitive or consistent. So it may well be that the other approach you found in the documentation also works. Have you managed to try the other approach with success?)