stm32: Add Arduino UNO Q (STM32U585) board with LED matrix driver#19311
Open
EmbeddedAndroid wants to merge 2 commits into
Open
stm32: Add Arduino UNO Q (STM32U585) board with LED matrix driver#19311EmbeddedAndroid wants to merge 2 commits into
EmbeddedAndroid wants to merge 2 commits into
Conversation
The Arduino UNO Q combines an application processor running Linux with an STM32U585. Add a board definition for the STM32U585: it runs at 160MHz from the 16MHz HSE, executes from the start of internal flash (no bootloader) and is programmed over SWD. The REPL is on LPUART1, the UART that connects to the application processor; USB is disabled because the USB-C port belongs to the application processor. The Arduino R3 header pins, USART1, I2C2 and SPI2 are exposed, along with SPI3 to the application processor. Signed-off-by: Tyler Baker <tyler.baker@oss.qualcomm.com>
The UNO Q carries a 13x8 charlieplexed LED matrix (104 LEDs) on the STM32U585 port F lines PF0..PF10. Add a driver for it in two parts. _ledmatrix is a C module that owns the lines and TIM17. It scans one pixel per timer interrupt, lighting it by driving its high line high and its low line low while the other nine float, so persistence of vision shows the whole frame. The frame is a MONO_VLSB buffer exposed to Python as a writable memoryview. ledmatrix is a frozen module whose LedMatrix class wraps that buffer in a framebuf.FrameBuffer, so the usual drawing methods are available and edits appear on the panel without an explicit flush. Signed-off-by: Tyler Baker <tyler.baker@oss.qualcomm.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #19311 +/- ##
=======================================
Coverage 98.47% 98.47%
=======================================
Files 176 176
Lines 22845 22845
=======================================
Hits 22497 22497
Misses 348 348 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Code size report: |
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
The Arduino UNO Q is an STM32U585 paired with a Qualcomm application processor
running Linux. This adds a
ports/stm32board for the STM32U585 so MicroPythonruns natively on the MCU (there's already a
ports/zephyrboard for it in#18940).
The board runs at 160MHz off the 16MHz HSE, boots straight from internal flash
with no bootloader, and is flashed over SWD. The REPL is on LPUART1, which is
the UART wired to the application processor. USB is off since the USB-C port
belongs to the AP. The Arduino header pins, USART1, I2C2 and SPI2 are exposed,
plus SPI3 to the AP.
The second commit adds a driver for the on-board 13x8 LED matrix. It's
charlieplexed across PF0..PF10, so a small C module scans it with TIM17 (one
pixel per interrupt) and exposes the frame buffer, and a frozen Python module
wraps that in a framebuf.FrameBuffer.
Testing
Built with gcc 13.2 and flashed on a UNO Q over SWD. Checked the REPL on
LPUART1, the internal filesystem, machine.freq() at 160MHz, and Pin/SPI/I2C
from the REPL. For the matrix I imported it and drew with fill/pixel/text, and
the panel lit correctly.
I also ran the repo's CI checks locally (codeformat, ruff, codespell,
verifygitlog, and the stm32 build that now includes this board) and they pass locally.
Trade-offs and Alternatives
The matrix driver is board specific rather than a generic display driver because
the panel is charlieplexed straight onto fixed GPIOs. It takes over TIM17 for
the scan, so TIM17 isn't available via pyb.Timer on this board. It's mono and
full brightness for now; grayscale could come later.
I tried doing the scan in Python with machine.Timer first, but the refresh rate
it needs is too high for Python-level callbacks, so it has to run in a C
interrupt handler.
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.