SX1261 and sx1262 common library
Dependents: SX126xDevKit SX1262PingPong SX126X_TXonly SX126X_PingPong_Demo ... more
Fork of SX126xLib by
Revision 6:1e2345700991, committed 2018-07-18
- Comitter:
- GregCr
- Date:
- Wed Jul 18 13:33:42 2018 +0000
- Parent:
- 5:e488e6f185f3
- Commit message:
- added support for sx1268
Changed in this revision
diff -r e488e6f185f3 -r 1e2345700991 sx126x-hal.cpp --- a/sx126x-hal.cpp Fri Mar 09 13:19:45 2018 +0000 +++ b/sx126x-hal.cpp Wed Jul 18 13:33:42 2018 +0000 @@ -291,12 +291,56 @@ uint8_t SX126xHal::GetDeviceType( void ) { - return( DeviceSelect.read( ) ); + uint16_t val = 0; + val = DeviceSelect.read_u16( ); + + if( val <= 0x2000 ) + { + return( SX1262 ); + } + else if( val <= 0xA000 ) + { + return( SX1268 ); + } + else + { + return( SX1261 ); + } } uint8_t SX126xHal::GetFreqSelect( void ) { - return( FreqSelect.read( ) ); + uint16_t val = 0; + val = FreqSelect.read_u16( ); + + if( val < 100 ) + { + return( MATCHING_FREQ_915 ); + } + else if( val <= 0x3000 ) + { + return( MATCHING_FREQ_780 ); + } + else if( val <= 0x4900 ) // 0x4724 + { + return( MATCHING_FREQ_490 ); + } + else if( val <= 1 ) + { + return( MATCHING_FREQ_434 ); + } + else if( val <= 1 ) + { + return( MATCHING_FREQ_280 ); + } + else if( val <= 0xF000 ) + { + return( MATCHING_FREQ_169 ); + } + else + { + return( MATCHING_FREQ_868 ); + } } void SX126xHal::AntSwOn( void )
diff -r e488e6f185f3 -r 1e2345700991 sx126x-hal.h --- a/sx126x-hal.h Fri Mar 09 13:19:45 2018 +0000 +++ b/sx126x-hal.h Wed Jul 18 13:33:42 2018 +0000 @@ -139,7 +139,7 @@ /*! * \brief Returns the device type * - * \retval 1: SX1261, 0: sx1262 + * \retval 0: SX1261, 1: SX1262, 2: SX1268 */ virtual uint8_t GetDeviceType( void ); @@ -171,8 +171,8 @@ InterruptIn *DIO1; //!< The pin connected to DIO1 InterruptIn *DIO2; //!< The pin connected to DIO2 InterruptIn *DIO3; //!< The pin connected to DIO3 - DigitalIn FreqSelect; //!< The pin connected to a pull-up/down to select Frequency of the matching - DigitalIn DeviceSelect; //!< The pin connected to a pull-up/down to select device + AnalogIn FreqSelect; //!< The pin connected to a pull-up/down to select Frequency of the matching + AnalogIn DeviceSelect; //!< The pin connected to a pull-up/down to select device DigitalOut antSwitchPower; //!< The pin connected to the RF Switch Power /*!
diff -r e488e6f185f3 -r 1e2345700991 sx126x.cpp --- a/sx126x.cpp Fri Mar 09 13:19:45 2018 +0000 +++ b/sx126x.cpp Wed Jul 18 13:33:42 2018 +0000 @@ -490,7 +490,7 @@ printf("SetTxParams "); #endif - if( GetDeviceType( ) == 1 ) // sx1261 + if( GetDeviceType( ) == SX1261 ) { if( power == 15 ) { @@ -510,7 +510,7 @@ } WriteReg( REG_OCP, 0x18 ); // current max is 80 mA for the whole device } - else // sx1262 + else // sx1262 or sx1268 { SetPaConfig( 0x04, 0x07, 0x00, 0x01 ); if( power > 22 )
diff -r e488e6f185f3 -r 1e2345700991 sx126x.h --- a/sx126x.h Fri Mar 09 13:19:45 2018 +0000 +++ b/sx126x.h Wed Jul 18 13:33:42 2018 +0000 @@ -47,6 +47,25 @@ #define FREQ_STEP 0.95367431640625 // ( ( double )( XTAL_FREQ / ( double )FREQ_DIV ) ) #define FREQ_ERR 0.47683715820312 + +/*! + * \brief List of devices supported by this driver + */ +#define SX1261 0 +#define SX1262 1 +#define SX1268 2 + +/*! + * \brief List of matching supported by the sx126x + */ +#define MATCHING_FREQ_915 0 +#define MATCHING_FREQ_780 1 +#define MATCHING_FREQ_490 2 +#define MATCHING_FREQ_434 3 +#define MATCHING_FREQ_280 4 +#define MATCHING_FREQ_169 5 +#define MATCHING_FREQ_868 6 + /*! * \brief Compensation delay for SetAutoTx/Rx functions in 15.625 microseconds */ @@ -1197,7 +1216,7 @@ /*! * \brief Returns the device type * - * \retval 1: SX1261, 0: sx1262 + * \retval 0: SX1261, 1: SX1262, 2: SX1268 */ virtual uint8_t GetDeviceType( void ) = 0;