111 lines
2.6 KiB
C
111 lines
2.6 KiB
C
#pragma once
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/* Includes ----------------------------------------------------------------- */
|
|
#include <stdint.h>
|
|
#include <stdbool.h>
|
|
#include "sx1281_driver.h"
|
|
#include "device/device.h"
|
|
|
|
/* USER INCLUDE BEGIN */
|
|
|
|
/* USER INCLUDE END */
|
|
|
|
/* Exported constants ------------------------------------------------------- */
|
|
/* Exported macro ----------------------------------------------------------- */
|
|
/*!
|
|
* \brief Defines the buffer size, i.e. the payload size
|
|
*/
|
|
#define BUFFER_SIZE 5
|
|
|
|
|
|
|
|
/* Exported types ----------------------------------------------------------- */
|
|
|
|
typedef enum {
|
|
MODE_BLE, /* Bluetooth Low Energy */
|
|
MODE_LORA, /* Long Range */
|
|
MODE_GFSK, /* Gaussian Frequency Shift Keying */
|
|
MODE_FLRC /* Fast Long Range Codec */
|
|
}SX1281_Mode_t;
|
|
|
|
typedef enum {
|
|
LOWPOWER,
|
|
RUNNING,
|
|
RX_DONE,
|
|
RX_TIMEOUT,
|
|
RX_ERROR,
|
|
TX_DONE,
|
|
TX_TIMEOUT,
|
|
LORA_CAD_DONE
|
|
}SX1281_States_t;
|
|
|
|
typedef enum {
|
|
RF_BAUDRATE_LORA_216B=0,
|
|
RF_BAUDRATE_LORA_001K,
|
|
RF_BAUDRATE_LORA_005K,
|
|
RF_BAUDRATE_LORA_010K,
|
|
RF_BAUDRATE_LORA_020K,
|
|
RF_BAUDRATE_LORA_061K,
|
|
RF_BAUDRATE_LORA_127K,
|
|
RF_BAUDRATE_LORA_203K,
|
|
RF_BAUDRATE_LORA_NUM,
|
|
|
|
RF_BAUDRATE_FLRC_130K,
|
|
RF_BAUDRATE_FLRC_260K,
|
|
RF_BAUDRATE_FLRC_520K,
|
|
RF_BAUDRATE_FLRC_1040K,
|
|
RF_BAUDRATE_FLRC_NUM,
|
|
|
|
RF_BAUDRATE_NONE
|
|
}SX1281_Baudrate_t;
|
|
|
|
typedef struct
|
|
{
|
|
uint8_t SignalBw; // LORA_BW_0200, LORA_BW_0400, LORA_BW_0800, LORA_BW_1600,
|
|
uint8_t SpreadingFactor; // LORA_SF5~LORA_SF12
|
|
uint8_t ErrorCoding; // 1-LORA_CR_4_5, 2-LORA_CR_4_6, 3-LORA_CR_4_7 , 4-LORA_CR_4_8 , 5-LORA_CR_LI_4_5, 6-LORA_CR_LI_4_6, 7-LORA_CR_LI_4_7,
|
|
}SX1281_LORAConfig_t;
|
|
|
|
typedef struct
|
|
{
|
|
uint8_t BitrateBandwidth; //@RadioFlrcBitrates_t
|
|
uint8_t CodingRate; //@RadioFlrcCodingRates_t
|
|
uint8_t ModulationShaping; //@RadioModShapings_t
|
|
}SX1281_FLRCConfig_t;
|
|
|
|
typedef struct {
|
|
|
|
int8_t txOutputPower;//The range of the output power is [-18..+13] dBm
|
|
|
|
PacketParams_t packetParams;
|
|
|
|
ModulationParams_t modulationParams;
|
|
|
|
SX1281_Mode_t mode;
|
|
SX1281_Baudrate_t baudrate;
|
|
PacketStatus_t packetStatus;
|
|
|
|
int8_t rxBuffer[BUFFER_SIZE];
|
|
}SX1281_t;
|
|
|
|
|
|
/* Exported functions prototypes -------------------------------------------- */
|
|
|
|
/* USER FUNCTION BEGIN */
|
|
int8_t SX1281_Init(SX1281_t *radio, SX1281_Mode_t mode);
|
|
int8_t SX1281_SetRXSingle(void);
|
|
int8_t SX1281_SetRXSuccessive(void);
|
|
int8_t SX1281_SetTX (void);
|
|
int8_t SX1281_Running(void);
|
|
|
|
void SetBLEAdvertisingPacket(SX1281_t *radio, uint8_t *data, uint8_t length);
|
|
/* USER FUNCTION END */
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|