Skip to content

Commit d4732de

Browse files
authored
Merge pull request #50 from joestarwalker/master
Enable blocking.Write for UART, replace Void with Infallible
2 parents 7e0d7e6 + 467d727 commit d4732de

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
77

88
## [Unreleased]
99

10+
### Added
11+
12+
- Use Infallible error type for UART
13+
- Implement blocking Write for UART
14+
1015
## [v0.4.0] - 2019-12-27
1116

1217
### Added

src/serial.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
//! Serial
22
3+
use core::convert::Infallible;
34
use core::marker::PhantomData;
45
use core::ptr;
56

7+
use crate::hal::blocking::serial::write::Default;
68
use crate::hal::serial;
79
use crate::stm32::{USART1, USART2, USART3};
810
use nb;
9-
use void::Void;
1011

1112
use crate::gpio::gpioa::{PA10, PA2, PA3, PA9};
1213
#[cfg(any(
@@ -337,13 +338,13 @@ macro_rules! hal {
337338
}
338339

339340
impl serial::Write<u8> for Tx<$USARTX> {
340-
// NOTE(Void) See section "29.7 USART interrupts"; the only possible errors during
341+
// NOTE(Infallible) See section "29.7 USART interrupts"; the only possible errors during
341342
// transmission are: clear to send (which is disabled in this case) errors and
342343
// framing errors (which only occur in SmartCard mode); neither of these apply to
343344
// our hardware configuration
344-
type Error = Void;
345+
type Error = Infallible;
345346

346-
fn flush(&mut self) -> nb::Result<(), Void> {
347+
fn flush(&mut self) -> nb::Result<(), Infallible> {
347348
// NOTE(unsafe) atomic read with no side effects
348349
let isr = unsafe { (*$USARTX::ptr()).isr.read() };
349350

@@ -354,7 +355,7 @@ macro_rules! hal {
354355
}
355356
}
356357

357-
fn write(&mut self, byte: u8) -> nb::Result<(), Void> {
358+
fn write(&mut self, byte: u8) -> nb::Result<(), Infallible> {
358359
// NOTE(unsafe) atomic read with no side effects
359360
let isr = unsafe { (*$USARTX::ptr()).isr.read() };
360361

@@ -370,6 +371,8 @@ macro_rules! hal {
370371
}
371372
}
372373
}
374+
375+
impl Default<u8> for Tx<$USARTX> {}
373376
)+
374377
}
375378
}

0 commit comments

Comments
 (0)