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