diff --git a/keywords.txt b/keywords.txt index 9195919a..d312388d 100644 --- a/keywords.txt +++ b/keywords.txt @@ -125,6 +125,7 @@ startReceiveDutyCycle KEYWORD2 startReceiveDutyCycleAuto KEYWORD2 setRegulatorLDO KEYWORD2 setRegulatorDCDC KEYWORD2 +getCurrentLimit KEYWORD2 # ESP8266 join KEYWORD2 diff --git a/src/modules/SX126x/SX126x.cpp b/src/modules/SX126x/SX126x.cpp index 291cc715..2441615f 100644 --- a/src/modules/SX126x/SX126x.cpp +++ b/src/modules/SX126x/SX126x.cpp @@ -674,6 +674,15 @@ int16_t SX126x::setCurrentLimit(float currentLimit) { return(writeRegister(SX126X_REG_OCP_CONFIGURATION, &rawLimit, 1)); } +float SX126x::getCurrentLimit() { + // get the raw value + uint8_t ocp = 0; + readRegister(SX126X_REG_OCP_CONFIGURATION, &ocp, 1); + + // return the actual value + return((float)ocp * 2.5); +} + int16_t SX126x::setPreambleLength(uint16_t preambleLength) { uint8_t modem = getPacketType(); if(modem == SX126X_PACKET_TYPE_LORA) { diff --git a/src/modules/SX126x/SX126x.h b/src/modules/SX126x/SX126x.h index 9d7c4719..16c0e85b 100644 --- a/src/modules/SX126x/SX126x.h +++ b/src/modules/SX126x/SX126x.h @@ -601,6 +601,13 @@ class SX126x: public PhysicalLayer { */ int16_t setCurrentLimit(float currentLimit); + /*! + \brief Reads current protection limit. + + \returns Currently configured overcurrent protection limit in mA. + */ + float getCurrentLimit(); + /*! \brief Sets preamble length for LoRa or FSK modem. Allowed values range from 1 to 65535.