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

Several improvements to serial #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Ben-Lichtman
Copy link

  • 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.

@Ben-Lichtman
Copy link
Author

Ben-Lichtman commented Feb 9, 2020

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.

@sajattack
Copy link
Owner

I'll checkout this PR with the board the example is for and adapt the example and see if it works.

@sajattack
Copy link
Owner

I think the time should be in Hz/baud (115200) not a duration.

@sajattack
Copy link
Owner

sajattack commented Feb 9, 2020

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?

@Ben-Lichtman
Copy link
Author

The rate is set based on the set_rate function - the input of which is a baud rate

@Ben-Lichtman
Copy link
Author

Ben-Lichtman commented Feb 9, 2020

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...

@sajattack
Copy link
Owner

I think this will have to go on hold until we have cross-platform Hertz or nanosecond delay.

@sajattack
Copy link
Owner

This should help https://github.com/FluenTech/embedded-time

@sajattack sajattack mentioned this pull request Mar 16, 2021
@tgross35
Copy link

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.

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.

3 participants