From 8f1ac9edfb7a153e57b18a8c1d16b1efd99ca42a Mon Sep 17 00:00:00 2001 From: Davide Bettio Date: Tue, 5 Nov 2024 17:51:31 +0100 Subject: [PATCH] ESP32: fix `gpio:init/1` on GPIO >= 32 Use 1ULL as integer constant (so uint64_t is used), in order to make room for GPIO index >= 32 when shifting. Signed-off-by: Davide Bettio --- CHANGELOG.md | 1 + src/platforms/esp32/components/avm_builtins/gpio_driver.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4afa68ede..8d1700ee0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Fixed specifications of nifs from `esp_adc` module +- ESP32: fix `gpio:init/1` on GPIO >= 32 ## [0.6.5] - 2024-10-15 diff --git a/src/platforms/esp32/components/avm_builtins/gpio_driver.c b/src/platforms/esp32/components/avm_builtins/gpio_driver.c index a0c3202c1..17ec8f69c 100644 --- a/src/platforms/esp32/components/avm_builtins/gpio_driver.c +++ b/src/platforms/esp32/components/avm_builtins/gpio_driver.c @@ -660,7 +660,7 @@ static term nif_gpio_init(Context *ctx, int argc, term argv[]) } gpio_config_t config = {}; - config.pin_bit_mask = 1 << gpio_num; + config.pin_bit_mask = 1ULL << gpio_num; config.mode = GPIO_MODE_DISABLE; config.pull_up_en = GPIO_PULLUP_DISABLE; config.pull_down_en = GPIO_PULLDOWN_DISABLE;