Replace embassy::io with embedded_io.

This commit is contained in:
Dario Nieuwenhuis
2022-05-04 20:48:37 +02:00
parent fc32b3750c
commit 931a137f8c
47 changed files with 697 additions and 1760 deletions

View File

@ -1,6 +1,6 @@
[target.'cfg(all(target_arch = "arm", target_os = "none"))']
# replace your chip as listed in `probe-run --list-chips`
runner = "probe-run --chip STM32L072CZTx"
runner = "probe-run --chip STM32L053R8Tx"
[build]
target = "thumbv6m-none-eabi"

View File

@ -7,12 +7,11 @@ resolver = "2"
[features]
default = ["nightly"]
nightly = ["embassy-stm32/nightly", "embassy-lora", "lorawan-device", "lorawan"]
nightly = ["embassy-stm32/nightly", "embassy-lora", "lorawan-device", "lorawan", "embedded-io/async"]
[dependencies]
embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt", "defmt-timestamp-uptime"] }
embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "stm32l072cz", "time-driver-any", "exti", "unstable-traits", "memory-x"] }
embassy-lora = { version = "0.1.0", path = "../../embassy-lora", features = ["sx127x", "time", "defmt"], optional = true}
lorawan-device = { version = "0.7.1", default-features = false, features = ["async"], optional = true }
@ -22,6 +21,7 @@ defmt = "0.3"
defmt-rtt = "0.3"
embedded-storage = "0.3.0"
embedded-io = "0.2.0"
cortex-m = "0.7.3"
cortex-m-rt = "0.7.0"

View File

@ -2,13 +2,14 @@
#![no_main]
#![feature(type_alias_impl_trait)]
use defmt_rtt as _; // global logger
use defmt_rtt as _;
use embedded_io::asynch::{Read, Write};
// global logger
use panic_probe as _;
use defmt::*;
use embassy::executor::Spawner;
use embassy::io::{AsyncBufReadExt, AsyncWriteExt};
use embassy_stm32::dma::NoDma;
use embassy_stm32::interrupt;
use embassy_stm32::usart::{BufferedUart, Config, State, Uart};
@ -16,19 +17,21 @@ use embassy_stm32::Peripherals;
#[embassy::main]
async fn main(_spawner: Spawner, p: Peripherals) {
info!("Hi!");
static mut TX_BUFFER: [u8; 8] = [0; 8];
static mut RX_BUFFER: [u8; 256] = [0; 256];
let mut config = Config::default();
config.baudrate = 9600;
let usart = Uart::new(p.USART1, p.PA10, p.PA9, NoDma, NoDma, config);
let usart = Uart::new(p.USART2, p.PA3, p.PA2, NoDma, NoDma, config);
let mut state = State::new();
let mut usart = unsafe {
BufferedUart::new(
&mut state,
usart,
interrupt::take!(USART1),
interrupt::take!(USART2),
&mut TX_BUFFER,
&mut RX_BUFFER,
)