/*************************************************************************** * Copyright (C) 11/2014 by Olaf Rempel * * razzor@kopf-tisch.de * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; version 2 of the License, * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #include #include "event.h" /* *********************************************************************** */ #define TIMER_COUNT 2 static uint16_t timers[TIMER_COUNT]; /* *********************************************************************** */ void timer_tick(void) { uint8_t i; for (i = 0; i < TIMER_COUNT; i++) { if (timers[i] > 0) { timers[i]--; if (timers[i] == 0) { event_queue(EVENT_TYPE_TIMER_ELAPSED, i, 0); } } } } /* timer_tick */ void timer_event_handler(struct event_entry *event) { if ((event->type == EVENT_TYPE_TIMER_SET) && (event->num < TIMER_COUNT) ) { timers[event->num] = event->value; } } /* timer_event_handler */