Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add buffered UART exercise #159

Open
jonathanpallant opened this issue Jan 13, 2025 · 2 comments
Open

Add buffered UART exercise #159

jonathanpallant opened this issue Jan 13, 2025 · 2 comments

Comments

@jonathanpallant
Copy link
Member

jonathanpallant commented Jan 13, 2025

I'd like to see an exercise for building a fully buffered, interrupt-driven UART, as an extension to the UART exercise.

We should probably do this on a Cortex-M target, as interrupt handling on Cortex-R is not as well handled (the interrupt controllers aren't standardised, and we don't have good drivers for them).

  1. Make a blocking UART (existing exercise)
  2. Make it global (needs to be Mutex<RefCell<Option<Uart>>>)
  3. Give it a one-byte buffer (an Option<u8>) and make it interrupt driven.
  4. Replace the Option<u8> with some kind of heapless queue
  5. Use a bbqueue and DMA the data into the UART rather than copying a byte at a time
  6. Set up a second UART

QEMU probably makes sense (assuming the simulated UART has working interrupts and FIFO and DMA)

@jonathanpallant
Copy link
Member Author

jonathanpallant commented Jan 13, 2025

MPS3-AN505 (Cortex-M33) apparently has a PL081 DMA controller and five CMSDK UARTs

MPS3-AN536 (Dual Cortex-R52) should also work

@jonathanpallant
Copy link
Member Author

QEMU doesn't do flow control though (although I think that's OK): https://github.com/qemu/qemu/blob/e8aa7fdcddfc8589bdc7c973a052e76e8f999455/hw/char/cmsdk-apb-uart.c#L344

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

No branches or pull requests

1 participant