Skip to content

Uart shared variant emitter#390

Open
crabel99 wants to merge 46 commits into
adafruit:masterfrom
crabel99:uart-shared-variant-emitter
Open

Uart shared variant emitter#390
crabel99 wants to merge 46 commits into
adafruit:masterfrom
crabel99:uart-shared-variant-emitter

Conversation

@crabel99

Copy link
Copy Markdown

Summary

Refactors UART variant setup so Uart.cpp owns the common Serial* object and interrupt-handler emission, matching the structure already used by Wire and SPI.

Changes

  • Adds shared UART emitters for Serial, Serial1 through Serial5, and SerialUART.
  • Derives UART SERCOM interrupt handlers from each variant's PERIPH_SERIAL* macro.
  • Removes duplicated Uart Serial* object definitions from variant .cpp files.
  • Removes duplicated SERIAL*_IT_HANDLER definitions from variant headers where the core can derive them.
  • Keeps variant-owned UART opt-outs for special cases such as gemma_m0.

Validation

  • git diff --check -- cores/arduino/Uart.cpp variants
  • python3 tools/build_all.py metro_m0
  • python3 tools/build_all.py metro_m4
  • python3 tools/build_all.py matrixportal_m4

…added stopTransmissionWIRE to allow sync closeout, handle errors and continue processing the transaction queue
Upstream commit 289a272 added ERROR flag clearing for synchronous blocking
I2C operations, but this branch uses ISR-driven async architecture where
errors are handled and cleared immediately in interrupt context. The
upstream fix doesn't apply to the rewritten async code.
- Fix misleading indentation in retry logic (lines 847, 857)
- Remove ambiguous overload for Wire.begin() with integer literals
  (uint16_t version now requires explicit enableGeneralCall parameter)
- Remove unused variable in SPI.cpp
- Remove redundant unsigned < 0 check in setPending()
- Add __attribute__((weak)) to all SPI interrupt handlers (SERCOM4, SPI1, etc)
  This allows variants to override them when SERCOM is used for other
  peripherals (e.g., MKR variants use SERCOM4 for Serial2/UART)

- Explicitly cast slave addresses to uint8_t in Wire examples to avoid
  any potential overload resolution issues on different compiler versions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants