Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make PA ramp up time configurable for SX1262 #1054

Closed
wants to merge 13 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/modules/LLCC68/LLCC68.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ LLCC68::LLCC68(Module* mod) : SX1262(mod) {
this->XTAL = true;
}

int16_t LLCC68::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t syncWord, int8_t pwr, uint16_t preambleLength, float tcxoVoltage, bool useRegulatorLDO) {
int16_t LLCC68::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t syncWord, int8_t pwr, uint16_t preambleLength, float tcxoVoltage, bool useRegulatorLDO, uint8_t rampTime) {
// execute common part
int16_t state = SX126x::begin(cr, syncWord, preambleLength, tcxoVoltage, useRegulatorLDO);
RADIOLIB_ASSERT(state);
Expand All @@ -21,7 +21,7 @@ int16_t LLCC68::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t sync
state = setSpreadingFactor(sf);
RADIOLIB_ASSERT(state);

state = setOutputPower(pwr);
state = setOutputPower(pwr, rampTime);
RADIOLIB_ASSERT(state);

state = SX126x::fixPaClamping();
Expand Down
3 changes: 2 additions & 1 deletion src/modules/LLCC68/LLCC68.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ class LLCC68: public SX1262 {
If you are seeing -706/-707 error codes, it likely means you are using a module with TCXO.
To use TCXO, either set this value to its reference voltage, or set SX126x::XTAL to false.
\param useRegulatorLDO Whether to use only LDO regulator (true) or DC-DC regulator (false). Defaults to false.
\param rampTime The time delayed to allow the PA to ramp up. Defaults to 200 us.
\returns \ref status_codes
*/
int16_t begin(float freq = 434.0, float bw = 125.0, uint8_t sf = 9, uint8_t cr = 7, uint8_t syncWord = RADIOLIB_SX126X_SYNC_WORD_PRIVATE, int8_t pwr = 10, uint16_t preambleLength = 8, float tcxoVoltage = 0, bool useRegulatorLDO = false);
int16_t begin(float freq = 434.0, float bw = 125.0, uint8_t sf = 9, uint8_t cr = 7, uint8_t syncWord = RADIOLIB_SX126X_SYNC_WORD_PRIVATE, int8_t pwr = 10, uint16_t preambleLength = 8, float tcxoVoltage = 0, bool useRegulatorLDO = false, uint8_t rampTime = RADIOLIB_SX126X_PA_RAMP_200U);

// configuration methods

Expand Down
16 changes: 8 additions & 8 deletions src/modules/SX126x/SX1262.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ SX1262::SX1262(Module* mod) : SX126x(mod) {
chipType = RADIOLIB_SX1262_CHIP_TYPE;
}

int16_t SX1262::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t syncWord, int8_t power, uint16_t preambleLength, float tcxoVoltage, bool useRegulatorLDO) {
int16_t SX1262::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t syncWord, int8_t power, uint16_t preambleLength, float tcxoVoltage, bool useRegulatorLDO, uint8_t rampTime) {
// execute common part
int16_t state = SX126x::begin(cr, syncWord, preambleLength, tcxoVoltage, useRegulatorLDO);
RADIOLIB_ASSERT(state);
Expand All @@ -23,13 +23,13 @@ int16_t SX1262::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t sync
state = SX126x::fixPaClamping();
RADIOLIB_ASSERT(state);

state = setOutputPower(power);
state = setOutputPower(power, rampTime);
RADIOLIB_ASSERT(state);

return(state);
}

int16_t SX1262::beginFSK(float freq, float br, float freqDev, float rxBw, int8_t power, uint16_t preambleLength, float tcxoVoltage, bool useRegulatorLDO) {
int16_t SX1262::beginFSK(float freq, float br, float freqDev, float rxBw, int8_t power, uint16_t preambleLength, float tcxoVoltage, bool useRegulatorLDO, uint8_t rampTime) {
// execute common part
int16_t state = SX126x::beginFSK(br, freqDev, rxBw, preambleLength, tcxoVoltage, useRegulatorLDO);
RADIOLIB_ASSERT(state);
Expand All @@ -41,7 +41,7 @@ int16_t SX1262::beginFSK(float freq, float br, float freqDev, float rxBw, int8_t
state = SX126x::fixPaClamping();
RADIOLIB_ASSERT(state);

state = setOutputPower(power);
state = setOutputPower(power, rampTime);
RADIOLIB_ASSERT(state);

return(state);
Expand Down Expand Up @@ -97,7 +97,7 @@ int16_t SX1262::setFrequency(float freq, bool calibrate) {
return(SX126x::setFrequencyRaw(freq));
}

int16_t SX1262::setOutputPower(int8_t power) {
int16_t SX1262::setOutputPower(int8_t power, uint8_t rampTime) {
RADIOLIB_CHECK_RANGE(power, -9, 22, RADIOLIB_ERR_INVALID_OUTPUT_POWER);

// get current OCP configuration
Expand All @@ -109,9 +109,9 @@ int16_t SX1262::setOutputPower(int8_t power) {
state = SX126x::setPaConfig(0x04, RADIOLIB_SX126X_PA_CONFIG_SX1262);
RADIOLIB_ASSERT(state);

// set output power
/// \todo power ramp time configuration
state = SX126x::setTxParams(power);
// set output power and PA ramp time
// fixme: perform check to see if rampTime is in valid range?
state = SX126x::setTxParams(power, rampTime);
RADIOLIB_ASSERT(state);

// restore OCP configuration
Expand Down
9 changes: 6 additions & 3 deletions src/modules/SX126x/SX1262.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@ class SX1262: public SX126x {
If you are seeing -706/-707 error codes, it likely means you are using non-0 value for module with XTAL.
To use XTAL, either set this value to 0, or set SX126x::XTAL to true.
\param useRegulatorLDO Whether to use only LDO regulator (true) or DC-DC regulator (false). Defaults to false.
\param rampTime The time delayed to allow the PA to ramp up. Defaults to 200 us.
\returns \ref status_codes
*/
int16_t begin(float freq = 434.0, float bw = 125.0, uint8_t sf = 9, uint8_t cr = 7, uint8_t syncWord = RADIOLIB_SX126X_SYNC_WORD_PRIVATE, int8_t power = 10, uint16_t preambleLength = 8, float tcxoVoltage = 1.6, bool useRegulatorLDO = false);
int16_t begin(float freq = 434.0, float bw = 125.0, uint8_t sf = 9, uint8_t cr = 7, uint8_t syncWord = RADIOLIB_SX126X_SYNC_WORD_PRIVATE, int8_t power = 10, uint16_t preambleLength = 8, float tcxoVoltage = 1.6, bool useRegulatorLDO = false, uint8_t rampTime = RADIOLIB_SX126X_PA_RAMP_200U);

/*!
\brief Initialization method for FSK modem.
Expand All @@ -58,9 +59,10 @@ class SX1262: public SX126x {
If you are seeing -706/-707 error codes, it likely means you are using non-0 value for module with XTAL.
To use XTAL, either set this value to 0, or set SX126x::XTAL to true.
\param useRegulatorLDO Whether to use only LDO regulator (true) or DC-DC regulator (false). Defaults to false.
\param rampTime The time delayed to allow the PA to ramp up. Defaults to 200 us.
\returns \ref status_codes
*/
int16_t beginFSK(float freq = 434.0, float br = 4.8, float freqDev = 5.0, float rxBw = 156.2, int8_t power = 10, uint16_t preambleLength = 16, float tcxoVoltage = 1.6, bool useRegulatorLDO = false);
int16_t beginFSK(float freq = 434.0, float br = 4.8, float freqDev = 5.0, float rxBw = 156.2, int8_t power = 10, uint16_t preambleLength = 16, float tcxoVoltage = 1.6, bool useRegulatorLDO = false, uint8_t rampTime = RADIOLIB_SX126X_PA_RAMP_200U);

// configuration methods

Expand All @@ -83,9 +85,10 @@ class SX1262: public SX126x {
\brief Sets output power. Allowed values are in range from -9 to 22 dBm.
This method is virtual to allow override from the SX1261 class.
\param power Output power to be set in dBm.
\param rampTime The time delayed to allow the PA to ramp up. Defaults to 200 us.
\returns \ref status_codes
*/
virtual int16_t setOutputPower(int8_t power);
virtual int16_t setOutputPower(int8_t power, uint8_t rampTime = RADIOLIB_SX126X_PA_RAMP_200U);

#if !RADIOLIB_GODMODE
private:
Expand Down
Loading