aboutsummaryrefslogtreecommitdiff
path: root/examples/stm32f7
diff options
context:
space:
mode:
authorUlf Lilleengen <[email protected]>2023-12-21 08:50:54 +0100
committerUlf Lilleengen <[email protected]>2023-12-21 10:29:57 +0100
commit0acf7b09c3bc9176d00479d601356d8df2537a9b (patch)
tree7a04543c661b38b6aba8893c9150ef8090199ee5 /examples/stm32f7
parentd832d45c0ba5f2624a5f5c1e549e2d7fe8bd0e01 (diff)
chore: replace make_static! macro usage with non-macro version
Diffstat (limited to 'examples/stm32f7')
-rw-r--r--examples/stm32f7/src/bin/can.rs7
-rw-r--r--examples/stm32f7/src/bin/eth.rs13
2 files changed, 13 insertions, 7 deletions
diff --git a/examples/stm32f7/src/bin/can.rs b/examples/stm32f7/src/bin/can.rs
index 78b21ceaa..06cd1ac7e 100644
--- a/examples/stm32f7/src/bin/can.rs
+++ b/examples/stm32f7/src/bin/can.rs
@@ -12,6 +12,7 @@ use embassy_stm32::can::{
12}; 12};
13use embassy_stm32::gpio::{Input, Pull}; 13use embassy_stm32::gpio::{Input, Pull};
14use embassy_stm32::peripherals::CAN3; 14use embassy_stm32::peripherals::CAN3;
15use static_cell::StaticCell;
15use {defmt_rtt as _, panic_probe as _}; 16use {defmt_rtt as _, panic_probe as _};
16 17
17bind_interrupts!(struct Irqs { 18bind_interrupts!(struct Irqs {
@@ -43,7 +44,8 @@ async fn main(spawner: Spawner) {
43 let rx_pin = Input::new(&mut p.PA15, Pull::Up); 44 let rx_pin = Input::new(&mut p.PA15, Pull::Up);
44 core::mem::forget(rx_pin); 45 core::mem::forget(rx_pin);
45 46
46 let can: &'static mut Can<'static, CAN3> = static_cell::make_static!(Can::new(p.CAN3, p.PA8, p.PA15, Irqs)); 47 static CAN: StaticCell<Can<'static, CAN3>> = StaticCell::new();
48 let can = CAN.init(Can::new(p.CAN3, p.PA8, p.PA15, Irqs));
47 can.as_mut() 49 can.as_mut()
48 .modify_filters() 50 .modify_filters()
49 .enable_bank(0, Fifo::Fifo0, Mask32::accept_all()); 51 .enable_bank(0, Fifo::Fifo0, Mask32::accept_all());
@@ -56,7 +58,8 @@ async fn main(spawner: Spawner) {
56 58
57 let (tx, mut rx) = can.split(); 59 let (tx, mut rx) = can.split();
58 60
59 let tx: &'static mut CanTx<'static, 'static, CAN3> = static_cell::make_static!(tx); 61 static CAN_TX: StaticCell<CanTx<'static, 'static, CAN3>> = StaticCell::new();
62 let tx = CAN_TX.init(tx);
60 spawner.spawn(send_can_message(tx)).unwrap(); 63 spawner.spawn(send_can_message(tx)).unwrap();
61 64
62 loop { 65 loop {
diff --git a/examples/stm32f7/src/bin/eth.rs b/examples/stm32f7/src/bin/eth.rs
index dd0069447..86c709852 100644
--- a/examples/stm32f7/src/bin/eth.rs
+++ b/examples/stm32f7/src/bin/eth.rs
@@ -15,7 +15,7 @@ use embassy_stm32::{bind_interrupts, eth, peripherals, rng, Config};
15use embassy_time::Timer; 15use embassy_time::Timer;
16use embedded_io_async::Write; 16use embedded_io_async::Write;
17use rand_core::RngCore; 17use rand_core::RngCore;
18use static_cell::make_static; 18use static_cell::StaticCell;
19use {defmt_rtt as _, panic_probe as _}; 19use {defmt_rtt as _, panic_probe as _};
20 20
21bind_interrupts!(struct Irqs { 21bind_interrupts!(struct Irqs {
@@ -64,8 +64,9 @@ async fn main(spawner: Spawner) -> ! {
64 64
65 let mac_addr = [0x00, 0x00, 0xDE, 0xAD, 0xBE, 0xEF]; 65 let mac_addr = [0x00, 0x00, 0xDE, 0xAD, 0xBE, 0xEF];
66 66
67 static PACKETS: StaticCell<PacketQueue<16, 16>> = StaticCell::new();
67 let device = Ethernet::new( 68 let device = Ethernet::new(
68 make_static!(PacketQueue::<16, 16>::new()), 69 PACKETS.init(PacketQueue::<16, 16>::new()),
69 p.ETH, 70 p.ETH,
70 Irqs, 71 Irqs,
71 p.PA1, 72 p.PA1,
@@ -89,11 +90,13 @@ async fn main(spawner: Spawner) -> ! {
89 //}); 90 //});
90 91
91 // Init network stack 92 // Init network stack
92 let stack = &*make_static!(Stack::new( 93 static STACK: StaticCell<Stack<Device>> = StaticCell::new();
94 static RESOURCES: StaticCell<StackResources<2>> = StaticCell::new();
95 let stack = &*STACK.init(Stack::new(
93 device, 96 device,
94 config, 97 config,
95 make_static!(StackResources::<2>::new()), 98 RESOURCES.init(StackResources::<2>::new()),
96 seed 99 seed,
97 )); 100 ));
98 101
99 // Launch network task 102 // Launch network task