-
Notifications
You must be signed in to change notification settings - Fork 11
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
Several improvements to serial #10
base: master
Are you sure you want to change the base?
Conversation
Note - this has changed the syntax for creating a serial port - now the timer's associated type must implement From<Duration> and you must set the baud rate after creating the serial. The provided example should be changed to reflect this, but since the library contains dependencies on another dev board I cant test them. |
I'll checkout this PR with the board the example is for and adapt the example and see if it works. |
I think the time should be in Hz/baud (115200) not a duration. |
Also rate should be based on the timer, right? They're interconnected, and how does the user know what to set the nanosecond delay to? |
The rate is set based on the set_rate function - the input of which is a baud rate |
for the timer, the problem is that the Countdown implementation for CountdownTimer in the nrf51_hal library (that i have been using) requires the associated type HFTicks which implements From<Duration>, so I just used the impl From as the associated type. However it seems that other hals' Countdown implementation for their timers take a Hz struct defined within the hal itsself... I'm not sure how to make this generalisable across the differeht hals... |
I think this will have to go on hold until we have cross-platform Hertz or nanosecond delay. |
This should help https://github.com/FluenTech/embedded-time |
I think a few ecosystems have moved from embedded-time to fugit (e.g. atsamd-hal and stm32*-hal) https://docs.rs/fugit/0.3.7/fugit/index.html, which is better maintained at this time. @Ben-Lichtman are you able to get this over the line? It would be awesome to have support. |
Serial read works now
Timings are fixed and have been tested to work from 300 baud to 115200 baud.
Read with timeout (try_read())
A convenience function - now you can provide a limit to the number of loops the waiting loop will try before the read fails. This currently contains mostly code duplicated from read so it could probably be optimised or changed to improve. It served my purpose well though,.
Rate is runtime configurable
In the previous version there was no way to change the speed of the serial port at runtime, now you can.
Decompose the port
Now you can destroy the serial port to return the pins and timer.