mirror of
https://github.com/rust-embedded/embedded-hal.git
synced 2026-03-15 02:17:40 +00:00
Improve Mutex example
Fix some problems in the `Mutex` example. Please note that it still doesn't compile, as it's obviously rather abstract and incomplete, in order to demonstrate the principle.
This commit is contained in:
parent
3901140993
commit
6cb27ab120
13
src/lib.rs
13
src/lib.rs
@ -190,16 +190,21 @@
|
||||
//! implementation:
|
||||
//!
|
||||
//! ``` ignore
|
||||
//! extern crate embedded_hal as hal;
|
||||
//! extern crate nb;
|
||||
//!
|
||||
//! /// A synchronized serial interface
|
||||
//! // NOTE This is a global singleton
|
||||
//! pub struct Serial1;
|
||||
//! pub struct Serial1(Mutex<..>);
|
||||
//!
|
||||
//! // NOTE private
|
||||
//! static USART1: Mutex<_> = Mutex::new(..);
|
||||
//!
|
||||
//! impl hal::Serial for Serial {
|
||||
//! fn read(&self) -> Result<u8, nb::Error<Error>> {
|
||||
//! hal::Serial::read(&Serial(USART1.lock()))
|
||||
//! impl hal::serial::Read<u8> for Serial1 {
|
||||
//! type Error = !;
|
||||
//!
|
||||
//! fn read(&self) -> Result<u8, nb::Error<Self::Error>> {
|
||||
//! hal::serial::Read::read(&Serial1(USART1.lock()))
|
||||
//! }
|
||||
//! }
|
||||
//! ```
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user