Stabilus 322699 wDoublePID

Dependencies:   mbed QEI PID DmTftLibraryEx

Committer:
GregCr
Date:
Mon Mar 13 15:12:05 2017 +0000
Revision:
0:9c0917bfde97
Child:
8:c0a5f53fe196
alpha release

Who changed what in which revision?

UserRevisionLine numberNew contents of line
GregCr 0:9c0917bfde97 1 /*
GregCr 0:9c0917bfde97 2 ______ _
GregCr 0:9c0917bfde97 3 / _____) _ | |
GregCr 0:9c0917bfde97 4 ( (____ _____ ____ _| |_ _____ ____| |__
GregCr 0:9c0917bfde97 5 \____ \| ___ | (_ _) ___ |/ ___) _ \
GregCr 0:9c0917bfde97 6 _____) ) ____| | | || |_| ____( (___| | | |
GregCr 0:9c0917bfde97 7 (______/|_____)_|_|_| \__)_____)\____)_| |_|
GregCr 0:9c0917bfde97 8 (C)2016 Semtech
GregCr 0:9c0917bfde97 9
GregCr 0:9c0917bfde97 10 Description: EEPROM routines header
GregCr 0:9c0917bfde97 11
GregCr 0:9c0917bfde97 12 Maintainer: Gregory Cristian & Gilbert Menth
GregCr 0:9c0917bfde97 13 */
GregCr 0:9c0917bfde97 14
GregCr 0:9c0917bfde97 15 #ifndef EEPROM_H
GregCr 0:9c0917bfde97 16 #define EEPROM_H
GregCr 0:9c0917bfde97 17
GregCr 0:9c0917bfde97 18
GregCr 0:9c0917bfde97 19 #include "Menu.h"
GregCr 0:9c0917bfde97 20 #include "DemoApplication.h"
GregCr 0:9c0917bfde97 21 #include "sx1280.h"
GregCr 0:9c0917bfde97 22
GregCr 0:9c0917bfde97 23
GregCr 0:9c0917bfde97 24 /*!
GregCr 0:9c0917bfde97 25 * \brief Define Buffer indexes for each EepromData for copy and restore
GregCr 0:9c0917bfde97 26 */
GregCr 0:9c0917bfde97 27 #define SCR_CAL_FLAG_EEPROM_ADDR 0 // boolean
GregCr 0:9c0917bfde97 28 #define SCR_CAL_POSA_EEPROM_ADDR 1 // int32
GregCr 0:9c0917bfde97 29 #define SCR_CAL_POSB_EEPROM_ADDR 5 // int32
GregCr 0:9c0917bfde97 30 #define SCR_CAL_POSC_EEPROM_ADDR 9 // int32
GregCr 0:9c0917bfde97 31 #define SCR_CAL_POSD_EEPROM_ADDR 13 // int32
GregCr 0:9c0917bfde97 32 #define SCR_CAL_POSE_EEPROM_ADDR 17 // int32
GregCr 0:9c0917bfde97 33 #define SCR_CAL_POSF_EEPROM_ADDR 21 // int32
GregCr 0:9c0917bfde97 34 #define APP_ENTITY_EEPROM_ADDR 25 // uint8
GregCr 0:9c0917bfde97 35 #define APP_ANT_SW_EEPROM_ADDR 26 // uint8
GregCr 0:9c0917bfde97 36 #define APP_FREQ_EEPROM_ADDR 27 // uint32_t Frequency;
GregCr 0:9c0917bfde97 37 #define APP_TXPWR_EEPROM_ADDR 31 // int8_t TxPower;
GregCr 0:9c0917bfde97 38 #define APP_MOD_TYPE_EEPROM_ADDR 32 // uint8_t ModulationType;
GregCr 0:9c0917bfde97 39 #define APP_PER_NPAK_MAX_EEPROM_ADDR 33 // uint32_t MaxNumPacket;
GregCr 0:9c0917bfde97 40 #define APP_RADIO_POWER_MODE_EEPROM_ADDR 37 // RadioRegulatorMode_t
GregCr 0:9c0917bfde97 41 #define APP_RNG_REQ_COUNT_EEPROM_ADDR 38 // uint8_t
GregCr 0:9c0917bfde97 42 #define APP_RNG_FULLSCALE_EEPROM_ADDR 39 // uint16_t
GregCr 0:9c0917bfde97 43 #define APP_RNG_ZSCORE_EEPROM_ADDR 41
GregCr 0:9c0917bfde97 44 #define APP_RNG_UNIT_EEPROM_ADDR 42 // ranging distance unit
GregCr 0:9c0917bfde97 45 #define APP_RNG_ADDR_EEPROM_ADDR 43 // uint32_t
GregCr 0:9c0917bfde97 46 #define APP_RNG_ANT_EEPROM_ADDR 47 // uint8_t RngAntenna
GregCr 0:9c0917bfde97 47 #define MOD_PAK_TYPE_EEPROM_ADDR 48 // enum
GregCr 0:9c0917bfde97 48 #define MOD_GFS_BRBW_EEPROM_ADDR 49 // BitrateBandwidth
GregCr 0:9c0917bfde97 49 #define MOD_GFS_MOD_IND_EEPROM_ADDR 50 // ModulationIndex
GregCr 0:9c0917bfde97 50 #define MOD_GFS_MOD_SHAP_EEPROM_ADDR 51 // ModulationShaping
GregCr 0:9c0917bfde97 51 #define MOD_LOR_SPREADF_EEPROM_ADDR 52 // SpreadingFactor
GregCr 0:9c0917bfde97 52 #define MOD_LOR_BW_EEPROM_ADDR 53 // Bandwidth
GregCr 0:9c0917bfde97 53 #define MOD_LOR_CODERATE_EEPROM_ADDR 54 // CodingRate
GregCr 0:9c0917bfde97 54 #define MOD_FLR_BRBW_EEPROM_ADDR 55 // BitrateBandwidth
GregCr 0:9c0917bfde97 55 #define MOD_FLR_CODERATE_EEPROM_ADDR 56 // CodingRate
GregCr 0:9c0917bfde97 56 #define MOD_FLR_MOD_SHAP_EEPROM_ADDR 57 // ModulationShaping
GregCr 0:9c0917bfde97 57 #define MOD_BLE_BRBW_EEPROM_ADDR 58 // BitrateBandwidth
GregCr 0:9c0917bfde97 58 #define MOD_BLE_MOD_IND_EEPROM_ADDR 59 // ModulationIndex
GregCr 0:9c0917bfde97 59 #define MOD_BLE_MOD_SHAP_EEPROM_ADDR 60 // ModulationShaping
GregCr 0:9c0917bfde97 60 #define MOD_RNG_SPREADF_EEPROM_ADDR 61 // SpreadingFactor
GregCr 0:9c0917bfde97 61 #define MOD_RNG_BW_EEPROM_ADDR 62 // Bandwidth
GregCr 0:9c0917bfde97 62 #define MOD_RNG_CODERATE_EEPROM_ADDR 63 // CodingRate
GregCr 0:9c0917bfde97 63 #define PAK_PAK_TYPE_EEPROM_ADDR 64 //
GregCr 0:9c0917bfde97 64 #define PAK_GFS_PREAMBLE_LEN_EEPROM_ADDR 65 // PreambleLength
GregCr 0:9c0917bfde97 65 #define PAK_GFS_SYNC_LEN_EEPROM_ADDR 66 // SyncWordLength
GregCr 0:9c0917bfde97 66 #define PAK_GFS_SYNC_MATCH_EEPROM_ADDR 67 // SyncWordMatch
GregCr 0:9c0917bfde97 67 #define PAK_GFS_HEADERTYPE_EEPROM_ADDR 68 // HeaderType
GregCr 0:9c0917bfde97 68 #define PAK_GFS_PL_LEN_EEPROM_ADDR 69 // PayloadLength
GregCr 0:9c0917bfde97 69 #define PAK_GFS_CRC_LEN_EEPROM_ADDR 70 // CrcLength
GregCr 0:9c0917bfde97 70 #define PAK_GFS_WHITENING_EEPROM_ADDR 71 // Whitening
GregCr 0:9c0917bfde97 71 #define PAK_LOR_PREAMBLE_LEN_EEPROM_ADDR 72 // PreambleLength
GregCr 0:9c0917bfde97 72 #define PAK_LOR_HEADERTYPE_EEPROM_ADDR 73 // HeaderType
GregCr 0:9c0917bfde97 73 #define PAK_LOR_PL_LEN_EEPROM_ADDR 74 // PayloadLength
GregCr 0:9c0917bfde97 74 #define PAK_LOR_CRC_MODE_EEPROM_ADDR 75 // CrcMode
GregCr 0:9c0917bfde97 75 #define PAK_LOR_IQ_INV_EEPROM_ADDR 76 // InvertIQ
GregCr 0:9c0917bfde97 76 #define PAK_RNG_PREAMBLE_LEN_EEPROM_ADDR 77 // PreambleLength
GregCr 0:9c0917bfde97 77 #define PAK_RNG_HEADERTYPE_EEPROM_ADDR 78 // HeaderType
GregCr 0:9c0917bfde97 78 #define PAK_RNG_PL_LEN_EEPROM_ADDR 79 // PayloadLength
GregCr 0:9c0917bfde97 79 #define PAK_RNG_CRC_MODE_EEPROM_ADDR 80 // CrcMode
GregCr 0:9c0917bfde97 80 #define PAK_RNG_IQ_INV_EEPROM_ADDR 81 // InvertIQ
GregCr 0:9c0917bfde97 81 #define PAK_FLR_PREAMBLE_LEN_EEPROM_ADDR 82 // PreambleLength
GregCr 0:9c0917bfde97 82 #define PAK_FLR_SYNC_LEN_EEPROM_ADDR 83 // SyncWordLength
GregCr 0:9c0917bfde97 83 #define PAK_FLR_SYNC_MATCH_EEPROM_ADDR 84 // SyncWordMatch
GregCr 0:9c0917bfde97 84 #define PAK_FLR_HEADERTYPE_EEPROM_ADDR 85 // HeaderType
GregCr 0:9c0917bfde97 85 #define PAK_FLR_PL_LEN_EEPROM_ADDR 86 // PayloadLength
GregCr 0:9c0917bfde97 86 #define PAK_FLR_CRC_LEN_EEPROM_ADDR 87 // CrcLength
GregCr 0:9c0917bfde97 87 #define PAK_FLR_WHITENING_EEPROM_ADDR 88 // Whitening
GregCr 0:9c0917bfde97 88 #define PAK_BLE_CON_STATE_EEPROM_ADDR 89 // ConnectionState
GregCr 0:9c0917bfde97 89 #define PAK_BLE_CRC_FIELD_EEPROM_ADDR 90 // CrcField
GregCr 0:9c0917bfde97 90 #define PAK_BLE_PAK_TYPE_EEPROM_ADDR 91 // BlePacketType
GregCr 0:9c0917bfde97 91 #define PAK_BLE_WHITENING_EEPROM_ADDR 92 // Whitening
GregCr 0:9c0917bfde97 92 #define EEPROM_CRC_EEPROM_ADDR 93 // uint16
GregCr 0:9c0917bfde97 93
GregCr 0:9c0917bfde97 94 /*!
GregCr 0:9c0917bfde97 95 * \brief Eeprom buffer size. Cf. above.
GregCr 0:9c0917bfde97 96 */
GregCr 0:9c0917bfde97 97 #define EEPROM_BUFFER_SIZE 95
GregCr 0:9c0917bfde97 98
GregCr 0:9c0917bfde97 99
GregCr 0:9c0917bfde97 100 /*!
GregCr 0:9c0917bfde97 101 * \brief Part of EEPROM to save or restore
GregCr 0:9c0917bfde97 102 */
GregCr 0:9c0917bfde97 103 typedef enum
GregCr 0:9c0917bfde97 104 {
GregCr 0:9c0917bfde97 105 ALL_DATA,
GregCr 0:9c0917bfde97 106 SCREEN_DATA,
GregCr 0:9c0917bfde97 107 DEMO_SETTINGS,
GregCr 0:9c0917bfde97 108 RADIO_LORA_PARAMS,
GregCr 0:9c0917bfde97 109 RADIO_RANGING_PARAMS,
GregCr 0:9c0917bfde97 110 RADIO_FLRC_PARAMS,
GregCr 0:9c0917bfde97 111 RADIO_GFSK_PARAMS,
GregCr 0:9c0917bfde97 112 RADIO_BLE_PARAMS
GregCr 0:9c0917bfde97 113 }EepromDataSet_t;
GregCr 0:9c0917bfde97 114
GregCr 0:9c0917bfde97 115 /*!
GregCr 0:9c0917bfde97 116 * \brief EepromData structure
GregCr 0:9c0917bfde97 117 */
GregCr 0:9c0917bfde97 118 typedef struct
GregCr 0:9c0917bfde97 119 {
GregCr 0:9c0917bfde97 120 MenuSettings_t MenuSettings;
GregCr 0:9c0917bfde97 121 DemoSettings_t DemoSettings;
GregCr 0:9c0917bfde97 122 ModulationParams_t ModulationParams;
GregCr 0:9c0917bfde97 123 PacketParams_t PacketParams;
GregCr 0:9c0917bfde97 124 uint16_t CheckSum;
GregCr 0:9c0917bfde97 125 }EepromData_t;
GregCr 0:9c0917bfde97 126
GregCr 0:9c0917bfde97 127 /*!
GregCr 0:9c0917bfde97 128 * \brief Eeprom structure
GregCr 0:9c0917bfde97 129 */
GregCr 0:9c0917bfde97 130 typedef struct
GregCr 0:9c0917bfde97 131 {
GregCr 0:9c0917bfde97 132 EepromData_t EepromData;
GregCr 0:9c0917bfde97 133 // Allows for the checksum to be carried out
GregCr 0:9c0917bfde97 134 uint8_t Buffer[EEPROM_BUFFER_SIZE];
GregCr 0:9c0917bfde97 135 }Eeprom_t;
GregCr 0:9c0917bfde97 136
GregCr 0:9c0917bfde97 137
GregCr 0:9c0917bfde97 138 /*!
GregCr 0:9c0917bfde97 139 * \brief Local copy of Eeprom. (defined in Eeprom.cpp)
GregCr 0:9c0917bfde97 140 */
GregCr 0:9c0917bfde97 141 extern Eeprom_t Eeprom;
GregCr 0:9c0917bfde97 142
GregCr 0:9c0917bfde97 143
GregCr 0:9c0917bfde97 144 /*!
GregCr 0:9c0917bfde97 145 * \brief Initialises the contents of EepromData
GregCr 0:9c0917bfde97 146 */
GregCr 0:9c0917bfde97 147 void EepromInit( void );
GregCr 0:9c0917bfde97 148
GregCr 0:9c0917bfde97 149 /*!
GregCr 0:9c0917bfde97 150 * \brief Read Eeprom from emulated EEPROM (in fact in Flash " higher address).
GregCr 0:9c0917bfde97 151 *
GregCr 0:9c0917bfde97 152 * \param [in] addr address of data (EEPROM offset not to be include)
GregCr 0:9c0917bfde97 153 * \param [in] buffer buffer to use for copy
GregCr 0:9c0917bfde97 154 * \param [in] size size of data to copy
GregCr 0:9c0917bfde97 155 *
GregCr 0:9c0917bfde97 156 * \retval status Status of operation (SUCCESS, ..)
GregCr 0:9c0917bfde97 157 */
GregCr 0:9c0917bfde97 158 uint8_t EepromMcuReadBuffer( uint16_t addr, uint8_t *buffer, uint16_t size );
GregCr 0:9c0917bfde97 159
GregCr 0:9c0917bfde97 160 /*!
GregCr 0:9c0917bfde97 161 * \brief Writes the EepromData to emulated EEPROM
GregCr 0:9c0917bfde97 162 *
GregCr 0:9c0917bfde97 163 * \param [in] dataSet Set of data to save or restore
GregCr 0:9c0917bfde97 164 */
GregCr 0:9c0917bfde97 165 void EepromSaveSettings( EepromDataSet_t dataSet);
GregCr 0:9c0917bfde97 166
GregCr 0:9c0917bfde97 167 /*!
GregCr 0:9c0917bfde97 168 * \brief Loads EepromData from emulated EEPROM
GregCr 0:9c0917bfde97 169 */
GregCr 0:9c0917bfde97 170 void EepromLoadGeneralSettings ( void );
GregCr 0:9c0917bfde97 171
GregCr 0:9c0917bfde97 172 /*!
GregCr 0:9c0917bfde97 173 * \brief Loads EepromData with updated modulation and packet parameters
GregCr 0:9c0917bfde97 174 *
GregCr 0:9c0917bfde97 175 * \param [in] modulation modulation type to select for mod. & packet params
GregCr 0:9c0917bfde97 176 */
GregCr 0:9c0917bfde97 177 void EepromLoadSettings( RadioPacketTypes_t modulation );
GregCr 0:9c0917bfde97 178
GregCr 0:9c0917bfde97 179 /*!
GregCr 0:9c0917bfde97 180 * \brief Initialises the contents of flash to default values & save to EEPROM
GregCr 0:9c0917bfde97 181 */
GregCr 0:9c0917bfde97 182 void EepromSetDefaultSettings( void );
GregCr 0:9c0917bfde97 183
GregCr 0:9c0917bfde97 184 /*!
GregCr 0:9c0917bfde97 185 * \brief Initialises the contents of flash to default values (for ranging
GregCr 0:9c0917bfde97 186 * demo : best set) & save to EEPROM
GregCr 0:9c0917bfde97 187 */
GregCr 0:9c0917bfde97 188 void EepromSetRangingDefaultSettings( void );
GregCr 0:9c0917bfde97 189
GregCr 0:9c0917bfde97 190 #endif //EEPROM_H