Skip to content

Commit 81abc9c

Browse files
committed
Improve "serial with periodic flushing" example
It still doesn't compile, due to the fake `Mutex` and `CircularBuffer` types, as well as the ".." placeholders, but I've fixed the other errors.
1 parent 3359363 commit 81abc9c

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/lib.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -508,9 +508,9 @@
508508
//!
509509
//! use hal::prelude::*;
510510
//!
511-
//! fn flush(serial: &S, cb: &mut CircularBuffer) -> Result<(), S::Error>
511+
//! fn flush<S>(serial: &S, cb: &mut CircularBuffer) -> Result<(), S::Error>
512512
//! where
513-
//! S: hal::Serial,
513+
//! S: hal::serial::Write<u8>,
514514
//! {
515515
//! loop {
516516
//! if let Some(byte) = cb.peek() {
@@ -532,23 +532,22 @@
532532
//!
533533
//! // NOTE private
534534
//! static BUFFER: Mutex<CircularBuffer> = ..;
535-
//! static SERIAL: Mutex<impl hal::Serial> = ..;
535+
//! static SERIAL: Mutex<impl hal::serial::Write<u8>> = ..;
536536
//!
537537
//! impl BufferedSerial {
538-
//! pub fn write(&self, byte: u8) {
538+
//! pub fn write(&self, bytes: &[u8]) {
539539
//! let mut buffer = BUFFER.lock();
540-
//! for byte in byte {
540+
//! for byte in bytes {
541541
//! buffer.push(*byte).unwrap();
542542
//! }
543543
//! }
544544
//!
545545
//! pub fn write_all(&self, bytes: &[u8]) {
546546
//! let mut buffer = BUFFER.lock();
547547
//! for byte in bytes {
548-
//! cb.push(*byte).unwrap();
548+
//! buffer.push(*byte).unwrap();
549549
//! }
550550
//! }
551-
//!
552551
//! }
553552
//!
554553
//! fn interrupt_handler() {

0 commit comments

Comments
 (0)