Lab 1 Program C

Dependents:   Lab1C

Fork of mbed by -deleted-

Committer:
emilmont
Date:
Tue Nov 29 14:59:27 2011 +0000
Revision:
27:7110ebee3484
Parent:
11:1c1ebd0324fa
Child:
43:aff670d0d510
New Libraries 11.11

Who changed what in which revision?

UserRevisionLine numberNew 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
rolf.meyer@arm.com 11:1c1ebd0324fa 10 // Base abstraction for timer interrupts
rolf.meyer@arm.com 11:1c1ebd0324fa 11 class TimerEvent {
rolf.meyer@arm.com 11:1c1ebd0324fa 12
rolf.meyer@arm.com 11:1c1ebd0324fa 13 public:
rolf.meyer@arm.com 11:1c1ebd0324fa 14
rolf.meyer@arm.com 11:1c1ebd0324fa 15 TimerEvent();
rolf.meyer@arm.com 11:1c1ebd0324fa 16
rolf.meyer@arm.com 11:1c1ebd0324fa 17 // The handler registered with the underlying timer interrupt
rolf.meyer@arm.com 11:1c1ebd0324fa 18 static void irq();
rolf.meyer@arm.com 11:1c1ebd0324fa 19
rolf.meyer@arm.com 11:1c1ebd0324fa 20 // Destruction removes it...
rolf.meyer@arm.com 11:1c1ebd0324fa 21 virtual ~TimerEvent();
rolf.meyer@arm.com 11:1c1ebd0324fa 22
rolf.meyer@arm.com 11:1c1ebd0324fa 23 protected:
rolf.meyer@arm.com 11:1c1ebd0324fa 24
rolf.meyer@arm.com 11:1c1ebd0324fa 25 // The handler called to service the timer event of the derived class
rolf.meyer@arm.com 11:1c1ebd0324fa 26 virtual void handler() = 0;
rolf.meyer@arm.com 11:1c1ebd0324fa 27
rolf.meyer@arm.com 11:1c1ebd0324fa 28 // insert in to linked list
rolf.meyer@arm.com 11:1c1ebd0324fa 29 void insert(unsigned int timestamp);
rolf.meyer@arm.com 11:1c1ebd0324fa 30
rolf.meyer@arm.com 11:1c1ebd0324fa 31 // remove from linked list, if in it
rolf.meyer@arm.com 11:1c1ebd0324fa 32 void remove();
rolf.meyer@arm.com 11:1c1ebd0324fa 33
rolf.meyer@arm.com 11:1c1ebd0324fa 34 // Get the current usec timestamp
rolf.meyer@arm.com 11:1c1ebd0324fa 35 static unsigned int timestamp();
rolf.meyer@arm.com 11:1c1ebd0324fa 36
rolf.meyer@arm.com 11:1c1ebd0324fa 37 static TimerEvent *_head; // The head of the list of the events, NULL if none
rolf.meyer@arm.com 11:1c1ebd0324fa 38 TimerEvent *_next; // Pointer to the next in the list, NULL if last
rolf.meyer@arm.com 11:1c1ebd0324fa 39 unsigned int _timestamp; // The timestamp at which the even should be triggered
rolf.meyer@arm.com 11:1c1ebd0324fa 40
rolf.meyer@arm.com 11:1c1ebd0324fa 41 };
rolf.meyer@arm.com 11:1c1ebd0324fa 42
rolf.meyer@arm.com 11:1c1ebd0324fa 43 } // namespace mbed
rolf.meyer@arm.com 11:1c1ebd0324fa 44
rolf.meyer@arm.com 11:1c1ebd0324fa 45 #endif