| 1 | /* mbed Microcontroller Library - TimerEvent\r |
| 2 | * Copyright (c) 2007-2009 ARM Limited. All rights reserved.\r |
| 3 | */ \r |
| 4 | \r |
| 5 | #ifndef MBED_TIMEREVENT_H\r |
| 6 | #define MBED_TIMEREVENT_H\r |
| 7 | \r |
| 8 | namespace mbed {\r |
| 9 | \r |
| 10 | // Base abstraction for timer interrupts\r |
| 11 | class TimerEvent {\r |
| 12 | \r |
| 13 | public:\r |
| 14 | \r |
| 15 | TimerEvent();\r |
| 16 | \r |
| 17 | // The handler registered with the underlying timer interrupt\r |
| 18 | static void irq();\r |
| 19 | \r |
| 20 | // Destruction removes it... \r |
| 21 | virtual ~TimerEvent();\r |
| 22 | \r |
| 23 | protected:\r |
| 24 | \r |
| 25 | // The handler called to service the timer event of the derived class\r |
| 26 | virtual void handler() = 0;\r |
| 27 | \r |
| 28 | // insert in to linked list\r |
| 29 | void insert(unsigned int timestamp);\r |
| 30 | \r |
| 31 | // remove from linked list, if in it\r |
| 32 | void remove();\r |
| 33 | \r |
| 34 | // Get the current usec timestamp\r |
| 35 | static unsigned int timestamp();\r |
| 36 | \r |
| 37 | static TimerEvent *_head; // The head of the list of the events, NULL if none\r |
| 38 | TimerEvent *_next; // Pointer to the next in the list, NULL if last\r |
| 39 | unsigned int _timestamp; // The timestamp at which the even should be triggered\r |
| 40 | \r |
| 41 | };\r |
| 42 | \r |
| 43 | } // namespace mbed\r |
| 44 | \r |
| 45 | #endif\r |