mbed libraries for KL25Z
TimerEvent.h@0:8024c367e29f, 2012-10-05 (annotated)
- Committer:
- emilmont
- Date:
- Fri Oct 05 09:16:41 2012 +0000
- Revision:
- 0:8024c367e29f
- Child:
- 2:e9a661555b58
First release of the mbed libraries for KL25Z
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
emilmont | 0:8024c367e29f | 1 | /* mbed Microcontroller Library - TimerEvent |
emilmont | 0:8024c367e29f | 2 | * Copyright (c) 2007-2009 ARM Limited. All rights reserved. |
emilmont | 0:8024c367e29f | 3 | */ |
emilmont | 0:8024c367e29f | 4 | |
emilmont | 0:8024c367e29f | 5 | #ifndef MBED_TIMEREVENT_H |
emilmont | 0:8024c367e29f | 6 | #define MBED_TIMEREVENT_H |
emilmont | 0:8024c367e29f | 7 | |
emilmont | 0:8024c367e29f | 8 | #include "us_ticker_api.h" |
emilmont | 0:8024c367e29f | 9 | |
emilmont | 0:8024c367e29f | 10 | namespace mbed { |
emilmont | 0:8024c367e29f | 11 | |
emilmont | 0:8024c367e29f | 12 | // Base abstraction for timer interrupts |
emilmont | 0:8024c367e29f | 13 | class TimerEvent { |
emilmont | 0:8024c367e29f | 14 | |
emilmont | 0:8024c367e29f | 15 | public: |
emilmont | 0:8024c367e29f | 16 | |
emilmont | 0:8024c367e29f | 17 | TimerEvent(); |
emilmont | 0:8024c367e29f | 18 | |
emilmont | 0:8024c367e29f | 19 | // The handler registered with the underlying timer interrupt |
emilmont | 0:8024c367e29f | 20 | static void irq(); |
emilmont | 0:8024c367e29f | 21 | |
emilmont | 0:8024c367e29f | 22 | // Destruction removes it... |
emilmont | 0:8024c367e29f | 23 | virtual ~TimerEvent(); |
emilmont | 0:8024c367e29f | 24 | |
emilmont | 0:8024c367e29f | 25 | protected: |
emilmont | 0:8024c367e29f | 26 | |
emilmont | 0:8024c367e29f | 27 | // The handler called to service the timer event of the derived class |
emilmont | 0:8024c367e29f | 28 | virtual void handler() = 0; |
emilmont | 0:8024c367e29f | 29 | |
emilmont | 0:8024c367e29f | 30 | // insert in to linked list |
emilmont | 0:8024c367e29f | 31 | void insert(unsigned int timestamp); |
emilmont | 0:8024c367e29f | 32 | |
emilmont | 0:8024c367e29f | 33 | // remove from linked list, if in it |
emilmont | 0:8024c367e29f | 34 | void remove(); |
emilmont | 0:8024c367e29f | 35 | |
emilmont | 0:8024c367e29f | 36 | static TimerEvent *_head; // The head of the list of the events, NULL if none |
emilmont | 0:8024c367e29f | 37 | TimerEvent *_next; // Pointer to the next in the list, NULL if last |
emilmont | 0:8024c367e29f | 38 | unsigned int _timestamp; // The timestamp at which the even should be triggered |
emilmont | 0:8024c367e29f | 39 | |
emilmont | 0:8024c367e29f | 40 | }; |
emilmont | 0:8024c367e29f | 41 | |
emilmont | 0:8024c367e29f | 42 | } // namespace mbed |
emilmont | 0:8024c367e29f | 43 | |
emilmont | 0:8024c367e29f | 44 | #endif |