Lab 1 Program C
Fork of mbed by
TimerEvent.h@4:5d1359a283bc, 2008-11-27 (annotated)
- Committer:
- simon.ford@mbed.co.uk
- Date:
- Thu Nov 27 16:23:24 2008 +0000
- Revision:
- 4:5d1359a283bc
- Parent:
- 3:aefd12a1f1c5
- Child:
- 9:cf0d45ce28a6
New version of framework: vectors, environment, platform, base and file system
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
simon.ford@mbed.co.uk | 4:5d1359a283bc | 1 | /* mbed Microcontroller Library - TimerEvent |
simon.ford@mbed.co.uk | 4:5d1359a283bc | 2 | * Copyright (c) 2007-2008, sford |
simon.ford@mbed.co.uk | 4:5d1359a283bc | 3 | */ |
simon.ford@mbed.co.uk | 4:5d1359a283bc | 4 | |
simon.ford@mbed.co.uk | 4:5d1359a283bc | 5 | #ifndef MBED_TIMEREVENT_H |
simon.ford@mbed.co.uk | 4:5d1359a283bc | 6 | #define MBED_TIMEREVENT_H |
simon.ford@mbed.co.uk | 4:5d1359a283bc | 7 | |
simon.ford@mbed.co.uk | 4:5d1359a283bc | 8 | namespace mbed { |
simon.ford@mbed.co.uk | 4:5d1359a283bc | 9 | |
simon.ford@mbed.co.uk | 4:5d1359a283bc | 10 | // Base abstraction for timer interrupts |
simon.ford@mbed.co.uk | 4:5d1359a283bc | 11 | class TimerEvent { |
simon.ford@mbed.co.uk | 4:5d1359a283bc | 12 | |
simon.ford@mbed.co.uk | 4:5d1359a283bc | 13 | public: |
simon.ford@mbed.co.uk | 4:5d1359a283bc | 14 | |
simon.ford@mbed.co.uk | 4:5d1359a283bc | 15 | // The handler registered with the underlying timer interrupt |
simon.ford@mbed.co.uk | 4:5d1359a283bc | 16 | static void irq(); |
simon.ford@mbed.co.uk | 4:5d1359a283bc | 17 | |
simon.ford@mbed.co.uk | 4:5d1359a283bc | 18 | // Destruction removes it... |
simon.ford@mbed.co.uk | 4:5d1359a283bc | 19 | virtual ~TimerEvent(); |
simon.ford@mbed.co.uk | 4:5d1359a283bc | 20 | |
simon.ford@mbed.co.uk | 4:5d1359a283bc | 21 | protected: |
simon.ford@mbed.co.uk | 4:5d1359a283bc | 22 | |
simon.ford@mbed.co.uk | 4:5d1359a283bc | 23 | // The handler called to service the timer event of the derived class |
simon.ford@mbed.co.uk | 4:5d1359a283bc | 24 | virtual void handler() = 0; |
simon.ford@mbed.co.uk | 4:5d1359a283bc | 25 | |
simon.ford@mbed.co.uk | 4:5d1359a283bc | 26 | // insert in to linked list |
simon.ford@mbed.co.uk | 4:5d1359a283bc | 27 | void insert(unsigned int timestamp); |
simon.ford@mbed.co.uk | 4:5d1359a283bc | 28 | |
simon.ford@mbed.co.uk | 4:5d1359a283bc | 29 | // remove from linked list, if in it |
simon.ford@mbed.co.uk | 4:5d1359a283bc | 30 | void remove(); |
simon.ford@mbed.co.uk | 4:5d1359a283bc | 31 | |
simon.ford@mbed.co.uk | 4:5d1359a283bc | 32 | // Get the current usec timestamp |
simon.ford@mbed.co.uk | 4:5d1359a283bc | 33 | static unsigned int timestamp(); |
simon.ford@mbed.co.uk | 4:5d1359a283bc | 34 | |
simon.ford@mbed.co.uk | 4:5d1359a283bc | 35 | static TimerEvent *_head; // The head of the list of the events, NULL if none |
simon.ford@mbed.co.uk | 4:5d1359a283bc | 36 | TimerEvent *_next; // Pointer to the next in the list, NULL if last |
simon.ford@mbed.co.uk | 4:5d1359a283bc | 37 | unsigned int _timestamp; // The timestamp at which the even should be triggered |
simon.ford@mbed.co.uk | 4:5d1359a283bc | 38 | |
simon.ford@mbed.co.uk | 4:5d1359a283bc | 39 | }; |
simon.ford@mbed.co.uk | 4:5d1359a283bc | 40 | |
simon.ford@mbed.co.uk | 4:5d1359a283bc | 41 | } |
simon.ford@mbed.co.uk | 4:5d1359a283bc | 42 | |
simon.ford@mbed.co.uk | 4:5d1359a283bc | 43 | #endif |