Tock capsule periodic "Hello World"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use kernel::hil::time::{self, Alarm, Frequency}; | |
pub struct Accelerate<'a, A: Alarm + 'a> { | |
alarm: &'a A | |
} | |
impl<'a, A: Alarm> Accelerate<'a, A> { | |
pub fn new(alarm: &'a A) -> Accelerate<'a, A> { | |
Accelerate { | |
alarm: alarm | |
} | |
} | |
pub fn start(&self) { | |
self.alarm.set_alarm( | |
self.alarm.now().wrapping_add(<A::Frequency>::frequency())) | |
} | |
} | |
impl<'a, A: Alarm> time::Client for Accelerate<'a, A> { | |
fn fired(&self) { | |
self.start(); | |
debug!("Hello world"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let accelerate_virtual_alarm = static_init!( | |
VirtualMuxAlarm<'static, sam4l::ast::Ast>, | |
VirtualMuxAlarm::new(mux_alarm)); | |
let accelerate = static_init!( | |
capsules::accelerate::Accelerate<'static, | |
VirtualMuxAlarm<'static, sam4l::ast::Ast<'static>>>, | |
capsules::accelerate::Accelerate::new(accelerate_virtual_alarm)); | |
accelerate_virtual_alarm.set_client(accelerate); | |
accelerate.start(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment