arty_e21/
timer_test.rs

1// Licensed under the Apache License, Version 2.0 or the MIT License.
2// SPDX-License-Identifier: Apache-2.0 OR MIT
3// Copyright Tock Contributors 2022.
4
5use kernel::debug;
6use kernel::hil::time::{self, Alarm, Ticks};
7
8pub struct TimerTest<'a, A: Alarm<'a>> {
9    alarm: &'a A,
10}
11
12impl<'a, A: Alarm<'a>> TimerTest<'a, A> {
13    pub const fn new(alarm: &'a A) -> TimerTest<'a, A> {
14        TimerTest { alarm }
15    }
16
17    pub fn start(&self) {
18        debug!("starting");
19        let start = self.alarm.now();
20        let exp = start.wrapping_add(A::Ticks::from(99999u32));
21        self.alarm.set_alarm(start, exp);
22    }
23}
24
25impl<'a, A: Alarm<'a>> time::AlarmClient for TimerTest<'a, A> {
26    fn alarm(&self) {
27        debug!("timer!!");
28    }
29}