aboutsummaryrefslogtreecommitdiff
path: root/examples/stm32h7/src
diff options
context:
space:
mode:
authorQuentin Smith <[email protected]>2022-08-23 23:01:51 -0400
committerQuentin Smith <[email protected]>2022-08-23 23:01:51 -0400
commit2900ab79e7afa0ca3e0d800f8a91c3253a333db1 (patch)
treea5066235f8b1ac6c2520105db2e5c48630bc006d /examples/stm32h7/src
parent14eae9ca06f63a69ccc29d5fd9e1dec3848a3e98 (diff)
parent529535194d4b5d58b31fd6a7541176105e3c63f7 (diff)
Merge remote-tracking branch 'origin/master' into nrf-pdm
Diffstat (limited to 'examples/stm32h7/src')
-rw-r--r--examples/stm32h7/src/bin/eth.rs14
-rw-r--r--examples/stm32h7/src/bin/eth_client.rs14
-rw-r--r--examples/stm32h7/src/bin/signal.rs2
-rw-r--r--examples/stm32h7/src/bin/spi.rs6
-rw-r--r--examples/stm32h7/src/bin/spi_dma.rs6
-rw-r--r--examples/stm32h7/src/bin/usart.rs6
-rw-r--r--examples/stm32h7/src/bin/usart_dma.rs6
-rw-r--r--examples/stm32h7/src/bin/usart_split.rs4
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;
13use embassy_stm32::time::mhz; 13use embassy_stm32::time::mhz;
14use embassy_stm32::{interrupt, Config}; 14use embassy_stm32::{interrupt, Config};
15use embassy_time::{Duration, Timer}; 15use embassy_time::{Duration, Timer};
16use embassy_util::Forever;
17use embedded_io::asynch::Write; 16use embedded_io::asynch::Write;
18use rand_core::RngCore; 17use rand_core::RngCore;
18use static_cell::StaticCell;
19use {defmt_rtt as _, panic_probe as _}; 19use {defmt_rtt as _, panic_probe as _};
20 20
21macro_rules! forever { 21macro_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;
13use embassy_stm32::time::mhz; 13use embassy_stm32::time::mhz;
14use embassy_stm32::{interrupt, Config}; 14use embassy_stm32::{interrupt, Config};
15use embassy_time::{Duration, Timer}; 15use embassy_time::{Duration, Timer};
16use embassy_util::Forever;
17use embedded_io::asynch::Write; 16use embedded_io::asynch::Write;
18use embedded_nal_async::{Ipv4Addr, SocketAddr, SocketAddrV4, TcpConnect}; 17use embedded_nal_async::{Ipv4Addr, SocketAddr, SocketAddrV4, TcpConnect};
19use rand_core::RngCore; 18use rand_core::RngCore;
19use static_cell::StaticCell;
20use {defmt_rtt as _, panic_probe as _}; 20use {defmt_rtt as _, panic_probe as _};
21 21
22macro_rules! forever { 22macro_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
5use defmt::{info, unwrap}; 5use defmt::{info, unwrap};
6use embassy_executor::Spawner; 6use embassy_executor::Spawner;
7use embassy_sync::signal::Signal;
7use embassy_time::{Duration, Timer}; 8use embassy_time::{Duration, Timer};
8use embassy_util::channel::signal::Signal;
9use {defmt_rtt as _, panic_probe as _}; 9use {defmt_rtt as _, panic_probe as _};
10 10
11static SIGNAL: Signal<u32> = Signal::new(); 11static 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;
12use embassy_stm32::peripherals::SPI3; 12use embassy_stm32::peripherals::SPI3;
13use embassy_stm32::time::mhz; 13use embassy_stm32::time::mhz;
14use embassy_stm32::{spi, Config}; 14use embassy_stm32::{spi, Config};
15use embassy_util::Forever;
16use heapless::String; 15use heapless::String;
16use static_cell::StaticCell;
17use {defmt_rtt as _, panic_probe as _}; 17use {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
34static EXECUTOR: Forever<Executor> = Forever::new(); 34static EXECUTOR: StaticCell<Executor> = StaticCell::new();
35 35
36#[entry] 36#[entry]
37fn main() -> ! { 37fn 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;
11use embassy_stm32::peripherals::{DMA1_CH3, DMA1_CH4, SPI3}; 11use embassy_stm32::peripherals::{DMA1_CH3, DMA1_CH4, SPI3};
12use embassy_stm32::time::mhz; 12use embassy_stm32::time::mhz;
13use embassy_stm32::{spi, Config}; 13use embassy_stm32::{spi, Config};
14use embassy_util::Forever;
15use heapless::String; 14use heapless::String;
15use static_cell::StaticCell;
16use {defmt_rtt as _, panic_probe as _}; 16use {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
30static EXECUTOR: Forever<Executor> = Forever::new(); 30static EXECUTOR: StaticCell<Executor> = StaticCell::new();
31 31
32#[entry] 32#[entry]
33fn main() -> ! { 33fn 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::*;
7use embassy_executor::Executor; 7use embassy_executor::Executor;
8use embassy_stm32::dma::NoDma; 8use embassy_stm32::dma::NoDma;
9use embassy_stm32::usart::{Config, Uart}; 9use embassy_stm32::usart::{Config, Uart};
10use embassy_util::Forever; 10use static_cell::StaticCell;
11use {defmt_rtt as _, panic_probe as _}; 11use {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
30static EXECUTOR: Forever<Executor> = Forever::new(); 30static EXECUTOR: StaticCell<Executor> = StaticCell::new();
31 31
32#[entry] 32#[entry]
33fn main() -> ! { 33fn 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::*;
9use embassy_executor::Executor; 9use embassy_executor::Executor;
10use embassy_stm32::dma::NoDma; 10use embassy_stm32::dma::NoDma;
11use embassy_stm32::usart::{Config, Uart}; 11use embassy_stm32::usart::{Config, Uart};
12use embassy_util::Forever;
13use heapless::String; 12use heapless::String;
13use static_cell::StaticCell;
14use {defmt_rtt as _, panic_probe as _}; 14use {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
33static EXECUTOR: Forever<Executor> = Forever::new(); 33static EXECUTOR: StaticCell<Executor> = StaticCell::new();
34 34
35#[entry] 35#[entry]
36fn main() -> ! { 36fn 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;
7use embassy_stm32::dma::NoDma; 7use embassy_stm32::dma::NoDma;
8use embassy_stm32::peripherals::{DMA1_CH1, UART7}; 8use embassy_stm32::peripherals::{DMA1_CH1, UART7};
9use embassy_stm32::usart::{Config, Uart, UartRx}; 9use embassy_stm32::usart::{Config, Uart, UartRx};
10use embassy_util::blocking_mutex::raw::ThreadModeRawMutex; 10use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex;
11use embassy_util::channel::mpmc::Channel; 11use embassy_sync::channel::Channel;
12use {defmt_rtt as _, panic_probe as _}; 12use {defmt_rtt as _, panic_probe as _};
13 13
14#[embassy_executor::task] 14#[embassy_executor::task]