@@ -23,6 +23,7 @@ extern crate alloc;
23
23
mod allocator;
24
24
mod board;
25
25
mod storage;
26
+ #[ cfg( feature = "debug" ) ]
26
27
mod systick;
27
28
28
29
use core:: cell:: RefCell ;
@@ -69,6 +70,7 @@ use wasefire_one_of::{at_most_one_of, exactly_one_of};
69
70
use wasefire_scheduler:: Scheduler ;
70
71
71
72
use crate :: board:: button:: { Button , Channels } ;
73
+ use crate :: board:: clock:: Clock ;
72
74
#[ cfg( feature = "gpio" ) ]
73
75
use crate :: board:: gpio:: Gpio ;
74
76
use crate :: board:: timer:: Timers ;
@@ -103,6 +105,7 @@ struct State {
103
105
ctap : Ctap < ' static , Usb > ,
104
106
#[ cfg( feature = "usb-serial" ) ]
105
107
serial : Serial < ' static , Usb > ,
108
+ clock : Clock ,
106
109
timers : Timers ,
107
110
#[ cfg( feature = "ble-adv" ) ]
108
111
ble : Ble ,
@@ -134,7 +137,9 @@ fn main() -> ! {
134
137
static mut USB_BUS : MaybeUninit < UsbBusAllocator < Usb > > = MaybeUninit :: uninit ( ) ;
135
138
136
139
allocator:: init ( ) ;
140
+ #[ cfg( feature = "debug" ) ]
137
141
let c = nrf52840_hal:: pac:: CorePeripherals :: take ( ) . unwrap ( ) ;
142
+ #[ cfg( feature = "debug" ) ]
138
143
systick:: init ( c. SYST ) ;
139
144
log:: debug!( "Runner starts." ) ;
140
145
let p = nrf52840_hal:: pac:: Peripherals :: take ( ) . unwrap ( ) ;
@@ -183,7 +188,8 @@ fn main() -> ! {
183
188
Gpio :: new ( port0. p0_30 . degrade ( ) , 0 , 30 ) ,
184
189
Gpio :: new ( port0. p0_31 . degrade ( ) , 0 , 31 ) ,
185
190
] ;
186
- let timers = Timers :: new ( p. TIMER1 , p. TIMER2 , p. TIMER3 , p. TIMER4 ) ;
191
+ let clock = Clock :: new ( p. TIMER1 ) ;
192
+ let timers = Timers :: new ( p. TIMER2 , p. TIMER3 , p. TIMER4 ) ;
187
193
let gpiote = Gpiote :: new ( p. GPIOTE ) ;
188
194
#[ cfg_attr( not( feature = "fpc2534" ) , allow( unused_mut) ) ]
189
195
let mut channels = Channels :: default ( ) ;
@@ -255,6 +261,7 @@ fn main() -> ! {
255
261
ctap,
256
262
#[ cfg( feature = "usb-serial" ) ]
257
263
serial,
264
+ clock,
258
265
timers,
259
266
#[ cfg( feature = "ble-adv" ) ]
260
267
ble,
@@ -300,10 +307,10 @@ interrupts! {
300
307
RADIO = radio( ) ,
301
308
#[ cfg( feature = "ble-adv" ) ]
302
309
TIMER0 = radio_timer( ) ,
303
- TIMER1 = timer ( 0 ) ,
304
- TIMER2 = timer( 1 ) ,
305
- TIMER3 = timer( 2 ) ,
306
- TIMER4 = timer( 3 ) ,
310
+ TIMER1 = clock ( ) ,
311
+ TIMER2 = timer( 0 ) ,
312
+ TIMER3 = timer( 1 ) ,
313
+ TIMER4 = timer( 2 ) ,
307
314
#[ cfg( feature = "uart" ) ]
308
315
UARTE0_UART0 = uarte( 0 ) ,
309
316
#[ cfg( feature = "uart" ) ]
@@ -345,6 +352,10 @@ fn radio_timer() {
345
352
with_state ( |state| state. ble . tick_timer ( ) )
346
353
}
347
354
355
+ fn clock ( ) {
356
+ with_state ( |state| state. clock . tick ( ) )
357
+ }
358
+
348
359
fn timer ( timer : usize ) {
349
360
let timer = Id :: new ( timer) . unwrap ( ) ;
350
361
with_state ( |state| {
0 commit comments