SX126xDevKit
Dependencies: mbed DmTftLibrary SX126xLib
Diff: Peripherals/Eeprom.cpp
- Revision:
- 1:b96176a4ccb8
- Parent:
- 0:e5420f1a8a1a
- Child:
- 2:8e1b4210df6b
--- a/Peripherals/Eeprom.cpp Tue Sep 05 08:15:37 2017 +0000 +++ b/Peripherals/Eeprom.cpp Fri Mar 09 13:28:34 2018 +0000 @@ -64,15 +64,10 @@ static MemTestStruct_t EepromDataCheckSum( void ); uint8_t EepromMcuWriteBuffer( uint16_t addr, uint8_t *buffer, uint16_t size ); -void EepromInit( uint8_t deviceConnected ) +void EepromInit( uint8_t deviceConnected, uint8_t matchingFreq ) { MemTestStruct_t memTestStruct; - if( deviceConnected == 0xFF ) - { - EepromSetDefaultSettings( deviceConnected ); - } - EepromMcuReadBuffer( 0, Eeprom.Buffer, EEPROM_BUFFER_SIZE ); EepromLoadGeneralSettings( ); @@ -82,7 +77,7 @@ #ifdef ADV_DEBUG printf("EepromDataCheckSum failed\n\r"); #endif - EepromSetDefaultSettings( deviceConnected ); + EepromSetDefaultSettings( deviceConnected, matchingFreq ); } EepromLoadSettings( ( RadioPacketTypes_t ) Eeprom.EepromData.DemoSettings.ModulationType ); } @@ -304,7 +299,7 @@ Eeprom.EepromData.DemoSettings.ModulationType = modulation; } -void EepromSetDefaultSettings( uint8_t deviceConnected ) +void EepromSetDefaultSettings( uint8_t deviceConnected, uint8_t matchingFreq ) { Eeprom.EepromData.MenuSettings.ScreenCalibrated = false; @@ -349,21 +344,29 @@ EepromSaveSettings( RADIO_GFSK_PARAMS ); Eeprom.EepromData.DemoSettings.Entity = SLAVE; - Eeprom.EepromData.DemoSettings.BoostedRx = 0x00; + Eeprom.EepromData.DemoSettings.BoostedRx = true; if( deviceConnected == SX1261 ) { Eeprom.EepromData.DemoSettings.LastDeviceConnected = deviceConnected; Eeprom.EepromData.DemoSettings.RadioPowerMode = USE_DCDC; - Eeprom.EepromData.DemoSettings.Frequency = DEMO_CENTRAL_FREQ_PRESET1; Eeprom.EepromData.DemoSettings.TxPower = SX1261_POWER_TX_MAX; } else { Eeprom.EepromData.DemoSettings.LastDeviceConnected = deviceConnected; Eeprom.EepromData.DemoSettings.RadioPowerMode = USE_LDO; - Eeprom.EepromData.DemoSettings.Frequency = DEMO_CENTRAL_FREQ_PRESET2; Eeprom.EepromData.DemoSettings.TxPower = SX1262_POWER_TX_MAX; } + + if( matchingFreq == 1 ) + { + Eeprom.EepromData.DemoSettings.Frequency = DEMO_CENTRAL_FREQ_PRESET1; // 868 MHz + } + else + { + Eeprom.EepromData.DemoSettings.Frequency = DEMO_CENTRAL_FREQ_PRESET2; // 915 MHz + } + Eeprom.EepromData.DemoSettings.MaxNumPacket = 0x00; Eeprom.EepromData.DemoSettings.ModulationType = PACKET_TYPE_LORA; @@ -465,3 +468,9 @@ return memTestStruct; } + +void EepromEraseCheckSum( void ) +{ + memset( Eeprom.Buffer, 0, sizeof( Eeprom.Buffer ) ); + EepromMcuWriteBuffer( 0, Eeprom.Buffer, EEPROM_BUFFER_SIZE ); +}