[SX126x] Added method to get currently configured OCP

This commit is contained in:
jgromes 2020-01-27 09:30:44 +01:00
parent f336922013
commit ff97f3957b
3 changed files with 17 additions and 0 deletions

View file

@ -125,6 +125,7 @@ startReceiveDutyCycle KEYWORD2
startReceiveDutyCycleAuto KEYWORD2
setRegulatorLDO KEYWORD2
setRegulatorDCDC KEYWORD2
getCurrentLimit KEYWORD2
# ESP8266
join KEYWORD2

View file

@ -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) {

View file

@ -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.