From 829210e7e7c4c2927fb9aa8cf18ba8aff04150b8 Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Wed, 13 Dec 2017 17:43:00 +0100 Subject: [PATCH] adapt for RIOT --- src/mac/LoRaMac.c | 28 +++++++++++----------------- src/mac/LoRaMac.h | 4 +++- src/mac/region/Region.c | 2 +- src/mac/region/RegionAS923.c | 2 +- src/mac/region/RegionAU915.c | 2 +- src/mac/region/RegionCN470.c | 2 +- src/mac/region/RegionCN779.c | 2 +- src/mac/region/RegionCommon.c | 2 +- src/mac/region/RegionEU433.c | 2 +- src/mac/region/RegionEU868.c | 2 +- src/mac/region/RegionIN865.c | 2 +- src/mac/region/RegionKR920.c | 2 +- src/mac/region/RegionUS915-Hybrid.c | 2 +- src/mac/region/RegionUS915.c | 2 +- 14 files changed, 26 insertions(+), 30 deletions(-) diff --git a/src/mac/LoRaMac.c b/src/mac/LoRaMac.c index 0750ee5..3b9dbdf 100644 --- a/src/mac/LoRaMac.c +++ b/src/mac/LoRaMac.c @@ -17,7 +17,8 @@ License: Revised BSD License, see LICENSE.TXT file include in the project Maintainer: Miguel Luis ( Semtech ), Gregory Cristian ( Semtech ) and Daniel Jaeckle ( STACKFORCE ) */ -#include "board.h" +#include "semtech-loramac/board.h" +#include "utilities.h" #include "LoRaMac.h" #include "region/Region.h" @@ -316,11 +317,6 @@ static LoRaMacPrimitives_t *LoRaMacPrimitives; static LoRaMacCallback_t *LoRaMacCallbacks; /*! - * Radio events function pointer - */ -static RadioEvents_t RadioEvents; - -/*! * LoRaMac duty cycle delayed Tx timer */ static TimerEvent_t TxDelayedTimer; @@ -687,8 +683,7 @@ static void PrepareRxDoneAbort( void ) LoRaMacFlags.Bits.MacDone = 1; // Trig OnMacCheckTimerEvent call as soon as possible - TimerSetValue( &MacStateCheckTimer, 1 ); - TimerStart( &MacStateCheckTimer ); + OnMacStateCheckTimerEvent(); } static void OnRadioRxDone( uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr ) @@ -1106,8 +1101,7 @@ static void OnRadioRxDone( uint8_t *payload, uint16_t size, int16_t rssi, int8_t LoRaMacFlags.Bits.MacDone = 1; // Trig OnMacCheckTimerEvent call as soon as possible - TimerSetValue( &MacStateCheckTimer, 1 ); - TimerStart( &MacStateCheckTimer ); + OnMacStateCheckTimerEvent(); } static void OnRadioTxTimeout( void ) @@ -2285,7 +2279,7 @@ LoRaMacStatus_t SetTxContinuousWave1( uint16_t timeout, uint32_t frequency, uint return LORAMAC_STATUS_OK; } -LoRaMacStatus_t LoRaMacInitialization( LoRaMacPrimitives_t *primitives, LoRaMacCallback_t *callbacks, LoRaMacRegion_t region ) +LoRaMacStatus_t LoRaMacInitialization( RadioEvents_t *radio_events, LoRaMacPrimitives_t *primitives, LoRaMacCallback_t *callbacks, LoRaMacRegion_t region ) { GetPhyParams_t getPhy; PhyParam_t phyParam; @@ -2416,12 +2410,12 @@ LoRaMacStatus_t LoRaMacInitialization( LoRaMacPrimitives_t *primitives, LoRaMacC LoRaMacInitializationTime = TimerGetCurrentTime( ); // Initialize Radio driver - RadioEvents.TxDone = OnRadioTxDone; - RadioEvents.RxDone = OnRadioRxDone; - RadioEvents.RxError = OnRadioRxError; - RadioEvents.TxTimeout = OnRadioTxTimeout; - RadioEvents.RxTimeout = OnRadioRxTimeout; - Radio.Init( &RadioEvents ); + radio_events->TxDone = OnRadioTxDone; + radio_events->RxDone = OnRadioRxDone; + radio_events->RxError = OnRadioRxError; + radio_events->TxTimeout = OnRadioTxTimeout; + radio_events->RxTimeout = OnRadioRxTimeout; + Radio.Init( radio_events ); // Random seed initialization srand1( Radio.Random( ) ); diff --git a/src/mac/LoRaMac.h b/src/mac/LoRaMac.h index 8e479d2..dde8712 100644 --- a/src/mac/LoRaMac.h +++ b/src/mac/LoRaMac.h @@ -82,6 +82,8 @@ #ifndef __LORAMAC_H__ #define __LORAMAC_H__ +#include "radio/radio.h" + /*! * Check the Mac layer state every MAC_STATE_CHECK_TIMEOUT in ms */ @@ -1728,7 +1730,7 @@ static const uint8_t LoRaMacMaxEirpTable[] = { 8, 10, 12, 13, 14, 16, 18, 20, 21 * \ref LORAMAC_STATUS_PARAMETER_INVALID, * \ref LORAMAC_STATUS_REGION_NOT_SUPPORTED. */ -LoRaMacStatus_t LoRaMacInitialization( LoRaMacPrimitives_t *primitives, LoRaMacCallback_t *callbacks, LoRaMacRegion_t region ); +LoRaMacStatus_t LoRaMacInitialization( RadioEvents_t *RadioEvents, LoRaMacPrimitives_t *primitives, LoRaMacCallback_t *callbacks, LoRaMacRegion_t region ); /*! * \brief Queries the LoRaMAC if it is possible to send the next frame with diff --git a/src/mac/region/Region.c b/src/mac/region/Region.c index 1d0be81..f6ce9f5 100644 --- a/src/mac/region/Region.c +++ b/src/mac/region/Region.c @@ -21,7 +21,7 @@ Maintainer: Miguel Luis ( Semtech ), Gregory Cristian ( Semtech ) and Daniel Jae #include #include -#include "timer.h" +#include "semtech-loramac/timer.h" #include "LoRaMac.h" diff --git a/src/mac/region/RegionAS923.c b/src/mac/region/RegionAS923.c index 2677d0c..8312b46 100644 --- a/src/mac/region/RegionAS923.c +++ b/src/mac/region/RegionAS923.c @@ -22,7 +22,7 @@ Maintainer: Miguel Luis ( Semtech ), Gregory Cristian ( Semtech ) and Daniel Jae #include #include -#include "board.h" +#include "semtech-loramac/board.h" #include "LoRaMac.h" #include "utilities.h" diff --git a/src/mac/region/RegionAU915.c b/src/mac/region/RegionAU915.c index 4c8fc33..6b3817b 100644 --- a/src/mac/region/RegionAU915.c +++ b/src/mac/region/RegionAU915.c @@ -22,7 +22,7 @@ Maintainer: Miguel Luis ( Semtech ), Gregory Cristian ( Semtech ) and Daniel Jae #include #include -#include "board.h" +#include "semtech-loramac/board.h" #include "LoRaMac.h" #include "utilities.h" diff --git a/src/mac/region/RegionCN470.c b/src/mac/region/RegionCN470.c index dbbc745..2daddc9 100644 --- a/src/mac/region/RegionCN470.c +++ b/src/mac/region/RegionCN470.c @@ -22,7 +22,7 @@ Maintainer: Miguel Luis ( Semtech ), Gregory Cristian ( Semtech ) and Daniel Jae #include #include -#include "board.h" +#include "semtech-loramac/board.h" #include "LoRaMac.h" #include "utilities.h" diff --git a/src/mac/region/RegionCN779.c b/src/mac/region/RegionCN779.c index c5d9b7b..5c55ffd 100644 --- a/src/mac/region/RegionCN779.c +++ b/src/mac/region/RegionCN779.c @@ -22,7 +22,7 @@ Maintainer: Miguel Luis ( Semtech ), Gregory Cristian ( Semtech ) and Daniel Jae #include #include -#include "board.h" +#include "semtech-loramac/board.h" #include "LoRaMac.h" #include "utilities.h" diff --git a/src/mac/region/RegionCommon.c b/src/mac/region/RegionCommon.c index fb0b139..53e1e6c 100644 --- a/src/mac/region/RegionCommon.c +++ b/src/mac/region/RegionCommon.c @@ -23,7 +23,7 @@ Maintainer: Miguel Luis ( Semtech ), Gregory Cristian ( Semtech ) and Daniel Jae #include #include -#include "timer.h" +#include "semtech-loramac/timer.h" #include "utilities.h" #include "LoRaMac.h" #include "RegionCommon.h" diff --git a/src/mac/region/RegionEU433.c b/src/mac/region/RegionEU433.c index 5446c51..ca0fa9f 100644 --- a/src/mac/region/RegionEU433.c +++ b/src/mac/region/RegionEU433.c @@ -22,7 +22,7 @@ Maintainer: Miguel Luis ( Semtech ), Gregory Cristian ( Semtech ) and Daniel Jae #include #include -#include "board.h" +#include "semtech-loramac/board.h" #include "LoRaMac.h" #include "utilities.h" diff --git a/src/mac/region/RegionEU868.c b/src/mac/region/RegionEU868.c index f4385a5..3a27f42 100644 --- a/src/mac/region/RegionEU868.c +++ b/src/mac/region/RegionEU868.c @@ -22,7 +22,7 @@ Maintainer: Miguel Luis ( Semtech ), Gregory Cristian ( Semtech ) and Daniel Jae #include #include -#include "board.h" +#include "semtech-loramac/board.h" #include "LoRaMac.h" #include "utilities.h" diff --git a/src/mac/region/RegionIN865.c b/src/mac/region/RegionIN865.c index 75e2a4b..4770050 100644 --- a/src/mac/region/RegionIN865.c +++ b/src/mac/region/RegionIN865.c @@ -22,7 +22,7 @@ Maintainer: Miguel Luis ( Semtech ), Gregory Cristian ( Semtech ) and Daniel Jae #include #include -#include "board.h" +#include "semtech-loramac/board.h" #include "LoRaMac.h" #include "utilities.h" diff --git a/src/mac/region/RegionKR920.c b/src/mac/region/RegionKR920.c index eda6652..ca689d6 100644 --- a/src/mac/region/RegionKR920.c +++ b/src/mac/region/RegionKR920.c @@ -22,7 +22,7 @@ Maintainer: Miguel Luis ( Semtech ), Gregory Cristian ( Semtech ) and Daniel Jae #include #include -#include "board.h" +#include "semtech-loramac/board.h" #include "LoRaMac.h" #include "utilities.h" diff --git a/src/mac/region/RegionUS915-Hybrid.c b/src/mac/region/RegionUS915-Hybrid.c index 426e40d..3a3d085 100644 --- a/src/mac/region/RegionUS915-Hybrid.c +++ b/src/mac/region/RegionUS915-Hybrid.c @@ -22,7 +22,7 @@ Maintainer: Miguel Luis ( Semtech ), Gregory Cristian ( Semtech ) and Daniel Jae #include #include -#include "board.h" +#include "semtech-loramac/board.h" #include "LoRaMac.h" #include "utilities.h" diff --git a/src/mac/region/RegionUS915.c b/src/mac/region/RegionUS915.c index 8aa788a..97c3785 100644 --- a/src/mac/region/RegionUS915.c +++ b/src/mac/region/RegionUS915.c @@ -22,7 +22,7 @@ Maintainer: Miguel Luis ( Semtech ), Gregory Cristian ( Semtech ) and Daniel Jae #include #include -#include "board.h" +#include "semtech-loramac/board.h" #include "LoRaMac.h" #include "utilities.h" -- 2.11.0