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 910070148de72718bae35093014d2be7b6119678..ab4fdbe8ebf022cbe23d19de1bed2921a0c9d937 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 @@ -58,7 +58,7 @@ bool GPIOtimer::absoluteWait(long long tick){ //NOTE: Think about how to set the right ms32chkp related to the captured timestamp long long GPIOtimer::getExtEventTimestamp() const{ - return b.IRQgetSetTimeGPIO(); + return b.IRQgetSetTimeGPIO() - stabilizingTime; } bool GPIOtimer::absoluteWaitTimeoutOrEvent(long long tick){ @@ -162,6 +162,8 @@ GPIOtimer& GPIOtimer::instance(){ return instance; } +const int GPIOtimer::stabilizingTime = 4; + GPIOtimer::GPIOtimer(): b(HighResolutionTimerBase::instance()),tc(b.getTimerFrequency()) { b.setModeGPIOTimer(true); expansion::gpio10::mode(Mode::INPUT); diff --git a/miosix/arch/cortexM3_efm32gg/efm32gg332f1024_wandstem/interfaces-impl/gpio_timer.h b/miosix/arch/cortexM3_efm32gg/efm32gg332f1024_wandstem/interfaces-impl/gpio_timer.h index 95d62455b31805af54bf3caa6584c917c2cb31f3..9a42827416ad789e8a843cfd6992134936fac82f 100644 --- a/miosix/arch/cortexM3_efm32gg/efm32gg332f1024_wandstem/interfaces-impl/gpio_timer.h +++ b/miosix/arch/cortexM3_efm32gg/efm32gg332f1024_wandstem/interfaces-impl/gpio_timer.h @@ -78,6 +78,7 @@ namespace miosix { HighResolutionTimerBase& b; bool isInput; TimeConversion tc; + static const int stabilizingTime; }; } 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 cbead9978158f4708b619199e9ac5714ff1e7af6..72426b1c58306c2531e2edb1e2e6a08abd5677da 100644 --- a/miosix/arch/cortexM3_efm32gg/efm32gg332f1024_wandstem/interfaces-impl/transceiver.cpp +++ b/miosix/arch/cortexM3_efm32gg/efm32gg332f1024_wandstem/interfaces-impl/transceiver.cpp @@ -68,6 +68,9 @@ const auto slack=128000; /// Measured STXON to SFD_TX delay (turnaround+preambleSfdTime) is 352.370us const auto turnaround=192370; +/// Measured SFD_TX to SFD_RX delay +const auto rxSfdLag=3374; + /// Time to send one byte as float const auto timePerByte=32000; @@ -337,7 +340,8 @@ RecvResult Transceiver::recv(void *pkt, int size, long long timeout) if(inFifo>=lengthByte+1) { //Timestamp is wrong and we know it, so we don't set valid - result.timestamp=timer.getExtEventTimestamp()-timer.ns2tick(preambleSfdTime); + result.timestamp=timer.getExtEventTimestamp()- + timer.ns2tick(preambleSfdTime+rxSfdLag); //We may still be in the middle of another packet reception, so //this may cause FRM_DONE to occur without a previous SFD, @@ -559,7 +563,8 @@ bool Transceiver::handlePacketReceptionEvents(long long timeout, int size, RecvR } //NOTE: the returned timestamp is the time where the first byte of the //packet is received, while the cc2520 allows timestamping at the SFD - result.timestamp=timer.getExtEventTimestamp()-timer.ns2tick(preambleSfdTime); + result.timestamp=timer.getExtEventTimestamp()- + timer.ns2tick(preambleSfdTime+rxSfdLag); unsigned int exc=getExceptions(0b011); if(exc & CC2520Exception::RX_OVERFLOW) 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 3cff537e9db10019fcff0601d2608b8a22e01a16..65508e18a2725b8d7af3e004743af55522f82899 100644 --- a/miosix/arch/cortexM3_efm32gg/efm32gg332f1024_wandstem/interfaces-impl/transceiver.h +++ b/miosix/arch/cortexM3_efm32gg/efm32gg332f1024_wandstem/interfaces-impl/transceiver.h @@ -149,7 +149,7 @@ public: * This function is meant to be called after sending or receiving data to * make sure the transceiver is set to the idle state to save some power. * Its use is not required for the operation of the transceiver, and if not - * used the transceiver may reamin in receive mode more than necessary. + * used the transceiver may remain in receive mode more than necessary. */ void idle(); 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 3e113111e91c08f36914b6e8fc132a4ef2a31290..59feaf8236cb97cb286c628fe11e96d230a4a181 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 @@ -105,9 +105,11 @@ unsigned int TransceiverTimer::getTickFrequency() const{ long long TransceiverTimer::getExtEventTimestamp() const{ - return b.IRQgetSetTimeTransceiver(); + return b.IRQgetSetTimeTransceiver()-stabilizingTime; } - + +const int TransceiverTimer::stabilizingTime=7; + TransceiverTimer::TransceiverTimer():b(HighResolutionTimerBase::instance()),tc(b.getTimerFrequency()) { b.setModeTransceiverTimer(); } diff --git a/miosix/arch/cortexM3_efm32gg/efm32gg332f1024_wandstem/interfaces-impl/transceiver_timer.h b/miosix/arch/cortexM3_efm32gg/efm32gg332f1024_wandstem/interfaces-impl/transceiver_timer.h index 556e8ba775d04b75dd0991adb1c867fbf66776e1..87e405d2084a15f3aa71a4e82ad441bfe7bf7c11 100644 --- a/miosix/arch/cortexM3_efm32gg/efm32gg332f1024_wandstem/interfaces-impl/transceiver_timer.h +++ b/miosix/arch/cortexM3_efm32gg/efm32gg332f1024_wandstem/interfaces-impl/transceiver_timer.h @@ -62,6 +62,7 @@ namespace miosix{ TransceiverTimer(); HighResolutionTimerBase& b; TimeConversion tc; + static const int stabilizingTime; }; } //miosix namespace