Implemented AFC&AGC trigger control
This commit is contained in:
parent
2ae0188e50
commit
ac4ea556ae
2 changed files with 52 additions and 11 deletions
|
@ -92,7 +92,11 @@ int16_t SX127x::beginFSK(uint8_t chipVersion, float br, float freqDev, float rxB
|
|||
state = SX127x::setAFCBandwidth(rxBw);
|
||||
RADIOLIB_ASSERT(state);
|
||||
|
||||
state = _mod->SPIsetRegValue(SX127X_REG_RX_CONFIG, 0x1E);//TODO
|
||||
//sets AFC&AGC trigger to RSSI and preamble detect
|
||||
state = SX127x::setAFCAGCTrigger(SX127X_RX_TRIGGER_BOTH);
|
||||
RADIOLIB_ASSERT(state);
|
||||
|
||||
state = SX127x::setAFC(true);
|
||||
RADIOLIB_ASSERT(state);
|
||||
|
||||
// set receiver bandwidth
|
||||
|
@ -783,6 +787,25 @@ int16_t SX127x::setAFCBandwidth(float rxBw){
|
|||
return(_mod->SPIsetRegValue(SX127X_REG_AFC_BW, calculateBWManExp(rxBw), 4, 0));
|
||||
}
|
||||
|
||||
int16_t SX127x::setAFC(bool isEnabled){
|
||||
// check active modem
|
||||
if(getActiveModem() != SX127X_FSK_OOK) {
|
||||
return(ERR_WRONG_MODEM);
|
||||
}
|
||||
|
||||
//set AFC auto on/off
|
||||
return(_mod->SPIsetRegValue(SX127X_REG_RX_CONFIG, isEnabled ? SX127X_AFC_AUTO_ON : SX127X_AFC_AUTO_OFF, 4, 4));
|
||||
}
|
||||
|
||||
int16_t SX127x::setAFCAGCTrigger(uint8_t trigger){
|
||||
if(getActiveModem() != SX127X_FSK_OOK) {
|
||||
return(ERR_WRONG_MODEM);
|
||||
}
|
||||
|
||||
//set AFC&AGC trigger
|
||||
return(_mod->SPIsetRegValue(SX127X_REG_RX_CONFIG, trigger, 2, 0));
|
||||
}
|
||||
|
||||
int16_t SX127x::setSyncWord(uint8_t* syncWord, size_t len) {
|
||||
// check active modem
|
||||
if(getActiveModem() != SX127X_FSK_OOK) {
|
||||
|
|
|
@ -823,6 +823,24 @@ class SX127x: public PhysicalLayer {
|
|||
*/
|
||||
int16_t setAFCBandwidth(float afcBw);
|
||||
|
||||
/*!
|
||||
\brief Enables or disables FSK automatic frequency correction(AFC)
|
||||
|
||||
\param isEnabled AFC enabled or disabled
|
||||
|
||||
\return \ref status_codes
|
||||
*/
|
||||
int16_t setAFC(bool isEnabled);
|
||||
|
||||
/*!
|
||||
\brief Controls trigger of AFC and AGC
|
||||
|
||||
\param trigger one from SX127X_RX_TRIGGER_NONE, SX127X_RX_TRIGGER_RSSI_INTERRUPT, SX127X_RX_TRIGGER_PREAMBLE_DETECT, SX127X_RX_TRIGGER_BOTH
|
||||
|
||||
\return \ref status_codes
|
||||
*/
|
||||
int16_t setAFCAGCTrigger(uint8_t trigger);
|
||||
|
||||
/*!
|
||||
\brief Sets FSK sync word. Allowed sync words are up to 8 bytes long and can not contain null bytes. Only available in FSK mode.
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue