-
Notifications
You must be signed in to change notification settings - Fork 18
Get the VCP working #22
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
base: master
Are you sure you want to change the base?
Get the VCP working #22
Conversation
Thank you for adding the UART functionality! I'm going to give it a look and a try. How did it feel to implement? I've been planning to switch to embassy's HAL so we get an async UART. |
It was honestly quite a pain to implement. I've used embassy on a couple projects and it can be really nice, especially since their hal is well integrated and a lot of the abstractions already have dma written into them. However I believe async gets complicated pretty fast especially when you start using some of the magic like pin. |
This branch is great and I would love to see this functionality merged into main, anything I can do to help here? |
Sorry for the delay, I'm not having the bandwidth to properly review this. One thing that sticks out to me is that it basically implements an IRQ based UART driver. It feels like we should port the entire app to |
Here's an implementation of the hardware serial port that keeps all the features that use the usb serial port working with it.
The implementation uses an intermediate buffer for transmitting, but uses only the buffer internal to the usb serial software for receiving. When data is received on the usb side the usb interrupt is triggered and it writes data to the intermediate transmit buffer before writing it to the hardware transmit fifo in the uart peripheral. When data is received on the uart side the uart interrupt is triggered and reads all data from the hardware transmit buffer and writes it to the usb serial buffer to be transmitted over usb.
Transmitting data from the usb side to the uart side can get a little funky. When my host tries to write more data than the combined transmit buffers on the device it rails the usb until all it's data gets buffered on the device. When it's finished buffering everything, the usb interrupts stop so the uart interrupt needs to take over reading from the usb buffer to keep the transmit data flowing. I setup the flush_write_buffer function to enable the uart transmit interrupt so the uart interrupt can pull more data in from the buffer. It also needs to disable the transmit interrupt once there is no more data to write because the driver never clears the transmit interrupt.
Changes:
Testing:
Related Issues: