SX1276Lib updated in order to be RTOS aware
Fork of SX1276Lib by
Revision 5:11ec8a6ba4f0, committed 2014-08-21
- Comitter:
- GregCr
- Date:
- Thu Aug 21 11:58:28 2014 +0000
- Parent:
- 4:f0ce52e94d3f
- Child:
- 6:e7f02929cd3d
- Commit message:
- Corrected bug in FSK
Changed in this revision
--- a/enums/enums.h Wed Aug 20 06:29:01 2014 +0000 +++ b/enums/enums.h Thu Aug 21 11:58:28 2014 +0000 @@ -49,7 +49,8 @@ enum BoardType { SX1276MB1MAS = 0, - SX1276MB1LAS + SX1276MB1LAS, + UNKNOWN }; /*! * Radio FSK modem parameters @@ -118,7 +119,7 @@ */ typedef struct { - RadioState State; + RadioState State; ModemType Modem; uint32_t Channel; RadioFskSettings_t Fsk;
--- a/sx1276/sx1276-hal.cpp Wed Aug 20 06:29:01 2014 +0000 +++ b/sx1276/sx1276-hal.cpp Thu Aug 21 11:58:28 2014 +0000 @@ -25,7 +25,7 @@ { MODEM_FSK , REG_SYNCVALUE1 , 0xC1 }, { MODEM_FSK , REG_SYNCVALUE2 , 0x94 }, { MODEM_FSK , REG_SYNCVALUE3 , 0xC1 }, - { MODEM_FSK , REG_PACKETCONFIG1 , 0xD8 }, + { MODEM_FSK , REG_PACKETCONFIG1 , 0x98 }, { MODEM_FSK , REG_FIFOTHRESH , 0x8F }, { MODEM_FSK , REG_IMAGECAL , 0x02 }, { MODEM_FSK , REG_DIOMAPPING1 , 0x00 }, @@ -79,6 +79,8 @@ { Reset( ); + boardConnected = UNKNOWN; + DetectBoardType( ); RxChainCalibration( ); @@ -100,19 +102,21 @@ //------------------------------------------------------------------------- uint8_t SX1276MB1xAS::DetectBoardType( void ) { - antSwitch.input( ); - wait_ms( 1 ); - if( antSwitch == 1 ) + if( boardConnected == UNKNOWN ) { - boardConnected = SX1276MB1LAS; + antSwitch.input( ); + wait_ms( 1 ); + if( antSwitch == 1 ) + { + boardConnected = SX1276MB1LAS; + } + else + { + boardConnected = SX1276MB1MAS; + } + antSwitch.output( ); + wait_ms( 1 ); } - else - { - boardConnected = SX1276MB1MAS; - } - antSwitch.output( ); - wait_ms( 1 ); - return ( boardConnected ); }
--- a/sx1276/sx1276.cpp Wed Aug 20 06:29:01 2014 +0000 +++ b/sx1276/sx1276.cpp Thu Aug 21 11:58:28 2014 +0000 @@ -589,6 +589,8 @@ { uint32_t txTimeout = 0; + this->settings.State = IDLE; + switch( this->settings.Modem ) { case MODEM_FSK: @@ -687,7 +689,7 @@ // DIO3=FifoEmpty // DIO4=Preamble // DIO5=ModeReady - Write( REG_DIOMAPPING1, ( Read( REG_DIOMAPPING1 ) & RF_DIOMAPPING1_DIO0_MASK & + Write( REG_DIOMAPPING1, ( Read( REG_DIOMAPPING1 ) & RF_DIOMAPPING1_DIO0_MASK & RF_DIOMAPPING1_DIO1_MASK & RF_DIOMAPPING1_DIO2_MASK ) | RF_DIOMAPPING1_DIO0_00 | RF_DIOMAPPING1_DIO2_11 ); @@ -781,7 +783,7 @@ // DIO3=FifoEmpty // DIO4=LowBat // DIO5=ModeReady - Write( REG_DIOMAPPING1, ( Read( REG_DIOMAPPING1 ) & RF_DIOMAPPING1_DIO0_MASK & + Write( REG_DIOMAPPING1, ( Read( REG_DIOMAPPING1 ) & RF_DIOMAPPING1_DIO0_MASK & RF_DIOMAPPING1_DIO1_MASK & RF_DIOMAPPING1_DIO2_MASK ) ); Write( REG_DIOMAPPING2, ( Read( REG_DIOMAPPING2 ) & RF_DIOMAPPING2_DIO4_MASK & @@ -890,8 +892,6 @@ void SX1276::OnTimeoutIrq( void ) { - RadioState state = IDLE; - switch( this->settings.State ) { case RX: @@ -910,17 +910,13 @@ if( this->settings.Fsk.RxContinuous == true ) { - state = this->settings.State; // Continuous mode restart Rx chain Write( REG_RXCONFIG, Read( REG_RXCONFIG ) | RF_RXCONFIG_RESTARTRXWITHOUTPLLLOCK ); } else { - rxTimeoutSyncWord.attach_us( this, &SX1276::OnTimeoutIrq, ( 8.0 * ( this->settings.Fsk.PreambleLen + - ( ( Read( REG_SYNCCONFIG ) & - ~RF_SYNCCONFIG_SYNCSIZE_MASK ) + - 1.0 ) + 1.0 ) / - ( double )this->settings.Fsk.Datarate ) * 1e6 ) ; + this->settings.State = IDLE; + rxTimeoutSyncWord.detach( ); } } if( ( rxTimeout != NULL ) ) @@ -929,6 +925,7 @@ } break; case TX: + this->settings.State = IDLE; if( ( txTimeout != NULL ) ) { txTimeout( ); @@ -937,7 +934,6 @@ default: break; } - this->settings.State = state; } void SX1276::OnDio0Irq( void )