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

Fix Serial Write #23

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/serial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ where
type Error = crate::serial::Error<E>;

fn write(&mut self, byte: u8) -> nb::Result<(), Self::Error> {
// WORKAROUND: Since we don't cancel the timer it is possible that the timer has already
// overflown, in which case the first call will immediately return, with no guarantees of
// being aligned with the start of the count. The second call ensures that we start the
// timing at the right moment, since it will for sure block.
self.wait_for_timer();
self.wait_for_timer();
let mut data_out = byte;
self.tx.set_low().map_err(Error::Bus)?; // start bit
self.wait_for_timer();
Expand Down