TargetManager

Dependents:   TargetManagerManualTest NerfUSTarget

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers NerfusTicker.cpp Source File

NerfusTicker.cpp

00001 #include "NerfusTicker.hpp"
00002 
00003 void NerfusTicker::start(int timeout_ms)
00004 {
00005     ticker = Ticker();
00006     ticker.attach_us(callback(this, &NerfusTicker::timeout), timeout_ms * 1000);
00007     timer.reset();
00008     timer.start();
00009 }
00010 
00011 void NerfusTicker::stop()
00012 {
00013     ticker.detach();
00014     timer.stop();
00015 }
00016 
00017 int NerfusTicker::get_time_ms()
00018 {
00019     return timer.read_ms();
00020 }
00021 
00022 void NerfusTicker::init(NerfusCallbackInterface *nerfus_callback)
00023 {
00024     this->nerfus_callback = nerfus_callback;
00025 }
00026 
00027 void NerfusTicker::timeout()
00028 {
00029     nerfus_callback->call();
00030     stop();
00031 }