[SX1231] Update to 5.0.0
This commit is contained in:
parent
9504bc24ab
commit
bd5d824d73
4 changed files with 24 additions and 24 deletions
|
@ -33,7 +33,7 @@ void setup() {
|
|||
// initialize SX1231 with default settings
|
||||
Serial.print(F("[SX1231] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
@ -55,7 +55,7 @@ void loop() {
|
|||
int state = radio.receive(byteArr, 8);
|
||||
*/
|
||||
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
// packet was successfully received
|
||||
Serial.println(F("success!"));
|
||||
|
||||
|
@ -63,11 +63,11 @@ void loop() {
|
|||
Serial.print(F("[SX1231] Data:\t\t"));
|
||||
Serial.println(str);
|
||||
|
||||
} else if (state == ERR_RX_TIMEOUT) {
|
||||
} else if (state == RADIOLIB_ERR_RX_TIMEOUT) {
|
||||
// timeout occurred while waiting for a packet
|
||||
Serial.println(F("timeout!"));
|
||||
|
||||
} else if (state == ERR_CRC_MISMATCH) {
|
||||
} else if (state == RADIOLIB_ERR_CRC_MISMATCH) {
|
||||
// packet was received, but is malformed
|
||||
Serial.println(F("CRC error!"));
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ void setup() {
|
|||
// initialize SX1231 with default settings
|
||||
Serial.print(F("[SX1231] Initializing ... "));
|
||||
int state = radio.begin();
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print(F("failed, code "));
|
||||
|
@ -54,11 +54,11 @@ void loop() {
|
|||
int state = radio.transmit(byteArr, 8);
|
||||
*/
|
||||
|
||||
if (state == ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
// the packet was successfully transmitted
|
||||
Serial.println(F("success!"));
|
||||
|
||||
} else if (state == ERR_PACKET_TOO_LONG) {
|
||||
} else if (state == RADIOLIB_ERR_PACKET_TOO_LONG) {
|
||||
// the supplied packet was longer than 256 bytes
|
||||
Serial.println(F("too long!"));
|
||||
|
||||
|
|
|
@ -7,9 +7,9 @@ SX1231::SX1231(Module* mod) : RF69(mod) {
|
|||
|
||||
int16_t SX1231::begin(float freq, float br, float rxBw, float freqDev, int8_t power, uint8_t preambleLen) {
|
||||
// set module properties
|
||||
_mod->init(RADIOLIB_USE_SPI);
|
||||
Module::pinMode(_mod->getIrq(), INPUT);
|
||||
Module::pinMode(_mod->getRst(), OUTPUT);
|
||||
_mod->init();
|
||||
_mod->pinMode(_mod->getIrq(), INPUT);
|
||||
_mod->pinMode(_mod->getRst(), OUTPUT);
|
||||
|
||||
// try to find the SX1231 chip
|
||||
uint8_t i = 0;
|
||||
|
@ -20,7 +20,7 @@ int16_t SX1231::begin(float freq, float br, float rxBw, float freqDev, int8_t po
|
|||
flagFound = true;
|
||||
_chipRevision = version;
|
||||
} else {
|
||||
#ifdef RADIOLIB_DEBUG
|
||||
#if defined(RADIOLIB_DEBUG)
|
||||
RADIOLIB_DEBUG_PRINT(F("SX1231 not found! ("));
|
||||
RADIOLIB_DEBUG_PRINT(i + 1);
|
||||
RADIOLIB_DEBUG_PRINT(F(" of 10 tries) RF69_REG_VERSION == "));
|
||||
|
@ -31,15 +31,15 @@ int16_t SX1231::begin(float freq, float br, float rxBw, float freqDev, int8_t po
|
|||
RADIOLIB_DEBUG_PRINT(F(", expected 0x0021 / 0x0022 / 0x0023"));
|
||||
RADIOLIB_DEBUG_PRINTLN();
|
||||
#endif
|
||||
Module::delay(10);
|
||||
_mod->delay(10);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
if(!flagFound) {
|
||||
RADIOLIB_DEBUG_PRINTLN(F("No SX1231 found!"));
|
||||
_mod->term(RADIOLIB_USE_SPI);
|
||||
return(ERR_CHIP_NOT_FOUND);
|
||||
_mod->term();
|
||||
return(RADIOLIB_ERR_CHIP_NOT_FOUND);
|
||||
}
|
||||
RADIOLIB_DEBUG_PRINTLN(F("M\tSX1231"));
|
||||
|
||||
|
@ -80,22 +80,22 @@ int16_t SX1231::begin(float freq, float br, float rxBw, float freqDev, int8_t po
|
|||
|
||||
// set default packet length mode
|
||||
state = variablePacketLengthMode();
|
||||
if (state != ERR_NONE) {
|
||||
if (state != RADIOLIB_ERR_NONE) {
|
||||
return(state);
|
||||
}
|
||||
|
||||
// SX1231 V2a only
|
||||
if(_chipRevision == SX1231_CHIP_REVISION_2_A) {
|
||||
if(_chipRevision == RADIOLIB_SX1231_CHIP_REVISION_2_A) {
|
||||
// modify default OOK threshold value
|
||||
state = _mod->SPIsetRegValue(SX1231_REG_TEST_OOK, SX1231_OOK_DELTA_THRESHOLD);
|
||||
state = _mod->SPIsetRegValue(RADIOLIB_SX1231_REG_TEST_OOK, RADIOLIB_SX1231_OOK_DELTA_THRESHOLD);
|
||||
RADIOLIB_ASSERT(state);
|
||||
|
||||
// enable OCP with 95 mA limit
|
||||
state = _mod->SPIsetRegValue(RF69_REG_OCP, RF69_OCP_ON | RF69_OCP_TRIM, 4, 0);
|
||||
state = _mod->SPIsetRegValue(RADIOLIB_RF69_REG_OCP, RADIOLIB_RF69_OCP_ON | RADIOLIB_RF69_OCP_TRIM, 4, 0);
|
||||
RADIOLIB_ASSERT(state);
|
||||
}
|
||||
|
||||
return(ERR_NONE);
|
||||
return(RADIOLIB_ERR_NONE);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -8,15 +8,15 @@
|
|||
#include "../../Module.h"
|
||||
#include "../RF69/RF69.h"
|
||||
|
||||
#define SX1231_CHIP_REVISION_2_A 0x21
|
||||
#define SX1231_CHIP_REVISION_2_B 0x22
|
||||
#define SX1231_CHIP_REVISION_2_C 0x23
|
||||
#define RADIOLIB_SX1231_CHIP_REVISION_2_A 0x21
|
||||
#define RADIOLIB_SX1231_CHIP_REVISION_2_B 0x22
|
||||
#define RADIOLIB_SX1231_CHIP_REVISION_2_C 0x23
|
||||
|
||||
//SX1231 specific register map
|
||||
#define SX1231_REG_TEST_OOK 0x6E
|
||||
#define RADIOLIB_SX1231_REG_TEST_OOK 0x6E
|
||||
|
||||
//SX1231_REG_TEST_OOK
|
||||
#define SX1231_OOK_DELTA_THRESHOLD 0x0C
|
||||
#define RADIOLIB_SX1231_OOK_DELTA_THRESHOLD 0x0C
|
||||
|
||||
/*!
|
||||
\class SX1231
|
||||
|
|
Loading…
Add table
Reference in a new issue