view timer.h @ 6:acbd0ddd002b

Add shared 1ms timer code Now blinks in a slightly useful manner Now has several submodes for acceptor state machine Clean ups
author Frank Kingswood <frank@kingswood-consulting.co.uk>
date Tue, 01 Apr 2014 20:35:06 +0100
parents
children
line wrap: on
line source
1 /* #------------------------------------------------------------------------#
2 | |
3 | timer.h |
4 | |
5 | Shared 1ms timer. |
6 | |
7 | Copyright 2014, Frank A. Kingswood, www.kingswood-consulting.co.uk |
8 | |
9 #------------------------------------------------------------------------# */
11 #ifndef TIMER_H_
12 #define TIMER_H_
14 void TimerInterrupt();
16 class SharedTimer
17 {
18 friend void TimerInterrupt();
19 static SharedTimer *volatile First;
20 SharedTimer *Next;
21 protected:
22 virtual void Tick();
23 SharedTimer();
24 };
26 class Timer:public SharedTimer
27 {
28 uint16_t Count,
29 Reload;
30 bool TimedOut;
32 protected:
33 virtual void Tick();
35 public:
36 Timer();
37 void Single(uint16_t time);
38 void Repeat(uint16_t time);
39 void Clear();
40 uint16_t Read() const;
41 bool Timeout() const
42 { return TimedOut;
43 }
44 };
46 class Blinky:public SharedTimer
47 {
48 uint8_t Count,
49 Reload;
50 uint16_t Pattern;
52 protected:
53 virtual void Tick();
55 public:
56 Blinky();
57 void operator()(uint8_t period,uint16_t pattern);
58 void operator()(uint16_t pattern);
59 };
61 extern Blinky blinky;
63 #endif /* TIMER_H_ */
65 /* ----- EOF timer.h ----- */