This is my quadcopter prototype software, still in development!
quadv3/mbed/TimerEvent.h@0:978110f7f027, 2013-01-30 (annotated)
- Committer:
- Anaesthetix
- Date:
- Wed Jan 30 13:14:44 2013 +0000
- Revision:
- 0:978110f7f027
My quadcopter prototype software, still in development.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Anaesthetix | 0:978110f7f027 | 1 | /* mbed Microcontroller Library - TimerEvent |
Anaesthetix | 0:978110f7f027 | 2 | * Copyright (c) 2007-2009 ARM Limited. All rights reserved. |
Anaesthetix | 0:978110f7f027 | 3 | */ |
Anaesthetix | 0:978110f7f027 | 4 | |
Anaesthetix | 0:978110f7f027 | 5 | #ifndef MBED_TIMEREVENT_H |
Anaesthetix | 0:978110f7f027 | 6 | #define MBED_TIMEREVENT_H |
Anaesthetix | 0:978110f7f027 | 7 | |
Anaesthetix | 0:978110f7f027 | 8 | namespace mbed { |
Anaesthetix | 0:978110f7f027 | 9 | |
Anaesthetix | 0:978110f7f027 | 10 | // Base abstraction for timer interrupts |
Anaesthetix | 0:978110f7f027 | 11 | class TimerEvent { |
Anaesthetix | 0:978110f7f027 | 12 | |
Anaesthetix | 0:978110f7f027 | 13 | public: |
Anaesthetix | 0:978110f7f027 | 14 | |
Anaesthetix | 0:978110f7f027 | 15 | TimerEvent(); |
Anaesthetix | 0:978110f7f027 | 16 | |
Anaesthetix | 0:978110f7f027 | 17 | // The handler registered with the underlying timer interrupt |
Anaesthetix | 0:978110f7f027 | 18 | static void irq(); |
Anaesthetix | 0:978110f7f027 | 19 | |
Anaesthetix | 0:978110f7f027 | 20 | // Destruction removes it... |
Anaesthetix | 0:978110f7f027 | 21 | virtual ~TimerEvent(); |
Anaesthetix | 0:978110f7f027 | 22 | |
Anaesthetix | 0:978110f7f027 | 23 | protected: |
Anaesthetix | 0:978110f7f027 | 24 | |
Anaesthetix | 0:978110f7f027 | 25 | // The handler called to service the timer event of the derived class |
Anaesthetix | 0:978110f7f027 | 26 | virtual void handler() = 0; |
Anaesthetix | 0:978110f7f027 | 27 | |
Anaesthetix | 0:978110f7f027 | 28 | // insert in to linked list |
Anaesthetix | 0:978110f7f027 | 29 | void insert(unsigned int timestamp); |
Anaesthetix | 0:978110f7f027 | 30 | |
Anaesthetix | 0:978110f7f027 | 31 | // remove from linked list, if in it |
Anaesthetix | 0:978110f7f027 | 32 | void remove(); |
Anaesthetix | 0:978110f7f027 | 33 | |
Anaesthetix | 0:978110f7f027 | 34 | // Get the current usec timestamp |
Anaesthetix | 0:978110f7f027 | 35 | static unsigned int timestamp(); |
Anaesthetix | 0:978110f7f027 | 36 | |
Anaesthetix | 0:978110f7f027 | 37 | static TimerEvent *_head; // The head of the list of the events, NULL if none |
Anaesthetix | 0:978110f7f027 | 38 | TimerEvent *_next; // Pointer to the next in the list, NULL if last |
Anaesthetix | 0:978110f7f027 | 39 | unsigned int _timestamp; // The timestamp at which the even should be triggered |
Anaesthetix | 0:978110f7f027 | 40 | |
Anaesthetix | 0:978110f7f027 | 41 | }; |
Anaesthetix | 0:978110f7f027 | 42 | |
Anaesthetix | 0:978110f7f027 | 43 | } // namespace mbed |
Anaesthetix | 0:978110f7f027 | 44 | |
Anaesthetix | 0:978110f7f027 | 45 | #endif |