Lab 1 Program C
Fork of mbed by
TimerEvent.h@44:1c5f591fce58, 2015-09-29 (annotated)
- Committer:
- mattsims12
- Date:
- Tue Sep 29 03:04:58 2015 +0000
- Revision:
- 44:1c5f591fce58
- Parent:
- 43:aff670d0d510
Lab 1 Program C
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
rolf.meyer@arm.com | 11:1c1ebd0324fa | 1 | /* mbed Microcontroller Library - TimerEvent |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 2 | * Copyright (c) 2007-2009 ARM Limited. All rights reserved. |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 3 | */ |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 4 | |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 5 | #ifndef MBED_TIMEREVENT_H |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 6 | #define MBED_TIMEREVENT_H |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 7 | |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 8 | namespace mbed { |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 9 | |
screamer | 43:aff670d0d510 | 10 | /** Base abstraction for timer interrupts |
screamer | 43:aff670d0d510 | 11 | */ |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 12 | class TimerEvent { |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 13 | |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 14 | public: |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 15 | |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 16 | TimerEvent(); |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 17 | |
screamer | 43:aff670d0d510 | 18 | /** The handler registered with the underlying timer interrupt |
screamer | 43:aff670d0d510 | 19 | */ |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 20 | static void irq(); |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 21 | |
screamer | 43:aff670d0d510 | 22 | /** Destruction removes it... |
screamer | 43:aff670d0d510 | 23 | */ |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 24 | virtual ~TimerEvent(); |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 25 | |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 26 | protected: |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 27 | |
screamer | 43:aff670d0d510 | 28 | /** The handler called to service the timer event of the derived class |
screamer | 43:aff670d0d510 | 29 | */ |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 30 | virtual void handler() = 0; |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 31 | |
screamer | 43:aff670d0d510 | 32 | /** Insert in to linked list |
screamer | 43:aff670d0d510 | 33 | */ |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 34 | void insert(unsigned int timestamp); |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 35 | |
screamer | 43:aff670d0d510 | 36 | /** Remove from linked list, if in it |
screamer | 43:aff670d0d510 | 37 | */ |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 38 | void remove(); |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 39 | |
screamer | 43:aff670d0d510 | 40 | /** Get the current usec timestamp |
screamer | 43:aff670d0d510 | 41 | */ |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 42 | static unsigned int timestamp(); |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 43 | |
screamer | 43:aff670d0d510 | 44 | /** The head of the list of the events, NULL if none |
screamer | 43:aff670d0d510 | 45 | */ |
screamer | 43:aff670d0d510 | 46 | static TimerEvent *_head; |
screamer | 43:aff670d0d510 | 47 | |
screamer | 43:aff670d0d510 | 48 | /** Pointer to the next in the list, NULL if last |
screamer | 43:aff670d0d510 | 49 | */ |
screamer | 43:aff670d0d510 | 50 | TimerEvent *_next; |
screamer | 43:aff670d0d510 | 51 | |
screamer | 43:aff670d0d510 | 52 | /** The timestamp at which the even should be triggered |
screamer | 43:aff670d0d510 | 53 | */ |
screamer | 43:aff670d0d510 | 54 | unsigned int _timestamp; |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 55 | |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 56 | }; |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 57 | |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 58 | } // namespace mbed |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 59 | |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 60 | #endif |