UART embedded-io fixes #66
@ -8,6 +8,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
|||||||
|
|
||||||
# [unreleased]
|
# [unreleased]
|
||||||
|
|
||||||
|
# [v0.5.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.5.0] 2025-03-07
|
# [v0.5.0] 2025-03-07
|
||||||
|
|
||||||
- Bugfix for I2C `TimingCfg::reg`
|
- Bugfix for I2C `TimingCfg::reg`
|
||||||
@ -111,6 +119,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
|||||||
- Initial release with basic HAL drivers
|
- Initial release with basic HAL drivers
|
||||||
|
|
||||||
[unreleased]: https://egit.irs.uni-stuttgart.de/rust/va416xx-rs/compare/va416xx-hal-v0.5.0...HEAD
|
[unreleased]: https://egit.irs.uni-stuttgart.de/rust/va416xx-rs/compare/va416xx-hal-v0.5.0...HEAD
|
||||||
|
[v0.5.1]: https://egit.irs.uni-stuttgart.de/rust/va416xx-rs/compare/va416xx-hal-v0.5.0...va416xx-hal-v0.5.1
|
||||||
[v0.5.0]: https://egit.irs.uni-stuttgart.de/rust/va416xx-rs/compare/va416xx-hal-v0.4.1...va416xx-hal-v0.5.0
|
[v0.5.0]: https://egit.irs.uni-stuttgart.de/rust/va416xx-rs/compare/va416xx-hal-v0.4.1...va416xx-hal-v0.5.0
|
||||||
[v0.4.1]: https://egit.irs.uni-stuttgart.de/rust/va416xx-rs/compare/va416xx-hal-v0.4.0...va416xx-hal-v0.4.1
|
[v0.4.1]: https://egit.irs.uni-stuttgart.de/rust/va416xx-rs/compare/va416xx-hal-v0.4.0...va416xx-hal-v0.4.1
|
||||||
[v0.4.0]: https://egit.irs.uni-stuttgart.de/rust/va416xx-rs/compare/va416xx-hal-v0.3.0...va416xx-hal-v0.4.0
|
[v0.4.0]: https://egit.irs.uni-stuttgart.de/rust/va416xx-rs/compare/va416xx-hal-v0.3.0...va416xx-hal-v0.4.0
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "va416xx-hal"
|
name = "va416xx-hal"
|
||||||
version = "0.5.0"
|
version = "0.5.1"
|
||||||
authors = ["Robin Mueller <muellerr@irs.uni-stuttgart.de>"]
|
authors = ["Robin Mueller <muellerr@irs.uni-stuttgart.de>"]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
description = "HAL for the Vorago VA416xx family of MCUs"
|
description = "HAL for the Vorago VA416xx family of MCUs"
|
||||||
|
@ -868,7 +868,15 @@ impl<Uart: Instance> embedded_hal_nb::serial::Read<u8> for Rx<Uart> {
|
|||||||
|
|
||||||
impl<Uart: Instance> embedded_io::Read for Rx<Uart> {
|
impl<Uart: Instance> embedded_io::Read for Rx<Uart> {
|
||||||
fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error> {
|
fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error> {
|
||||||
|
if buf.is_empty() {
|
||||||
|
return Ok(0);
|
||||||
|
}
|
||||||
let mut read = 0;
|
let mut read = 0;
|
||||||
|
loop {
|
||||||
|
if self.0.rxstatus().read().rdavl().bit_is_set() {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
for byte in buf.iter_mut() {
|
for byte in buf.iter_mut() {
|
||||||
match <Self as embedded_hal_nb::serial::Read<u8>>::read(self) {
|
match <Self as embedded_hal_nb::serial::Read<u8>>::read(self) {
|
||||||
Ok(w) => {
|
Ok(w) => {
|
||||||
@ -1038,14 +1046,19 @@ impl<Uart: Instance> embedded_io::Write for Tx<Uart> {
|
|||||||
if buf.is_empty() {
|
if buf.is_empty() {
|
||||||
return Ok(0);
|
return Ok(0);
|
||||||
}
|
}
|
||||||
|
loop {
|
||||||
for byte in buf.iter() {
|
if self.0.txstatus().read().wrrdy().bit_is_set() {
|
||||||
nb::block!(<Self as embedded_hal_nb::serial::Write<u8>>::write(
|
break;
|
||||||
self, *byte
|
|
||||||
))?;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Ok(buf.len())
|
let mut written = 0;
|
||||||
|
for byte in buf.iter() {
|
||||||
|
match <Self as embedded_hal_nb::serial::Write<u8>>::write(self, *byte) {
|
||||||
|
Ok(_) => written += 1,
|
||||||
|
Err(nb::Error::WouldBlock) => return Ok(written),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok(written)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn flush(&mut self) -> Result<(), Self::Error> {
|
fn flush(&mut self) -> Result<(), Self::Error> {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user