From 3f6bcdd3ecb5ea4e6b7772072393dbdd5f8507ae Mon Sep 17 00:00:00 2001 From: Fabiano Riccardi <fabiuz4@hotmail.it> Date: Fri, 28 Oct 2016 14:10:40 +0200 Subject: [PATCH] SendAt(...) is working Signed-off-by: Fabiano Riccardi <fabiuz4@hotmail.it> --- .../high_resolution_timer_base.cpp | 22 +++++++++++++------ .../interfaces-impl/transceiver.cpp | 2 +- .../interfaces-impl/transceiver_timer.cpp | 1 - 3 files changed, 16 insertions(+), 9 deletions(-) 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 03ead2d2..d7356a4f 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 @@ -191,14 +191,24 @@ void __attribute__((used)) cstirqhnd2(){ } 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; - - 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); - interruptTransceiverTimerRoutine(); + if(faseTransceiver==0){ + //get nextInterrupt + long long t=ms32chkp[0]|TIMER2->CC[1].CCV; + long long diff=t-IRQgetTick(); + if(diff<=0xFFFF){ + TIMER2->CC[1].CTRL = (TIMER2->CC[1].CTRL & ~_TIMER_CC_CTRL_CMOA_MASK) | TIMER_CC_CTRL_CMOA_SET; + faseTransceiver=1; + } + }else{ + TIMER2->IEN &= ~TIMER_IEN_CC1; + 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); + interruptTransceiverTimerRoutine(); + } } } @@ -413,8 +423,6 @@ void HighResolutionTimerBase::cleanBufferGPIO(){ } void HighResolutionTimerBase::setModeTransceiverTimer(){ - - //For input capture feature: //Connect TIMER2->CC0 to pin PA8 TIMER2->ROUTE |= TIMER_ROUTE_CC0PEN diff --git a/miosix/arch/cortexM3_efm32gg/efm32gg332f1024_wandstem/interfaces-impl/transceiver.cpp b/miosix/arch/cortexM3_efm32gg/efm32gg332f1024_wandstem/interfaces-impl/transceiver.cpp index 8bac61bc..cbead997 100644 --- a/miosix/arch/cortexM3_efm32gg/efm32gg332f1024_wandstem/interfaces-impl/transceiver.cpp +++ b/miosix/arch/cortexM3_efm32gg/efm32gg332f1024_wandstem/interfaces-impl/transceiver.cpp @@ -298,7 +298,7 @@ void Transceiver::sendAt(const void* pkt, int size, long long when) //while the cc2520 requires the turnaround from STXON to sending if(timer.absoluteWaitTrigger(when-timer.ns2tick(turnaround))==true) { - //See diagram on page 69 of datasheet + //See diagram on page 69 of datasheet commandStrobe(CC2520Command::SFLUSHTX); throw runtime_error("Transceiver::sendAt too late to send"); } 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 d0c77f4b..4cb85a0b 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 @@ -55,7 +55,6 @@ bool TransceiverTimer::absoluteWaitTimeoutOrEvent(long long tick){ return true; } - b.enableCC0Interrupt(false); b.enableCC0InterruptTim2(true); do { -- GitLab