File tree Expand file tree Collapse file tree 1 file changed +18
-13
lines changed Expand file tree Collapse file tree 1 file changed +18
-13
lines changed Original file line number Diff line number Diff line change 2828#include "sx126x.h"
2929#include "sx126x-board.h"
3030
31+ /*!
32+ * \brief Maximum value for parameter symbNum in \ref SX126xSetLoRaSymbNumTimeout
33+ */
34+ #define SX126X_MAX_LORA_SYMB_NUM_TIMEOUT 248
35+
3136/*!
3237 * \brief Radio registers definition
3338 */
@@ -326,23 +331,23 @@ void SX126xSetStopRxTimerOnPreambleDetect( bool enable )
326331
327332void SX126xSetLoRaSymbNumTimeout ( uint8_t symbNum )
328333{
329- SX126xWriteCommand ( RADIO_SET_LORASYMBTIMEOUT , & symbNum , 1 );
334+ uint8_t mant = ( ( ( symbNum > SX126X_MAX_LORA_SYMB_NUM_TIMEOUT ) ?
335+ SX126X_MAX_LORA_SYMB_NUM_TIMEOUT :
336+ symbNum ) + 1 ) >> 1 ;
337+ uint8_t exp = 0 ;
338+ uint8_t reg = 0 ;
330339
331- if ( symbNum >= 64 )
340+ while ( mant > 31 )
332341 {
333- uint8_t mant = symbNum >> 1 ;
334- uint8_t exp = 0 ;
335- uint8_t reg = 0 ;
342+ mant = ( mant + 3 ) >> 2 ;
343+ exp ++ ;
344+ }
336345
337- while ( mant > 31 )
338- {
339- mant >>= 2 ;
340- exp ++ ;
341- }
346+ reg = mant << ( 2 * exp + 1 );
347+ SX126xWriteCommand ( RADIO_SET_LORASYMBTIMEOUT , & reg , 1 );
342348
343- reg = exp + ( mant << 3 );
344- SX126xWriteRegister ( REG_LR_SYNCH_TIMEOUT , reg );
345- }
349+ reg = exp + ( mant << 3 );
350+ SX126xWriteRegister ( REG_LR_SYNCH_TIMEOUT , reg );
346351}
347352
348353void SX126xSetRegulatorMode ( RadioRegulatorMode_t mode )
You can’t perform that action at this time.
0 commit comments