[SX126x] Fixed chip id (#707)

This commit is contained in:
jgromes 2023-03-21 18:18:17 +01:00
parent dc2eb523a9
commit cd4575ebb0
7 changed files with 12 additions and 11 deletions

View file

@ -2,7 +2,7 @@
#if !defined(RADIOLIB_EXCLUDE_SX126X)
LLCC68::LLCC68(Module* mod) : SX1262(mod) {
_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) {

View file

@ -8,6 +8,9 @@
#include "../../Module.h"
#include "../SX126x/SX1262.h"
//RADIOLIB_SX126X_REG_VERSION_STRING
#define RADIOLIB_LLCC68_CHIP_TYPE "LLCC68"
/*!
\class LLCC68

View file

@ -13,7 +13,7 @@
#define RADIOLIB_SX126X_PA_CONFIG_SX1261 0x01
//RADIOLIB_SX126X_REG_VERSION_STRING
#define RADIOLIB_SX1261_CHIP_TYPE 1
#define RADIOLIB_SX1261_CHIP_TYPE "SX1261"
/*!
\class SX1261

View file

@ -13,7 +13,7 @@
//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 1
#define RADIOLIB_SX1262_CHIP_TYPE "SX1261"
/*!
\class SX1262

View file

@ -12,7 +12,7 @@
#define RADIOLIB_SX126X_PA_CONFIG_SX1268 0x00
//RADIOLIB_SX126X_REG_VERSION_STRING
#define RADIOLIB_SX1268_CHIP_TYPE 8
#define RADIOLIB_SX1268_CHIP_TYPE "SX1268"
/*!
\class SX1268

View file

@ -1962,11 +1962,9 @@ int16_t SX126x::SPIparseStatus(uint8_t in) {
return(RADIOLIB_ERR_NONE);
}
bool SX126x::findChip(uint8_t ver) {
bool SX126x::findChip(const char* verStr) {
uint8_t i = 0;
bool flagFound = false;
char versionBuff[16];
sprintf(versionBuff, "SX126%d", ver);
while((i < 10) && !flagFound) {
// reset the module
reset();
@ -1976,7 +1974,7 @@ bool SX126x::findChip(uint8_t ver) {
_mod->SPIreadRegisterBurst(RADIOLIB_SX126X_REG_VERSION_STRING, 16, (uint8_t*)version);
// check version register
if(strncmp(versionBuff, version, 6) == 0) {
if(strncmp(verStr, version, 6) == 0) {
RADIOLIB_DEBUG_PRINTLN(F("Found SX126x: RADIOLIB_SX126X_REG_VERSION_STRING:"));
_mod->hexdump((uint8_t*)version, 16, RADIOLIB_SX126X_REG_VERSION_STRING);
RADIOLIB_DEBUG_PRINTLN();
@ -1988,7 +1986,7 @@ bool SX126x::findChip(uint8_t ver) {
RADIOLIB_DEBUG_PRINTLN(F(" of 10 tries) RADIOLIB_SX126X_REG_VERSION_STRING:"));
_mod->hexdump((uint8_t*)version, 16, RADIOLIB_SX126X_REG_VERSION_STRING);
RADIOLIB_DEBUG_PRINT(F("Expected string: "));
RADIOLIB_DEBUG_PRINTLN(versionBuff);
RADIOLIB_DEBUG_PRINTLN(verStr);
#endif
_mod->delay(10);
i++;

View file

@ -1184,13 +1184,13 @@ class SX126x: public PhysicalLayer {
uint32_t _tcxoDelay = 0;
size_t _implicitLen = 0;
uint8_t _chipType = 0;
const char* _chipType;
// Allow subclasses to define different TX modes
uint8_t _tx_mode = Module::MODE_TX;
int16_t config(uint8_t modem);
bool findChip(uint8_t type);
bool findChip(const char* verStr);
};
#endif