From 00367e2e7fbb20093514184351b5ac504d6a8016 Mon Sep 17 00:00:00 2001 From: Fabiano Riccardi <fabiuz4@hotmail.it> Date: Fri, 25 Nov 2016 13:37:06 +0100 Subject: [PATCH] Improved the test suite for timers, solve the bug for tranceiver timer Signed-off-by: Fabiano Riccardi <fabiuz4@hotmail.it> --- .../interfaces-impl/gpio_timer.cpp | 5 --- .../high_resolution_timer_base.cpp | 31 +++++++++---------- .../interfaces-impl/transceiver_timer.cpp | 7 +++-- 3 files changed, 19 insertions(+), 24 deletions(-) diff --git a/miosix/arch/cortexM3_efm32gg/efm32gg332f1024_wandstem/interfaces-impl/gpio_timer.cpp b/miosix/arch/cortexM3_efm32gg/efm32gg332f1024_wandstem/interfaces-impl/gpio_timer.cpp index e8b47acb..d1da2c85 100644 --- a/miosix/arch/cortexM3_efm32gg/efm32gg332f1024_wandstem/interfaces-impl/gpio_timer.cpp +++ b/miosix/arch/cortexM3_efm32gg/efm32gg332f1024_wandstem/interfaces-impl/gpio_timer.cpp @@ -26,11 +26,6 @@ ***************************************************************************/ #include "gpio_timer.h" -#include "hwmapping.h" -#include "miosix.h" -#include <cstdlib> -#include <cstdio> -#include "../../../../debugpin.h" #include "gpioirq.h" using namespace miosix; diff --git a/miosix/arch/cortexM3_efm32gg/efm32gg332f1024_wandstem/interfaces-impl/high_resolution_timer_base.cpp b/miosix/arch/cortexM3_efm32gg/efm32gg332f1024_wandstem/interfaces-impl/high_resolution_timer_base.cpp index e7ea65ea..5e702632 100644 --- a/miosix/arch/cortexM3_efm32gg/efm32gg332f1024_wandstem/interfaces-impl/high_resolution_timer_base.cpp +++ b/miosix/arch/cortexM3_efm32gg/efm32gg332f1024_wandstem/interfaces-impl/high_resolution_timer_base.cpp @@ -25,16 +25,13 @@ * along with this program; if not, see <http://www.gnu.org/licenses/> * ***************************************************************************/ -#include "interfaces/arch_registers.h" #include "kernel/kernel.h" #include "kernel/scheduler/timer_interrupt.h" #include "high_resolution_timer_base.h" #include "kernel/timeconversion.h" #include "gpio_timer.h" #include "transceiver_timer.h" -#include "../../../../debugpin.h" #include "rtc.h" -#include "gpioirq.h" using namespace miosix; @@ -483,17 +480,18 @@ void HighResolutionTimerBase::setModeGPIOTimer(bool input){ | TIMER_ROUTE_LOCATION_LOC1; if(input){ //Configuro la modalità input - //Configuro la modalità input - TIMER1->CC[2].CTRL = TIMER_CC_CTRL_PRSSEL_PRSCH0 + //The consumer are both timers + TIMER1->CC[2].CTRL = TIMER_CC_CTRL_PRSSEL_PRSCH0 | TIMER_CC_CTRL_INSEL_PRS | TIMER_CC_CTRL_ICEDGE_RISING //NOTE: when does the output get low? | TIMER_CC_CTRL_MODE_INPUTCAPTURE; - TIMER3->CC[2].CTRL= TIMER_CC_CTRL_PRSSEL_PRSCH0 + TIMER3->CC[2].CTRL= TIMER_CC_CTRL_PRSSEL_PRSCH0 | TIMER_CC_CTRL_INSEL_PRS | TIMER_CC_CTRL_ICEDGE_RISING //NOTE: when does the output get low? | TIMER_CC_CTRL_MODE_INPUTCAPTURE; - - PRS->CH[0].CTRL = PRS_CH_CTRL_SOURCESEL_GPIOH + + // The producer is the PGIO12 + PRS->CH[0].CTRL = PRS_CH_CTRL_SOURCESEL_GPIOH | PRS_CH_CTRL_SIGSEL_GPIOPIN12; //Configured for timeout TIMER1->CC[0].CTRL = TIMER_CC_CTRL_MODE_OUTPUTCOMPARE; @@ -509,24 +507,23 @@ void HighResolutionTimerBase::setModeTransceiverTimer(bool input){ if(input){ //For input capture feature: //Connect TIMER2->CC0 to pin PA8 aka excChB - TIMER2->ROUTE |= TIMER_ROUTE_CC0PEN - | TIMER_ROUTE_LOCATION_LOC0; - - //Configuro la modalità input - TIMER2->CC[0].CTRL = TIMER_CC_CTRL_MODE_INPUTCAPTURE | - TIMER_CC_CTRL_ICEDGE_RISING | - TIMER_CC_CTRL_INSEL_PIN; +// TIMER2->ROUTE |= TIMER_ROUTE_CC0PEN +// | TIMER_ROUTE_LOCATION_LOC0; //Config PRS: Timer3 has to be a consumer, Timer2 a producer, TIMER3 keeps the most significative part //TIMER2->CC0 as producer, i have to specify the event i'm interest in - PRS->CH[1].CTRL|= PRS_CH_CTRL_SOURCESEL_TIMER2 - | PRS_CH_CTRL_SIGSEL_TIMER2CC0; + PRS->CH[1].CTRL|= PRS_CH_CTRL_SOURCESEL_GPIOH + | PRS_CH_CTRL_SIGSEL_GPIOPIN8; //TIMER3->CC2 as consumer TIMER3->CC[0].CTRL=TIMER_CC_CTRL_PRSSEL_PRSCH1 | TIMER_CC_CTRL_INSEL_PRS | TIMER_CC_CTRL_ICEDGE_RISING | TIMER_CC_CTRL_MODE_INPUTCAPTURE; + TIMER2->CC[0].CTRL=TIMER_CC_CTRL_PRSSEL_PRSCH1 + | TIMER_CC_CTRL_INSEL_PRS + | TIMER_CC_CTRL_ICEDGE_RISING + | TIMER_CC_CTRL_MODE_INPUTCAPTURE; TIMER2->CC[1].CTRL = TIMER_CC_CTRL_MODE_OUTPUTCOMPARE; TIMER2->ROUTE &= ~TIMER_ROUTE_CC1PEN; //used as timeout the incoming event diff --git a/miosix/arch/cortexM3_efm32gg/efm32gg332f1024_wandstem/interfaces-impl/transceiver_timer.cpp b/miosix/arch/cortexM3_efm32gg/efm32gg332f1024_wandstem/interfaces-impl/transceiver_timer.cpp index 57c2dbb8..51d160fd 100644 --- a/miosix/arch/cortexM3_efm32gg/efm32gg332f1024_wandstem/interfaces-impl/transceiver_timer.cpp +++ b/miosix/arch/cortexM3_efm32gg/efm32gg332f1024_wandstem/interfaces-impl/transceiver_timer.cpp @@ -26,6 +26,7 @@ ***************************************************************************/ #include "transceiver_timer.h" +#include "gpioirq.h" using namespace miosix; @@ -109,9 +110,11 @@ long long TransceiverTimer::getExtEventTimestamp() const{ return b.IRQgetSetTimeTransceiver()-stabilizingTime; } -const int TransceiverTimer::stabilizingTime=7; +const int TransceiverTimer::stabilizingTime=6; -TransceiverTimer::TransceiverTimer():b(HighResolutionTimerBase::instance()),tc(b.getTimerFrequency()) {} +TransceiverTimer::TransceiverTimer():b(HighResolutionTimerBase::instance()),tc(b.getTimerFrequency()) { + registerGpioIrq(transceiver::excChB::getPin(),GpioIrqEdge::RISING,[](){}); +} TransceiverTimer& TransceiverTimer::instance(){ static TransceiverTimer instance; -- GitLab