Skip to content

Instantly share code, notes, and snippets.

@alevy alevy/accelerate.rs

Last active Aug 18, 2017
Embed
What would you like to do?
Tock capsule periodic "Hello World"
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");
}
}
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
You can’t perform that action at this time.