![](/media/cache/group/Semtech_stack_color_logo_highres.jpg.50x50_q85.jpg)
This code holds the complete demo set for the sx1280: PingPong, PER and Ranging Outdoor demo application. >>>>> This code MUST run on the mbed library release 127 or everything will be painfully slow.
Dependencies: mbed SX1280Lib DmTftLibrary
* This code MUST run on the mbed library release 127 or everything will be painfully slow.*
Peripherals/Eeprom.cpp@20:626b92b70bf7, 2018-11-08 (annotated)
- Committer:
- mverdy
- Date:
- Thu Nov 08 10:14:39 2018 +0000
- Revision:
- 20:626b92b70bf7
Addition of missing modules to synchronize with v1.5.2
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mverdy | 20:626b92b70bf7 | 1 | /* |
mverdy | 20:626b92b70bf7 | 2 | ______ _ |
mverdy | 20:626b92b70bf7 | 3 | / _____) _ | | |
mverdy | 20:626b92b70bf7 | 4 | ( (____ _____ ____ _| |_ _____ ____| |__ |
mverdy | 20:626b92b70bf7 | 5 | \____ \| ___ | (_ _) ___ |/ ___) _ \ |
mverdy | 20:626b92b70bf7 | 6 | _____) ) ____| | | || |_| ____( (___| | | | |
mverdy | 20:626b92b70bf7 | 7 | (______/|_____)_|_|_| \__)_____)\____)_| |_| |
mverdy | 20:626b92b70bf7 | 8 | (C)2016 Semtech |
mverdy | 20:626b92b70bf7 | 9 | |
mverdy | 20:626b92b70bf7 | 10 | Description: EEPROM routines |
mverdy | 20:626b92b70bf7 | 11 | |
mverdy | 20:626b92b70bf7 | 12 | Maintainer: Gregory Cristian & Gilbert Menth |
mverdy | 20:626b92b70bf7 | 13 | */ |
mverdy | 20:626b92b70bf7 | 14 | |
mverdy | 20:626b92b70bf7 | 15 | #include "mbed.h" |
mverdy | 20:626b92b70bf7 | 16 | #include "string.h" |
mverdy | 20:626b92b70bf7 | 17 | #include "Eeprom.h" |
mverdy | 20:626b92b70bf7 | 18 | #include "Menu.h" |
mverdy | 20:626b92b70bf7 | 19 | #include "DemoApplication.h" |
mverdy | 20:626b92b70bf7 | 20 | #include "sx1280.h" |
mverdy | 20:626b92b70bf7 | 21 | #if defined( TARGET_NUCLEO_L476RG ) |
mverdy | 20:626b92b70bf7 | 22 | #include "stm32l4xx_hal_flash.h" |
mverdy | 20:626b92b70bf7 | 23 | #elif defined( TARGET_NUCLEO_L152RE ) |
mverdy | 20:626b92b70bf7 | 24 | #include "stm32l1xx_hal_flash.h" |
mverdy | 20:626b92b70bf7 | 25 | #else |
mverdy | 20:626b92b70bf7 | 26 | #error "Please define include file" |
mverdy | 20:626b92b70bf7 | 27 | #endif |
mverdy | 20:626b92b70bf7 | 28 | #include "DisplayDriver.h" |
mverdy | 20:626b92b70bf7 | 29 | |
mverdy | 20:626b92b70bf7 | 30 | |
mverdy | 20:626b92b70bf7 | 31 | /*! |
mverdy | 20:626b92b70bf7 | 32 | * \brief Define address of Emulated EEPROM (in fact region of Flash) |
mverdy | 20:626b92b70bf7 | 33 | */ |
mverdy | 20:626b92b70bf7 | 34 | #if defined( TARGET_NUCLEO_L476RG ) |
mverdy | 20:626b92b70bf7 | 35 | #define DATA_EEPROM_BASE ( ( uint32_t )0x0807F800U ) |
mverdy | 20:626b92b70bf7 | 36 | #define DATA_EEPROM_END ( ( uint32_t )DATA_EEPROM_BASE + 2048 ) |
mverdy | 20:626b92b70bf7 | 37 | #elif defined( TARGET_NUCLEO_L152RE ) |
mverdy | 20:626b92b70bf7 | 38 | #define DATA_EEPROM_BASE ( ( uint32_t )0x08080000U ) |
mverdy | 20:626b92b70bf7 | 39 | #define DATA_EEPROM_END ( ( uint32_t )0x080807FFU ) |
mverdy | 20:626b92b70bf7 | 40 | #else |
mverdy | 20:626b92b70bf7 | 41 | #error "Please define EEPROM base address and size for your board " |
mverdy | 20:626b92b70bf7 | 42 | #endif |
mverdy | 20:626b92b70bf7 | 43 | |
mverdy | 20:626b92b70bf7 | 44 | |
mverdy | 20:626b92b70bf7 | 45 | /*! |
mverdy | 20:626b92b70bf7 | 46 | * \brief CRC of EEPROM buffer and its valid status |
mverdy | 20:626b92b70bf7 | 47 | */ |
mverdy | 20:626b92b70bf7 | 48 | typedef struct |
mverdy | 20:626b92b70bf7 | 49 | { |
mverdy | 20:626b92b70bf7 | 50 | uint16_t Value; |
mverdy | 20:626b92b70bf7 | 51 | bool Valid; |
mverdy | 20:626b92b70bf7 | 52 | }MemTestStruct_t; |
mverdy | 20:626b92b70bf7 | 53 | |
mverdy | 20:626b92b70bf7 | 54 | /*! |
mverdy | 20:626b92b70bf7 | 55 | * \brief Local copy of Eeprom. |
mverdy | 20:626b92b70bf7 | 56 | */ |
mverdy | 20:626b92b70bf7 | 57 | Eeprom_t Eeprom; |
mverdy | 20:626b92b70bf7 | 58 | |
mverdy | 20:626b92b70bf7 | 59 | |
mverdy | 20:626b92b70bf7 | 60 | // Check CRC of local copy of Eeprom (Buffer). This update Valid & Value |
mverdy | 20:626b92b70bf7 | 61 | static MemTestStruct_t EepromDataCheckSum( void ); |
mverdy | 20:626b92b70bf7 | 62 | uint8_t EepromMcuWriteBuffer( uint16_t addr, uint8_t *buffer, uint16_t size ); |
mverdy | 20:626b92b70bf7 | 63 | |
mverdy | 20:626b92b70bf7 | 64 | void EepromInit( void ) |
mverdy | 20:626b92b70bf7 | 65 | { |
mverdy | 20:626b92b70bf7 | 66 | MemTestStruct_t memTestStruct; |
mverdy | 20:626b92b70bf7 | 67 | |
mverdy | 20:626b92b70bf7 | 68 | EepromMcuReadBuffer( 0, Eeprom.Buffer, EEPROM_BUFFER_SIZE ); |
mverdy | 20:626b92b70bf7 | 69 | EepromLoadGeneralSettings( ); |
mverdy | 20:626b92b70bf7 | 70 | |
mverdy | 20:626b92b70bf7 | 71 | memTestStruct = EepromDataCheckSum( ); |
mverdy | 20:626b92b70bf7 | 72 | if( !( memTestStruct.Valid ) ) |
mverdy | 20:626b92b70bf7 | 73 | { |
mverdy | 20:626b92b70bf7 | 74 | #ifdef PRINT_DEBUG |
mverdy | 20:626b92b70bf7 | 75 | printf("EepromDataCheckSum failed\n\r"); |
mverdy | 20:626b92b70bf7 | 76 | #endif |
mverdy | 20:626b92b70bf7 | 77 | EepromSetDefaultSettings( ); |
mverdy | 20:626b92b70bf7 | 78 | } |
mverdy | 20:626b92b70bf7 | 79 | EepromLoadSettings( ( RadioPacketTypes_t ) Eeprom.EepromData.DemoSettings.ModulationType ); |
mverdy | 20:626b92b70bf7 | 80 | } |
mverdy | 20:626b92b70bf7 | 81 | |
mverdy | 20:626b92b70bf7 | 82 | void EepromSaveSettings( EepromDataSet_t dataSet) |
mverdy | 20:626b92b70bf7 | 83 | { |
mverdy | 20:626b92b70bf7 | 84 | MemTestStruct_t memTestStruct; |
mverdy | 20:626b92b70bf7 | 85 | |
mverdy | 20:626b92b70bf7 | 86 | switch( dataSet ) |
mverdy | 20:626b92b70bf7 | 87 | { |
mverdy | 20:626b92b70bf7 | 88 | case RADIO_LORA_PARAMS: |
mverdy | 20:626b92b70bf7 | 89 | Eeprom.EepromData.ModulationParams.Params.LoRa.SpreadingFactor = ( RadioLoRaSpreadingFactors_t ) Eeprom.EepromData.DemoSettings.ModulationParam1; |
mverdy | 20:626b92b70bf7 | 90 | Eeprom.EepromData.ModulationParams.Params.LoRa.Bandwidth = ( RadioLoRaBandwidths_t ) Eeprom.EepromData.DemoSettings.ModulationParam2; |
mverdy | 20:626b92b70bf7 | 91 | Eeprom.EepromData.ModulationParams.Params.LoRa.CodingRate = ( RadioLoRaCodingRates_t ) Eeprom.EepromData.DemoSettings.ModulationParam3; |
mverdy | 20:626b92b70bf7 | 92 | Eeprom.EepromData.PacketParams.Params.LoRa.PreambleLength = Eeprom.EepromData.DemoSettings.PacketParam1; |
mverdy | 20:626b92b70bf7 | 93 | Eeprom.EepromData.PacketParams.Params.LoRa.HeaderType = ( RadioLoRaPacketLengthsModes_t )Eeprom.EepromData.DemoSettings.PacketParam2; |
mverdy | 20:626b92b70bf7 | 94 | Eeprom.EepromData.PacketParams.Params.LoRa.PayloadLength = Eeprom.EepromData.DemoSettings.PacketParam3; |
mverdy | 20:626b92b70bf7 | 95 | Eeprom.EepromData.PacketParams.Params.LoRa.Crc = ( RadioLoRaCrcModes_t ) Eeprom.EepromData.DemoSettings.PacketParam4; |
mverdy | 20:626b92b70bf7 | 96 | Eeprom.EepromData.PacketParams.Params.LoRa.InvertIQ = ( RadioLoRaIQModes_t ) Eeprom.EepromData.DemoSettings.PacketParam5; |
mverdy | 20:626b92b70bf7 | 97 | |
mverdy | 20:626b92b70bf7 | 98 | memcpy( Eeprom.Buffer + MOD_LOR_SPREADF_EEPROM_ADDR, &( Eeprom.EepromData.ModulationParams.Params.LoRa.SpreadingFactor ), 1 ); |
mverdy | 20:626b92b70bf7 | 99 | memcpy( Eeprom.Buffer + MOD_LOR_BW_EEPROM_ADDR, &( Eeprom.EepromData.ModulationParams.Params.LoRa.Bandwidth ), 1 ); |
mverdy | 20:626b92b70bf7 | 100 | memcpy( Eeprom.Buffer + MOD_LOR_CODERATE_EEPROM_ADDR, &( Eeprom.EepromData.ModulationParams.Params.LoRa.CodingRate ), 1 ); |
mverdy | 20:626b92b70bf7 | 101 | memcpy( Eeprom.Buffer + PAK_LOR_PREAMBLE_LEN_EEPROM_ADDR, &( Eeprom.EepromData.PacketParams.Params.LoRa.PreambleLength ), 1 ); |
mverdy | 20:626b92b70bf7 | 102 | memcpy( Eeprom.Buffer + PAK_LOR_HEADERTYPE_EEPROM_ADDR, &( Eeprom.EepromData.PacketParams.Params.LoRa.HeaderType ), 1 ); |
mverdy | 20:626b92b70bf7 | 103 | memcpy( Eeprom.Buffer + PAK_LOR_PL_LEN_EEPROM_ADDR, &( Eeprom.EepromData.PacketParams.Params.LoRa.PayloadLength ), 1 ); |
mverdy | 20:626b92b70bf7 | 104 | memcpy( Eeprom.Buffer + PAK_LOR_CRC_MODE_EEPROM_ADDR, &( Eeprom.EepromData.PacketParams.Params.LoRa.Crc ), 1 ); |
mverdy | 20:626b92b70bf7 | 105 | memcpy( Eeprom.Buffer + PAK_LOR_IQ_INV_EEPROM_ADDR, &( Eeprom.EepromData.PacketParams.Params.LoRa.InvertIQ ), 1 ); |
mverdy | 20:626b92b70bf7 | 106 | #ifdef PRINT_DEBUG |
mverdy | 20:626b92b70bf7 | 107 | printf("Saved RADIO_LORA_PARAMS\n\r"); |
mverdy | 20:626b92b70bf7 | 108 | #endif |
mverdy | 20:626b92b70bf7 | 109 | break; |
mverdy | 20:626b92b70bf7 | 110 | |
mverdy | 20:626b92b70bf7 | 111 | case RADIO_RANGING_PARAMS: |
mverdy | 20:626b92b70bf7 | 112 | memcpy( Eeprom.Buffer + MOD_RNG_SPREADF_EEPROM_ADDR, &( Eeprom.EepromData.DemoSettings.ModulationParam1 ), 1 ); |
mverdy | 20:626b92b70bf7 | 113 | memcpy( Eeprom.Buffer + MOD_RNG_BW_EEPROM_ADDR, &( Eeprom.EepromData.DemoSettings.ModulationParam2 ), 1 ); |
mverdy | 20:626b92b70bf7 | 114 | memcpy( Eeprom.Buffer + MOD_RNG_CODERATE_EEPROM_ADDR, &( Eeprom.EepromData.DemoSettings.ModulationParam3 ), 1 ); |
mverdy | 20:626b92b70bf7 | 115 | memcpy( Eeprom.Buffer + PAK_RNG_PREAMBLE_LEN_EEPROM_ADDR, &( Eeprom.EepromData.DemoSettings.PacketParam1 ), 1 ); |
mverdy | 20:626b92b70bf7 | 116 | memcpy( Eeprom.Buffer + PAK_RNG_HEADERTYPE_EEPROM_ADDR, &( Eeprom.EepromData.DemoSettings.PacketParam2 ), 1 ); |
mverdy | 20:626b92b70bf7 | 117 | memcpy( Eeprom.Buffer + PAK_RNG_PL_LEN_EEPROM_ADDR, &( Eeprom.EepromData.DemoSettings.PacketParam3 ), 1 ); |
mverdy | 20:626b92b70bf7 | 118 | memcpy( Eeprom.Buffer + PAK_RNG_CRC_MODE_EEPROM_ADDR, &( Eeprom.EepromData.DemoSettings.PacketParam4 ), 1 ); |
mverdy | 20:626b92b70bf7 | 119 | memcpy( Eeprom.Buffer + PAK_RNG_IQ_INV_EEPROM_ADDR, &( Eeprom.EepromData.DemoSettings.PacketParam5 ), 1 ); |
mverdy | 20:626b92b70bf7 | 120 | |
mverdy | 20:626b92b70bf7 | 121 | memcpy( Eeprom.Buffer + APP_RNG_REQ_COUNT_EEPROM_ADDR, &( Eeprom.EepromData.DemoSettings.RngRequestCount ), 1 ); |
mverdy | 20:626b92b70bf7 | 122 | memcpy( Eeprom.Buffer + APP_RNG_FULLSCALE_EEPROM_ADDR, &( Eeprom.EepromData.DemoSettings.RngFullScale ), 2 ); |
mverdy | 20:626b92b70bf7 | 123 | memcpy( Eeprom.Buffer + APP_RNG_ADDR_EEPROM_ADDR, &( Eeprom.EepromData.DemoSettings.RngAddress ), 4 ); |
mverdy | 20:626b92b70bf7 | 124 | memcpy( Eeprom.Buffer + APP_RNG_ANT_EEPROM_ADDR, &( Eeprom.EepromData.DemoSettings.RngAntenna ), 1 ); |
mverdy | 20:626b92b70bf7 | 125 | memcpy( Eeprom.Buffer + APP_RNG_UNIT_EEPROM_ADDR, &( Eeprom.EepromData.DemoSettings.RngUnit ), 1 ); |
mverdy | 20:626b92b70bf7 | 126 | #ifdef PRINT_DEBUG |
mverdy | 20:626b92b70bf7 | 127 | printf("Saved RADIO_RANGING_PARAMS\n\r"); |
mverdy | 20:626b92b70bf7 | 128 | #endif |
mverdy | 20:626b92b70bf7 | 129 | break; |
mverdy | 20:626b92b70bf7 | 130 | |
mverdy | 20:626b92b70bf7 | 131 | case RADIO_FLRC_PARAMS: |
mverdy | 20:626b92b70bf7 | 132 | Eeprom.EepromData.ModulationParams.Params.Flrc.BitrateBandwidth = ( RadioFlrcBitrates_t ) Eeprom.EepromData.DemoSettings.ModulationParam1; |
mverdy | 20:626b92b70bf7 | 133 | Eeprom.EepromData.ModulationParams.Params.Flrc.CodingRate = ( RadioFlrcCodingRates_t ) Eeprom.EepromData.DemoSettings.ModulationParam2; |
mverdy | 20:626b92b70bf7 | 134 | Eeprom.EepromData.ModulationParams.Params.Flrc.ModulationShaping = ( RadioModShapings_t ) Eeprom.EepromData.DemoSettings.ModulationParam3; |
mverdy | 20:626b92b70bf7 | 135 | Eeprom.EepromData.PacketParams.Params.Flrc.PreambleLength = ( RadioPreambleLengths_t ) Eeprom.EepromData.DemoSettings.PacketParam1; |
mverdy | 20:626b92b70bf7 | 136 | Eeprom.EepromData.PacketParams.Params.Flrc.SyncWordLength = ( RadioFlrcSyncWordLengths_t )Eeprom.EepromData.DemoSettings.PacketParam2; |
mverdy | 20:626b92b70bf7 | 137 | Eeprom.EepromData.PacketParams.Params.Flrc.SyncWordMatch = ( RadioSyncWordRxMatchs_t ) Eeprom.EepromData.DemoSettings.PacketParam3; |
mverdy | 20:626b92b70bf7 | 138 | Eeprom.EepromData.PacketParams.Params.Flrc.HeaderType = ( RadioPacketLengthModes_t ) Eeprom.EepromData.DemoSettings.PacketParam4; |
mverdy | 20:626b92b70bf7 | 139 | Eeprom.EepromData.PacketParams.Params.Flrc.PayloadLength = Eeprom.EepromData.DemoSettings.PacketParam5; |
mverdy | 20:626b92b70bf7 | 140 | Eeprom.EepromData.PacketParams.Params.Flrc.CrcLength = ( RadioCrcTypes_t ) Eeprom.EepromData.DemoSettings.PacketParam6; |
mverdy | 20:626b92b70bf7 | 141 | Eeprom.EepromData.PacketParams.Params.Flrc.Whitening = ( RadioWhiteningModes_t ) Eeprom.EepromData.DemoSettings.PacketParam7; |
mverdy | 20:626b92b70bf7 | 142 | |
mverdy | 20:626b92b70bf7 | 143 | memcpy( Eeprom.Buffer + MOD_FLR_BRBW_EEPROM_ADDR, &( Eeprom.EepromData.ModulationParams.Params.Flrc.BitrateBandwidth ), 1 ); |
mverdy | 20:626b92b70bf7 | 144 | memcpy( Eeprom.Buffer + MOD_FLR_CODERATE_EEPROM_ADDR, &( Eeprom.EepromData.ModulationParams.Params.Flrc.CodingRate ), 1 ); |
mverdy | 20:626b92b70bf7 | 145 | memcpy( Eeprom.Buffer + MOD_FLR_MOD_SHAP_EEPROM_ADDR, &( Eeprom.EepromData.ModulationParams.Params.Flrc.ModulationShaping ), 1 ); |
mverdy | 20:626b92b70bf7 | 146 | memcpy( Eeprom.Buffer + PAK_FLR_PREAMBLE_LEN_EEPROM_ADDR, &( Eeprom.EepromData.PacketParams.Params.Flrc.PreambleLength ), 1 ); |
mverdy | 20:626b92b70bf7 | 147 | memcpy( Eeprom.Buffer + PAK_FLR_SYNC_LEN_EEPROM_ADDR, &( Eeprom.EepromData.PacketParams.Params.Flrc.SyncWordLength ), 1 ); |
mverdy | 20:626b92b70bf7 | 148 | memcpy( Eeprom.Buffer + PAK_FLR_SYNC_MATCH_EEPROM_ADDR, &( Eeprom.EepromData.PacketParams.Params.Flrc.SyncWordMatch ), 1 ); |
mverdy | 20:626b92b70bf7 | 149 | memcpy( Eeprom.Buffer + PAK_FLR_HEADERTYPE_EEPROM_ADDR, &( Eeprom.EepromData.PacketParams.Params.Flrc.HeaderType ), 1 ); |
mverdy | 20:626b92b70bf7 | 150 | memcpy( Eeprom.Buffer + PAK_FLR_PL_LEN_EEPROM_ADDR, &( Eeprom.EepromData.PacketParams.Params.Flrc.PayloadLength ), 1 ); |
mverdy | 20:626b92b70bf7 | 151 | memcpy( Eeprom.Buffer + PAK_FLR_CRC_LEN_EEPROM_ADDR, &( Eeprom.EepromData.PacketParams.Params.Flrc.CrcLength ), 1 ); |
mverdy | 20:626b92b70bf7 | 152 | memcpy( Eeprom.Buffer + PAK_FLR_WHITENING_EEPROM_ADDR, &( Eeprom.EepromData.PacketParams.Params.Flrc.Whitening ), 1 ); |
mverdy | 20:626b92b70bf7 | 153 | #ifdef PRINT_DEBUG |
mverdy | 20:626b92b70bf7 | 154 | printf("Saved RADIO_FLRC_PARAMS\n\r"); |
mverdy | 20:626b92b70bf7 | 155 | #endif |
mverdy | 20:626b92b70bf7 | 156 | break; |
mverdy | 20:626b92b70bf7 | 157 | |
mverdy | 20:626b92b70bf7 | 158 | case RADIO_GFSK_PARAMS: |
mverdy | 20:626b92b70bf7 | 159 | Eeprom.EepromData.ModulationParams.Params.Gfsk.BitrateBandwidth = ( RadioGfskBleBitrates_t ) Eeprom.EepromData.DemoSettings.ModulationParam1; |
mverdy | 20:626b92b70bf7 | 160 | Eeprom.EepromData.ModulationParams.Params.Gfsk.ModulationIndex = ( RadioGfskBleModIndexes_t )Eeprom.EepromData.DemoSettings.ModulationParam2; |
mverdy | 20:626b92b70bf7 | 161 | Eeprom.EepromData.ModulationParams.Params.Gfsk.ModulationShaping = ( RadioModShapings_t ) Eeprom.EepromData.DemoSettings.ModulationParam3; |
mverdy | 20:626b92b70bf7 | 162 | Eeprom.EepromData.PacketParams.Params.Gfsk.PreambleLength = ( RadioPreambleLengths_t ) Eeprom.EepromData.DemoSettings.PacketParam1; |
mverdy | 20:626b92b70bf7 | 163 | Eeprom.EepromData.PacketParams.Params.Gfsk.SyncWordLength = ( RadioSyncWordLengths_t ) Eeprom.EepromData.DemoSettings.PacketParam2; |
mverdy | 20:626b92b70bf7 | 164 | Eeprom.EepromData.PacketParams.Params.Gfsk.SyncWordMatch = ( RadioSyncWordRxMatchs_t ) Eeprom.EepromData.DemoSettings.PacketParam3; |
mverdy | 20:626b92b70bf7 | 165 | Eeprom.EepromData.PacketParams.Params.Gfsk.HeaderType = ( RadioPacketLengthModes_t )Eeprom.EepromData.DemoSettings.PacketParam4; |
mverdy | 20:626b92b70bf7 | 166 | Eeprom.EepromData.PacketParams.Params.Gfsk.PayloadLength = Eeprom.EepromData.DemoSettings.PacketParam5; |
mverdy | 20:626b92b70bf7 | 167 | Eeprom.EepromData.PacketParams.Params.Gfsk.CrcLength = ( RadioCrcTypes_t ) Eeprom.EepromData.DemoSettings.PacketParam6; |
mverdy | 20:626b92b70bf7 | 168 | Eeprom.EepromData.PacketParams.Params.Gfsk.Whitening = ( RadioWhiteningModes_t ) Eeprom.EepromData.DemoSettings.PacketParam7; |
mverdy | 20:626b92b70bf7 | 169 | |
mverdy | 20:626b92b70bf7 | 170 | memcpy( Eeprom.Buffer + MOD_GFS_BRBW_EEPROM_ADDR, &( Eeprom.EepromData.ModulationParams.Params.Gfsk.BitrateBandwidth ), 1 ); |
mverdy | 20:626b92b70bf7 | 171 | memcpy( Eeprom.Buffer + MOD_GFS_MOD_IND_EEPROM_ADDR, &( Eeprom.EepromData.ModulationParams.Params.Gfsk.ModulationIndex ), 1 ); |
mverdy | 20:626b92b70bf7 | 172 | memcpy( Eeprom.Buffer + MOD_GFS_MOD_SHAP_EEPROM_ADDR, &( Eeprom.EepromData.ModulationParams.Params.Gfsk.ModulationShaping ), 1 ); |
mverdy | 20:626b92b70bf7 | 173 | memcpy( Eeprom.Buffer + PAK_GFS_PREAMBLE_LEN_EEPROM_ADDR, &( Eeprom.EepromData.PacketParams.Params.Gfsk.PreambleLength ), 1 ); |
mverdy | 20:626b92b70bf7 | 174 | memcpy( Eeprom.Buffer + PAK_GFS_SYNC_LEN_EEPROM_ADDR, &( Eeprom.EepromData.PacketParams.Params.Gfsk.SyncWordLength ), 1 ); |
mverdy | 20:626b92b70bf7 | 175 | memcpy( Eeprom.Buffer + PAK_GFS_SYNC_MATCH_EEPROM_ADDR, &( Eeprom.EepromData.PacketParams.Params.Gfsk.SyncWordMatch ), 1 ); |
mverdy | 20:626b92b70bf7 | 176 | memcpy( Eeprom.Buffer + PAK_GFS_HEADERTYPE_EEPROM_ADDR, &( Eeprom.EepromData.PacketParams.Params.Gfsk.HeaderType ), 1 ); |
mverdy | 20:626b92b70bf7 | 177 | memcpy( Eeprom.Buffer + PAK_GFS_PL_LEN_EEPROM_ADDR, &( Eeprom.EepromData.PacketParams.Params.Gfsk.PayloadLength ), 1 ); |
mverdy | 20:626b92b70bf7 | 178 | memcpy( Eeprom.Buffer + PAK_GFS_CRC_LEN_EEPROM_ADDR, &( Eeprom.EepromData.PacketParams.Params.Gfsk.CrcLength ), 1 ); |
mverdy | 20:626b92b70bf7 | 179 | memcpy( Eeprom.Buffer + PAK_GFS_WHITENING_EEPROM_ADDR, &( Eeprom.EepromData.PacketParams.Params.Gfsk.Whitening ), 1 ); |
mverdy | 20:626b92b70bf7 | 180 | #ifdef PRINT_DEBUG |
mverdy | 20:626b92b70bf7 | 181 | printf("Saved RADIO_GFSK_PARAMS\n\r"); |
mverdy | 20:626b92b70bf7 | 182 | #endif |
mverdy | 20:626b92b70bf7 | 183 | break; |
mverdy | 20:626b92b70bf7 | 184 | |
mverdy | 20:626b92b70bf7 | 185 | case DEMO_SETTINGS: |
mverdy | 20:626b92b70bf7 | 186 | memcpy( Eeprom.Buffer + APP_ENTITY_EEPROM_ADDR, &( Eeprom.EepromData.DemoSettings.Entity ), 1 ); |
mverdy | 20:626b92b70bf7 | 187 | memcpy( Eeprom.Buffer + APP_ANT_SW_EEPROM_ADDR, &( Eeprom.EepromData.DemoSettings.AntennaSwitch ), 1 ); |
mverdy | 20:626b92b70bf7 | 188 | memcpy( Eeprom.Buffer + APP_FREQ_EEPROM_ADDR, &( Eeprom.EepromData.DemoSettings.Frequency ), 4 ); |
mverdy | 20:626b92b70bf7 | 189 | memcpy( Eeprom.Buffer + APP_TXPWR_EEPROM_ADDR, &( Eeprom.EepromData.DemoSettings.TxPower ), 1 ); |
mverdy | 20:626b92b70bf7 | 190 | memcpy( Eeprom.Buffer + APP_MOD_TYPE_EEPROM_ADDR, &( Eeprom.EepromData.DemoSettings.ModulationType ), 1 ); |
mverdy | 20:626b92b70bf7 | 191 | memcpy( Eeprom.Buffer + APP_PER_NPAK_MAX_EEPROM_ADDR, &( Eeprom.EepromData.DemoSettings.MaxNumPacket ), 4 ); |
mverdy | 20:626b92b70bf7 | 192 | memcpy( Eeprom.Buffer + APP_RADIO_POWER_MODE_EEPROM_ADDR, &( Eeprom.EepromData.DemoSettings.RadioPowerMode ), 1 ); |
mverdy | 20:626b92b70bf7 | 193 | memcpy( Eeprom.Buffer + MOD_PAK_TYPE_EEPROM_ADDR, &( Eeprom.EepromData.DemoSettings.ModulationType ), 1 ); |
mverdy | 20:626b92b70bf7 | 194 | memcpy( Eeprom.Buffer + PAK_PAK_TYPE_EEPROM_ADDR, &( Eeprom.EepromData.DemoSettings.ModulationType ), 1 ); |
mverdy | 20:626b92b70bf7 | 195 | #ifdef PRINT_DEBUG |
mverdy | 20:626b92b70bf7 | 196 | printf("Saved DEMO_SETTINGS\n\r"); |
mverdy | 20:626b92b70bf7 | 197 | #endif |
mverdy | 20:626b92b70bf7 | 198 | break; |
mverdy | 20:626b92b70bf7 | 199 | |
mverdy | 20:626b92b70bf7 | 200 | case SCREEN_DATA: |
mverdy | 20:626b92b70bf7 | 201 | memcpy( Eeprom.Buffer + SCR_CAL_FLAG_EEPROM_ADDR, &( Eeprom.EepromData.MenuSettings.ScreenCalibrated ), 1 ); |
mverdy | 20:626b92b70bf7 | 202 | memcpy( Eeprom.Buffer + SCR_CAL_POSA_EEPROM_ADDR, &( Eeprom.EepromData.MenuSettings.Calibration.a ), 4 ); |
mverdy | 20:626b92b70bf7 | 203 | memcpy( Eeprom.Buffer + SCR_CAL_POSB_EEPROM_ADDR, &( Eeprom.EepromData.MenuSettings.Calibration.b ), 4 ); |
mverdy | 20:626b92b70bf7 | 204 | memcpy( Eeprom.Buffer + SCR_CAL_POSC_EEPROM_ADDR, &( Eeprom.EepromData.MenuSettings.Calibration.c ), 4 ); |
mverdy | 20:626b92b70bf7 | 205 | memcpy( Eeprom.Buffer + SCR_CAL_POSD_EEPROM_ADDR, &( Eeprom.EepromData.MenuSettings.Calibration.d ), 4 ); |
mverdy | 20:626b92b70bf7 | 206 | memcpy( Eeprom.Buffer + SCR_CAL_POSE_EEPROM_ADDR, &( Eeprom.EepromData.MenuSettings.Calibration.e ), 4 ); |
mverdy | 20:626b92b70bf7 | 207 | memcpy( Eeprom.Buffer + SCR_CAL_POSF_EEPROM_ADDR, &( Eeprom.EepromData.MenuSettings.Calibration.f ), 4 ); |
mverdy | 20:626b92b70bf7 | 208 | break; |
mverdy | 20:626b92b70bf7 | 209 | |
mverdy | 20:626b92b70bf7 | 210 | default: |
mverdy | 20:626b92b70bf7 | 211 | #ifdef PRINT_DEBUG |
mverdy | 20:626b92b70bf7 | 212 | printf("data not saved\n\r"); |
mverdy | 20:626b92b70bf7 | 213 | #endif |
mverdy | 20:626b92b70bf7 | 214 | break; |
mverdy | 20:626b92b70bf7 | 215 | } |
mverdy | 20:626b92b70bf7 | 216 | |
mverdy | 20:626b92b70bf7 | 217 | memTestStruct = EepromDataCheckSum( ); |
mverdy | 20:626b92b70bf7 | 218 | memcpy( Eeprom.Buffer + EEPROM_CRC_EEPROM_ADDR, &( memTestStruct.Value ), 2 ); |
mverdy | 20:626b92b70bf7 | 219 | |
mverdy | 20:626b92b70bf7 | 220 | EepromMcuWriteBuffer( 0, Eeprom.Buffer, EEPROM_BUFFER_SIZE ); |
mverdy | 20:626b92b70bf7 | 221 | } |
mverdy | 20:626b92b70bf7 | 222 | |
mverdy | 20:626b92b70bf7 | 223 | void EepromLoadGeneralSettings( void ) |
mverdy | 20:626b92b70bf7 | 224 | { |
mverdy | 20:626b92b70bf7 | 225 | printf("Load General Settings\n\r"); |
mverdy | 20:626b92b70bf7 | 226 | memcpy( &( Eeprom.EepromData.MenuSettings.ScreenCalibrated ), Eeprom.Buffer + SCR_CAL_FLAG_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 227 | memcpy( &( Eeprom.EepromData.MenuSettings.Calibration.a ), Eeprom.Buffer + SCR_CAL_POSA_EEPROM_ADDR, 4 ); |
mverdy | 20:626b92b70bf7 | 228 | memcpy( &( Eeprom.EepromData.MenuSettings.Calibration.b ), Eeprom.Buffer + SCR_CAL_POSB_EEPROM_ADDR, 4 ); |
mverdy | 20:626b92b70bf7 | 229 | memcpy( &( Eeprom.EepromData.MenuSettings.Calibration.c ), Eeprom.Buffer + SCR_CAL_POSC_EEPROM_ADDR, 4 ); |
mverdy | 20:626b92b70bf7 | 230 | memcpy( &( Eeprom.EepromData.MenuSettings.Calibration.d ), Eeprom.Buffer + SCR_CAL_POSD_EEPROM_ADDR, 4 ); |
mverdy | 20:626b92b70bf7 | 231 | memcpy( &( Eeprom.EepromData.MenuSettings.Calibration.e ), Eeprom.Buffer + SCR_CAL_POSE_EEPROM_ADDR, 4 ); |
mverdy | 20:626b92b70bf7 | 232 | memcpy( &( Eeprom.EepromData.MenuSettings.Calibration.f ), Eeprom.Buffer + SCR_CAL_POSF_EEPROM_ADDR, 4 ); |
mverdy | 20:626b92b70bf7 | 233 | |
mverdy | 20:626b92b70bf7 | 234 | memcpy( &( Eeprom.EepromData.DemoSettings.Entity ), Eeprom.Buffer + APP_ENTITY_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 235 | memcpy( &( Eeprom.EepromData.DemoSettings.AntennaSwitch ), Eeprom.Buffer + APP_ANT_SW_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 236 | memcpy( &( Eeprom.EepromData.DemoSettings.Frequency ), Eeprom.Buffer + APP_FREQ_EEPROM_ADDR, 4 ); |
mverdy | 20:626b92b70bf7 | 237 | memcpy( &( Eeprom.EepromData.DemoSettings.RadioPowerMode ), Eeprom.Buffer + APP_RADIO_POWER_MODE_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 238 | memcpy( &( Eeprom.EepromData.DemoSettings.TxPower ), Eeprom.Buffer + APP_TXPWR_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 239 | memcpy( &( Eeprom.EepromData.DemoSettings.ModulationType ), Eeprom.Buffer + APP_MOD_TYPE_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 240 | memcpy( &( Eeprom.EepromData.DemoSettings.MaxNumPacket ), Eeprom.Buffer + APP_PER_NPAK_MAX_EEPROM_ADDR, 4 ); |
mverdy | 20:626b92b70bf7 | 241 | |
mverdy | 20:626b92b70bf7 | 242 | memcpy( &( Eeprom.EepromData.ModulationParams.PacketType ), Eeprom.Buffer + MOD_PAK_TYPE_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 243 | memcpy( &( Eeprom.EepromData.ModulationParams.Params.Gfsk.BitrateBandwidth ), Eeprom.Buffer + MOD_GFS_BRBW_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 244 | memcpy( &( Eeprom.EepromData.ModulationParams.Params.Gfsk.ModulationIndex ), Eeprom.Buffer + MOD_GFS_MOD_IND_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 245 | memcpy( &( Eeprom.EepromData.ModulationParams.Params.Gfsk.ModulationShaping ), Eeprom.Buffer + MOD_GFS_MOD_SHAP_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 246 | memcpy( &( Eeprom.EepromData.ModulationParams.Params.LoRa.SpreadingFactor ), Eeprom.Buffer + MOD_LOR_SPREADF_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 247 | memcpy( &( Eeprom.EepromData.ModulationParams.Params.LoRa.Bandwidth ), Eeprom.Buffer + MOD_LOR_BW_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 248 | memcpy( &( Eeprom.EepromData.ModulationParams.Params.LoRa.CodingRate ), Eeprom.Buffer + MOD_LOR_CODERATE_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 249 | memcpy( &( Eeprom.EepromData.ModulationParams.Params.Flrc.BitrateBandwidth ), Eeprom.Buffer + MOD_FLR_BRBW_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 250 | memcpy( &( Eeprom.EepromData.ModulationParams.Params.Flrc.CodingRate ), Eeprom.Buffer + MOD_FLR_CODERATE_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 251 | memcpy( &( Eeprom.EepromData.ModulationParams.Params.Flrc.ModulationShaping ), Eeprom.Buffer + MOD_FLR_MOD_SHAP_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 252 | memcpy( &( Eeprom.EepromData.ModulationParams.Params.Ble.BitrateBandwidth ), Eeprom.Buffer + MOD_BLE_BRBW_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 253 | memcpy( &( Eeprom.EepromData.ModulationParams.Params.Ble.ModulationIndex ), Eeprom.Buffer + MOD_BLE_MOD_IND_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 254 | memcpy( &( Eeprom.EepromData.ModulationParams.Params.Ble.ModulationShaping ), Eeprom.Buffer + MOD_BLE_MOD_SHAP_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 255 | |
mverdy | 20:626b92b70bf7 | 256 | memcpy( &( Eeprom.EepromData.PacketParams.PacketType ), Eeprom.Buffer + PAK_PAK_TYPE_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 257 | memcpy( &( Eeprom.EepromData.PacketParams.Params.Gfsk.PreambleLength ), Eeprom.Buffer + PAK_GFS_PREAMBLE_LEN_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 258 | memcpy( &( Eeprom.EepromData.PacketParams.Params.Gfsk.SyncWordLength ), Eeprom.Buffer + PAK_GFS_SYNC_LEN_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 259 | memcpy( &( Eeprom.EepromData.PacketParams.Params.Gfsk.SyncWordMatch ), Eeprom.Buffer + PAK_GFS_SYNC_MATCH_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 260 | memcpy( &( Eeprom.EepromData.PacketParams.Params.Gfsk.HeaderType ), Eeprom.Buffer + PAK_GFS_HEADERTYPE_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 261 | memcpy( &( Eeprom.EepromData.PacketParams.Params.Gfsk.PayloadLength ), Eeprom.Buffer + PAK_GFS_PL_LEN_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 262 | memcpy( &( Eeprom.EepromData.PacketParams.Params.Gfsk.CrcLength ), Eeprom.Buffer + PAK_GFS_CRC_LEN_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 263 | memcpy( &( Eeprom.EepromData.PacketParams.Params.Gfsk.Whitening ), Eeprom.Buffer + PAK_GFS_WHITENING_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 264 | memcpy( &( Eeprom.EepromData.PacketParams.Params.LoRa.PreambleLength ), Eeprom.Buffer + PAK_LOR_PREAMBLE_LEN_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 265 | memcpy( &( Eeprom.EepromData.PacketParams.Params.LoRa.HeaderType ), Eeprom.Buffer + PAK_LOR_HEADERTYPE_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 266 | memcpy( &( Eeprom.EepromData.PacketParams.Params.LoRa.PayloadLength ), Eeprom.Buffer + PAK_LOR_PL_LEN_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 267 | memcpy( &( Eeprom.EepromData.PacketParams.Params.LoRa.Crc ), Eeprom.Buffer + PAK_LOR_CRC_MODE_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 268 | memcpy( &( Eeprom.EepromData.PacketParams.Params.LoRa.InvertIQ ), Eeprom.Buffer + PAK_LOR_IQ_INV_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 269 | memcpy( &( Eeprom.EepromData.PacketParams.Params.Flrc.PreambleLength ), Eeprom.Buffer + PAK_FLR_PREAMBLE_LEN_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 270 | memcpy( &( Eeprom.EepromData.PacketParams.Params.Flrc.SyncWordLength ), Eeprom.Buffer + PAK_FLR_SYNC_LEN_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 271 | memcpy( &( Eeprom.EepromData.PacketParams.Params.Flrc.SyncWordMatch ), Eeprom.Buffer + PAK_FLR_SYNC_MATCH_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 272 | memcpy( &( Eeprom.EepromData.PacketParams.Params.Flrc.HeaderType ), Eeprom.Buffer + PAK_FLR_HEADERTYPE_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 273 | memcpy( &( Eeprom.EepromData.PacketParams.Params.Flrc.PayloadLength ), Eeprom.Buffer + PAK_FLR_PL_LEN_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 274 | memcpy( &( Eeprom.EepromData.PacketParams.Params.Flrc.CrcLength ), Eeprom.Buffer + PAK_FLR_CRC_LEN_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 275 | memcpy( &( Eeprom.EepromData.PacketParams.Params.Flrc.Whitening ), Eeprom.Buffer + PAK_FLR_WHITENING_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 276 | memcpy( &( Eeprom.EepromData.PacketParams.Params.Ble.BleTestPayload ), Eeprom.Buffer + PAK_BLE_PAK_TYPE_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 277 | memcpy( &( Eeprom.EepromData.PacketParams.Params.Ble.ConnectionState ), Eeprom.Buffer + PAK_BLE_CON_STATE_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 278 | memcpy( &( Eeprom.EepromData.PacketParams.Params.Ble.CrcLength ), Eeprom.Buffer + PAK_BLE_CRC_FIELD_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 279 | memcpy( &( Eeprom.EepromData.PacketParams.Params.Ble.Whitening ), Eeprom.Buffer + PAK_BLE_WHITENING_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 280 | |
mverdy | 20:626b92b70bf7 | 281 | memcpy( &( Eeprom.EepromData.DemoSettings.RngRequestCount ), Eeprom.Buffer + APP_RNG_REQ_COUNT_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 282 | memcpy( &( Eeprom.EepromData.DemoSettings.RngFullScale ), Eeprom.Buffer + APP_RNG_FULLSCALE_EEPROM_ADDR, 2 ); |
mverdy | 20:626b92b70bf7 | 283 | memcpy( &( Eeprom.EepromData.DemoSettings.RngAddress ), Eeprom.Buffer + APP_RNG_ADDR_EEPROM_ADDR, 4 ); |
mverdy | 20:626b92b70bf7 | 284 | memcpy( &( Eeprom.EepromData.DemoSettings.RngAntenna ), Eeprom.Buffer + APP_RNG_ANT_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 285 | memcpy( &( Eeprom.EepromData.DemoSettings.RngUnit ), Eeprom.Buffer + APP_RNG_UNIT_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 286 | } |
mverdy | 20:626b92b70bf7 | 287 | |
mverdy | 20:626b92b70bf7 | 288 | void EepromLoadSettings( RadioPacketTypes_t modulation ) |
mverdy | 20:626b92b70bf7 | 289 | { |
mverdy | 20:626b92b70bf7 | 290 | if( modulation == PACKET_TYPE_LORA ) |
mverdy | 20:626b92b70bf7 | 291 | { |
mverdy | 20:626b92b70bf7 | 292 | #ifdef PRINT_DEBUG |
mverdy | 20:626b92b70bf7 | 293 | printf("Load Settings PACKET_TYPE_LORA\n\r"); |
mverdy | 20:626b92b70bf7 | 294 | #endif |
mverdy | 20:626b92b70bf7 | 295 | memcpy( &( Eeprom.EepromData.ModulationParams.Params.LoRa.SpreadingFactor ), Eeprom.Buffer + MOD_LOR_SPREADF_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 296 | memcpy( &( Eeprom.EepromData.ModulationParams.Params.LoRa.Bandwidth ), Eeprom.Buffer + MOD_LOR_BW_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 297 | memcpy( &( Eeprom.EepromData.ModulationParams.Params.LoRa.CodingRate ), Eeprom.Buffer + MOD_LOR_CODERATE_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 298 | memcpy( &( Eeprom.EepromData.PacketParams.Params.LoRa.PreambleLength ), Eeprom.Buffer + PAK_LOR_PREAMBLE_LEN_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 299 | memcpy( &( Eeprom.EepromData.PacketParams.Params.LoRa.HeaderType ), Eeprom.Buffer + PAK_LOR_HEADERTYPE_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 300 | memcpy( &( Eeprom.EepromData.PacketParams.Params.LoRa.PayloadLength ), Eeprom.Buffer + PAK_LOR_PL_LEN_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 301 | memcpy( &( Eeprom.EepromData.PacketParams.Params.LoRa.Crc ), Eeprom.Buffer + PAK_LOR_CRC_MODE_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 302 | memcpy( &( Eeprom.EepromData.PacketParams.Params.LoRa.InvertIQ ), Eeprom.Buffer + PAK_LOR_IQ_INV_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 303 | |
mverdy | 20:626b92b70bf7 | 304 | Eeprom.EepromData.ModulationParams.PacketType = PACKET_TYPE_LORA; |
mverdy | 20:626b92b70bf7 | 305 | Eeprom.EepromData.PacketParams.PacketType = PACKET_TYPE_LORA; |
mverdy | 20:626b92b70bf7 | 306 | Eeprom.EepromData.DemoSettings.ModulationParam1 = Eeprom.EepromData.ModulationParams.Params.LoRa.SpreadingFactor; |
mverdy | 20:626b92b70bf7 | 307 | Eeprom.EepromData.DemoSettings.ModulationParam2 = Eeprom.EepromData.ModulationParams.Params.LoRa.Bandwidth; |
mverdy | 20:626b92b70bf7 | 308 | Eeprom.EepromData.DemoSettings.ModulationParam3 = Eeprom.EepromData.ModulationParams.Params.LoRa.CodingRate; |
mverdy | 20:626b92b70bf7 | 309 | |
mverdy | 20:626b92b70bf7 | 310 | Eeprom.EepromData.DemoSettings.PacketParam1 = Eeprom.EepromData.PacketParams.Params.LoRa.PreambleLength; |
mverdy | 20:626b92b70bf7 | 311 | Eeprom.EepromData.DemoSettings.PacketParam2 = Eeprom.EepromData.PacketParams.Params.LoRa.HeaderType; |
mverdy | 20:626b92b70bf7 | 312 | Eeprom.EepromData.DemoSettings.PacketParam3 = Eeprom.EepromData.PacketParams.Params.LoRa.PayloadLength; |
mverdy | 20:626b92b70bf7 | 313 | Eeprom.EepromData.DemoSettings.PacketParam4 = Eeprom.EepromData.PacketParams.Params.LoRa.Crc; |
mverdy | 20:626b92b70bf7 | 314 | Eeprom.EepromData.DemoSettings.PacketParam5 = Eeprom.EepromData.PacketParams.Params.LoRa.InvertIQ; |
mverdy | 20:626b92b70bf7 | 315 | Eeprom.EepromData.DemoSettings.PacketParam6 = 0x00; |
mverdy | 20:626b92b70bf7 | 316 | Eeprom.EepromData.DemoSettings.PacketParam7 = 0x00; |
mverdy | 20:626b92b70bf7 | 317 | } |
mverdy | 20:626b92b70bf7 | 318 | else if( modulation == PACKET_TYPE_RANGING ) |
mverdy | 20:626b92b70bf7 | 319 | { |
mverdy | 20:626b92b70bf7 | 320 | #ifdef PRINT_DEBUG |
mverdy | 20:626b92b70bf7 | 321 | printf("Load Settings PACKET_TYPE_RANGING\n\r"); |
mverdy | 20:626b92b70bf7 | 322 | #endif |
mverdy | 20:626b92b70bf7 | 323 | memcpy( &( Eeprom.EepromData.ModulationParams.Params.LoRa.SpreadingFactor ), Eeprom.Buffer + MOD_RNG_SPREADF_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 324 | memcpy( &( Eeprom.EepromData.ModulationParams.Params.LoRa.Bandwidth ), Eeprom.Buffer + MOD_RNG_BW_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 325 | memcpy( &( Eeprom.EepromData.ModulationParams.Params.LoRa.CodingRate ), Eeprom.Buffer + MOD_RNG_CODERATE_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 326 | memcpy( &( Eeprom.EepromData.PacketParams.Params.LoRa.PreambleLength ), Eeprom.Buffer + PAK_RNG_PREAMBLE_LEN_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 327 | memcpy( &( Eeprom.EepromData.PacketParams.Params.LoRa.HeaderType ), Eeprom.Buffer + PAK_RNG_HEADERTYPE_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 328 | memcpy( &( Eeprom.EepromData.PacketParams.Params.LoRa.PayloadLength ), Eeprom.Buffer + PAK_RNG_PL_LEN_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 329 | memcpy( &( Eeprom.EepromData.PacketParams.Params.LoRa.Crc ), Eeprom.Buffer + PAK_RNG_CRC_MODE_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 330 | memcpy( &( Eeprom.EepromData.PacketParams.Params.LoRa.InvertIQ ), Eeprom.Buffer + PAK_RNG_IQ_INV_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 331 | memcpy( &( Eeprom.EepromData.DemoSettings.RngRequestCount ), Eeprom.Buffer + APP_RNG_REQ_COUNT_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 332 | memcpy( &( Eeprom.EepromData.DemoSettings.RngFullScale ), Eeprom.Buffer + APP_RNG_FULLSCALE_EEPROM_ADDR, 2 ); |
mverdy | 20:626b92b70bf7 | 333 | memcpy( &( Eeprom.EepromData.DemoSettings.RngAddress ), Eeprom.Buffer + APP_RNG_ADDR_EEPROM_ADDR, 4 ); |
mverdy | 20:626b92b70bf7 | 334 | memcpy( &( Eeprom.EepromData.DemoSettings.RngAntenna ), Eeprom.Buffer + APP_RNG_ANT_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 335 | memcpy( &( Eeprom.EepromData.DemoSettings.RngUnit ), Eeprom.Buffer + APP_RNG_UNIT_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 336 | |
mverdy | 20:626b92b70bf7 | 337 | Eeprom.EepromData.ModulationParams.PacketType = PACKET_TYPE_RANGING; |
mverdy | 20:626b92b70bf7 | 338 | Eeprom.EepromData.PacketParams.PacketType = PACKET_TYPE_RANGING; |
mverdy | 20:626b92b70bf7 | 339 | Eeprom.EepromData.DemoSettings.ModulationParam1 = Eeprom.EepromData.ModulationParams.Params.LoRa.SpreadingFactor; |
mverdy | 20:626b92b70bf7 | 340 | Eeprom.EepromData.DemoSettings.ModulationParam2 = Eeprom.EepromData.ModulationParams.Params.LoRa.Bandwidth; |
mverdy | 20:626b92b70bf7 | 341 | Eeprom.EepromData.DemoSettings.ModulationParam3 = Eeprom.EepromData.ModulationParams.Params.LoRa.CodingRate; |
mverdy | 20:626b92b70bf7 | 342 | |
mverdy | 20:626b92b70bf7 | 343 | Eeprom.EepromData.DemoSettings.PacketParam1 = Eeprom.EepromData.PacketParams.Params.LoRa.PreambleLength; |
mverdy | 20:626b92b70bf7 | 344 | Eeprom.EepromData.DemoSettings.PacketParam2 = Eeprom.EepromData.PacketParams.Params.LoRa.HeaderType; |
mverdy | 20:626b92b70bf7 | 345 | Eeprom.EepromData.DemoSettings.PacketParam3 = Eeprom.EepromData.PacketParams.Params.LoRa.PayloadLength; |
mverdy | 20:626b92b70bf7 | 346 | Eeprom.EepromData.DemoSettings.PacketParam4 = Eeprom.EepromData.PacketParams.Params.LoRa.Crc; |
mverdy | 20:626b92b70bf7 | 347 | Eeprom.EepromData.DemoSettings.PacketParam5 = Eeprom.EepromData.PacketParams.Params.LoRa.InvertIQ; |
mverdy | 20:626b92b70bf7 | 348 | Eeprom.EepromData.DemoSettings.PacketParam6 = 0x00; |
mverdy | 20:626b92b70bf7 | 349 | Eeprom.EepromData.DemoSettings.PacketParam7 = 0x00; |
mverdy | 20:626b92b70bf7 | 350 | } |
mverdy | 20:626b92b70bf7 | 351 | else if( modulation == PACKET_TYPE_FLRC ) |
mverdy | 20:626b92b70bf7 | 352 | { |
mverdy | 20:626b92b70bf7 | 353 | #ifdef PRINT_DEBUG |
mverdy | 20:626b92b70bf7 | 354 | printf("Load Settings PACKET_TYPE_FLRC\n\r"); |
mverdy | 20:626b92b70bf7 | 355 | #endif |
mverdy | 20:626b92b70bf7 | 356 | memcpy( &( Eeprom.EepromData.ModulationParams.Params.Flrc.BitrateBandwidth ), Eeprom.Buffer + MOD_FLR_BRBW_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 357 | memcpy( &( Eeprom.EepromData.ModulationParams.Params.Flrc.CodingRate ), Eeprom.Buffer + MOD_FLR_CODERATE_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 358 | memcpy( &( Eeprom.EepromData.ModulationParams.Params.Flrc.ModulationShaping ), Eeprom.Buffer + MOD_FLR_MOD_SHAP_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 359 | memcpy( &( Eeprom.EepromData.PacketParams.Params.Flrc.PreambleLength ), Eeprom.Buffer + PAK_FLR_PREAMBLE_LEN_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 360 | memcpy( &( Eeprom.EepromData.PacketParams.Params.Flrc.SyncWordLength ), Eeprom.Buffer + PAK_FLR_SYNC_LEN_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 361 | memcpy( &( Eeprom.EepromData.PacketParams.Params.Flrc.SyncWordMatch ), Eeprom.Buffer + PAK_FLR_SYNC_MATCH_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 362 | memcpy( &( Eeprom.EepromData.PacketParams.Params.Flrc.HeaderType ), Eeprom.Buffer + PAK_FLR_HEADERTYPE_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 363 | memcpy( &( Eeprom.EepromData.PacketParams.Params.Flrc.PayloadLength ), Eeprom.Buffer + PAK_FLR_PL_LEN_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 364 | memcpy( &( Eeprom.EepromData.PacketParams.Params.Flrc.CrcLength ), Eeprom.Buffer + PAK_FLR_CRC_LEN_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 365 | memcpy( &( Eeprom.EepromData.PacketParams.Params.Flrc.Whitening ), Eeprom.Buffer + PAK_FLR_WHITENING_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 366 | |
mverdy | 20:626b92b70bf7 | 367 | Eeprom.EepromData.ModulationParams.PacketType = PACKET_TYPE_FLRC; |
mverdy | 20:626b92b70bf7 | 368 | Eeprom.EepromData.PacketParams.PacketType = PACKET_TYPE_FLRC; |
mverdy | 20:626b92b70bf7 | 369 | Eeprom.EepromData.DemoSettings.ModulationParam1 = Eeprom.EepromData.ModulationParams.Params.Flrc.BitrateBandwidth; |
mverdy | 20:626b92b70bf7 | 370 | Eeprom.EepromData.DemoSettings.ModulationParam2 = Eeprom.EepromData.ModulationParams.Params.Flrc.CodingRate; |
mverdy | 20:626b92b70bf7 | 371 | Eeprom.EepromData.DemoSettings.ModulationParam3 = Eeprom.EepromData.ModulationParams.Params.Flrc.ModulationShaping; |
mverdy | 20:626b92b70bf7 | 372 | |
mverdy | 20:626b92b70bf7 | 373 | Eeprom.EepromData.DemoSettings.PacketParam1 = Eeprom.EepromData.PacketParams.Params.Flrc.PreambleLength; |
mverdy | 20:626b92b70bf7 | 374 | Eeprom.EepromData.DemoSettings.PacketParam2 = Eeprom.EepromData.PacketParams.Params.Flrc.SyncWordLength; |
mverdy | 20:626b92b70bf7 | 375 | Eeprom.EepromData.DemoSettings.PacketParam3 = Eeprom.EepromData.PacketParams.Params.Flrc.SyncWordMatch; |
mverdy | 20:626b92b70bf7 | 376 | Eeprom.EepromData.DemoSettings.PacketParam4 = Eeprom.EepromData.PacketParams.Params.Flrc.HeaderType; |
mverdy | 20:626b92b70bf7 | 377 | Eeprom.EepromData.DemoSettings.PacketParam5 = Eeprom.EepromData.PacketParams.Params.Flrc.PayloadLength; |
mverdy | 20:626b92b70bf7 | 378 | Eeprom.EepromData.DemoSettings.PacketParam6 = Eeprom.EepromData.PacketParams.Params.Flrc.CrcLength; |
mverdy | 20:626b92b70bf7 | 379 | Eeprom.EepromData.DemoSettings.PacketParam7 = Eeprom.EepromData.PacketParams.Params.Flrc.Whitening; |
mverdy | 20:626b92b70bf7 | 380 | } |
mverdy | 20:626b92b70bf7 | 381 | else // GFSK |
mverdy | 20:626b92b70bf7 | 382 | { |
mverdy | 20:626b92b70bf7 | 383 | #ifdef PRINT_DEBUG |
mverdy | 20:626b92b70bf7 | 384 | printf("Load Settings PACKET_TYPE_GFSK\n\r"); |
mverdy | 20:626b92b70bf7 | 385 | #endif |
mverdy | 20:626b92b70bf7 | 386 | memcpy( &( Eeprom.EepromData.ModulationParams.Params.Gfsk.BitrateBandwidth ), Eeprom.Buffer + MOD_GFS_BRBW_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 387 | memcpy( &( Eeprom.EepromData.ModulationParams.Params.Gfsk.ModulationIndex ), Eeprom.Buffer + MOD_GFS_MOD_IND_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 388 | memcpy( &( Eeprom.EepromData.ModulationParams.Params.Gfsk.ModulationShaping ), Eeprom.Buffer + MOD_GFS_MOD_SHAP_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 389 | memcpy( &( Eeprom.EepromData.PacketParams.Params.Gfsk.PreambleLength ), Eeprom.Buffer + PAK_GFS_PREAMBLE_LEN_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 390 | memcpy( &( Eeprom.EepromData.PacketParams.Params.Gfsk.SyncWordLength ), Eeprom.Buffer + PAK_GFS_SYNC_LEN_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 391 | memcpy( &( Eeprom.EepromData.PacketParams.Params.Gfsk.SyncWordMatch ), Eeprom.Buffer + PAK_GFS_SYNC_MATCH_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 392 | memcpy( &( Eeprom.EepromData.PacketParams.Params.Gfsk.HeaderType ), Eeprom.Buffer + PAK_GFS_HEADERTYPE_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 393 | memcpy( &( Eeprom.EepromData.PacketParams.Params.Gfsk.PayloadLength ), Eeprom.Buffer + PAK_GFS_PL_LEN_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 394 | memcpy( &( Eeprom.EepromData.PacketParams.Params.Gfsk.CrcLength ), Eeprom.Buffer + PAK_GFS_CRC_LEN_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 395 | memcpy( &( Eeprom.EepromData.PacketParams.Params.Gfsk.Whitening ), Eeprom.Buffer + PAK_GFS_WHITENING_EEPROM_ADDR, 1 ); |
mverdy | 20:626b92b70bf7 | 396 | |
mverdy | 20:626b92b70bf7 | 397 | Eeprom.EepromData.ModulationParams.PacketType = PACKET_TYPE_GFSK; |
mverdy | 20:626b92b70bf7 | 398 | Eeprom.EepromData.PacketParams.PacketType = PACKET_TYPE_GFSK; |
mverdy | 20:626b92b70bf7 | 399 | Eeprom.EepromData.DemoSettings.ModulationParam1 = Eeprom.EepromData.ModulationParams.Params.Gfsk.BitrateBandwidth; |
mverdy | 20:626b92b70bf7 | 400 | Eeprom.EepromData.DemoSettings.ModulationParam2 = Eeprom.EepromData.ModulationParams.Params.Gfsk.ModulationIndex; |
mverdy | 20:626b92b70bf7 | 401 | Eeprom.EepromData.DemoSettings.ModulationParam3 = Eeprom.EepromData.ModulationParams.Params.Gfsk.ModulationShaping; |
mverdy | 20:626b92b70bf7 | 402 | |
mverdy | 20:626b92b70bf7 | 403 | Eeprom.EepromData.DemoSettings.PacketParam1 = Eeprom.EepromData.PacketParams.Params.Gfsk.PreambleLength; |
mverdy | 20:626b92b70bf7 | 404 | Eeprom.EepromData.DemoSettings.PacketParam2 = Eeprom.EepromData.PacketParams.Params.Gfsk.SyncWordLength; |
mverdy | 20:626b92b70bf7 | 405 | Eeprom.EepromData.DemoSettings.PacketParam3 = Eeprom.EepromData.PacketParams.Params.Gfsk.SyncWordMatch; |
mverdy | 20:626b92b70bf7 | 406 | Eeprom.EepromData.DemoSettings.PacketParam4 = Eeprom.EepromData.PacketParams.Params.Gfsk.HeaderType; |
mverdy | 20:626b92b70bf7 | 407 | Eeprom.EepromData.DemoSettings.PacketParam5 = Eeprom.EepromData.PacketParams.Params.Gfsk.PayloadLength; |
mverdy | 20:626b92b70bf7 | 408 | Eeprom.EepromData.DemoSettings.PacketParam6 = Eeprom.EepromData.PacketParams.Params.Gfsk.CrcLength; |
mverdy | 20:626b92b70bf7 | 409 | Eeprom.EepromData.DemoSettings.PacketParam7 = Eeprom.EepromData.PacketParams.Params.Gfsk.Whitening; |
mverdy | 20:626b92b70bf7 | 410 | } |
mverdy | 20:626b92b70bf7 | 411 | |
mverdy | 20:626b92b70bf7 | 412 | Eeprom.EepromData.DemoSettings.ModulationType = modulation; |
mverdy | 20:626b92b70bf7 | 413 | } |
mverdy | 20:626b92b70bf7 | 414 | |
mverdy | 20:626b92b70bf7 | 415 | void EepromSetRangingDefaultSettings( void ) |
mverdy | 20:626b92b70bf7 | 416 | { |
mverdy | 20:626b92b70bf7 | 417 | #ifdef PRINT_DEBUG |
mverdy | 20:626b92b70bf7 | 418 | printf("Set Ranging Default Settings\n\r"); |
mverdy | 20:626b92b70bf7 | 419 | #endif |
mverdy | 20:626b92b70bf7 | 420 | |
mverdy | 20:626b92b70bf7 | 421 | Eeprom.EepromData.DemoSettings.ModulationType = PACKET_TYPE_RANGING; |
mverdy | 20:626b92b70bf7 | 422 | Eeprom.EepromData.ModulationParams.PacketType = PACKET_TYPE_RANGING; |
mverdy | 20:626b92b70bf7 | 423 | Eeprom.EepromData.PacketParams.PacketType = PACKET_TYPE_RANGING; |
mverdy | 20:626b92b70bf7 | 424 | |
mverdy | 20:626b92b70bf7 | 425 | Eeprom.EepromData.DemoSettings.ModulationParam1 = LORA_SF6; |
mverdy | 20:626b92b70bf7 | 426 | Eeprom.EepromData.DemoSettings.ModulationParam2 = LORA_BW_1600; |
mverdy | 20:626b92b70bf7 | 427 | Eeprom.EepromData.DemoSettings.ModulationParam3 = LORA_CR_4_5; |
mverdy | 20:626b92b70bf7 | 428 | |
mverdy | 20:626b92b70bf7 | 429 | Eeprom.EepromData.DemoSettings.PacketParam1 = 12; // PreambleLength |
mverdy | 20:626b92b70bf7 | 430 | Eeprom.EepromData.DemoSettings.PacketParam2 = LORA_PACKET_VARIABLE_LENGTH; |
mverdy | 20:626b92b70bf7 | 431 | Eeprom.EepromData.DemoSettings.PacketParam3 = 10; // PayloadLength |
mverdy | 20:626b92b70bf7 | 432 | Eeprom.EepromData.DemoSettings.PacketParam4 = LORA_CRC_ON; |
mverdy | 20:626b92b70bf7 | 433 | Eeprom.EepromData.DemoSettings.PacketParam5 = LORA_IQ_NORMAL; |
mverdy | 20:626b92b70bf7 | 434 | Eeprom.EepromData.DemoSettings.RngRequestCount = 60; |
mverdy | 20:626b92b70bf7 | 435 | Eeprom.EepromData.DemoSettings.RngAntenna = DEMO_RNG_ANT_1; |
mverdy | 20:626b92b70bf7 | 436 | |
mverdy | 20:626b92b70bf7 | 437 | EepromSaveSettings( RADIO_RANGING_PARAMS ); |
mverdy | 20:626b92b70bf7 | 438 | } |
mverdy | 20:626b92b70bf7 | 439 | |
mverdy | 20:626b92b70bf7 | 440 | void EepromSetDefaultSettings( void ) |
mverdy | 20:626b92b70bf7 | 441 | { |
mverdy | 20:626b92b70bf7 | 442 | Eeprom.EepromData.MenuSettings.ScreenCalibrated = false; |
mverdy | 20:626b92b70bf7 | 443 | |
mverdy | 20:626b92b70bf7 | 444 | #ifdef PRINT_DEBUG |
mverdy | 20:626b92b70bf7 | 445 | printf("Set Default Settings\n\r"); |
mverdy | 20:626b92b70bf7 | 446 | #endif |
mverdy | 20:626b92b70bf7 | 447 | |
mverdy | 20:626b92b70bf7 | 448 | EepromSaveSettings( SCREEN_DATA ); |
mverdy | 20:626b92b70bf7 | 449 | |
mverdy | 20:626b92b70bf7 | 450 | Eeprom.EepromData.DemoSettings.ModulationType = PACKET_TYPE_RANGING; |
mverdy | 20:626b92b70bf7 | 451 | Eeprom.EepromData.ModulationParams.PacketType = PACKET_TYPE_RANGING; |
mverdy | 20:626b92b70bf7 | 452 | Eeprom.EepromData.PacketParams.PacketType = PACKET_TYPE_RANGING; |
mverdy | 20:626b92b70bf7 | 453 | |
mverdy | 20:626b92b70bf7 | 454 | Eeprom.EepromData.DemoSettings.ModulationParam1 = LORA_SF6; |
mverdy | 20:626b92b70bf7 | 455 | Eeprom.EepromData.DemoSettings.ModulationParam2 = LORA_BW_1600; |
mverdy | 20:626b92b70bf7 | 456 | Eeprom.EepromData.DemoSettings.ModulationParam3 = LORA_CR_4_5; |
mverdy | 20:626b92b70bf7 | 457 | |
mverdy | 20:626b92b70bf7 | 458 | Eeprom.EepromData.DemoSettings.PacketParam1 = 12; // PreambleLength |
mverdy | 20:626b92b70bf7 | 459 | Eeprom.EepromData.DemoSettings.PacketParam2 = LORA_PACKET_VARIABLE_LENGTH; |
mverdy | 20:626b92b70bf7 | 460 | Eeprom.EepromData.DemoSettings.PacketParam3 = 10; // PayloadLength |
mverdy | 20:626b92b70bf7 | 461 | Eeprom.EepromData.DemoSettings.PacketParam4 = LORA_CRC_ON; |
mverdy | 20:626b92b70bf7 | 462 | Eeprom.EepromData.DemoSettings.PacketParam5 = LORA_IQ_NORMAL; |
mverdy | 20:626b92b70bf7 | 463 | Eeprom.EepromData.DemoSettings.RngRequestCount = 60; |
mverdy | 20:626b92b70bf7 | 464 | Eeprom.EepromData.DemoSettings.RngFullScale = 30; |
mverdy | 20:626b92b70bf7 | 465 | Eeprom.EepromData.DemoSettings.RngAddress = DEMO_RNG_ADDR_1; |
mverdy | 20:626b92b70bf7 | 466 | Eeprom.EepromData.DemoSettings.RngAntenna = DEMO_RNG_ANT_1; |
mverdy | 20:626b92b70bf7 | 467 | Eeprom.EepromData.DemoSettings.RngUnit = DEMO_RNG_UNIT_SEL_M; |
mverdy | 20:626b92b70bf7 | 468 | |
mverdy | 20:626b92b70bf7 | 469 | EepromSaveSettings( RADIO_RANGING_PARAMS ); |
mverdy | 20:626b92b70bf7 | 470 | |
mverdy | 20:626b92b70bf7 | 471 | Eeprom.EepromData.DemoSettings.ModulationType = PACKET_TYPE_LORA; |
mverdy | 20:626b92b70bf7 | 472 | Eeprom.EepromData.ModulationParams.PacketType = PACKET_TYPE_LORA; |
mverdy | 20:626b92b70bf7 | 473 | Eeprom.EepromData.PacketParams.PacketType = PACKET_TYPE_LORA; |
mverdy | 20:626b92b70bf7 | 474 | |
mverdy | 20:626b92b70bf7 | 475 | Eeprom.EepromData.DemoSettings.ModulationParam1 = LORA_SF10; |
mverdy | 20:626b92b70bf7 | 476 | Eeprom.EepromData.DemoSettings.ModulationParam2 = LORA_BW_1600; |
mverdy | 20:626b92b70bf7 | 477 | Eeprom.EepromData.DemoSettings.ModulationParam3 = LORA_CR_4_5; |
mverdy | 20:626b92b70bf7 | 478 | |
mverdy | 20:626b92b70bf7 | 479 | Eeprom.EepromData.DemoSettings.PacketParam1 = 12; // PreambleLength |
mverdy | 20:626b92b70bf7 | 480 | Eeprom.EepromData.DemoSettings.PacketParam2 = LORA_PACKET_VARIABLE_LENGTH; |
mverdy | 20:626b92b70bf7 | 481 | Eeprom.EepromData.DemoSettings.PacketParam3 = DEMO_MIN_PAYLOAD; |
mverdy | 20:626b92b70bf7 | 482 | Eeprom.EepromData.DemoSettings.PacketParam4 = LORA_CRC_ON; |
mverdy | 20:626b92b70bf7 | 483 | Eeprom.EepromData.DemoSettings.PacketParam5 = LORA_IQ_NORMAL; |
mverdy | 20:626b92b70bf7 | 484 | |
mverdy | 20:626b92b70bf7 | 485 | EepromSaveSettings( RADIO_LORA_PARAMS ); |
mverdy | 20:626b92b70bf7 | 486 | |
mverdy | 20:626b92b70bf7 | 487 | Eeprom.EepromData.DemoSettings.ModulationType = PACKET_TYPE_GFSK; |
mverdy | 20:626b92b70bf7 | 488 | Eeprom.EepromData.ModulationParams.PacketType = PACKET_TYPE_GFSK; |
mverdy | 20:626b92b70bf7 | 489 | Eeprom.EepromData.PacketParams.PacketType = PACKET_TYPE_GFSK; |
mverdy | 20:626b92b70bf7 | 490 | |
mverdy | 20:626b92b70bf7 | 491 | Eeprom.EepromData.DemoSettings.ModulationParam1 = GFSK_BLE_BR_0_125_BW_0_3; |
mverdy | 20:626b92b70bf7 | 492 | Eeprom.EepromData.DemoSettings.ModulationParam2 = GFSK_BLE_MOD_IND_1_00; |
mverdy | 20:626b92b70bf7 | 493 | Eeprom.EepromData.DemoSettings.ModulationParam3 = RADIO_MOD_SHAPING_BT_1_0; |
mverdy | 20:626b92b70bf7 | 494 | |
mverdy | 20:626b92b70bf7 | 495 | Eeprom.EepromData.DemoSettings.PacketParam1 = PREAMBLE_LENGTH_32_BITS; |
mverdy | 20:626b92b70bf7 | 496 | Eeprom.EepromData.DemoSettings.PacketParam2 = GFSK_SYNCWORD_LENGTH_5_BYTE; |
mverdy | 20:626b92b70bf7 | 497 | Eeprom.EepromData.DemoSettings.PacketParam3 = RADIO_RX_MATCH_SYNCWORD_1; |
mverdy | 20:626b92b70bf7 | 498 | Eeprom.EepromData.DemoSettings.PacketParam4 = RADIO_PACKET_VARIABLE_LENGTH; |
mverdy | 20:626b92b70bf7 | 499 | Eeprom.EepromData.DemoSettings.PacketParam5 = DEMO_MIN_PAYLOAD; |
mverdy | 20:626b92b70bf7 | 500 | Eeprom.EepromData.DemoSettings.PacketParam6 = RADIO_CRC_3_BYTES; |
mverdy | 20:626b92b70bf7 | 501 | Eeprom.EepromData.DemoSettings.PacketParam7 = RADIO_WHITENING_ON; |
mverdy | 20:626b92b70bf7 | 502 | |
mverdy | 20:626b92b70bf7 | 503 | EepromSaveSettings( RADIO_GFSK_PARAMS ); |
mverdy | 20:626b92b70bf7 | 504 | |
mverdy | 20:626b92b70bf7 | 505 | Eeprom.EepromData.DemoSettings.ModulationType = PACKET_TYPE_FLRC; |
mverdy | 20:626b92b70bf7 | 506 | Eeprom.EepromData.ModulationParams.PacketType = PACKET_TYPE_FLRC; |
mverdy | 20:626b92b70bf7 | 507 | Eeprom.EepromData.PacketParams.PacketType = PACKET_TYPE_FLRC; |
mverdy | 20:626b92b70bf7 | 508 | |
mverdy | 20:626b92b70bf7 | 509 | Eeprom.EepromData.DemoSettings.ModulationParam1 = FLRC_BR_0_260_BW_0_3; |
mverdy | 20:626b92b70bf7 | 510 | Eeprom.EepromData.DemoSettings.ModulationParam2 = FLRC_CR_1_2; |
mverdy | 20:626b92b70bf7 | 511 | Eeprom.EepromData.DemoSettings.ModulationParam3 = RADIO_MOD_SHAPING_BT_1_0; |
mverdy | 20:626b92b70bf7 | 512 | |
mverdy | 20:626b92b70bf7 | 513 | Eeprom.EepromData.DemoSettings.PacketParam1 = PREAMBLE_LENGTH_32_BITS; |
mverdy | 20:626b92b70bf7 | 514 | Eeprom.EepromData.DemoSettings.PacketParam2 = FLRC_SYNCWORD_LENGTH_4_BYTE; |
mverdy | 20:626b92b70bf7 | 515 | Eeprom.EepromData.DemoSettings.PacketParam3 = RADIO_RX_MATCH_SYNCWORD_1; |
mverdy | 20:626b92b70bf7 | 516 | Eeprom.EepromData.DemoSettings.PacketParam4 = RADIO_PACKET_VARIABLE_LENGTH; |
mverdy | 20:626b92b70bf7 | 517 | Eeprom.EepromData.DemoSettings.PacketParam5 = DEMO_MIN_PAYLOAD; |
mverdy | 20:626b92b70bf7 | 518 | Eeprom.EepromData.DemoSettings.PacketParam6 = RADIO_CRC_3_BYTES; |
mverdy | 20:626b92b70bf7 | 519 | Eeprom.EepromData.DemoSettings.PacketParam7 = RADIO_WHITENING_OFF; |
mverdy | 20:626b92b70bf7 | 520 | |
mverdy | 20:626b92b70bf7 | 521 | EepromSaveSettings( RADIO_FLRC_PARAMS ); |
mverdy | 20:626b92b70bf7 | 522 | |
mverdy | 20:626b92b70bf7 | 523 | Eeprom.EepromData.DemoSettings.Entity = SLAVE; |
mverdy | 20:626b92b70bf7 | 524 | Eeprom.EepromData.DemoSettings.AntennaSwitch = 0x00; |
mverdy | 20:626b92b70bf7 | 525 | Eeprom.EepromData.DemoSettings.RadioPowerMode = USE_DCDC; |
mverdy | 20:626b92b70bf7 | 526 | Eeprom.EepromData.DemoSettings.Frequency = DEMO_CENTRAL_FREQ_PRESET1; |
mverdy | 20:626b92b70bf7 | 527 | Eeprom.EepromData.DemoSettings.TxPower = DEMO_POWER_TX_MAX; |
mverdy | 20:626b92b70bf7 | 528 | Eeprom.EepromData.DemoSettings.MaxNumPacket = 0x00; // infinite |
mverdy | 20:626b92b70bf7 | 529 | Eeprom.EepromData.DemoSettings.ModulationType = PACKET_TYPE_LORA; |
mverdy | 20:626b92b70bf7 | 530 | |
mverdy | 20:626b92b70bf7 | 531 | EepromSaveSettings( DEMO_SETTINGS ); |
mverdy | 20:626b92b70bf7 | 532 | } |
mverdy | 20:626b92b70bf7 | 533 | |
mverdy | 20:626b92b70bf7 | 534 | /*! |
mverdy | 20:626b92b70bf7 | 535 | * \brief Erase a page of Flash. Here used to Erase EEPROM region. |
mverdy | 20:626b92b70bf7 | 536 | * |
mverdy | 20:626b92b70bf7 | 537 | * \param [in] page address of page to erase |
mverdy | 20:626b92b70bf7 | 538 | * \param [in] banks address of banks to erase |
mverdy | 20:626b92b70bf7 | 539 | */ |
mverdy | 20:626b92b70bf7 | 540 | void FlashPageErase( uint32_t page, uint32_t banks ) |
mverdy | 20:626b92b70bf7 | 541 | { |
mverdy | 20:626b92b70bf7 | 542 | // Check the parameters |
mverdy | 20:626b92b70bf7 | 543 | assert_param( IS_FLASH_PAGE( page ) ); |
mverdy | 20:626b92b70bf7 | 544 | assert_param( IS_FLASH_BANK_EXCLUSIVE( banks ) ); |
mverdy | 20:626b92b70bf7 | 545 | |
mverdy | 20:626b92b70bf7 | 546 | if( ( banks & FLASH_BANK_1 ) != RESET ) |
mverdy | 20:626b92b70bf7 | 547 | { |
mverdy | 20:626b92b70bf7 | 548 | CLEAR_BIT( FLASH->CR, FLASH_CR_BKER ); |
mverdy | 20:626b92b70bf7 | 549 | } |
mverdy | 20:626b92b70bf7 | 550 | else |
mverdy | 20:626b92b70bf7 | 551 | { |
mverdy | 20:626b92b70bf7 | 552 | SET_BIT( FLASH->CR, FLASH_CR_BKER ); |
mverdy | 20:626b92b70bf7 | 553 | } |
mverdy | 20:626b92b70bf7 | 554 | |
mverdy | 20:626b92b70bf7 | 555 | // Proceed to erase the page |
mverdy | 20:626b92b70bf7 | 556 | MODIFY_REG( FLASH->CR, FLASH_CR_PNB, ( page << 3 ) ); |
mverdy | 20:626b92b70bf7 | 557 | SET_BIT( FLASH->CR, FLASH_CR_PER ); |
mverdy | 20:626b92b70bf7 | 558 | SET_BIT( FLASH->CR, FLASH_CR_STRT ); |
mverdy | 20:626b92b70bf7 | 559 | } |
mverdy | 20:626b92b70bf7 | 560 | |
mverdy | 20:626b92b70bf7 | 561 | /*! |
mverdy | 20:626b92b70bf7 | 562 | * \brief Write Eeprom to emulated EEPROM (in fact in Flash " higher address). |
mverdy | 20:626b92b70bf7 | 563 | * |
mverdy | 20:626b92b70bf7 | 564 | * \param [in] addr address of data (EEPROM offset not to be include) |
mverdy | 20:626b92b70bf7 | 565 | * \param [in] buffer buffer to use for copy |
mverdy | 20:626b92b70bf7 | 566 | * \param [in] size size of data to copy |
mverdy | 20:626b92b70bf7 | 567 | * |
mverdy | 20:626b92b70bf7 | 568 | * \retval status Status of operation (SUCCESS, ..) |
mverdy | 20:626b92b70bf7 | 569 | */ |
mverdy | 20:626b92b70bf7 | 570 | uint8_t EepromMcuWriteBuffer( uint16_t addr, uint8_t *buffer, uint16_t size ) |
mverdy | 20:626b92b70bf7 | 571 | { |
mverdy | 20:626b92b70bf7 | 572 | uint64_t *flash = ( uint64_t* )buffer; |
mverdy | 20:626b92b70bf7 | 573 | |
mverdy | 20:626b92b70bf7 | 574 | // assert_param( addr >= DATA_EEPROM_BASE ); |
mverdy | 20:626b92b70bf7 | 575 | assert_param( buffer != NULL ); |
mverdy | 20:626b92b70bf7 | 576 | assert_param( size < ( DATA_EEPROM_END - DATA_EEPROM_BASE ) ); |
mverdy | 20:626b92b70bf7 | 577 | |
mverdy | 20:626b92b70bf7 | 578 | HAL_FLASH_Unlock( ); |
mverdy | 20:626b92b70bf7 | 579 | |
mverdy | 20:626b92b70bf7 | 580 | FlashPageErase( 255, 1 ); |
mverdy | 20:626b92b70bf7 | 581 | |
mverdy | 20:626b92b70bf7 | 582 | WRITE_REG( FLASH->CR, 0x40000000 ); |
mverdy | 20:626b92b70bf7 | 583 | |
mverdy | 20:626b92b70bf7 | 584 | for( uint32_t i = 0; i < size; i++ ) |
mverdy | 20:626b92b70bf7 | 585 | { |
mverdy | 20:626b92b70bf7 | 586 | HAL_FLASH_Program( FLASH_TYPEPROGRAM_DOUBLEWORD, DATA_EEPROM_BASE + \ |
mverdy | 20:626b92b70bf7 | 587 | ( 8 * i ), flash[i] ); |
mverdy | 20:626b92b70bf7 | 588 | } |
mverdy | 20:626b92b70bf7 | 589 | |
mverdy | 20:626b92b70bf7 | 590 | HAL_FLASH_Lock( ); |
mverdy | 20:626b92b70bf7 | 591 | |
mverdy | 20:626b92b70bf7 | 592 | return SUCCESS; |
mverdy | 20:626b92b70bf7 | 593 | } |
mverdy | 20:626b92b70bf7 | 594 | |
mverdy | 20:626b92b70bf7 | 595 | uint8_t EepromMcuReadBuffer( uint16_t addr, uint8_t *buffer, uint16_t size ) |
mverdy | 20:626b92b70bf7 | 596 | { |
mverdy | 20:626b92b70bf7 | 597 | assert_param( buffer != NULL ); |
mverdy | 20:626b92b70bf7 | 598 | |
mverdy | 20:626b92b70bf7 | 599 | // assert_param( addr >= DATA_EEPROM_BASE ); |
mverdy | 20:626b92b70bf7 | 600 | assert_param( buffer != NULL ); |
mverdy | 20:626b92b70bf7 | 601 | assert_param( size < ( DATA_EEPROM_END - DATA_EEPROM_BASE ) ); |
mverdy | 20:626b92b70bf7 | 602 | |
mverdy | 20:626b92b70bf7 | 603 | memcpy( buffer, ( uint8_t* )DATA_EEPROM_BASE, size ); |
mverdy | 20:626b92b70bf7 | 604 | return SUCCESS; |
mverdy | 20:626b92b70bf7 | 605 | } |
mverdy | 20:626b92b70bf7 | 606 | |
mverdy | 20:626b92b70bf7 | 607 | static MemTestStruct_t EepromDataCheckSum( void ) |
mverdy | 20:626b92b70bf7 | 608 | { |
mverdy | 20:626b92b70bf7 | 609 | MemTestStruct_t memTestStruct; |
mverdy | 20:626b92b70bf7 | 610 | uint8_t x; |
mverdy | 20:626b92b70bf7 | 611 | uint8_t i; |
mverdy | 20:626b92b70bf7 | 612 | uint16_t crcBuf; |
mverdy | 20:626b92b70bf7 | 613 | memTestStruct.Value = 0xFFFF; |
mverdy | 20:626b92b70bf7 | 614 | |
mverdy | 20:626b92b70bf7 | 615 | for( i = 0; i < EEPROM_BUFFER_SIZE - sizeof( uint16_t ); i++ ) |
mverdy | 20:626b92b70bf7 | 616 | { |
mverdy | 20:626b92b70bf7 | 617 | x = memTestStruct.Value >> 8 ^ Eeprom.Buffer[i]; |
mverdy | 20:626b92b70bf7 | 618 | x ^= x >> 4; |
mverdy | 20:626b92b70bf7 | 619 | memTestStruct.Value = ( memTestStruct.Value << 8 ) ^ \ |
mverdy | 20:626b92b70bf7 | 620 | ( ( uint16_t )( x << 12 ) ) ^ \ |
mverdy | 20:626b92b70bf7 | 621 | ( ( uint16_t )( x << 5 ) ) ^ \ |
mverdy | 20:626b92b70bf7 | 622 | ( ( uint16_t )x ); |
mverdy | 20:626b92b70bf7 | 623 | } |
mverdy | 20:626b92b70bf7 | 624 | memcpy( &crcBuf, Eeprom.Buffer + EEPROM_CRC_EEPROM_ADDR, 2 ); |
mverdy | 20:626b92b70bf7 | 625 | memTestStruct.Valid = ( crcBuf == memTestStruct.Value ); |
mverdy | 20:626b92b70bf7 | 626 | |
mverdy | 20:626b92b70bf7 | 627 | return memTestStruct; |
mverdy | 20:626b92b70bf7 | 628 | } |
mverdy | 20:626b92b70bf7 | 629 | |
mverdy | 20:626b92b70bf7 | 630 | void EepromFactoryReset( void ) |
mverdy | 20:626b92b70bf7 | 631 | { |
mverdy | 20:626b92b70bf7 | 632 | EepromSetDefaultSettings( ); |
mverdy | 20:626b92b70bf7 | 633 | EepromLoadSettings( ( RadioPacketTypes_t )Eeprom.EepromData.DemoSettings.ModulationType ); |
mverdy | 20:626b92b70bf7 | 634 | } |
mverdy | 20:626b92b70bf7 | 635 |