aboutsummaryrefslogtreecommitdiffstats
path: root/wirish/HardwareTimer.cpp
diff options
context:
space:
mode:
authorbnewbold <bnewbold@robocracy.org>2010-08-31 17:17:57 -0400
committerbnewbold <bnewbold@robocracy.org>2010-08-31 17:17:57 -0400
commite03d58f4dab4176514924baa3a1ff430bf5819b8 (patch)
treeb5c8269c34ab3bb4da0f7c52dea7049966753fb3 /wirish/HardwareTimer.cpp
parent01c38f5567bf624413d901c2b287e63cdccd03a6 (diff)
downloadlibrambutan-e03d58f4dab4176514924baa3a1ff430bf5819b8.tar.gz
librambutan-e03d58f4dab4176514924baa3a1ff430bf5819b8.zip
Further wirish portability progress
Sort of ugly changes. Compiles but untested.
Diffstat (limited to 'wirish/HardwareTimer.cpp')
-rw-r--r--wirish/HardwareTimer.cpp39
1 files changed, 35 insertions, 4 deletions
diff --git a/wirish/HardwareTimer.cpp b/wirish/HardwareTimer.cpp
index 3c8e9f4..5675948 100644
--- a/wirish/HardwareTimer.cpp
+++ b/wirish/HardwareTimer.cpp
@@ -32,10 +32,7 @@
#include "HardwareTimer.h"
HardwareTimer::HardwareTimer(uint8 timerNum) {
- ASSERT(timerNum == 1 ||
- timerNum == 2 ||
- timerNum == 3 ||
- timerNum == 4);
+ ASSERT(timerNum < NR_TIMERS);
this->timerNum = timerNum;
// Need to remember over flow for bounds checking
this->overflow = 0xFFFF;
@@ -141,9 +138,43 @@ void HardwareTimer::detachCompare3Interrupt(void) {
void HardwareTimer::detachCompare4Interrupt(void) {
timer_detach_interrupt(this->timerNum,4);
}
+#if NR_TIMERS >= 8
+void HardwareTimer::setChannel5Mode(uint8 mode) {
+ timer_set_mode(this->timerNum,5,mode);
+}
+void HardwareTimer::setChannel8Mode(uint8 mode) {
+ timer_set_mode(this->timerNum,8,mode);
+}
+void HardwareTimer::setCompare5(uint16 val) {
+ if(val > this->overflow)
+ val = this->overflow;
+ timer_set_compare_value(this->timerNum,5,val);
+}
+void HardwareTimer::setCompare8(uint16 val) {
+ if(val > this->overflow)
+ val = this->overflow;
+ timer_set_compare_value(this->timerNum,8,val);
+}
+void HardwareTimer::attachCompare5Interrupt(voidFuncPtr handler) {
+ timer_attach_interrupt(this->timerNum,5,handler);
+}
+void HardwareTimer::attachCompare8Interrupt(voidFuncPtr handler) {
+ timer_attach_interrupt(this->timerNum,8,handler);
+}
+void HardwareTimer::detachCompare5Interrupt(void) {
+ timer_detach_interrupt(this->timerNum,5);
+}
+void HardwareTimer::detachCompare8Interrupt(void) {
+ timer_detach_interrupt(this->timerNum,8);
+}
+#endif
HardwareTimer Timer1(1);
HardwareTimer Timer2(2);
HardwareTimer Timer3(3);
HardwareTimer Timer4(4);
+#if NR_TIMERS >= 8
+HardwareTimer Timer5(5); // High-density devices only
+HardwareTimer Timer8(8); // High-density devices only
+#endif