From d6c747ec1c5c27ba0940517346da75bc4945dc9e Mon Sep 17 00:00:00 2001 From: Vegard Storheil Eriksen Date: Sun, 28 Aug 2011 01:23:06 +0200 Subject: Adapted code to changes on new controller board. --- ppmsum.cpp | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) (limited to 'ppmsum.cpp') diff --git a/ppmsum.cpp b/ppmsum.cpp index 75faa17..927efa8 100644 --- a/ppmsum.cpp +++ b/ppmsum.cpp @@ -3,18 +3,23 @@ PPMSum* PPMSum::self = 0; template<> -void interrupt() { +void interrupt() { + PPMSum::self->irq(); +} + +template<> +void interrupt() { PPMSum::self->irq(); } void PPMSum::irq() { - int16_t sr = TIM4.SR; - TIM4.SR = 0; + int16_t sr = TIM1.SR; + TIM1.SR = 0; if(sr & 0x06) { - GPIOA.ODR = 1 << 5; + GPIOB.ODR = 1 << 1; } else { - GPIOA.ODR = 0; + GPIOB.ODR = 0; } @@ -26,7 +31,7 @@ void PPMSum::irq() { } else if(sr & 0x02) { // Period. - if(TIM4.CCR1 > 5000) { + if(TIM1.CCR1 > 5000) { synced = true; index = 0; } else { @@ -36,19 +41,20 @@ void PPMSum::irq() { } else if(sr & 0x04) { // Pulsewidth. - channels[index] = TIM4.CCR2; + channels[index] = TIM1.CCR2; } } void PPMSum::enable() { - RCC.enable(RCC.TIM4); - TIM4.PSC = 72; - TIM4.CCMR1 = 0x0201; - TIM4.SMCR = 0x54; - TIM4.CCER = 0x31; - TIM4.DIER = 0x07; + RCC.enable(RCC.TIM1); + TIM1.PSC = 72; + TIM1.CCMR1 = 0x0201; + TIM1.SMCR = 0x54; + TIM1.CCER = 0x31; + TIM1.DIER = 0x07; - Interrupt::enable(Interrupt::TIM4); + Interrupt::enable(Interrupt::TIM1_UP); + Interrupt::enable(Interrupt::TIM1_CC); - TIM4.CR1 = 0x05; + TIM1.CR1 = 0x05; } -- cgit v1.2.3