aboutsummaryrefslogtreecommitdiffstats
path: root/wirish/HardwareTimer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'wirish/HardwareTimer.cpp')
-rw-r--r--wirish/HardwareTimer.cpp47
1 files changed, 9 insertions, 38 deletions
diff --git a/wirish/HardwareTimer.cpp b/wirish/HardwareTimer.cpp
index f55e6b0..99863c1 100644
--- a/wirish/HardwareTimer.cpp
+++ b/wirish/HardwareTimer.cpp
@@ -32,8 +32,10 @@
#include "HardwareTimer.h"
HardwareTimer::HardwareTimer(uint8 timerNum) {
- ASSERT(timerNum <= NR_TIMERS);
+ ASSERT(timerNum <= NR_TIMERS && timerNum != 6 && timerNum != 7);
+
this->timerNum = timerNum;
+
// Need to remember over flow for bounds checking
this->overflow = 0xFFFF;
}
@@ -104,7 +106,6 @@ void HardwareTimer::setCompare2(uint16 val) {
timer_set_compare_value(this->timerNum,2,val);
}
void HardwareTimer::setCompare3(uint16 val) {
- ASSERT(this->timerNum);
if(val > this->overflow)
val = this->overflow;
timer_set_compare_value(this->timerNum,3,val);
@@ -138,43 +139,13 @@ 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);
+HardwareTimer Timer1(TIMER1);
+HardwareTimer Timer2(TIMER2);
+HardwareTimer Timer3(TIMER3);
+HardwareTimer Timer4(TIMER4);
#if NR_TIMERS >= 8
-HardwareTimer Timer5(5); // High-density devices only
-HardwareTimer Timer8(8); // High-density devices only
+HardwareTimer Timer5(TIMER5); // High-density devices only
+HardwareTimer Timer8(TIMER8); // High-density devices only
#endif