diff options
| author | Dario Nieuwenhuis <[email protected]> | 2022-05-04 20:48:37 +0200 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2022-05-07 01:45:54 +0200 |
| commit | 931a137f8c5a760c2e06c437c98d14eff3e3a587 (patch) | |
| tree | 7b79ba8397c3eff730f634cbaf77aa5571337191 /examples | |
| parent | fc32b3750c448a81b7dd44cf9de98723b8eb4fcf (diff) | |
Replace embassy::io with embedded_io.
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/nrf/Cargo.toml | 3 | ||||
| -rw-r--r-- | examples/nrf/src/bin/buffered_uart.rs | 2 | ||||
| -rw-r--r-- | examples/nrf/src/bin/usb_ethernet.rs | 8 | ||||
| -rw-r--r-- | examples/std/Cargo.toml | 3 | ||||
| -rw-r--r-- | examples/std/src/bin/net.rs | 5 | ||||
| -rw-r--r-- | examples/std/src/bin/serial.rs | 14 | ||||
| -rw-r--r-- | examples/stm32f7/Cargo.toml | 1 | ||||
| -rw-r--r-- | examples/stm32f7/src/bin/eth.rs | 7 | ||||
| -rw-r--r-- | examples/stm32h7/Cargo.toml | 3 | ||||
| -rw-r--r-- | examples/stm32h7/src/bin/eth.rs | 7 | ||||
| -rw-r--r-- | examples/stm32l0/.cargo/config.toml | 2 | ||||
| -rw-r--r-- | examples/stm32l0/Cargo.toml | 4 | ||||
| -rw-r--r-- | examples/stm32l0/src/bin/usart_irq.rs | 11 |
13 files changed, 38 insertions, 32 deletions
diff --git a/examples/nrf/Cargo.toml b/examples/nrf/Cargo.toml index 4258544f0..ffac0a769 100644 --- a/examples/nrf/Cargo.toml +++ b/examples/nrf/Cargo.toml | |||
| @@ -6,7 +6,7 @@ version = "0.1.0" | |||
| 6 | 6 | ||
| 7 | [features] | 7 | [features] |
| 8 | default = ["nightly"] | 8 | default = ["nightly"] |
| 9 | nightly = ["embassy-nrf/nightly", "embassy-nrf/unstable-traits", "embassy-usb", "embassy-usb-serial", "embassy-usb-hid", "embassy-usb-ncm"] | 9 | nightly = ["embassy-nrf/nightly", "embassy-nrf/unstable-traits", "embassy-usb", "embassy-usb-serial", "embassy-usb-hid", "embassy-usb-ncm", "embedded-io/async", "embassy-net/nightly"] |
| 10 | 10 | ||
| 11 | [dependencies] | 11 | [dependencies] |
| 12 | embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt", "defmt-timestamp-uptime"] } | 12 | embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt", "defmt-timestamp-uptime"] } |
| @@ -16,6 +16,7 @@ embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defm | |||
| 16 | embassy-usb-serial = { version = "0.1.0", path = "../../embassy-usb-serial", features = ["defmt"], optional = true } | 16 | embassy-usb-serial = { version = "0.1.0", path = "../../embassy-usb-serial", features = ["defmt"], optional = true } |
| 17 | embassy-usb-hid = { version = "0.1.0", path = "../../embassy-usb-hid", features = ["defmt"], optional = true } | 17 | embassy-usb-hid = { version = "0.1.0", path = "../../embassy-usb-hid", features = ["defmt"], optional = true } |
| 18 | embassy-usb-ncm = { version = "0.1.0", path = "../../embassy-usb-ncm", features = ["defmt"], optional = true } | 18 | embassy-usb-ncm = { version = "0.1.0", path = "../../embassy-usb-ncm", features = ["defmt"], optional = true } |
| 19 | embedded-io = "0.2.0" | ||
| 19 | 20 | ||
| 20 | defmt = "0.3" | 21 | defmt = "0.3" |
| 21 | defmt-rtt = "0.3" | 22 | defmt-rtt = "0.3" |
diff --git a/examples/nrf/src/bin/buffered_uart.rs b/examples/nrf/src/bin/buffered_uart.rs index 2cd163a9f..a64c5821b 100644 --- a/examples/nrf/src/bin/buffered_uart.rs +++ b/examples/nrf/src/bin/buffered_uart.rs | |||
| @@ -4,9 +4,9 @@ | |||
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy::executor::Spawner; | 6 | use embassy::executor::Spawner; |
| 7 | use embassy::io::{AsyncBufReadExt, AsyncWriteExt}; | ||
| 8 | use embassy_nrf::buffered_uarte::State; | 7 | use embassy_nrf::buffered_uarte::State; |
| 9 | use embassy_nrf::{buffered_uarte::BufferedUarte, interrupt, uarte, Peripherals}; | 8 | use embassy_nrf::{buffered_uarte::BufferedUarte, interrupt, uarte, Peripherals}; |
| 9 | use embedded_io::asynch::{Read, Write}; | ||
| 10 | use futures::pin_mut; | 10 | use futures::pin_mut; |
| 11 | 11 | ||
| 12 | use defmt_rtt as _; // global logger | 12 | use defmt_rtt as _; // global logger |
diff --git a/examples/nrf/src/bin/usb_ethernet.rs b/examples/nrf/src/bin/usb_ethernet.rs index f14a29c49..843487c03 100644 --- a/examples/nrf/src/bin/usb_ethernet.rs +++ b/examples/nrf/src/bin/usb_ethernet.rs | |||
| @@ -10,9 +10,9 @@ use defmt::*; | |||
| 10 | use embassy::blocking_mutex::raw::ThreadModeRawMutex; | 10 | use embassy::blocking_mutex::raw::ThreadModeRawMutex; |
| 11 | use embassy::channel::Channel; | 11 | use embassy::channel::Channel; |
| 12 | use embassy::executor::Spawner; | 12 | use embassy::executor::Spawner; |
| 13 | use embassy::io::{AsyncBufReadExt, AsyncWriteExt}; | ||
| 14 | use embassy::util::Forever; | 13 | use embassy::util::Forever; |
| 15 | use embassy_net::{PacketBox, PacketBoxExt, PacketBuf, TcpSocket}; | 14 | use embassy_net::tcp::TcpSocket; |
| 15 | use embassy_net::{PacketBox, PacketBoxExt, PacketBuf}; | ||
| 16 | use embassy_nrf::pac; | 16 | use embassy_nrf::pac; |
| 17 | use embassy_nrf::usb::Driver; | 17 | use embassy_nrf::usb::Driver; |
| 18 | use embassy_nrf::Peripherals; | 18 | use embassy_nrf::Peripherals; |
| @@ -20,7 +20,9 @@ use embassy_nrf::{interrupt, peripherals}; | |||
| 20 | use embassy_usb::{Builder, Config, UsbDevice}; | 20 | use embassy_usb::{Builder, Config, UsbDevice}; |
| 21 | use embassy_usb_ncm::{CdcNcmClass, Receiver, Sender, State}; | 21 | use embassy_usb_ncm::{CdcNcmClass, Receiver, Sender, State}; |
| 22 | 22 | ||
| 23 | use defmt_rtt as _; // global logger | 23 | use defmt_rtt as _; |
| 24 | use embedded_io::asynch::{Read, Write}; | ||
| 25 | // global logger | ||
| 24 | use panic_probe as _; | 26 | use panic_probe as _; |
| 25 | 27 | ||
| 26 | type MyDriver = Driver<'static, peripherals::USBD>; | 28 | type MyDriver = Driver<'static, peripherals::USBD>; |
diff --git a/examples/std/Cargo.toml b/examples/std/Cargo.toml index 0853c323e..fa2a98a49 100644 --- a/examples/std/Cargo.toml +++ b/examples/std/Cargo.toml | |||
| @@ -6,7 +6,8 @@ version = "0.1.0" | |||
| 6 | 6 | ||
| 7 | [dependencies] | 7 | [dependencies] |
| 8 | embassy = { version = "0.1.0", path = "../../embassy", features = ["log", "std", "time", "nightly"] } | 8 | embassy = { version = "0.1.0", path = "../../embassy", features = ["log", "std", "time", "nightly"] } |
| 9 | embassy-net = { version = "0.1.0", path = "../../embassy-net", features=["std", "log", "medium-ethernet", "tcp", "dhcpv4", "pool-16"] } | 9 | embassy-net = { version = "0.1.0", path = "../../embassy-net", features=["nightly", "std", "log", "medium-ethernet", "tcp", "dhcpv4", "pool-16"] } |
| 10 | embedded-io = { version = "0.2.0", features = ["async", "std"] } | ||
| 10 | 11 | ||
| 11 | async-io = "1.6.0" | 12 | async-io = "1.6.0" |
| 12 | env_logger = "0.9.0" | 13 | env_logger = "0.9.0" |
diff --git a/examples/std/src/bin/net.rs b/examples/std/src/bin/net.rs index 3b4bc6fea..daedffb0f 100644 --- a/examples/std/src/bin/net.rs +++ b/examples/std/src/bin/net.rs | |||
| @@ -2,12 +2,13 @@ | |||
| 2 | 2 | ||
| 3 | use clap::Parser; | 3 | use clap::Parser; |
| 4 | use embassy::executor::{Executor, Spawner}; | 4 | use embassy::executor::{Executor, Spawner}; |
| 5 | use embassy::io::AsyncWriteExt; | ||
| 6 | use embassy::util::Forever; | 5 | use embassy::util::Forever; |
| 6 | use embassy_net::tcp::TcpSocket; | ||
| 7 | use embassy_net::{ | 7 | use embassy_net::{ |
| 8 | Config, Configurator, DhcpConfigurator, Ipv4Address, Ipv4Cidr, StackResources, | 8 | Config, Configurator, DhcpConfigurator, Ipv4Address, Ipv4Cidr, StackResources, |
| 9 | StaticConfigurator, TcpSocket, | 9 | StaticConfigurator, |
| 10 | }; | 10 | }; |
| 11 | use embedded_io::asynch::Write; | ||
| 11 | use heapless::Vec; | 12 | use heapless::Vec; |
| 12 | use log::*; | 13 | use log::*; |
| 13 | 14 | ||
diff --git a/examples/std/src/bin/serial.rs b/examples/std/src/bin/serial.rs index 129dc2090..b1e5b0142 100644 --- a/examples/std/src/bin/serial.rs +++ b/examples/std/src/bin/serial.rs | |||
| @@ -5,8 +5,8 @@ mod serial_port; | |||
| 5 | 5 | ||
| 6 | use async_io::Async; | 6 | use async_io::Async; |
| 7 | use embassy::executor::Executor; | 7 | use embassy::executor::Executor; |
| 8 | use embassy::io::AsyncBufReadExt; | ||
| 9 | use embassy::util::Forever; | 8 | use embassy::util::Forever; |
| 9 | use embedded_io::asynch::Read; | ||
| 10 | use log::*; | 10 | use log::*; |
| 11 | use nix::sys::termios; | 11 | use nix::sys::termios; |
| 12 | 12 | ||
| @@ -24,12 +24,12 @@ async fn run() { | |||
| 24 | // Essentially, async_io::Async converts from AsRawFd+Read+Write to futures's AsyncRead+AsyncWrite | 24 | // Essentially, async_io::Async converts from AsRawFd+Read+Write to futures's AsyncRead+AsyncWrite |
| 25 | let port = Async::new(port).unwrap(); | 25 | let port = Async::new(port).unwrap(); |
| 26 | 26 | ||
| 27 | // This implements futures's AsyncBufRead based on futures's AsyncRead | 27 | // We can then use FromStdIo to convert from futures's AsyncRead+AsyncWrite |
| 28 | let port = futures::io::BufReader::new(port); | 28 | // to embedded_io's async Read+Write. |
| 29 | 29 | // | |
| 30 | // We can then use FromStdIo to convert from futures's AsyncBufRead+AsyncWrite | 30 | // This is not really needed, you could write the code below using futures::io directly. |
| 31 | // to embassy's AsyncBufRead+AsyncWrite | 31 | // It's useful if you want to have portable code across embedded and std. |
| 32 | let mut port = embassy::io::FromStdIo::new(port); | 32 | let mut port = embedded_io::adapters::FromFutures::new(port); |
| 33 | 33 | ||
| 34 | info!("Serial opened!"); | 34 | info!("Serial opened!"); |
| 35 | 35 | ||
diff --git a/examples/stm32f7/Cargo.toml b/examples/stm32f7/Cargo.toml index 09a06aa7f..bbeee179d 100644 --- a/examples/stm32f7/Cargo.toml +++ b/examples/stm32f7/Cargo.toml | |||
| @@ -9,6 +9,7 @@ resolver = "2" | |||
| 9 | embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt", "defmt-timestamp-uptime"] } | 9 | embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt", "defmt-timestamp-uptime"] } |
| 10 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "net", "stm32f767zi", "unstable-pac", "time-driver-any", "exti"] } | 10 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "net", "stm32f767zi", "unstable-pac", "time-driver-any", "exti"] } |
| 11 | embassy-net = { path = "../../embassy-net", features = ["defmt", "tcp", "medium-ethernet", "pool-16"] } | 11 | embassy-net = { path = "../../embassy-net", features = ["defmt", "tcp", "medium-ethernet", "pool-16"] } |
| 12 | embedded-io = { version = "0.2.0", features = ["async"] } | ||
| 12 | 13 | ||
| 13 | defmt = "0.3" | 14 | defmt = "0.3" |
| 14 | defmt-rtt = "0.3" | 15 | defmt-rtt = "0.3" |
diff --git a/examples/stm32f7/src/bin/eth.rs b/examples/stm32f7/src/bin/eth.rs index 33e41de9c..dca9338b2 100644 --- a/examples/stm32f7/src/bin/eth.rs +++ b/examples/stm32f7/src/bin/eth.rs | |||
| @@ -5,12 +5,10 @@ | |||
| 5 | use cortex_m_rt::entry; | 5 | use cortex_m_rt::entry; |
| 6 | use defmt::*; | 6 | use defmt::*; |
| 7 | use embassy::executor::{Executor, Spawner}; | 7 | use embassy::executor::{Executor, Spawner}; |
| 8 | use embassy::io::AsyncWriteExt; | ||
| 9 | use embassy::time::{Duration, Timer}; | 8 | use embassy::time::{Duration, Timer}; |
| 10 | use embassy::util::Forever; | 9 | use embassy::util::Forever; |
| 11 | use embassy_net::{ | 10 | use embassy_net::tcp::TcpSocket; |
| 12 | Config as NetConfig, Ipv4Address, Ipv4Cidr, StackResources, StaticConfigurator, TcpSocket, | 11 | use embassy_net::{Config as NetConfig, Ipv4Address, Ipv4Cidr, StackResources, StaticConfigurator}; |
| 13 | }; | ||
| 14 | use embassy_stm32::eth::generic_smi::GenericSMI; | 12 | use embassy_stm32::eth::generic_smi::GenericSMI; |
| 15 | use embassy_stm32::eth::{Ethernet, State}; | 13 | use embassy_stm32::eth::{Ethernet, State}; |
| 16 | use embassy_stm32::interrupt; | 14 | use embassy_stm32::interrupt; |
| @@ -19,6 +17,7 @@ use embassy_stm32::peripherals::RNG; | |||
| 19 | use embassy_stm32::rng::Rng; | 17 | use embassy_stm32::rng::Rng; |
| 20 | use embassy_stm32::time::U32Ext; | 18 | use embassy_stm32::time::U32Ext; |
| 21 | use embassy_stm32::Config; | 19 | use embassy_stm32::Config; |
| 20 | use embedded_io::asynch::Write; | ||
| 22 | use heapless::Vec; | 21 | use heapless::Vec; |
| 23 | 22 | ||
| 24 | use defmt_rtt as _; // global logger | 23 | use defmt_rtt as _; // global logger |
diff --git a/examples/stm32h7/Cargo.toml b/examples/stm32h7/Cargo.toml index 419bbec31..ff70e6db6 100644 --- a/examples/stm32h7/Cargo.toml +++ b/examples/stm32h7/Cargo.toml | |||
| @@ -5,12 +5,11 @@ name = "embassy-stm32h7-examples" | |||
| 5 | version = "0.1.0" | 5 | version = "0.1.0" |
| 6 | resolver = "2" | 6 | resolver = "2" |
| 7 | 7 | ||
| 8 | [features] | ||
| 9 | |||
| 10 | [dependencies] | 8 | [dependencies] |
| 11 | embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt", "defmt-timestamp-uptime", "unstable-traits"] } | 9 | embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt", "defmt-timestamp-uptime", "unstable-traits"] } |
| 12 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32h743bi", "net", "time-driver-any", "exti", "unstable-pac", "unstable-traits"] } | 10 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32h743bi", "net", "time-driver-any", "exti", "unstable-pac", "unstable-traits"] } |
| 13 | embassy-net = { path = "../../embassy-net", features = ["defmt", "tcp", "medium-ethernet", "pool-16"] } | 11 | embassy-net = { path = "../../embassy-net", features = ["defmt", "tcp", "medium-ethernet", "pool-16"] } |
| 12 | embedded-io = { version = "0.2.0", features = ["async"] } | ||
| 14 | 13 | ||
| 15 | defmt = "0.3" | 14 | defmt = "0.3" |
| 16 | defmt-rtt = "0.3" | 15 | defmt-rtt = "0.3" |
diff --git a/examples/stm32h7/src/bin/eth.rs b/examples/stm32h7/src/bin/eth.rs index 9a2e7a33d..8ece29403 100644 --- a/examples/stm32h7/src/bin/eth.rs +++ b/examples/stm32h7/src/bin/eth.rs | |||
| @@ -8,12 +8,10 @@ use panic_probe as _; | |||
| 8 | use cortex_m_rt::entry; | 8 | use cortex_m_rt::entry; |
| 9 | use defmt::*; | 9 | use defmt::*; |
| 10 | use embassy::executor::{Executor, Spawner}; | 10 | use embassy::executor::{Executor, Spawner}; |
| 11 | use embassy::io::AsyncWriteExt; | ||
| 12 | use embassy::time::{Duration, Timer}; | 11 | use embassy::time::{Duration, Timer}; |
| 13 | use embassy::util::Forever; | 12 | use embassy::util::Forever; |
| 14 | use embassy_net::{ | 13 | use embassy_net::tcp::TcpSocket; |
| 15 | Config as NetConfig, Ipv4Address, Ipv4Cidr, StackResources, StaticConfigurator, TcpSocket, | 14 | use embassy_net::{Config as NetConfig, Ipv4Address, Ipv4Cidr, StackResources, StaticConfigurator}; |
| 16 | }; | ||
| 17 | use embassy_stm32::eth::generic_smi::GenericSMI; | 15 | use embassy_stm32::eth::generic_smi::GenericSMI; |
| 18 | use embassy_stm32::eth::{Ethernet, State}; | 16 | use embassy_stm32::eth::{Ethernet, State}; |
| 19 | use embassy_stm32::interrupt; | 17 | use embassy_stm32::interrupt; |
| @@ -22,6 +20,7 @@ use embassy_stm32::peripherals::RNG; | |||
| 22 | use embassy_stm32::rng::Rng; | 20 | use embassy_stm32::rng::Rng; |
| 23 | use embassy_stm32::time::U32Ext; | 21 | use embassy_stm32::time::U32Ext; |
| 24 | use embassy_stm32::Config; | 22 | use embassy_stm32::Config; |
| 23 | use embedded_io::asynch::Write; | ||
| 25 | use heapless::Vec; | 24 | use heapless::Vec; |
| 26 | 25 | ||
| 27 | #[embassy::task] | 26 | #[embassy::task] |
diff --git a/examples/stm32l0/.cargo/config.toml b/examples/stm32l0/.cargo/config.toml index 840faa62e..ec0b931f2 100644 --- a/examples/stm32l0/.cargo/config.toml +++ b/examples/stm32l0/.cargo/config.toml | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | [target.'cfg(all(target_arch = "arm", target_os = "none"))'] | 1 | [target.'cfg(all(target_arch = "arm", target_os = "none"))'] |
| 2 | # replace your chip as listed in `probe-run --list-chips` | 2 | # replace your chip as listed in `probe-run --list-chips` |
| 3 | runner = "probe-run --chip STM32L072CZTx" | 3 | runner = "probe-run --chip STM32L053R8Tx" |
| 4 | 4 | ||
| 5 | [build] | 5 | [build] |
| 6 | target = "thumbv6m-none-eabi" | 6 | target = "thumbv6m-none-eabi" |
diff --git a/examples/stm32l0/Cargo.toml b/examples/stm32l0/Cargo.toml index 1cdb2f374..d6848c27a 100644 --- a/examples/stm32l0/Cargo.toml +++ b/examples/stm32l0/Cargo.toml | |||
| @@ -7,12 +7,11 @@ resolver = "2" | |||
| 7 | 7 | ||
| 8 | [features] | 8 | [features] |
| 9 | default = ["nightly"] | 9 | default = ["nightly"] |
| 10 | nightly = ["embassy-stm32/nightly", "embassy-lora", "lorawan-device", "lorawan"] | 10 | nightly = ["embassy-stm32/nightly", "embassy-lora", "lorawan-device", "lorawan", "embedded-io/async"] |
| 11 | 11 | ||
| 12 | [dependencies] | 12 | [dependencies] |
| 13 | embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt", "defmt-timestamp-uptime"] } | 13 | embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt", "defmt-timestamp-uptime"] } |
| 14 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "stm32l072cz", "time-driver-any", "exti", "unstable-traits", "memory-x"] } | 14 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "stm32l072cz", "time-driver-any", "exti", "unstable-traits", "memory-x"] } |
| 15 | |||
| 16 | embassy-lora = { version = "0.1.0", path = "../../embassy-lora", features = ["sx127x", "time", "defmt"], optional = true} | 15 | embassy-lora = { version = "0.1.0", path = "../../embassy-lora", features = ["sx127x", "time", "defmt"], optional = true} |
| 17 | 16 | ||
| 18 | lorawan-device = { version = "0.7.1", default-features = false, features = ["async"], optional = true } | 17 | lorawan-device = { version = "0.7.1", default-features = false, features = ["async"], optional = true } |
| @@ -22,6 +21,7 @@ defmt = "0.3" | |||
| 22 | defmt-rtt = "0.3" | 21 | defmt-rtt = "0.3" |
| 23 | 22 | ||
| 24 | embedded-storage = "0.3.0" | 23 | embedded-storage = "0.3.0" |
| 24 | embedded-io = "0.2.0" | ||
| 25 | 25 | ||
| 26 | cortex-m = "0.7.3" | 26 | cortex-m = "0.7.3" |
| 27 | cortex-m-rt = "0.7.0" | 27 | cortex-m-rt = "0.7.0" |
diff --git a/examples/stm32l0/src/bin/usart_irq.rs b/examples/stm32l0/src/bin/usart_irq.rs index abb27fa4f..4413a2945 100644 --- a/examples/stm32l0/src/bin/usart_irq.rs +++ b/examples/stm32l0/src/bin/usart_irq.rs | |||
| @@ -2,13 +2,14 @@ | |||
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt_rtt as _; // global logger | 5 | use defmt_rtt as _; |
| 6 | use embedded_io::asynch::{Read, Write}; | ||
| 7 | // global logger | ||
| 6 | use panic_probe as _; | 8 | use panic_probe as _; |
| 7 | 9 | ||
| 8 | use defmt::*; | 10 | use defmt::*; |
| 9 | 11 | ||
| 10 | use embassy::executor::Spawner; | 12 | use embassy::executor::Spawner; |
| 11 | use embassy::io::{AsyncBufReadExt, AsyncWriteExt}; | ||
| 12 | use embassy_stm32::dma::NoDma; | 13 | use embassy_stm32::dma::NoDma; |
| 13 | use embassy_stm32::interrupt; | 14 | use embassy_stm32::interrupt; |
| 14 | use embassy_stm32::usart::{BufferedUart, Config, State, Uart}; | 15 | use embassy_stm32::usart::{BufferedUart, Config, State, Uart}; |
| @@ -16,19 +17,21 @@ use embassy_stm32::Peripherals; | |||
| 16 | 17 | ||
| 17 | #[embassy::main] | 18 | #[embassy::main] |
| 18 | async fn main(_spawner: Spawner, p: Peripherals) { | 19 | async fn main(_spawner: Spawner, p: Peripherals) { |
| 20 | info!("Hi!"); | ||
| 21 | |||
| 19 | static mut TX_BUFFER: [u8; 8] = [0; 8]; | 22 | static mut TX_BUFFER: [u8; 8] = [0; 8]; |
| 20 | static mut RX_BUFFER: [u8; 256] = [0; 256]; | 23 | static mut RX_BUFFER: [u8; 256] = [0; 256]; |
| 21 | 24 | ||
| 22 | let mut config = Config::default(); | 25 | let mut config = Config::default(); |
| 23 | config.baudrate = 9600; | 26 | config.baudrate = 9600; |
| 24 | 27 | ||
| 25 | let usart = Uart::new(p.USART1, p.PA10, p.PA9, NoDma, NoDma, config); | 28 | let usart = Uart::new(p.USART2, p.PA3, p.PA2, NoDma, NoDma, config); |
| 26 | let mut state = State::new(); | 29 | let mut state = State::new(); |
| 27 | let mut usart = unsafe { | 30 | let mut usart = unsafe { |
| 28 | BufferedUart::new( | 31 | BufferedUart::new( |
| 29 | &mut state, | 32 | &mut state, |
| 30 | usart, | 33 | usart, |
| 31 | interrupt::take!(USART1), | 34 | interrupt::take!(USART2), |
| 32 | &mut TX_BUFFER, | 35 | &mut TX_BUFFER, |
| 33 | &mut RX_BUFFER, | 36 | &mut RX_BUFFER, |
| 34 | ) | 37 | ) |
