summaryrefslogtreecommitdiff
path: root/drivers/ppmsum.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ppmsum.cpp')
-rw-r--r--drivers/ppmsum.cpp32
1 files changed, 13 insertions, 19 deletions
diff --git a/drivers/ppmsum.cpp b/drivers/ppmsum.cpp
index ff00f42..c1bd101 100644
--- a/drivers/ppmsum.cpp
+++ b/drivers/ppmsum.cpp
@@ -5,18 +5,13 @@
PPMSum* PPMSum::self = 0;
template<>
-void interrupt<Interrupt::TIM1_UP>() {
- PPMSum::self->irq();
-}
-
-template<>
-void interrupt<Interrupt::TIM1_CC>() {
+void interrupt<Interrupt::TIM2>() {
PPMSum::self->irq();
}
void PPMSum::irq() {
- int16_t sr = TIM1.SR;
- TIM1.SR = 0;
+ int16_t sr = TIM2.SR;
+ TIM2.SR = 0;
if(sr & 0x01) {
// Timeout.
@@ -26,7 +21,7 @@ void PPMSum::irq() {
} else if(sr & 0x02) {
// Period.
- if(TIM1.CCR1 > 5000) {
+ if(TIM2.CCR1 > 5000) {
synced = true;
index = 0;
} else {
@@ -37,20 +32,19 @@ void PPMSum::irq() {
} else if(sr & 0x04) {
// Pulsewidth.
- channels[index] = TIM1.CCR2;
+ channels[index] = TIM2.CCR2;
}
}
void PPMSum::enable() {
- RCC.enable(RCC.TIM1);
- TIM1.PSC = 72;
- TIM1.CCMR1 = 0x0201;
- TIM1.SMCR = 0x54;
- TIM1.CCER = 0x31;
- TIM1.DIER = 0x07;
+ RCC.enable(RCC.TIM2);
+ TIM2.PSC = 84 - 1;
+ TIM2.CCMR1 = 0x0201;
+ TIM2.SMCR = 0x54;
+ TIM2.CCER = 0x13;
+ TIM2.DIER = 0x07;
- Interrupt::enable(Interrupt::TIM1_UP);
- Interrupt::enable(Interrupt::TIM1_CC);
+ Interrupt::enable(Interrupt::TIM2);
- TIM1.CR1 = 0x05;
+ TIM2.CR1 = 0x05;
}