Serial write actions should be blocking
This commit is contained in:
parent
eb9faa7593
commit
4c87af1991
|
@ -10,6 +10,7 @@ mod led;
|
||||||
use crate::led::{Led, LedCycle};
|
use crate::led::{Led, LedCycle};
|
||||||
use core::fmt::Write;
|
use core::fmt::Write;
|
||||||
use cortex_m_semihosting::hprintln;
|
use cortex_m_semihosting::hprintln;
|
||||||
|
use hal::block;
|
||||||
use hal::gpio::{Edge, ExtiPin, Floating, Input};
|
use hal::gpio::{Edge, ExtiPin, Floating, Input};
|
||||||
use hal::prelude::*;
|
use hal::prelude::*;
|
||||||
use hal::serial::{self, config::Config as SerialConfig, Serial};
|
use hal::serial::{self, config::Config as SerialConfig, Serial};
|
||||||
|
@ -109,12 +110,12 @@ const APP: () = {
|
||||||
|
|
||||||
// Read a byte from the serial port and write it back.
|
// Read a byte from the serial port and write it back.
|
||||||
let byte = resources.serial_rx.read().unwrap();
|
let byte = resources.serial_rx.read().unwrap();
|
||||||
resources.serial_tx.write(byte).unwrap();
|
block!(resources.serial_tx.write(byte)).unwrap();
|
||||||
//hprintln!("serial: {}", byte).unwrap();
|
//hprintln!("serial: {}", byte).unwrap();
|
||||||
|
|
||||||
// Handle the command in the buffer for newline, otherwise append to the buffer.
|
// Handle the command in the buffer for newline, otherwise append to the buffer.
|
||||||
if byte == b'\r' {
|
if byte == b'\r' {
|
||||||
resources.serial_tx.write(b'\n').unwrap();
|
block!(resources.serial_tx.write(b'\n')).unwrap();
|
||||||
match &buffer[..] {
|
match &buffer[..] {
|
||||||
b"flip" => {
|
b"flip" => {
|
||||||
resources.led_cycle.reverse();
|
resources.led_cycle.reverse();
|
||||||
|
|
Loading…
Reference in New Issue