Add ESP32-S3 and nRF52 GPIO support#162
Open
Elwimen wants to merge 4 commits intoPaulStoffregen:masterfrom
Open
Add ESP32-S3 and nRF52 GPIO support#162Elwimen wants to merge 4 commits intoPaulStoffregen:masterfrom
Elwimen wants to merge 4 commits intoPaulStoffregen:masterfrom
Conversation
ESP32-S3 (IDF v5): add explicit CONFIG_IDF_TARGET_ESP32S3 branches to all five GPIO functions. ESP32-S3 uses struct-based register access (.val) in IDF v5, unlike plain ESP32 which uses scalar registers. Also extends the valid pin range to 48 (GPIOs 0-48 on ESP32-S3 vs 0-45 on plain ESP32). nRF52 series (nRF52832/nRF52833/nRF52840): add a new platform section using nrf_gpio_*() SDK functions. g_ADigitalPinMap[] from the Adafruit/RAK nRF52 Arduino core translates Arduino pin numbers to the absolute hardware GPIO numbers that nrf_gpio_*() expects, covering dual-port (P0/P1) boards.
…e mismatch On some ARM toolchains uint32_t aliases to unsigned long, which is a distinct type from unsigned int even though both are 32-bit on Cortex-M. This caused a compile error in OneWire.cpp when assigning the IO_REG_TYPE* class member to a local volatile IO_REG_TYPE* variable. Using unsigned int directly avoids the ambiguity and matches the else-fallback definition used by other platforms.
IDF v4 GPIO registers for pins 0-31 are plain scalars (GPIO.in, GPIO.out_w1tc, etc.). IDF v5 changed them to structs requiring .val. The ESP32-S3 section now selects scalar or struct access at compile time based on ESP_IDF_VERSION_MAJOR, keeping the extended pin range (0-48) for both versions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds direct GPIO support for two platforms that are currently missing from
OneWire_direct_gpio.h.ESP32-S3
The ESP32-S3 uses struct-based GPIO register access (
.val) in IDF v5, unlike the plain ESP32 which uses scalar registers. This adds explicitCONFIG_IDF_TARGET_ESP32S3branches to all five GPIO functions (directRead,directWriteLow,directWriteHigh,directModeInput,directModeOutput) with anESP_IDF_VERSION_MAJOR >= 5guard to handle both IDF versions. The extended pin range (GPIOs 0–48) is also covered via thein1/out1_w1tc/out1_w1ts/enable1_w1tc/enable1_w1tsregisters for pins 32–48.nRF52 series (nRF52832/nRF52833/nRF52840)
Adds a new platform section using the
nrf_gpio_*()SDK functions.g_ADigitalPinMap[]from the Adafruit/RAK nRF52 Arduino core translates Arduino pin numbers to the absolute hardware GPIO numbers thatnrf_gpio_*()expects, covering both single-port and dual-port (P0/P1) boards.IO_REG_TYPEis defined asunsigned intrather thanuint32_tto avoid a pointer-type mismatch on ARM toolchains whereuint32_taliasesunsigned long.Tested with Meshtastic firmware on ESP32-S3 (IDF v4 and v5) and nRF52840.