aboutsummaryrefslogtreecommitdiffstats
path: root/libmaple/timers.h
diff options
context:
space:
mode:
authorbnewbold <bnewbold@robocracy.org>2010-09-05 18:34:44 -0400
committerbnewbold <bnewbold@robocracy.org>2010-09-05 22:58:36 -0400
commitb6e3624a705b36b15e7f4c0637d133c7dab059bd (patch)
tree700df3f574cb1ea64faf719de4bd6607a1addc6e /libmaple/timers.h
parent16b4c1fce5b1023cfb8210f9c12f09c71d4a755d (diff)
downloadlibrambutan-b6e3624a705b36b15e7f4c0637d133c7dab059bd.tar.gz
librambutan-b6e3624a705b36b15e7f4c0637d133c7dab059bd.zip
timer refactor (c, not c++)
also removed an old ASSERT()
Diffstat (limited to 'libmaple/timers.h')
-rw-r--r--libmaple/timers.h65
1 files changed, 65 insertions, 0 deletions
diff --git a/libmaple/timers.h b/libmaple/timers.h
index c49a00e..448a533 100644
--- a/libmaple/timers.h
+++ b/libmaple/timers.h
@@ -137,6 +137,71 @@ typedef volatile uint32* TimerCCR;
#define TIMER_PWM 1
#define TIMER_OUTPUTCOMPARE 2
+typedef struct {
+ volatile uint16 CR1;
+ uint16 RESERVED0;
+ volatile uint16 CR2;
+ uint16 RESERVED1;
+ volatile uint16 SMCR;
+ uint16 RESERVED2;
+ volatile uint16 DIER;
+ uint16 RESERVED3;
+ volatile uint16 SR;
+ uint16 RESERVED4;
+ volatile uint16 EGR;
+ uint16 RESERVED5;
+ volatile uint16 CCMR1;
+ uint16 RESERVED6;
+ volatile uint16 CCMR2;
+ uint16 RESERVED7;
+ volatile uint16 CCER;
+ uint16 RESERVED8;
+ volatile uint16 CNT;
+ uint16 RESERVED9;
+ volatile uint16 PSC;
+ uint16 RESERVED10;
+ volatile uint16 ARR;
+ uint16 RESERVED11;
+ volatile uint16 RCR;
+ uint16 RESERVED12;
+ volatile uint16 CCR1;
+ uint16 RESERVED13;
+ volatile uint16 CCR2;
+ uint16 RESERVED14;
+ volatile uint16 CCR3;
+ uint16 RESERVED15;
+ volatile uint16 CCR4;
+ uint16 RESERVED16;
+ volatile uint16 BDTR; // Not used in general purpose timers
+ uint16 RESERVED17; // Not used in general purpose timers
+ volatile uint16 DCR;
+ uint16 RESERVED18;
+ volatile uint16 DMAR;
+ uint16 RESERVED19;
+} timer_port;
+
+// timer device numbers
+enum {
+ TIMER1,
+ TIMER2,
+ TIMER3,
+ TIMER4,
+ TIMER5, // High density only
+ TIMER6, // High density only; no compare
+ TIMER7, // High density only; no compare
+ TIMER8, // High density only
+};
+
+// timer descriptor
+struct timer_dev {
+ timer_port *base;
+ const uint8 rcc_dev_num;
+ const uint8 nvic_dev_num;
+ volatile voidFuncPtr handlers[4];
+};
+
+extern struct timer_dev timer_dev_table[];
+
/* Turn on timer with prescale as the divisor
* void timer_init(uint32 timer, uint16 prescale)
* timer -> {1-4}