Lab 1 Program C

Dependents:   Lab1C

Fork of mbed by -deleted-

Committer:
simon.ford@mbed.co.uk
Date:
Wed Apr 15 14:15:04 2009 +0000
Revision:
9:cf0d45ce28a6
Parent:
4:5d1359a283bc
Child:
11:1c1ebd0324fa
Update library with fixes
* TimerEvent hang bugfix
* FileLike use as file pointer

Who changed what in which revision?

UserRevisionLine numberNew contents of line
simon.ford@mbed.co.uk 9:cf0d45ce28a6 1 /* mbed Microcontroller Library - TimerEvent
simon.ford@mbed.co.uk 9:cf0d45ce28a6 2 * Copyright (c) 2007-2008, sford
simon.ford@mbed.co.uk 9:cf0d45ce28a6 3 */
simon.ford@mbed.co.uk 9:cf0d45ce28a6 4
simon.ford@mbed.co.uk 9:cf0d45ce28a6 5 #ifndef MBED_TIMEREVENT_H
simon.ford@mbed.co.uk 9:cf0d45ce28a6 6 #define MBED_TIMEREVENT_H
simon.ford@mbed.co.uk 9:cf0d45ce28a6 7
simon.ford@mbed.co.uk 9:cf0d45ce28a6 8 namespace mbed {
simon.ford@mbed.co.uk 9:cf0d45ce28a6 9
simon.ford@mbed.co.uk 9:cf0d45ce28a6 10 // Base abstraction for timer interrupts
simon.ford@mbed.co.uk 9:cf0d45ce28a6 11 class TimerEvent {
simon.ford@mbed.co.uk 9:cf0d45ce28a6 12
simon.ford@mbed.co.uk 9:cf0d45ce28a6 13 public:
simon.ford@mbed.co.uk 9:cf0d45ce28a6 14
simon.ford@mbed.co.uk 9:cf0d45ce28a6 15 // The handler registered with the underlying timer interrupt
simon.ford@mbed.co.uk 9:cf0d45ce28a6 16 static void irq();
simon.ford@mbed.co.uk 9:cf0d45ce28a6 17
simon.ford@mbed.co.uk 9:cf0d45ce28a6 18 // Destruction removes it...
simon.ford@mbed.co.uk 9:cf0d45ce28a6 19 virtual ~TimerEvent();
simon.ford@mbed.co.uk 9:cf0d45ce28a6 20
simon.ford@mbed.co.uk 9:cf0d45ce28a6 21 protected:
simon.ford@mbed.co.uk 9:cf0d45ce28a6 22
simon.ford@mbed.co.uk 9:cf0d45ce28a6 23 // The handler called to service the timer event of the derived class
simon.ford@mbed.co.uk 9:cf0d45ce28a6 24 virtual void handler() = 0;
simon.ford@mbed.co.uk 9:cf0d45ce28a6 25
simon.ford@mbed.co.uk 9:cf0d45ce28a6 26 // insert in to linked list
simon.ford@mbed.co.uk 9:cf0d45ce28a6 27 void insert(unsigned int timestamp);
simon.ford@mbed.co.uk 9:cf0d45ce28a6 28
simon.ford@mbed.co.uk 9:cf0d45ce28a6 29 // remove from linked list, if in it
simon.ford@mbed.co.uk 9:cf0d45ce28a6 30 void remove();
simon.ford@mbed.co.uk 9:cf0d45ce28a6 31
simon.ford@mbed.co.uk 9:cf0d45ce28a6 32 // Get the current usec timestamp
simon.ford@mbed.co.uk 9:cf0d45ce28a6 33 static unsigned int timestamp();
simon.ford@mbed.co.uk 9:cf0d45ce28a6 34
simon.ford@mbed.co.uk 9:cf0d45ce28a6 35 static TimerEvent *_head; // The head of the list of the events, NULL if none
simon.ford@mbed.co.uk 9:cf0d45ce28a6 36 TimerEvent *_next; // Pointer to the next in the list, NULL if last
simon.ford@mbed.co.uk 9:cf0d45ce28a6 37 unsigned int _timestamp; // The timestamp at which the even should be triggered
simon.ford@mbed.co.uk 9:cf0d45ce28a6 38
simon.ford@mbed.co.uk 9:cf0d45ce28a6 39 };
simon.ford@mbed.co.uk 9:cf0d45ce28a6 40
simon.ford@mbed.co.uk 9:cf0d45ce28a6 41 }
simon.ford@mbed.co.uk 9:cf0d45ce28a6 42
simon.ford@mbed.co.uk 9:cf0d45ce28a6 43 #endif