Compare commits

..

1 Commits

Author SHA1 Message Date
Thomas Klaehn
ba83d9cdea Add virtual timer 2020-04-18 10:36:01 +02:00
4 changed files with 6 additions and 13 deletions

View File

@ -42,10 +42,10 @@ int main(void)
{
cm4::InterruptGuardian::enable_interrupts();
while(true) {
for(auto it = leds.begin(); it != leds.end(); ++it) {
nrf52::Gpio * led = *it;
led->toggle();
delay.ms(200);
for(auto it = std::begin(leds); it != std::end(leds); ++it) {
nrf52::Gpio * tmp = *it;
tmp->toggle();
delay.delay(200);
}
}
return 0;

View File

@ -9,7 +9,7 @@ Delay::Delay()
{
}
void Delay::ms(uint64_t time_ms)
void Delay::delay(uint64_t time_ms)
{
this->pause = true;
this->timer_set_period_ms(time_ms);

View File

@ -12,7 +12,7 @@ class Delay
public:
Delay();
void ms(uint64_t);
void delay(uint64_t);
void notification();

View File

@ -33,7 +33,6 @@ void VirtualTimerDistributor::register_timer(VirtualTimerInterface *timer)
}
for(auto it = this->virtual_timer_list.begin(); it != this->virtual_timer_list.end(); ++it) {
if(*it == nullptr) {
// FIXME: We might need an interrupt lock here?
*it = timer;
num_registered_timers++;
break;
@ -46,13 +45,8 @@ void VirtualTimerDistributor::register_timer(VirtualTimerInterface *timer)
void VirtualTimerDistributor::unregister_timer(VirtualTimerInterface *timer)
{
if(num_registered_timers == 0) {
// FIXME: Error notification
return;
}
for(auto it = this->virtual_timer_list.begin(); it != this->virtual_timer_list.end(); ++it) {
if(*it == timer) {
// FIXME: We might need an interrupt lock here?
*it = nullptr;
num_registered_timers--;
break;
@ -65,7 +59,6 @@ void VirtualTimerDistributor::unregister_timer(VirtualTimerInterface *timer)
void VirtualTimerDistributor::notify(uint64_t time_ms)
{
// FIXME: We're still in interrupt context of hw timer interrupt.
for(auto it = this->virtual_timer_list.begin(); it != this->virtual_timer_list.end(); ++it) {
if(*it != nullptr) {
VirtualTimerInterface *vt = *it;