diff options
| author | Quentin Smith <[email protected]> | 2022-08-23 23:01:51 -0400 |
|---|---|---|
| committer | Quentin Smith <[email protected]> | 2022-08-23 23:01:51 -0400 |
| commit | 2900ab79e7afa0ca3e0d800f8a91c3253a333db1 (patch) | |
| tree | a5066235f8b1ac6c2520105db2e5c48630bc006d /examples/stm32h7/src | |
| parent | 14eae9ca06f63a69ccc29d5fd9e1dec3848a3e98 (diff) | |
| parent | 529535194d4b5d58b31fd6a7541176105e3c63f7 (diff) | |
Merge remote-tracking branch 'origin/master' into nrf-pdm
Diffstat (limited to 'examples/stm32h7/src')
| -rw-r--r-- | examples/stm32h7/src/bin/eth.rs | 14 | ||||
| -rw-r--r-- | examples/stm32h7/src/bin/eth_client.rs | 14 | ||||
| -rw-r--r-- | examples/stm32h7/src/bin/signal.rs | 2 | ||||
| -rw-r--r-- | examples/stm32h7/src/bin/spi.rs | 6 | ||||
| -rw-r--r-- | examples/stm32h7/src/bin/spi_dma.rs | 6 | ||||
| -rw-r--r-- | examples/stm32h7/src/bin/usart.rs | 6 | ||||
| -rw-r--r-- | examples/stm32h7/src/bin/usart_dma.rs | 6 | ||||
| -rw-r--r-- | examples/stm32h7/src/bin/usart_split.rs | 4 |
8 files changed, 29 insertions, 29 deletions
diff --git a/examples/stm32h7/src/bin/eth.rs b/examples/stm32h7/src/bin/eth.rs index 83210bcb5..4ccc0b5ef 100644 --- a/examples/stm32h7/src/bin/eth.rs +++ b/examples/stm32h7/src/bin/eth.rs | |||
| @@ -13,16 +13,16 @@ use embassy_stm32::rng::Rng; | |||
| 13 | use embassy_stm32::time::mhz; | 13 | use embassy_stm32::time::mhz; |
| 14 | use embassy_stm32::{interrupt, Config}; | 14 | use embassy_stm32::{interrupt, Config}; |
| 15 | use embassy_time::{Duration, Timer}; | 15 | use embassy_time::{Duration, Timer}; |
| 16 | use embassy_util::Forever; | ||
| 17 | use embedded_io::asynch::Write; | 16 | use embedded_io::asynch::Write; |
| 18 | use rand_core::RngCore; | 17 | use rand_core::RngCore; |
| 18 | use static_cell::StaticCell; | ||
| 19 | use {defmt_rtt as _, panic_probe as _}; | 19 | use {defmt_rtt as _, panic_probe as _}; |
| 20 | 20 | ||
| 21 | macro_rules! forever { | 21 | macro_rules! singleton { |
| 22 | ($val:expr) => {{ | 22 | ($val:expr) => {{ |
| 23 | type T = impl Sized; | 23 | type T = impl Sized; |
| 24 | static FOREVER: Forever<T> = Forever::new(); | 24 | static STATIC_CELL: StaticCell<T> = StaticCell::new(); |
| 25 | FOREVER.put_with(move || $val) | 25 | STATIC_CELL.init_with(move || $val) |
| 26 | }}; | 26 | }}; |
| 27 | } | 27 | } |
| 28 | 28 | ||
| @@ -53,7 +53,7 @@ async fn main(spawner: Spawner) -> ! { | |||
| 53 | 53 | ||
| 54 | let device = unsafe { | 54 | let device = unsafe { |
| 55 | Ethernet::new( | 55 | Ethernet::new( |
| 56 | forever!(State::new()), | 56 | singleton!(State::new()), |
| 57 | p.ETH, | 57 | p.ETH, |
| 58 | eth_int, | 58 | eth_int, |
| 59 | p.PA1, | 59 | p.PA1, |
| @@ -79,10 +79,10 @@ async fn main(spawner: Spawner) -> ! { | |||
| 79 | //}); | 79 | //}); |
| 80 | 80 | ||
| 81 | // Init network stack | 81 | // Init network stack |
| 82 | let stack = &*forever!(Stack::new( | 82 | let stack = &*singleton!(Stack::new( |
| 83 | device, | 83 | device, |
| 84 | config, | 84 | config, |
| 85 | forever!(StackResources::<1, 2, 8>::new()), | 85 | singleton!(StackResources::<1, 2, 8>::new()), |
| 86 | seed | 86 | seed |
| 87 | )); | 87 | )); |
| 88 | 88 | ||
diff --git a/examples/stm32h7/src/bin/eth_client.rs b/examples/stm32h7/src/bin/eth_client.rs index 99946f504..64fd84141 100644 --- a/examples/stm32h7/src/bin/eth_client.rs +++ b/examples/stm32h7/src/bin/eth_client.rs | |||
| @@ -13,17 +13,17 @@ use embassy_stm32::rng::Rng; | |||
| 13 | use embassy_stm32::time::mhz; | 13 | use embassy_stm32::time::mhz; |
| 14 | use embassy_stm32::{interrupt, Config}; | 14 | use embassy_stm32::{interrupt, Config}; |
| 15 | use embassy_time::{Duration, Timer}; | 15 | use embassy_time::{Duration, Timer}; |
| 16 | use embassy_util::Forever; | ||
| 17 | use embedded_io::asynch::Write; | 16 | use embedded_io::asynch::Write; |
| 18 | use embedded_nal_async::{Ipv4Addr, SocketAddr, SocketAddrV4, TcpConnect}; | 17 | use embedded_nal_async::{Ipv4Addr, SocketAddr, SocketAddrV4, TcpConnect}; |
| 19 | use rand_core::RngCore; | 18 | use rand_core::RngCore; |
| 19 | use static_cell::StaticCell; | ||
| 20 | use {defmt_rtt as _, panic_probe as _}; | 20 | use {defmt_rtt as _, panic_probe as _}; |
| 21 | 21 | ||
| 22 | macro_rules! forever { | 22 | macro_rules! singleton { |
| 23 | ($val:expr) => {{ | 23 | ($val:expr) => {{ |
| 24 | type T = impl Sized; | 24 | type T = impl Sized; |
| 25 | static FOREVER: Forever<T> = Forever::new(); | 25 | static STATIC_CELL: StaticCell<T> = StaticCell::new(); |
| 26 | FOREVER.put_with(move || $val) | 26 | STATIC_CELL.init_with(move || $val) |
| 27 | }}; | 27 | }}; |
| 28 | } | 28 | } |
| 29 | 29 | ||
| @@ -54,7 +54,7 @@ async fn main(spawner: Spawner) -> ! { | |||
| 54 | 54 | ||
| 55 | let device = unsafe { | 55 | let device = unsafe { |
| 56 | Ethernet::new( | 56 | Ethernet::new( |
| 57 | forever!(State::new()), | 57 | singleton!(State::new()), |
| 58 | p.ETH, | 58 | p.ETH, |
| 59 | eth_int, | 59 | eth_int, |
| 60 | p.PA1, | 60 | p.PA1, |
| @@ -80,10 +80,10 @@ async fn main(spawner: Spawner) -> ! { | |||
| 80 | //}); | 80 | //}); |
| 81 | 81 | ||
| 82 | // Init network stack | 82 | // Init network stack |
| 83 | let stack = &*forever!(Stack::new( | 83 | let stack = &*singleton!(Stack::new( |
| 84 | device, | 84 | device, |
| 85 | config, | 85 | config, |
| 86 | forever!(StackResources::<1, 2, 8>::new()), | 86 | singleton!(StackResources::<1, 2, 8>::new()), |
| 87 | seed | 87 | seed |
| 88 | )); | 88 | )); |
| 89 | 89 | ||
diff --git a/examples/stm32h7/src/bin/signal.rs b/examples/stm32h7/src/bin/signal.rs index be2ac268e..cc3e4e3ca 100644 --- a/examples/stm32h7/src/bin/signal.rs +++ b/examples/stm32h7/src/bin/signal.rs | |||
| @@ -4,8 +4,8 @@ | |||
| 4 | 4 | ||
| 5 | use defmt::{info, unwrap}; | 5 | use defmt::{info, unwrap}; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_sync::signal::Signal; | ||
| 7 | use embassy_time::{Duration, Timer}; | 8 | use embassy_time::{Duration, Timer}; |
| 8 | use embassy_util::channel::signal::Signal; | ||
| 9 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 10 | ||
| 11 | static SIGNAL: Signal<u32> = Signal::new(); | 11 | static SIGNAL: Signal<u32> = Signal::new(); |
diff --git a/examples/stm32h7/src/bin/spi.rs b/examples/stm32h7/src/bin/spi.rs index c28f937a8..1f407f002 100644 --- a/examples/stm32h7/src/bin/spi.rs +++ b/examples/stm32h7/src/bin/spi.rs | |||
| @@ -12,8 +12,8 @@ use embassy_stm32::dma::NoDma; | |||
| 12 | use embassy_stm32::peripherals::SPI3; | 12 | use embassy_stm32::peripherals::SPI3; |
| 13 | use embassy_stm32::time::mhz; | 13 | use embassy_stm32::time::mhz; |
| 14 | use embassy_stm32::{spi, Config}; | 14 | use embassy_stm32::{spi, Config}; |
| 15 | use embassy_util::Forever; | ||
| 16 | use heapless::String; | 15 | use heapless::String; |
| 16 | use static_cell::StaticCell; | ||
| 17 | use {defmt_rtt as _, panic_probe as _}; | 17 | use {defmt_rtt as _, panic_probe as _}; |
| 18 | 18 | ||
| 19 | #[embassy_executor::task] | 19 | #[embassy_executor::task] |
| @@ -31,7 +31,7 @@ async fn main_task(mut spi: spi::Spi<'static, SPI3, NoDma, NoDma>) { | |||
| 31 | } | 31 | } |
| 32 | } | 32 | } |
| 33 | 33 | ||
| 34 | static EXECUTOR: Forever<Executor> = Forever::new(); | 34 | static EXECUTOR: StaticCell<Executor> = StaticCell::new(); |
| 35 | 35 | ||
| 36 | #[entry] | 36 | #[entry] |
| 37 | fn main() -> ! { | 37 | fn main() -> ! { |
| @@ -54,7 +54,7 @@ fn main() -> ! { | |||
| 54 | spi::Config::default(), | 54 | spi::Config::default(), |
| 55 | ); | 55 | ); |
| 56 | 56 | ||
| 57 | let executor = EXECUTOR.put(Executor::new()); | 57 | let executor = EXECUTOR.init(Executor::new()); |
| 58 | 58 | ||
| 59 | executor.run(|spawner| { | 59 | executor.run(|spawner| { |
| 60 | unwrap!(spawner.spawn(main_task(spi))); | 60 | unwrap!(spawner.spawn(main_task(spi))); |
diff --git a/examples/stm32h7/src/bin/spi_dma.rs b/examples/stm32h7/src/bin/spi_dma.rs index 6c78c194f..53004fc9b 100644 --- a/examples/stm32h7/src/bin/spi_dma.rs +++ b/examples/stm32h7/src/bin/spi_dma.rs | |||
| @@ -11,8 +11,8 @@ use embassy_executor::Executor; | |||
| 11 | use embassy_stm32::peripherals::{DMA1_CH3, DMA1_CH4, SPI3}; | 11 | use embassy_stm32::peripherals::{DMA1_CH3, DMA1_CH4, SPI3}; |
| 12 | use embassy_stm32::time::mhz; | 12 | use embassy_stm32::time::mhz; |
| 13 | use embassy_stm32::{spi, Config}; | 13 | use embassy_stm32::{spi, Config}; |
| 14 | use embassy_util::Forever; | ||
| 15 | use heapless::String; | 14 | use heapless::String; |
| 15 | use static_cell::StaticCell; | ||
| 16 | use {defmt_rtt as _, panic_probe as _}; | 16 | use {defmt_rtt as _, panic_probe as _}; |
| 17 | 17 | ||
| 18 | #[embassy_executor::task] | 18 | #[embassy_executor::task] |
| @@ -27,7 +27,7 @@ async fn main_task(mut spi: spi::Spi<'static, SPI3, DMA1_CH3, DMA1_CH4>) { | |||
| 27 | } | 27 | } |
| 28 | } | 28 | } |
| 29 | 29 | ||
| 30 | static EXECUTOR: Forever<Executor> = Forever::new(); | 30 | static EXECUTOR: StaticCell<Executor> = StaticCell::new(); |
| 31 | 31 | ||
| 32 | #[entry] | 32 | #[entry] |
| 33 | fn main() -> ! { | 33 | fn main() -> ! { |
| @@ -50,7 +50,7 @@ fn main() -> ! { | |||
| 50 | spi::Config::default(), | 50 | spi::Config::default(), |
| 51 | ); | 51 | ); |
| 52 | 52 | ||
| 53 | let executor = EXECUTOR.put(Executor::new()); | 53 | let executor = EXECUTOR.init(Executor::new()); |
| 54 | 54 | ||
| 55 | executor.run(|spawner| { | 55 | executor.run(|spawner| { |
| 56 | unwrap!(spawner.spawn(main_task(spi))); | 56 | unwrap!(spawner.spawn(main_task(spi))); |
diff --git a/examples/stm32h7/src/bin/usart.rs b/examples/stm32h7/src/bin/usart.rs index 1384d54c6..87c2b1253 100644 --- a/examples/stm32h7/src/bin/usart.rs +++ b/examples/stm32h7/src/bin/usart.rs | |||
| @@ -7,7 +7,7 @@ use defmt::*; | |||
| 7 | use embassy_executor::Executor; | 7 | use embassy_executor::Executor; |
| 8 | use embassy_stm32::dma::NoDma; | 8 | use embassy_stm32::dma::NoDma; |
| 9 | use embassy_stm32::usart::{Config, Uart}; | 9 | use embassy_stm32::usart::{Config, Uart}; |
| 10 | use embassy_util::Forever; | 10 | use static_cell::StaticCell; |
| 11 | use {defmt_rtt as _, panic_probe as _}; | 11 | use {defmt_rtt as _, panic_probe as _}; |
| 12 | 12 | ||
| 13 | #[embassy_executor::task] | 13 | #[embassy_executor::task] |
| @@ -27,13 +27,13 @@ async fn main_task() { | |||
| 27 | } | 27 | } |
| 28 | } | 28 | } |
| 29 | 29 | ||
| 30 | static EXECUTOR: Forever<Executor> = Forever::new(); | 30 | static EXECUTOR: StaticCell<Executor> = StaticCell::new(); |
| 31 | 31 | ||
| 32 | #[entry] | 32 | #[entry] |
| 33 | fn main() -> ! { | 33 | fn main() -> ! { |
| 34 | info!("Hello World!"); | 34 | info!("Hello World!"); |
| 35 | 35 | ||
| 36 | let executor = EXECUTOR.put(Executor::new()); | 36 | let executor = EXECUTOR.init(Executor::new()); |
| 37 | 37 | ||
| 38 | executor.run(|spawner| { | 38 | executor.run(|spawner| { |
| 39 | unwrap!(spawner.spawn(main_task())); | 39 | unwrap!(spawner.spawn(main_task())); |
diff --git a/examples/stm32h7/src/bin/usart_dma.rs b/examples/stm32h7/src/bin/usart_dma.rs index f8d58bb84..3adffcbeb 100644 --- a/examples/stm32h7/src/bin/usart_dma.rs +++ b/examples/stm32h7/src/bin/usart_dma.rs | |||
| @@ -9,8 +9,8 @@ use defmt::*; | |||
| 9 | use embassy_executor::Executor; | 9 | use embassy_executor::Executor; |
| 10 | use embassy_stm32::dma::NoDma; | 10 | use embassy_stm32::dma::NoDma; |
| 11 | use embassy_stm32::usart::{Config, Uart}; | 11 | use embassy_stm32::usart::{Config, Uart}; |
| 12 | use embassy_util::Forever; | ||
| 13 | use heapless::String; | 12 | use heapless::String; |
| 13 | use static_cell::StaticCell; | ||
| 14 | use {defmt_rtt as _, panic_probe as _}; | 14 | use {defmt_rtt as _, panic_probe as _}; |
| 15 | 15 | ||
| 16 | #[embassy_executor::task] | 16 | #[embassy_executor::task] |
| @@ -30,13 +30,13 @@ async fn main_task() { | |||
| 30 | } | 30 | } |
| 31 | } | 31 | } |
| 32 | 32 | ||
| 33 | static EXECUTOR: Forever<Executor> = Forever::new(); | 33 | static EXECUTOR: StaticCell<Executor> = StaticCell::new(); |
| 34 | 34 | ||
| 35 | #[entry] | 35 | #[entry] |
| 36 | fn main() -> ! { | 36 | fn main() -> ! { |
| 37 | info!("Hello World!"); | 37 | info!("Hello World!"); |
| 38 | 38 | ||
| 39 | let executor = EXECUTOR.put(Executor::new()); | 39 | let executor = EXECUTOR.init(Executor::new()); |
| 40 | 40 | ||
| 41 | executor.run(|spawner| { | 41 | executor.run(|spawner| { |
| 42 | unwrap!(spawner.spawn(main_task())); | 42 | unwrap!(spawner.spawn(main_task())); |
diff --git a/examples/stm32h7/src/bin/usart_split.rs b/examples/stm32h7/src/bin/usart_split.rs index 64080ec45..df2b600f8 100644 --- a/examples/stm32h7/src/bin/usart_split.rs +++ b/examples/stm32h7/src/bin/usart_split.rs | |||
| @@ -7,8 +7,8 @@ use embassy_executor::Spawner; | |||
| 7 | use embassy_stm32::dma::NoDma; | 7 | use embassy_stm32::dma::NoDma; |
| 8 | use embassy_stm32::peripherals::{DMA1_CH1, UART7}; | 8 | use embassy_stm32::peripherals::{DMA1_CH1, UART7}; |
| 9 | use embassy_stm32::usart::{Config, Uart, UartRx}; | 9 | use embassy_stm32::usart::{Config, Uart, UartRx}; |
| 10 | use embassy_util::blocking_mutex::raw::ThreadModeRawMutex; | 10 | use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex; |
| 11 | use embassy_util::channel::mpmc::Channel; | 11 | use embassy_sync::channel::Channel; |
| 12 | use {defmt_rtt as _, panic_probe as _}; | 12 | use {defmt_rtt as _, panic_probe as _}; |
| 13 | 13 | ||
| 14 | #[embassy_executor::task] | 14 | #[embassy_executor::task] |
