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 54142ecaadb5e7d84de40e91ceefd6d0293069b3..0291fd6f29348373961d9a90fcc18d2ec303a378 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 @@ -17,7 +17,7 @@ #include "high_resolution_timer_base.h" #include "kernel/timeconversion.h" #include "gpio_timer.h" -#include "radio_timer.h" +#include "transceiver_timer.h" #include "../../../../debugpin.h" using namespace miosix; @@ -32,7 +32,7 @@ static long long ms32chkp[3] = {0,0,0}; //most significant 32 bits of check poin static TimeConversion* tc; static int faseGPIO=0; -static int faseRadio=0; +static int faseTransceiver=0; static inline unsigned int IRQread32Timer(){ unsigned int high=TIMER3->CNT; @@ -83,18 +83,18 @@ inline void interruptGPIOTimerRoutine(){ } -inline void interruptRadioTimerRoutine(){ +inline void interruptTransceiverTimerRoutine(){ if(TIMER2->CC[1].CTRL & TIMER_CC_CTRL_MODE_OUTPUTCOMPARE){ TIMER2->CC[1].CTRL = (TIMER2->CC[1].CTRL & ~_TIMER_CC_CTRL_CMOA_MASK) | TIMER_CC_CTRL_CMOA_CLEAR; TIMER2->CC[1].CCV = static_cast<unsigned short>(TIMER2->CNT+10);//static_cast<unsigned int>(tick & 0xFFFF); } //Reactivating the thread that is waiting for the event. - if(RadioTimer::tWaiting){ - RadioTimer::tWaiting->IRQwakeup(); - if(RadioTimer::tWaiting->IRQgetPriority() > Thread::IRQgetCurrentThread()->IRQgetPriority()) + if(TransceiverTimer::tWaiting){ + TransceiverTimer::tWaiting->IRQwakeup(); + if(TransceiverTimer::tWaiting->IRQgetPriority() > Thread::IRQgetCurrentThread()->IRQgetPriority()) Scheduler::IRQfindNextThread(); - RadioTimer::tWaiting=nullptr; + TransceiverTimer::tWaiting=nullptr; } } @@ -183,13 +183,13 @@ void __attribute__((used)) cstirqhnd2(){ if ((TIMER2->IEN & TIMER_IEN_CC0) && (TIMER2->IF & TIMER_IF_CC0) ){ TIMER2->IEN &= ~ TIMER_IEN_CC0; TIMER2->IFC = TIMER_IFC_CC0; - interruptRadioTimerRoutine(); + interruptTransceiverTimerRoutine(); } //CC1 for output/trigger the sending packet event if ((TIMER2->IEN & TIMER_IEN_CC1) && (TIMER2->IF & TIMER_IF_CC1) ){ TIMER2->IEN &= ~ TIMER_IEN_CC1; TIMER2->IFC = TIMER_IFC_CC1; - interruptRadioTimerRoutine(); + interruptTransceiverTimerRoutine(); } } @@ -206,9 +206,7 @@ void __attribute__((used)) cstirqhnd1(){ //This if is used to manage the case of GPIOTimer, both INPUT and OUTPUT mode, in INPUT it goes direclty in the "else branch" if ((TIMER1->IEN & TIMER_IEN_CC2) && (TIMER1->IF & TIMER_IF_CC2)){ TIMER1->IFC = TIMER_IFC_CC2; - greenLed::toggle(); if(faseGPIO==0){ - //get nextInterrupt long long t=ms32chkp[2]|TIMER1->CC[2].CCV; long long diff=t-IRQgetTick(); @@ -284,14 +282,14 @@ long long HighResolutionTimerBase::getCurrentTick(){ } -WaitResult HighResolutionTimerBase::IRQsetNextRadioInterrupt(long long tick){ +WaitResult HighResolutionTimerBase::IRQsetNextTransceiverInterrupt(long long tick){ long long curTick = IRQgetTick(); // This require almost 1us about 50ticks long long diff=tick-curTick; // 150 are enough to make sure that this routine ends and the timer IEN is enabled. //NOTE: this is really dependent on compiler, optimization and other stuff if(diff>150){ - faseRadio=0; + faseTransceiver=0; unsigned short t1=static_cast<unsigned short>((tick & 0xFFFF)-1); //ms32chkp[0] is going to store even the middle part, because we don't need to use TIMER3 ms32chkp[0] = tick & (upperMask | 0xFFFF0000); @@ -302,7 +300,7 @@ WaitResult HighResolutionTimerBase::IRQsetNextRadioInterrupt(long long tick){ //0xFFFF because it's the roundtrip of timer if(diff<=0xFFFF){ TIMER2->CC[1].CTRL = (TIMER2->CC[1].CTRL & ~_TIMER_CC_CTRL_CMOA_MASK) | TIMER_CC_CTRL_CMOA_SET; - faseRadio=1; //if phase=1, this means that we have to shutdown the pin next time that TIMER1 triggers + faseTransceiver=1; //if phase=1, this means that we have to shutdown the pin next time that TIMER1 triggers } return WaitResult::WAITING; }else{ @@ -397,7 +395,7 @@ void HighResolutionTimerBase::cleanBufferGPIO(){ falseRead(&TIMER1->CC[2].CCV); } -void HighResolutionTimerBase::setModeRadioTimer(bool input){ +void HighResolutionTimerBase::setModeTransceiverTimer(bool input){ //Connect TIMER2->CC0/1 to pin PA8 and PA9 TIMER2->ROUTE = TIMER_ROUTE_CC0PEN | TIMER_ROUTE_CC1PEN diff --git a/miosix/arch/cortexM3_efm32gg/efm32gg332f1024_wandstem/interfaces-impl/high_resolution_timer_base.h b/miosix/arch/cortexM3_efm32gg/efm32gg332f1024_wandstem/interfaces-impl/high_resolution_timer_base.h index 0e511496790dac2c5bc269729c8ba7056ce10a25..4ae549c6adaa5d305f3e915c8477cf30dee62bf3 100644 --- a/miosix/arch/cortexM3_efm32gg/efm32gg332f1024_wandstem/interfaces-impl/high_resolution_timer_base.h +++ b/miosix/arch/cortexM3_efm32gg/efm32gg332f1024_wandstem/interfaces-impl/high_resolution_timer_base.h @@ -43,7 +43,7 @@ public: * Can be called with interrupts disabled or within an interrupt. * \param tick the time when the interrupt will be fired, in timer ticks */ - WaitResult IRQsetNextRadioInterrupt(long long tick); + WaitResult IRQsetNextTransceiverInterrupt(long long tick); void IRQsetNextInterrupt1(long long tick); WaitResult IRQsetNextGPIOInterrupt(long long tick); @@ -78,7 +78,7 @@ public: void setCCInterrupt2Tim1(bool enable); void setCCInterrupt0Tim2(bool enable); void setModeGPIOTimer(bool input); - void setModeRadioTimer(bool input); + void setModeTransceiverTimer(bool input); virtual ~HighResolutionTimerBase(); diff --git a/miosix/arch/cortexM3_efm32gg/efm32gg332f1024_wandstem/interfaces-impl/transceiver.h b/miosix/arch/cortexM3_efm32gg/efm32gg332f1024_wandstem/interfaces-impl/transceiver.h index a77bafea4ae61781e120707ff68d0d54fc687d3e..a6a7c2f1f652b4c3e3d4d84888095c77a36f4014 100644 --- a/miosix/arch/cortexM3_efm32gg/efm32gg332f1024_wandstem/interfaces-impl/transceiver.h +++ b/miosix/arch/cortexM3_efm32gg/efm32gg332f1024_wandstem/interfaces-impl/transceiver.h @@ -118,7 +118,7 @@ public: static Transceiver& instance(); /** - * Turn the thransceiver ON (i.e: bring it out of deep sleep) + * Turn the transceiver ON (i.e: bring it out of deep sleep) */ void turnOn(); diff --git a/miosix/arch/cortexM3_efm32gg/efm32gg332f1024_wandstem/interfaces-impl/radio_timer.cpp b/miosix/arch/cortexM3_efm32gg/efm32gg332f1024_wandstem/interfaces-impl/transceiver_timer.cpp similarity index 59% rename from miosix/arch/cortexM3_efm32gg/efm32gg332f1024_wandstem/interfaces-impl/radio_timer.cpp rename to miosix/arch/cortexM3_efm32gg/efm32gg332f1024_wandstem/interfaces-impl/transceiver_timer.cpp index ed7245f058067a2d260603a028b1d50ef2367df1..f4e5c4d32f7fbf80d50129e0bef495e19e5b6572 100644 --- a/miosix/arch/cortexM3_efm32gg/efm32gg332f1024_wandstem/interfaces-impl/radio_timer.cpp +++ b/miosix/arch/cortexM3_efm32gg/efm32gg332f1024_wandstem/interfaces-impl/transceiver_timer.cpp @@ -11,21 +11,21 @@ * Created on October 11, 2016, 11:17 AM */ -#include "radio_timer.h" +#include "transceiver_timer.h" using namespace miosix; -Thread* RadioTimer::tWaiting=nullptr; +Thread* TransceiverTimer::tWaiting=nullptr; -long long RadioTimer::getValue() const{ +long long TransceiverTimer::getValue() const{ return b.getCurrentTick(); } -void RadioTimer::wait(long long tick){ +void TransceiverTimer::wait(long long tick){ Thread::nanoSleep(tc.tick2ns(tick)); } -bool RadioTimer::absoluteWait(long long tick){ +bool TransceiverTimer::absoluteWait(long long tick){ if(b.getCurrentTick()>=tick){ return true; } @@ -33,10 +33,10 @@ bool RadioTimer::absoluteWait(long long tick){ return false; } -bool RadioTimer::absoluteWaitTrigger(long long tick){ +bool TransceiverTimer::absoluteWaitTrigger(long long tick){ FastInterruptDisableLock dLock; - b.setModeRadioTimer(false); //output timer - if(b.IRQsetNextRadioInterrupt(tick)==WaitResult::WAKEUP_IN_THE_PAST){ + b.setModeTransceiverTimer(false); //output timer + if(b.IRQsetNextTransceiverInterrupt(tick)==WaitResult::WAKEUP_IN_THE_PAST){ return true; } do { @@ -50,13 +50,13 @@ bool RadioTimer::absoluteWaitTrigger(long long tick){ return false; } -bool RadioTimer::absoluteWaitTimeoutOrEvent(long long tick){ +bool TransceiverTimer::absoluteWaitTimeoutOrEvent(long long tick){ FastInterruptDisableLock dLock; if(tick<b.getCurrentTick()){ return true; } - b.setModeRadioTimer(true); + b.setModeTransceiverTimer(true); b.setCCInterrupt0(false); b.setCCInterrupt0Tim2(true); do { @@ -75,29 +75,29 @@ bool RadioTimer::absoluteWaitTimeoutOrEvent(long long tick){ } } -long long RadioTimer::tick2ns(long long tick){ +long long TransceiverTimer::tick2ns(long long tick){ return tc.tick2ns(tick); } -long long RadioTimer::ns2tick(long long ns){ +long long TransceiverTimer::ns2tick(long long ns){ return tc.ns2tick(ns); } -unsigned int RadioTimer::getTickFrequency() const{ +unsigned int TransceiverTimer::getTickFrequency() const{ return b.getTimerFrequency(); } -long long RadioTimer::getExtEventTimestamp() const{ +long long TransceiverTimer::getExtEventTimestamp() const{ return b.IRQgetSetTimeCCV0(); } -RadioTimer::RadioTimer():b(HighResolutionTimerBase::instance()),tc(b.getTimerFrequency()) {} +TransceiverTimer::TransceiverTimer():b(HighResolutionTimerBase::instance()),tc(b.getTimerFrequency()) {} -RadioTimer& RadioTimer::instance(){ - static RadioTimer instance; +TransceiverTimer& TransceiverTimer::instance(){ + static TransceiverTimer instance; return instance; } -RadioTimer::~RadioTimer() {} +TransceiverTimer::~TransceiverTimer() {} diff --git a/miosix/arch/cortexM3_efm32gg/efm32gg332f1024_wandstem/interfaces-impl/radio_timer.h b/miosix/arch/cortexM3_efm32gg/efm32gg332f1024_wandstem/interfaces-impl/transceiver_timer.h similarity index 88% rename from miosix/arch/cortexM3_efm32gg/efm32gg332f1024_wandstem/interfaces-impl/radio_timer.h rename to miosix/arch/cortexM3_efm32gg/efm32gg332f1024_wandstem/interfaces-impl/transceiver_timer.h index 000bfd2b392e21cd267407913e3c12a99ea90d10..f1e9ea61105af9f64d826bc4c8b15b9182fd5755 100644 --- a/miosix/arch/cortexM3_efm32gg/efm32gg332f1024_wandstem/interfaces-impl/radio_timer.h +++ b/miosix/arch/cortexM3_efm32gg/efm32gg332f1024_wandstem/interfaces-impl/transceiver_timer.h @@ -18,13 +18,13 @@ #define RADIO_TIMER_H namespace miosix{ - class RadioTimer : public HardwareTimer { + class TransceiverTimer : public HardwareTimer { public: //transceiver::excChB //usato per la ricezione INPUT_CAPTURE TIM2_CC0 PA8 //transceiver::stxon //usato per attivare la trasmissione OUTPUTCOMPARE TIM2_CC1 PA9 static Thread *tWaiting; - static RadioTimer& instance(); - virtual ~RadioTimer(); + static TransceiverTimer& instance(); + virtual ~TransceiverTimer(); long long getValue() const; @@ -45,7 +45,7 @@ namespace miosix{ private: - RadioTimer(); + TransceiverTimer(); HighResolutionTimerBase& b; TimeConversion tc; };