Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: DISCO-L072CZ-LRWAN1_LoRa_PingPong
Fork of SX1276GenericLib by
Revision 39:706c32eda7e7, committed 2017-05-07
- Comitter:
- Helmut Tschemernjak
- Date:
- Sun May 07 20:26:02 2017 +0200
- Parent:
- 38:d9189d958db8
- Child:
- 40:0165543c0986
- Commit message:
- Further cleanup, removed enum.h which is not needed.
Changed in this revision
--- a/LoRa_TODO.txt Sun May 07 18:09:10 2017 +0200 +++ b/LoRa_TODO.txt Sun May 07 20:26:02 2017 +0200 @@ -1,32 +1,26 @@ -Tasks we needs to be done. (move finished tasks to Done: with you name & date) +Tasks we needs to be done. +Move finished tasks to Done section: + - Check of the MURATA TCXO config is correct - What needs to e done in the MURATA PA_BOOST case - Verify the Murata ANT Switch code. - Make the timers more generic and move the OS code into the HAL layer. - add support for Arduino - add sx1276-Arduino-hal.h/cpp - add support for Linux - add sx1276-Linux-hal.h/cpp - -- Migrate enum code into sx1276.h - - - - - - - - +- Add support for Cad detection before sending a packet +- Add support to provide the send/receive packet buffer, + no need to allocate packet data in the sx1276 driver. Can be provided + Rx/Tx parameters. +- Add support for larger Lora packets (can be up to 2048 bytes) + this feature is not so important, however the current implementation + is very basic. - - - - - - - + Done: -- Started a Generic SX1276 drive to support multiple SX1276 based modules (May-2017 Helmut Tsch) -- Migrated typedefs code into sx1276.h (7-May-2017 Helmut Tsch) +- Started a Generic SX1276 driver to support all SX1276 modules (May-2017 Helmut) +- Migrated typedefs code into sx1276.h (7-May-2017 Helmut) +- Migrated enum code into sx1276.h/radio.h (7-May-2017 Helmut)
--- a/enums/enums.h Sun May 07 18:09:10 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,139 +0,0 @@
-/*
- / _____) _ | |
-( (____ _____ ____ _| |_ _____ ____| |__
- \____ \| ___ | (_ _) ___ |/ ___) _ \
- _____) ) ____| | | || |_| ____( (___| | | |
-(______/|_____)_|_|_| \__)_____)\____)_| |_|
- (C) 2014 Semtech
-
-Description: -
-
-License: Revised BSD License, see LICENSE.TXT file include in the project
-
-Maintainers: Miguel Luis, Gregory Cristian and Nicolas Huguenin
-*/
-#ifndef __ENUMS_H__
-#define __ENUMS_H__
-
-/*!
- * Radio driver internal state machine states definition
- */
-typedef enum RadioState
-{
- RF_IDLE = 0,
- RF_RX_RUNNING,
- RF_TX_RUNNING,
- RF_CAD,
-}RadioState_t;
-
-/*!
- * Type of the modem. [LORA / FSK]
- */
-typedef enum ModemType
-{
- MODEM_FSK = 0,
- MODEM_LORA
-}RadioModems_t;
-
-/*!
- * Type of the supported board. [SX1276MB1MAS / SX1276MB1LAS]
- */
-typedef enum BoardType
-{
- SX1276MB1MAS = 0,
- SX1276MB1LAS,
- RFM95_SX1276,
- MURATA_SX1276,
- UNKNOWN
-}BoardType_t;
-
-/*!
- * Radio FSK modem parameters
- */
-typedef struct
-{
- int8_t Power;
- uint32_t Fdev;
- uint32_t Bandwidth;
- uint32_t BandwidthAfc;
- uint32_t Datarate;
- uint16_t PreambleLen;
- bool FixLen;
- uint8_t PayloadLen;
- bool CrcOn;
- bool IqInverted;
- bool RxContinuous;
- uint32_t TxTimeout;
- uint32_t RxSingleTimeout;
-}RadioFskSettings_t;
-
-/*!
- * Radio FSK packet handler state
- */
-typedef struct
-{
- uint8_t PreambleDetected;
- uint8_t SyncWordDetected;
- int8_t RssiValue;
- int32_t AfcValue;
- uint8_t RxGain;
- uint16_t Size;
- uint16_t NbBytes;
- uint8_t FifoThresh;
- uint8_t ChunkSize;
-}RadioFskPacketHandler_t;
-
-/*!
- * Radio LoRa modem parameters
- */
-typedef struct
-{
- int8_t Power;
- uint32_t Bandwidth;
- uint32_t Datarate;
- bool LowDatarateOptimize;
- uint8_t Coderate;
- uint16_t PreambleLen;
- bool FixLen;
- uint8_t PayloadLen;
- bool CrcOn;
- bool FreqHopOn;
- uint8_t HopPeriod;
- bool IqInverted;
- bool RxContinuous;
- uint32_t TxTimeout;
- bool PublicNetwork;
-}RadioLoRaSettings_t;
-
-/*!
- * Radio LoRa packet handler state
- */
-typedef struct
-{
- int8_t SnrValue;
- int8_t RssiValue;
- uint8_t Size;
- }RadioLoRaPacketHandler_t;
-
-/*!
- * Radio Settings
- */
-typedef struct
-{
- RadioState State;
- ModemType Modem;
- uint32_t Channel;
- RadioFskSettings_t Fsk;
- RadioFskPacketHandler_t FskPacketHandler;
- RadioLoRaSettings_t LoRa;
- RadioLoRaPacketHandler_t LoRaPacketHandler;
-}RadioSettings_t;
-
-typedef enum {
- RXTimeout,
- TXTimeout,
- RXTimeoutSyncWorld
-} Timeout_t;
-
-
-#endif //__ENUMS_H__
--- a/radio/radio.h Sun May 07 18:09:10 2017 +0200
+++ b/radio/radio.h Sun May 07 20:26:02 2017 +0200
@@ -17,7 +17,111 @@
#include "mbed.h"
-#include "./enums/enums.h"
+
+/*
+ !
+ * Radio driver internal state machine states definition
+ */
+typedef enum RadioState
+{
+ RF_IDLE = 0,
+ RF_RX_RUNNING,
+ RF_TX_RUNNING,
+ RF_CAD,
+}RadioState_t;
+
+
+/*!
+ * Type of the modem. [LORA / FSK]
+ */
+typedef enum ModemType
+{
+ MODEM_FSK = 0,
+ MODEM_LORA
+}RadioModems_t;
+
+
+/*!
+ * Radio LoRa modem parameters
+ */
+typedef struct
+{
+ int8_t Power;
+ uint32_t Bandwidth;
+ uint32_t Datarate;
+ bool LowDatarateOptimize;
+ uint8_t Coderate;
+ uint16_t PreambleLen;
+ bool FixLen;
+ uint8_t PayloadLen;
+ bool CrcOn;
+ bool FreqHopOn;
+ uint8_t HopPeriod;
+ bool IqInverted;
+ bool RxContinuous;
+ uint32_t TxTimeout;
+ bool PublicNetwork;
+}RadioLoRaSettings_t;
+
+/*!
+ * Radio FSK modem parameters
+ */
+typedef struct
+{
+ int8_t Power;
+ uint32_t Fdev;
+ uint32_t Bandwidth;
+ uint32_t BandwidthAfc;
+ uint32_t Datarate;
+ uint16_t PreambleLen;
+ bool FixLen;
+ uint8_t PayloadLen;
+ bool CrcOn;
+ bool IqInverted;
+ bool RxContinuous;
+ uint32_t TxTimeout;
+ uint32_t RxSingleTimeout;
+}RadioFskSettings_t;
+
+/*!
+ * Radio FSK packet handler state
+ */
+typedef struct
+{
+ uint8_t PreambleDetected;
+ uint8_t SyncWordDetected;
+ int8_t RssiValue;
+ int32_t AfcValue;
+ uint8_t RxGain;
+ uint16_t Size;
+ uint16_t NbBytes;
+ uint8_t FifoThresh;
+ uint8_t ChunkSize;
+}RadioFskPacketHandler_t;
+
+/*!
+ * Radio LoRa packet handler state
+ */
+typedef struct
+{
+ int8_t SnrValue;
+ int8_t RssiValue;
+ uint8_t Size;
+}RadioLoRaPacketHandler_t;
+
+/*!
+ * Radio Settings
+ */
+typedef struct
+{
+ RadioState State;
+ ModemType Modem;
+ uint32_t Channel;
+ RadioFskSettings_t Fsk;
+ RadioFskPacketHandler_t FskPacketHandler;
+ RadioLoRaSettings_t LoRa;
+ RadioLoRaPacketHandler_t LoRaPacketHandler;
+}RadioSettings_t;
/*!
* @brief Radio driver callback functions
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sx1276/sx1276-linux-hal.h Sun May 07 20:26:02 2017 +0200 @@ -0,0 +1,18 @@ + +/* + * This file contains a copy of the master content sx1276-mbed-hal.h + * with adaption for the Linux environment (PI or similar + * (c) 2017 Helmut Tschemernjak + * 30826 Garbsen (Hannover) Germany + */ +#ifdef __linux__ + + + + + + + + + +#endif // __linux__
--- a/sx1276/sx1276-mbed-hal.cpp Sun May 07 18:09:10 2017 +0200
+++ b/sx1276/sx1276-mbed-hal.cpp Sun May 07 20:26:02 2017 +0200
@@ -168,15 +168,15 @@
dio4.mode( PullDown );
#endif
if (_dio0)
- _dio0->rise(callback(this, static_cast< TriggerMB1xAS > ( irqHandlers[0] )));
+ _dio0->rise(callback(this, static_cast< Trigger > ( irqHandlers[0] )));
if (_dio1)
- _dio1->rise(callback(this, static_cast< TriggerMB1xAS > ( irqHandlers[1] )));
+ _dio1->rise(callback(this, static_cast< Trigger > ( irqHandlers[1] )));
if (_dio2)
- _dio2->rise(callback(this, static_cast< TriggerMB1xAS > ( irqHandlers[2] )));
+ _dio2->rise(callback(this, static_cast< Trigger > ( irqHandlers[2] )));
if (_dio3)
- _dio3->rise(callback(this, static_cast< TriggerMB1xAS > ( irqHandlers[3] )));
+ _dio3->rise(callback(this, static_cast< Trigger > ( irqHandlers[3] )));
if (_dio4)
- _dio4->rise(callback(this, static_cast< TriggerMB1xAS > ( irqHandlers[4] )));
+ _dio4->rise(callback(this, static_cast< Trigger > ( irqHandlers[4] )));
}
void SX1276Generic::IoDeInit( void )
--- a/sx1276/sx1276-mbed-hal.h Sun May 07 18:09:10 2017 +0200
+++ b/sx1276/sx1276-mbed-hal.h Sun May 07 20:26:02 2017 +0200
@@ -19,17 +19,11 @@
* 30826 Garbsen (Hannover) Germany
*/
-#ifndef __SX1276_HAL_H__
-#define __SX1276_HAL_H__
+#ifndef __SX1276_MBED_HAL_H__
+#define __SX1276_MBED_HAL_H__
#include "sx1276.h"
-/*!
- * triggers definition
- */
-typedef void ( SX1276::*Trigger )( void );
-typedef void ( SX1276Generic::*TriggerMB1xAS )( void );
-
/*!
* Actual implementation of a SX1276 radio, includes some modifications to make it compatible with the MB1 LAS board
@@ -74,6 +68,11 @@
private:
+ /*!
+ * triggers definition
+ */
+ typedef void (SX1276Generic::*Trigger)(void);
+
public:
SX1276Generic( RadioEvents_t *events, BoardType_t board,
@@ -230,4 +229,4 @@
virtual void Reset( void );
};
-#endif // __SX1276_HAL_H__
+#endif // __SX1276_MBED_HAL_H__
--- a/sx1276/sx1276.h Sun May 07 18:09:10 2017 +0200
+++ b/sx1276/sx1276.h Sun May 07 20:26:02 2017 +0200
@@ -26,9 +26,6 @@
#include "./registers/sx1276Regs-Fsk.h"
#include "./registers/sx1276Regs-LoRa.h"
-class SX1276;
-class SX1276Generic;
-
/*!
@@ -63,13 +60,6 @@
#define RF_MID_BAND_THRESH 525000000
-#if 0
-#ifdef TARGET_STM32L0
- #define MURATA_ANT_SWITCH 1 // STM B-L072Z-LRWAN1 device
-#elif TARGET_STM32L4
- #define RFM95_MODULE 1 // RFM95 modules are SX1276MB1LAS compatible
-#endif
-#endif
/*!
@@ -82,7 +72,6 @@
}FskBandwidth_t;
-
/*!
* Radio registers definition
*/
@@ -93,10 +82,25 @@
uint8_t Value;
}RadioRegisters_t;
+
+typedef enum {
+ RXTimeout,
+ TXTimeout,
+ RXTimeoutSyncWorld
+} Timeout_t;
+
/*!
- * Hardware IO IRQ callback function definition
+ * Type of the supported board. [SX1276MB1MAS / SX1276MB1LAS]
*/
-typedef void ( SX1276::*DioIrqHandler )( void );
+typedef enum BoardType
+{
+ SX1276MB1MAS = 0,
+ SX1276MB1LAS,
+ RFM95_SX1276,
+ MURATA_SX1276,
+ UNKNOWN
+}BoardType_t;
+
typedef enum {
@@ -158,10 +162,16 @@
uint8_t *rxtxBuffer;
/*!
+ * Hardware IO IRQ callback function definition
+ */
+ typedef void ( SX1276::*DioIrqHandler )( void );
+
+ /*!
* Hardware DIO IRQ functions
*/
DioIrqHandler *dioIrq;
+
/*!
* Tx and Rx timers
*/
@@ -474,6 +484,7 @@
//-------------------------------------------------------------------------
// Board relative functions
//-------------------------------------------------------------------------
+
static const RadioRegisters_t RadioRegsInit[];
private:
