@@ -28,22 +28,12 @@ use esp_hal::{
2828 interrupt:: Priority ,
2929 peripherals:: Peripherals ,
3030 system:: SystemControl ,
31- timer:: { timg:: TimerGroup , ErasedTimer , OneShotTimer } ,
31+ timer:: { timg:: TimerGroup , ErasedTimer } ,
3232} ;
3333use esp_hal_embassy:: InterruptExecutor ;
3434use esp_println:: println;
3535use static_cell:: StaticCell ;
3636
37- // When you are okay with using a nightly compiler it's better to use https://docs.rs/static_cell/2.1.0/static_cell/macro.make_static.html
38- macro_rules! mk_static {
39- ( $t: ty, $val: expr) => { {
40- static STATIC_CELL : static_cell:: StaticCell <$t> = static_cell:: StaticCell :: new( ) ;
41- #[ deny( unused_attributes) ]
42- let x = STATIC_CELL . uninit( ) . write( ( $val) ) ;
43- x
44- } } ;
45- }
46-
4737/// Periodically print something.
4838#[ embassy_executor:: task]
4939async fn high_prio ( ) {
@@ -89,23 +79,19 @@ async fn main(low_prio_spawner: Spawner) {
8979
9080 let timg0 = TimerGroup :: new ( peripherals. TIMG0 , & clocks) ;
9181 let timer0: ErasedTimer = timg0. timer0 . into ( ) ;
92- let timer0 = OneShotTimer :: new ( timer0) ;
9382
9483 cfg_if:: cfg_if! {
9584 if #[ cfg( feature = "esp32c2" ) ] {
9685 use esp_hal:: timer:: systimer:: { SystemTimer , Target } ;
9786 let systimer = SystemTimer :: new( peripherals. SYSTIMER ) . split:: <Target >( ) ;
98- let alarm0: ErasedTimer = systimer. alarm0. into( ) ;
99- let timer1 = OneShotTimer :: new( alarm0) ;
87+ let timer1: ErasedTimer = systimer. alarm0. into( ) ;
10088 } else {
10189 let timg1 = TimerGroup :: new( peripherals. TIMG1 , & clocks) ;
10290 let timer1: ErasedTimer = timg1. timer0. into( ) ;
103- let timer1 = OneShotTimer :: new( timer1) ;
10491 }
10592 }
10693
107- let timers = mk_static ! ( [ OneShotTimer <ErasedTimer >; 2 ] , [ timer0, timer1] ) ;
108- esp_hal_embassy:: init ( & clocks, timers) ;
94+ esp_hal_embassy:: init ( & clocks, [ timer0, timer1] ) ;
10995
11096 static EXECUTOR : StaticCell < InterruptExecutor < 2 > > = StaticCell :: new ( ) ;
11197 let executor = InterruptExecutor :: new ( system. software_interrupt_control . software_interrupt2 ) ;
0 commit comments