[SX126x] General reformatting

This commit is contained in:
jgromes 2023-04-23 19:06:45 +02:00
parent cab358ff09
commit a015e541f6
12 changed files with 707 additions and 915 deletions

View file

@ -2,7 +2,7 @@
#if !defined(RADIOLIB_EXCLUDE_SX126X)
LLCC68::LLCC68(Module* mod) : SX1262(mod) {
_chipType = RADIOLIB_LLCC68_CHIP_TYPE;
chipType = RADIOLIB_LLCC68_CHIP_TYPE;
}
int16_t LLCC68::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t syncWord, int8_t power, uint16_t preambleLength, float tcxoVoltage, bool useRegulatorLDO) {
@ -35,7 +35,7 @@ int16_t LLCC68::setBandwidth(float bw) {
}
int16_t LLCC68::setSpreadingFactor(uint8_t sf) {
switch(SX126x::_bw) {
switch(SX126x::bandwidth) {
case RADIOLIB_SX126X_LORA_BW_125_0:
RADIOLIB_CHECK_RANGE(sf, 5, 9, RADIOLIB_ERR_INVALID_SPREADING_FACTOR);
break;

View file

@ -9,43 +9,31 @@
#include "../SX126x/SX1262.h"
//RADIOLIB_SX126X_REG_VERSION_STRING
#define RADIOLIB_LLCC68_CHIP_TYPE "LLCC68"
#define RADIOLIB_LLCC68_CHIP_TYPE "LLCC68"
/*!
\class LLCC68
\brief Derived class for %LLCC68 modules.
*/
class LLCC68: public SX1262 {
public:
/*!
\brief Default constructor.
\param mod Instance of Module that will be used to communicate with the radio.
*/
LLCC68(Module* mod);
/*!
\brief Initialization method for LoRa modem.
\param freq Carrier frequency in MHz. Defaults to 434.0 MHz.
\param bw LoRa bandwidth in kHz. Defaults to 125.0 kHz.
\param sf LoRa spreading factor. Defaults to 9.
\param cr LoRa coding rate denominator. Defaults to 7 (coding rate 4/7).
\param syncWord 1-byte LoRa sync word. Defaults to RADIOLIB_SX126X_SYNC_WORD_PRIVATE (0x12).
\param power Output power in dBm. Defaults to 10 dBm.
\param preambleLength LoRa preamble length in symbols. Defaults to 8 symbols.
\param tcxoVoltage TCXO reference voltage to be set on DIO3. Defaults to 1.6 V, set to 0 to skip.
\param useRegulatorLDO Whether to use only LDO regulator (true) or DC-DC regulator (false). Defaults to false.
\returns \ref status_codes
*/
int16_t begin(float freq = 434.0, float bw = 125.0, uint8_t sf = 9, uint8_t cr = 7, uint8_t syncWord = RADIOLIB_SX126X_SYNC_WORD_PRIVATE, int8_t power = 10, uint16_t preambleLength = 8, float tcxoVoltage = 1.6, bool useRegulatorLDO = false);
@ -54,18 +42,14 @@ class LLCC68: public SX1262 {
/*!
\brief Sets LoRa bandwidth. Allowed values are 125.0, 250.0 and 500.0 kHz.
\param bw LoRa bandwidth to be set in kHz.
\returns \ref status_codes
*/
int16_t setBandwidth(float bw);
/*!
\brief Sets LoRa spreading factor. Allowed values range from 5 to 11, depending on currently set spreading factor.
\param sf LoRa spreading factor to be set.
\returns \ref status_codes
*/
int16_t setSpreadingFactor(uint8_t sf);

View file

@ -1,5 +1,4 @@
/*
Copyright (c) 2018 Jan Gromeš
Copyright (c) 2022 STMicroelectronics
@ -9,8 +8,7 @@ This file is licensed under the MIT License: https://opensource.org/licenses/MIT
#include "STM32WLx.h"
#if !defined(RADIOLIB_EXCLUDE_STM32WLX)
STM32WLx::STM32WLx(STM32WLx_Module* mod) : SX1262(mod) {
}
STM32WLx::STM32WLx(STM32WLx_Module* mod) : SX1262(mod) { }
int16_t STM32WLx::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t syncWord, int8_t power, uint16_t preambleLength, float tcxoVoltage, bool useRegulatorLDO) {
// Execute common part
@ -47,18 +45,18 @@ int16_t STM32WLx::setOutputPower(int8_t power) {
RADIOLIB_ASSERT(state);
// Use HP only if available and needed for the requested power
bool hp_supported = _mod->findRfSwitchMode(MODE_TX_HP);
bool hp_supported = this->mod->findRfSwitchMode(MODE_TX_HP);
bool use_hp = power > 14 && hp_supported;
// set PA config.
if(use_hp) {
RADIOLIB_CHECK_RANGE(power, -9, 22, RADIOLIB_ERR_INVALID_OUTPUT_POWER);
state = SX126x::setPaConfig(0x04, 0x00, 0x07); // HP output up to 22dBm
_tx_mode = MODE_TX_HP;
this->txMode = MODE_TX_HP;
} else {
RADIOLIB_CHECK_RANGE(power, -17, 14, RADIOLIB_ERR_INVALID_OUTPUT_POWER);
state = SX126x::setPaConfig(0x04, 0x01, 0x00); // LP output up to 14dBm
_tx_mode = MODE_TX_LP;
this->txMode = MODE_TX_LP;
}
RADIOLIB_ASSERT(state);

View file

@ -1,5 +1,4 @@
/*
Copyright (c) 2018 Jan Gromeš
Copyright (c) 2022 STMicroelectronics
@ -38,18 +37,17 @@ class STM32WLx : public SX1262 {
public:
/*!
\brief Default constructor.
\param mod Instance of STM32WLx_Module that will be used to communicate with the radio.
*/
STM32WLx(STM32WLx_Module* mod);
/*!
* \brief Custom operation modes for STMWLx.
*
* This splits the TX mode into two modes: Low-power and high-power.
* These constants can be used with the setRfSwitchTable() method,
* instead of the Module::OpMode_t constants.
*/
\brief Custom operation modes for STMWLx.
This splits the TX mode into two modes: Low-power and high-power.
These constants can be used with the setRfSwitchTable() method,
instead of the Module::OpMode_t constants.
*/
enum OpMode_t {
/*! End of table marker, use \ref END_OF_MODE_TABLE constant instead */
MODE_END_OF_TABLE = Module::MODE_END_OF_TABLE,
@ -112,7 +110,6 @@ class STM32WLx : public SX1262 {
/*!
\brief Sets interrupt service routine to call when DIO1/2/3 activates.
\param func ISR to call.
*/
void setDio1Action(void (*func)(void));

View file

@ -2,7 +2,7 @@
#if !defined(RADIOLIB_EXCLUDE_SX126X)
SX1261::SX1261(Module* mod): SX1262(mod) {
_chipType = RADIOLIB_SX1261_CHIP_TYPE;
chipType = RADIOLIB_SX1261_CHIP_TYPE;
}
int16_t SX1261::setOutputPower(int8_t power) {

View file

@ -10,30 +10,26 @@
#include "SX1262.h"
//RADIOLIB_SX126X_CMD_SET_PA_CONFIG
#define RADIOLIB_SX126X_PA_CONFIG_SX1261 0x01
#define RADIOLIB_SX126X_PA_CONFIG_SX1261 0x01
//RADIOLIB_SX126X_REG_VERSION_STRING
#define RADIOLIB_SX1261_CHIP_TYPE "SX1261"
#define RADIOLIB_SX1261_CHIP_TYPE "SX1261"
/*!
\class SX1261
\brief Derived class for %SX1261 modules.
*/
class SX1261 : public SX1262 {
public:
/*!
\brief Default constructor.
\param mod Instance of Module that will be used to communicate with the radio.
*/
SX1261(Module* mod);
/*!
\brief Sets output power. Allowed values are in range from -17 to 14 dBm.
\param power Output power to be set in dBm.
\returns \ref status_codes
*/
int16_t setOutputPower(int8_t power);

View file

@ -2,7 +2,7 @@
#if !defined(RADIOLIB_EXCLUDE_SX126X)
SX1262::SX1262(Module* mod) : SX126x(mod) {
_chipType = RADIOLIB_SX1262_CHIP_TYPE;
chipType = RADIOLIB_SX1262_CHIP_TYPE;
}
int16_t SX1262::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t syncWord, int8_t power, uint16_t preambleLength, float tcxoVoltage, bool useRegulatorLDO) {

View file

@ -9,22 +9,20 @@
#include "SX126x.h"
//RADIOLIB_SX126X_CMD_SET_PA_CONFIG
#define RADIOLIB_SX126X_PA_CONFIG_SX1262 0x00
#define RADIOLIB_SX126X_PA_CONFIG_SX1262 0x00
//RADIOLIB_SX126X_REG_VERSION_STRING
// Note: this should really be "2", however, it seems that all SX1262 devices report as SX1261
#define RADIOLIB_SX1262_CHIP_TYPE "SX1261"
#define RADIOLIB_SX1262_CHIP_TYPE "SX1261"
/*!
\class SX1262
\brief Derived class for %SX1262 modules.
*/
class SX1262: public SX126x {
public:
/*!
\brief Default constructor.
\param mod Instance of Module that will be used to communicate with the radio.
*/
SX1262(Module* mod);
@ -33,72 +31,46 @@ class SX1262: public SX126x {
/*!
\brief Initialization method for LoRa modem.
\param freq Carrier frequency in MHz. Defaults to 434.0 MHz.
\param bw LoRa bandwidth in kHz. Defaults to 125.0 kHz.
\param sf LoRa spreading factor. Defaults to 9.
\param cr LoRa coding rate denominator. Defaults to 7 (coding rate 4/7).
\param syncWord 1-byte LoRa sync word. Defaults to RADIOLIB_SX126X_SYNC_WORD_PRIVATE (0x12).
\param power Output power in dBm. Defaults to 10 dBm.
\param preambleLength LoRa preamble length in symbols. Defaults to 8 symbols.
\param tcxoVoltage TCXO reference voltage to be set on DIO3. Defaults to 1.6 V, set to 0 to skip.
\param useRegulatorLDO Whether to use only LDO regulator (true) or DC-DC regulator (false). Defaults to false.
\returns \ref status_codes
*/
int16_t begin(float freq = 434.0, float bw = 125.0, uint8_t sf = 9, uint8_t cr = 7, uint8_t syncWord = RADIOLIB_SX126X_SYNC_WORD_PRIVATE, int8_t power = 10, uint16_t preambleLength = 8, float tcxoVoltage = 1.6, bool useRegulatorLDO = false);
/*!
\brief Initialization method for FSK modem.
\param freq Carrier frequency in MHz. Defaults to 434.0 MHz.
\param br FSK bit rate in kbps. Defaults to 4.8 kbps.
\param freqDev Frequency deviation from carrier frequency in kHz. Defaults to 5.0 kHz.
\param rxBw Receiver bandwidth in kHz. Defaults to 156.2 kHz.
\param power Output power in dBm. Defaults to 10 dBm.
\param preambleLength FSK preamble length in bits. Defaults to 16 bits.
\param tcxoVoltage TCXO reference voltage to be set on DIO3. Defaults to 1.6 V, set to 0 to skip.
\param useRegulatorLDO Whether to use only LDO regulator (true) or DC-DC regulator (false). Defaults to false.
\returns \ref status_codes
*/
int16_t beginFSK(float freq = 434.0, float br = 4.8, float freqDev = 5.0, float rxBw = 156.2, int8_t power = 10, uint16_t preambleLength = 16, float tcxoVoltage = 1.6, bool useRegulatorLDO = false);
int16_t beginLRFHSS(float freq = 434.0, float tcxoVoltage = 0, bool useRegulatorLDO = false);
// configuration methods
/*!
\brief Sets carrier frequency. Allowed values are in range from 150.0 to 960.0 MHz.
\param freq Carrier frequency to be set in MHz.
\returns \ref status_codes
*/
int16_t setFrequency(float freq);
/*!
\brief Sets carrier frequency. Allowed values are in range from 150.0 to 960.0 MHz.
\param freq Carrier frequency to be set in MHz.
\param calibrate Run image calibration.
\returns \ref status_codes
*/
int16_t setFrequency(float freq, bool calibrate);
@ -106,9 +78,7 @@ class SX1262: public SX126x {
/*!
\brief Sets output power. Allowed values are in range from -9 to 22 dBm.
This method is virtual to allow override from the SX1261 class.
\param power Output power to be set in dBm.
\returns \ref status_codes
*/
virtual int16_t setOutputPower(int8_t power);

View file

@ -2,7 +2,7 @@
#if !defined(RADIOLIB_EXCLUDE_SX126X)
SX1268::SX1268(Module* mod) : SX126x(mod) {
_chipType = RADIOLIB_SX1268_CHIP_TYPE;
chipType = RADIOLIB_SX1268_CHIP_TYPE;
}
int16_t SX1268::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t syncWord, int8_t power, uint16_t preambleLength, float tcxoVoltage, bool useRegulatorLDO) {

View file

@ -9,21 +9,19 @@
#include "SX126x.h"
//RADIOLIB_SX126X_CMD_SET_PA_CONFIG
#define RADIOLIB_SX126X_PA_CONFIG_SX1268 0x00
#define RADIOLIB_SX126X_PA_CONFIG_SX1268 0x00
//RADIOLIB_SX126X_REG_VERSION_STRING
#define RADIOLIB_SX1268_CHIP_TYPE "SX1268"
#define RADIOLIB_SX1268_CHIP_TYPE "SX1268"
/*!
\class SX1268
\brief Derived class for %SX1268 modules.
*/
class SX1268: public SX126x {
public:
/*!
\brief Default constructor.
\param mod Instance of Module that will be used to communicate with the radio.
*/
SX1268(Module* mod);
@ -32,48 +30,29 @@ class SX1268: public SX126x {
/*!
\brief Initialization method for LoRa modem.
\param freq Carrier frequency in MHz. Defaults to 434.0 MHz.
\param bw LoRa bandwidth in kHz. Defaults to 125.0 kHz.
\param sf LoRa spreading factor. Defaults to 9.
\param cr LoRa coding rate denominator. Defaults to 7 (coding rate 4/7).
\param syncWord 1-byte LoRa sync word. Defaults to RADIOLIB_SX126X_SYNC_WORD_PRIVATE (0x12).
\param power Output power in dBm. Defaults to 10 dBm.
\param preambleLength LoRa preamble length in symbols. Defaults to 8 symbols.
\param tcxoVoltage TCXO reference voltage to be set on DIO3. Defaults to 1.6 V, set to 0 to skip.
\param useRegulatorLDO Whether to use only LDO regulator (true) or DC-DC regulator (false). Defaults to false.
\returns \ref status_codes
*/
int16_t begin(float freq = 434.0, float bw = 125.0, uint8_t sf = 9, uint8_t cr = 7, uint8_t syncWord = RADIOLIB_SX126X_SYNC_WORD_PRIVATE, int8_t power = 10, uint16_t preambleLength = 8, float tcxoVoltage = 1.6, bool useRegulatorLDO = false);
/*!
\brief Initialization method for FSK modem.
\param freq Carrier frequency in MHz. Defaults to 434.0 MHz.
\param br FSK bit rate in kbps. Defaults to 4.8 kbps.
\param freqDev Frequency deviation from carrier frequency in kHz. Defaults to 5.0 kHz.
\param rxBw Receiver bandwidth in kHz. Defaults to 156.2 kHz.
\param power Output power in dBm. Defaults to 10 dBm.
\param preambleLength FSK preamble length in bits. Defaults to 16 bits.
\param tcxoVoltage TCXO reference voltage to be set on DIO3. Defaults to 1.6 V, set to 0 to skip.
\param useRegulatorLDO Whether to use only LDO regulator (true) or DC-DC regulator (false). Defaults to false.
\returns \ref status_codes
*/
int16_t beginFSK(float freq = 434.0, float br = 4.8, float freqDev = 5.0, float rxBw = 156.2, int8_t power = 10, uint16_t preambleLength = 16, float tcxoVoltage = 1.6, bool useRegulatorLDO = false);
@ -82,29 +61,22 @@ class SX1268: public SX126x {
/*!
\brief Sets carrier frequency. Allowed values are in range from 410.0 to 810.0 MHz.
\param freq Carrier frequency to be set in MHz.
\returns \ref status_codes
*/
int16_t setFrequency(float freq);
/*!
\brief Sets carrier frequency. Allowed values are in range from 410.0 to 810.0 MHz.
\param freq Carrier frequency to be set in MHz.
\param calibrate Run image calibration.
\returns \ref status_codes
*/
int16_t setFrequency(float freq, bool calibrate);
/*!
\brief Sets output power. Allowed values are in range from -9 to 22 dBm.
\param power Output power to be set in dBm.
\returns \ref status_codes
*/
int16_t setOutputPower(int8_t power);

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff