nrf: Update nrfx to v3.14.0 and modernize machine interfaces.#37
Closed
andrewleech wants to merge 8 commits intoreview/nrfx-updatefrom
Closed
nrf: Update nrfx to v3.14.0 and modernize machine interfaces.#37andrewleech wants to merge 8 commits intoreview/nrfx-updatefrom
andrewleech wants to merge 8 commits intoreview/nrfx-updatefrom
Conversation
Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
|
Code size report: |
Add API version macros, convert NRFX_CHECK config to literal 0/1, add NRF_GPIOTE0 compat alias, implement required nrfx_glue.h macros (atomics, CLZ/CTZ, cache, event readback, IRQ pending), add haly/helpers include paths and new source files, and update startup_nrf52840.c IRQ handler names to match the nrfx v3 MDK renames in nrf52840_name_change.h. Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
Replace removed nrfx_gpiote_in_init/uninit/event_enable with the v3 instance-based API: channel allocation, input_configure, and trigger_enable. Allocates a hardware GPIOTE channel per pin to preserve high-accuracy edge detection. Falls back to PORT SENSE if all channels are in use. Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
49e25c4 to
0d61b1c
Compare
268d3ac to
616aa2a
Compare
Adapt UART, ADC, PWM, SPI, I2C, and RTC drivers for nrfx v3 renamed structs, constants, and function signatures. Notably: UARTE config members renamed and conditional on UART vs UARTE for nRF51 compatibility, SAADC value type changed to int16_t, pin-not-connected constants renamed, TWI vs TWIM pin config split, and RTC prescaler macro renamed. Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
Add fallback define for NRF_FPU_S which was removed from the nRF9160 device headers in nrfx v3. Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
Replace the nrf port's custom Pin.irq implementation with the shared mp_irq_obj_t pattern used by rp2 and alif ports. Adds support for the hard kwarg (soft IRQs via mp_sched_schedule when hard=False), makes handler optional, and returns a proper IRQ object with flags() and trigger() methods. Boards without MICROPY_ENABLE_SCHEDULER retain the direct ISR-only path. Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
Use -1 sentinels for SPI init parameters so that calling spi.init(baudrate=X) no longer resets polarity, phase, and other settings to defaults. Matches the rp2 port behavior. Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
Accept the timeout kwarg (default 50ms) for compatibility with rp2 and alif ports. Also fix TWI peripheral not being disabled on the transfer error path. Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
616aa2a to
6228ff5
Compare
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.
Summary
Updates the nrfx submodule from v2.0.0 (2019) to v3.14.0 and modernizes the nrf port's machine interfaces for consistency with rp2 and alif ports.
The nrfx upgrade is needed because TinyUSB's latest upstream broke its nrfx v2 code path in
dcd_nrf5x.c, requiring v3+ for correct API detection. The v2-to-v3 migration touches port configuration, the startup vector table, and all peripheral drivers that call nrfx APIs directly.While touching these drivers, the machine interfaces were brought in line with modern ports:
mp_irq_obj_tinfrastructure (matching rp2/alif). Addshardkwarg for soft IRQ support viamp_sched_schedule, makeshandleroptional, returns a proper IRQ object withflags()andtrigger()methods. Boards withoutMICROPY_ENABLE_SCHEDULERretain the direct ISR-only path.init()now preserves current config when parameters aren't passed (matching rp2), instead of resetting everything to defaults.timeoutkwarg (default 50ms, matching rp2/alif). Implemented using non-blocking transfers with an ISR completion callback andmp_hal_ticks_uspolling loop, so the timeout is actually enforced. Also fixed TWI peripheral not being disabled on the transfer error path.NRF_TIMER_FREQ_1MHzenum value (4) was interpreted as 4 Hz by the nrfx v3 config struct which now expects frequency in Hz.All 23 nrf board configs compile clean.
Testing
Built and verified all 23 nrf board configurations (6 nRF51, 15 nRF52, 2 nRF9160). Hardware tested on nRF52840-Dongle (PCA10059) flashed via pyocd/CMSIS-DAP with the following results:
<class 'irq'>object, no spurious triggersCould not test successful I2C data transfer (no I2C slave device wired to the dongle). Could not hardware-test nRF51 or nRF9160 boards (no hardware), but they compile clean.
Trade-offs and Alternatives
Code size on PCA10059 increased from 252,880 to ~257,268 bytes text (+1.7%). The increase comes from nrfx v3's HALY (HAL extension) layer, atomic operations, GPIOTE channel allocator, and the mp_irq infrastructure.
Generative AI
I used generative AI tools when creating this PR, but a human has checked the code and is responsible for the code and the description above.