printer

Dependents:   Good_Serial_HelloWorld_Mbed

Fork of mbed by gokmen ascioglu

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers TimerEvent.h Source File

TimerEvent.h

00001 /* mbed Microcontroller Library - TimerEvent
00002  * Copyright (c) 2007-2009 ARM Limited. All rights reserved.
00003  */ 
00004  
00005 #ifndef MBED_TIMEREVENT_H
00006 #define MBED_TIMEREVENT_H
00007 
00008 namespace mbed {
00009 
00010 // Base abstraction for timer interrupts
00011 class TimerEvent {
00012 
00013 public:
00014 
00015     TimerEvent();
00016     
00017     // The handler registered with the underlying timer interrupt
00018     static void irq();
00019 
00020     // Destruction removes it...    
00021     virtual ~TimerEvent();
00022 
00023 protected:
00024 
00025     // The handler called to service the timer event of the derived class
00026     virtual void handler() = 0;
00027     
00028     // insert in to linked list
00029     void insert(unsigned int timestamp);
00030     
00031     // remove from linked list, if in it
00032     void remove();
00033     
00034     // Get the current usec timestamp
00035     static unsigned int timestamp();
00036 
00037     static TimerEvent *_head;   // The head of the list of the events, NULL if none
00038     TimerEvent *_next;          // Pointer to the next in the list, NULL if last
00039     unsigned int _timestamp;    // The timestamp at which the even should be triggered
00040 
00041 };
00042 
00043 } // namespace mbed
00044 
00045 #endif