[SX127x] Sync with LoRaLib 8.0.5
This commit is contained in:
parent
bf85e16880
commit
975e6e116c
4 changed files with 97 additions and 100 deletions
|
@ -107,7 +107,7 @@ int16_t SX1272::setBandwidth(float bw) {
|
|||
|
||||
uint8_t newBandwidth;
|
||||
|
||||
// check alowed bandwidth values
|
||||
// check allowed bandwidth values
|
||||
if(abs(bw - 125.0) <= 0.001) {
|
||||
newBandwidth = SX1272_BW_125_00_KHZ;
|
||||
} else if(abs(bw - 250.0) <= 0.001) {
|
||||
|
@ -399,7 +399,7 @@ int16_t SX1272::config() {
|
|||
return(state);
|
||||
}
|
||||
|
||||
// calculate symbol length and set low datarate optimization, if needed
|
||||
// calculate symbol length and set low data rate optimization, if needed
|
||||
uint16_t base = 1;
|
||||
float symbolLength = (float)(base << _sf) / (float)_bw;
|
||||
if(symbolLength >= 16.0) {
|
||||
|
|
|
@ -163,7 +163,7 @@ int16_t SX1278::setBandwidth(float bw) {
|
|||
|
||||
uint8_t newBandwidth;
|
||||
|
||||
// check alowed bandwidth values
|
||||
// check allowed bandwidth values
|
||||
if(abs(bw - 7.8) <= 0.001) {
|
||||
newBandwidth = SX1278_BW_7_80_KHZ;
|
||||
} else if(abs(bw - 10.4) <= 0.001) {
|
||||
|
@ -475,7 +475,7 @@ int16_t SX1278::config() {
|
|||
return(state);
|
||||
}
|
||||
|
||||
// calculate symbol length and set low datarate optimization, if needed
|
||||
// calculate symbol length and set low data rate optimization, if needed
|
||||
uint16_t base = 1;
|
||||
float symbolLength = (float)(base << _sf) / (float)_bw;
|
||||
if(symbolLength >= 16.0) {
|
||||
|
|
|
@ -469,7 +469,7 @@ int16_t SX127x::startTransmit(uint8_t* data, size_t len, uint8_t addr) {
|
|||
|
||||
int16_t SX127x::readData(uint8_t* data, size_t len) {
|
||||
int16_t modem = getActiveModem();
|
||||
size_t length;
|
||||
size_t length = len;
|
||||
if(modem == SX127X_LORA) {
|
||||
// check integrity CRC
|
||||
if(_mod->SPIgetRegValue(SX127X_REG_IRQ_FLAGS, 5, 5) == SX127X_CLEAR_IRQ_FLAG_PAYLOAD_CRC_ERROR) {
|
||||
|
@ -480,7 +480,6 @@ int16_t SX127x::readData(uint8_t* data, size_t len) {
|
|||
}
|
||||
|
||||
// get packet length
|
||||
length = len;
|
||||
if(_sf != 6) {
|
||||
length = _mod->SPIgetRegValue(SX127X_REG_RX_NB_BYTES);
|
||||
}
|
||||
|
@ -506,9 +505,7 @@ int16_t SX127x::readData(uint8_t* data, size_t len) {
|
|||
_mod->SPIreadRegisterBurst(SX127X_REG_FIFO, length, data);
|
||||
|
||||
// add terminating null
|
||||
if(len == 0) {
|
||||
data[length] = 0;
|
||||
}
|
||||
data[length] = 0;
|
||||
|
||||
// clear interrupt flags
|
||||
clearIRQFlags();
|
||||
|
@ -652,7 +649,7 @@ int16_t SX127x::setBitRate(float br) {
|
|||
return(ERR_WRONG_MODEM);
|
||||
}
|
||||
|
||||
// check allowed bitrate
|
||||
// check allowed bit rate
|
||||
if(_ook) {
|
||||
if((br < 1.2) || (br > 32.768)) {
|
||||
return(ERR_INVALID_BIT_RATE);
|
||||
|
@ -674,7 +671,7 @@ int16_t SX127x::setBitRate(float br) {
|
|||
state = _mod->SPIsetRegValue(SX127X_REG_BITRATE_MSB, (bitRate & 0xFF00) >> 8, 7, 0);
|
||||
state |= _mod->SPIsetRegValue(SX127X_REG_BITRATE_LSB, bitRate & 0x00FF, 7, 0);
|
||||
|
||||
// TODO: fractional part of bit rate setting (not in OOK)
|
||||
// TODO fractional part of bit rate setting (not in OOK)
|
||||
if(state == ERR_NONE) {
|
||||
SX127x::_br = br;
|
||||
}
|
||||
|
@ -723,7 +720,7 @@ int16_t SX127x::setRxBandwidth(float rxBw) {
|
|||
return(state);
|
||||
}
|
||||
|
||||
// calculate exponent and mantisa values
|
||||
// calculate exponent and mantissa values
|
||||
for(uint8_t e = 7; e >= 1; e--) {
|
||||
for(int8_t m = 2; m >= 0; m--) {
|
||||
float point = (SX127X_CRYSTAL_FREQ * 1000000.0)/(((4 * m) + 16) * ((uint32_t)1 << (e + 2)));
|
||||
|
@ -955,7 +952,7 @@ int16_t SX127x::setActiveModem(uint8_t modem) {
|
|||
// set mode to SLEEP
|
||||
int16_t state = setMode(SX127X_SLEEP);
|
||||
|
||||
// set LoRa mode
|
||||
// set modem
|
||||
state |= _mod->SPIsetRegValue(SX127X_REG_OP_MODE, modem, 7, 7, 5);
|
||||
|
||||
// set mode to STANDBY
|
||||
|
|
|
@ -615,7 +615,7 @@ class SX127x: public PhysicalLayer {
|
|||
|
||||
/*!
|
||||
\brief Sets the %LoRa module to sleep to save power. %Module will not be able to transmit or receive any data while in sleep mode.
|
||||
%Module will wake up autmatically when methods like transmit or receive are called.
|
||||
%Module will wake up automatically when methods like transmit or receive are called.
|
||||
|
||||
\returns \ref status_codes
|
||||
*/
|
||||
|
@ -736,7 +736,7 @@ class SX127x: public PhysicalLayer {
|
|||
/*!
|
||||
\brief Gets frequency error of the latest received packet.
|
||||
|
||||
\param autoCorrect When set to true, frequency will be autmatically corrected.
|
||||
\param autoCorrect When set to true, frequency will be automatically corrected.
|
||||
|
||||
\returns Frequency error in Hz.
|
||||
*/
|
||||
|
@ -784,7 +784,7 @@ class SX127x: public PhysicalLayer {
|
|||
int16_t setRxBandwidth(float rxBw);
|
||||
|
||||
/*!
|
||||
\brief Sets FSK sync word. Allowed sync words are up to 8 bytes long and can not conatain null bytes. Only available in FSK mode.
|
||||
\brief Sets FSK sync word. Allowed sync words are up to 8 bytes long and can not contain null bytes. Only available in FSK mode.
|
||||
|
||||
\param syncWord Sync word array.
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue