Skip to content
Snippets Groups Projects
Commit 00367e2e authored by Fabiano Riccardi's avatar Fabiano Riccardi Committed by Federico
Browse files

Improved the test suite for timers, solve the bug for tranceiver timer

parent b2562264
Branches
No related tags found
2 merge requests!40Update to Miosix 2.7,!17Draft: Improved miosix build system and fixed cmake scripts
......@@ -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;
......
......@@ -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,7 +480,7 @@ void HighResolutionTimerBase::setModeGPIOTimer(bool input){
| TIMER_ROUTE_LOCATION_LOC1;
if(input){
//Configuro la modalità input
//Configuro la modalità input
//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?
......@@ -493,6 +490,7 @@ void HighResolutionTimerBase::setModeGPIOTimer(bool input){
| TIMER_CC_CTRL_ICEDGE_RISING //NOTE: when does the output get low?
| TIMER_CC_CTRL_MODE_INPUTCAPTURE;
// The producer is the PGIO12
PRS->CH[0].CTRL = PRS_CH_CTRL_SOURCESEL_GPIOH
| PRS_CH_CTRL_SIGSEL_GPIOPIN12;
//Configured for timeout
......@@ -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
......
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment