UART embedded-io fixes
This commit is contained in:
parent
3bc2ee4343
commit
5daa85269f
@ -8,6 +8,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
## [unreleased]
|
||||
|
||||
## [v0.11.1] 2025-03-10
|
||||
|
||||
## Fixed
|
||||
|
||||
- Fix `embedded_io` UART implementation to implement the documented contract properly.
|
||||
The implementation will now block until at least one byte is available or can be written, unless
|
||||
the send or receive buffer is empty.
|
||||
|
||||
## [v0.11.0] 2025-03-07
|
||||
|
||||
## Changed
|
||||
@ -253,6 +261,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||
- README with basic instructions how to set up own binary crate
|
||||
|
||||
[unreleased]: https://egit.irs.uni-stuttgart.de/rust/va108xx-rs/compare/va108xx-hal-v0.11.0...HEAD
|
||||
[v0.11.1]: https://egit.irs.uni-stuttgart.de/rust/va108xx-rs/compare/va108xx-hal-v0.11.0...va108xx-hal-v0.11.1
|
||||
[v0.11.0]: https://egit.irs.uni-stuttgart.de/rust/va108xx-rs/compare/va108xx-hal-v0.10.0...va108xx-hal-v0.11.0
|
||||
[v0.10.0]: https://egit.irs.uni-stuttgart.de/rust/va108xx-rs/compare/va108xx-hal-v0.9.0...va108xx-hal-v0.10.0
|
||||
[v0.9.0]: https://egit.irs.uni-stuttgart.de/rust/va108xx-rs/compare/va108xx-hal-v0.8.0...va108xx-hal-v0.9.0
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "va108xx-hal"
|
||||
version = "0.11.0"
|
||||
version = "0.11.1"
|
||||
authors = ["Robin Mueller <muellerr@irs.uni-stuttgart.de>"]
|
||||
edition = "2021"
|
||||
description = "HAL for the Vorago VA108xx family of microcontrollers"
|
||||
|
@ -892,7 +892,15 @@ impl<Uart: Instance> embedded_hal_nb::serial::Read<u8> for Rx<Uart> {
|
||||
|
||||
impl<Uart: Instance> embedded_io::Read for Rx<Uart> {
|
||||
fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error> {
|
||||
if buf.is_empty() {
|
||||
return Ok(0);
|
||||
}
|
||||
let mut read = 0;
|
||||
loop {
|
||||
if self.0.rxstatus().read().rdavl().bit_is_set() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
for byte in buf.iter_mut() {
|
||||
match <Self as embedded_hal_nb::serial::Read<u8>>::read(self) {
|
||||
Ok(w) => {
|
||||
@ -1058,6 +1066,14 @@ impl<Uart: Instance> embedded_hal_nb::serial::Write<u8> for Tx<Uart> {
|
||||
|
||||
impl<Uart: Instance> embedded_io::Write for Tx<Uart> {
|
||||
fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> {
|
||||
if buf.is_empty() {
|
||||
return Ok(0);
|
||||
}
|
||||
loop {
|
||||
if self.0.txstatus().read().wrrdy().bit_is_set() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
let mut written = 0;
|
||||
for byte in buf.iter() {
|
||||
match <Self as embedded_hal_nb::serial::Write<u8>>::write(self, *byte) {
|
||||
@ -1066,7 +1082,7 @@ impl<Uart: Instance> embedded_io::Write for Tx<Uart> {
|
||||
}
|
||||
}
|
||||
|
||||
Ok(buf.len())
|
||||
Ok(written)
|
||||
}
|
||||
|
||||
fn flush(&mut self) -> Result<(), Self::Error> {
|
||||
|
Loading…
x
Reference in New Issue
Block a user