SX126xDevKit

Dependencies:   mbed DmTftLibrary SX126xLib

Committer:
mantoine
Date:
Mon Jan 07 23:02:45 2019 +0100
Revision:
3:c3ab10127815
Parent:
1:b96176a4ccb8
Updated erroneous path to SX126xLib library.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
GregCr 0:e5420f1a8a1a 1 /*
GregCr 0:e5420f1a8a1a 2 ______ _
GregCr 0:e5420f1a8a1a 3 / _____) _ | |
GregCr 0:e5420f1a8a1a 4 ( (____ _____ ____ _| |_ _____ ____| |__
GregCr 0:e5420f1a8a1a 5 \____ \| ___ | (_ _) ___ |/ ___) _ \
GregCr 0:e5420f1a8a1a 6 _____) ) ____| | | || |_| ____( (___| | | |
GregCr 0:e5420f1a8a1a 7 (______/|_____)_|_|_| \__)_____)\____)_| |_|
GregCr 0:e5420f1a8a1a 8 (C)2016 Semtech
GregCr 0:e5420f1a8a1a 9
GregCr 0:e5420f1a8a1a 10 Description: EEPROM routines header
GregCr 0:e5420f1a8a1a 11
GregCr 0:e5420f1a8a1a 12 Maintainer: Gregory Cristian & Gilbert Menth
GregCr 0:e5420f1a8a1a 13 */
GregCr 0:e5420f1a8a1a 14
GregCr 0:e5420f1a8a1a 15 #ifndef EEPROM_H
GregCr 0:e5420f1a8a1a 16 #define EEPROM_H
GregCr 0:e5420f1a8a1a 17
GregCr 0:e5420f1a8a1a 18
GregCr 0:e5420f1a8a1a 19 #include "Menu.h"
GregCr 0:e5420f1a8a1a 20 #include "DemoApplication.h"
GregCr 0:e5420f1a8a1a 21 #include "sx126x.h"
GregCr 0:e5420f1a8a1a 22
GregCr 0:e5420f1a8a1a 23
GregCr 0:e5420f1a8a1a 24 /*!
GregCr 0:e5420f1a8a1a 25 * \brief Define Buffer indexes for each EepromData for copy and restore
GregCr 0:e5420f1a8a1a 26 */
GregCr 0:e5420f1a8a1a 27 #define SCR_CAL_FLAG_EEPROM_ADDR 0 // boolean
GregCr 0:e5420f1a8a1a 28 #define SCR_CAL_POSA_EEPROM_ADDR 1 // int32
GregCr 0:e5420f1a8a1a 29 #define SCR_CAL_POSB_EEPROM_ADDR 5 // int32
GregCr 0:e5420f1a8a1a 30 #define SCR_CAL_POSC_EEPROM_ADDR 9 // int32
GregCr 0:e5420f1a8a1a 31 #define SCR_CAL_POSD_EEPROM_ADDR 13 // int32
GregCr 0:e5420f1a8a1a 32 #define SCR_CAL_POSE_EEPROM_ADDR 17 // int32
GregCr 0:e5420f1a8a1a 33 #define SCR_CAL_POSF_EEPROM_ADDR 21 // int32
GregCr 0:e5420f1a8a1a 34 #define APP_ENTITY_EEPROM_ADDR 25 // uint8
GregCr 0:e5420f1a8a1a 35 #define APP_RADIO_BOOSTED_RX_EEPROM_ADDR 26 // uint8
GregCr 0:e5420f1a8a1a 36 #define APP_FREQ_EEPROM_ADDR 27 // uint32_t Frequency;
GregCr 0:e5420f1a8a1a 37 #define APP_TXPWR_EEPROM_ADDR 31 // int8_t TxPower;
GregCr 0:e5420f1a8a1a 38 #define APP_MOD_TYPE_EEPROM_ADDR 32 // uint8_t ModulationType;
GregCr 0:e5420f1a8a1a 39 #define APP_PER_NPAK_MAX_EEPROM_ADDR 33 // uint32_t MaxNumPacket;
GregCr 0:e5420f1a8a1a 40 #define APP_RADIO_POWER_MODE_EEPROM_ADDR 37 // RadioRegulatorMode_t
GregCr 0:e5420f1a8a1a 41 #define MOD_PKET_TYPE_EEPROM_ADDR 38 // uint8_t
GregCr 0:e5420f1a8a1a 42 #define MOD_GFSK_BR_EEPROM_ADDR 39 // uint32_t Bitrate
GregCr 0:e5420f1a8a1a 43 #define MOD_GFSK_FDEV_EEPROM_ADDR 43 // uint32_t FrequencyDeviation
GregCr 0:e5420f1a8a1a 44 #define MOD_GFSK_MOD_SHAPE_EEPROM_ADDR 47 // uint8_t ModulationShape
GregCr 0:e5420f1a8a1a 45 #define MOD_GFSK_BW_EEPROM_ADDR 48 // uint8_t Bandwidth
GregCr 0:e5420f1a8a1a 46 #define RFU_1 49
GregCr 0:e5420f1a8a1a 47 #define RFU_2 53
GregCr 0:e5420f1a8a1a 48 #define RFU_3 57
GregCr 0:e5420f1a8a1a 49 #define RFU_4 58
GregCr 0:e5420f1a8a1a 50 #define RFU_5 59
GregCr 0:e5420f1a8a1a 51 #define RFU_6 63
GregCr 0:e5420f1a8a1a 52 #define RFU_7 67
GregCr 0:e5420f1a8a1a 53 #define RFU_8 68
GregCr 0:e5420f1a8a1a 54 #define MOD_LORA_SPREADF_EEPROM_ADDR 69 // uint8_t SpreadingFactor
GregCr 0:e5420f1a8a1a 55 #define MOD_LORA_BW_EEPROM_ADDR 70 // uint8_t Bandwidth
GregCr 0:e5420f1a8a1a 56 #define MOD_LORA_CODERATE_EEPROM_ADDR 71 // uint8_t CodingRate
GregCr 0:e5420f1a8a1a 57 #define PAK_PKET_TYPE_EEPROM_ADDR 72 // uint8_t
GregCr 0:e5420f1a8a1a 58
GregCr 0:e5420f1a8a1a 59 #define PAK_GFSK_PREAMBLE_LEN_EEPROM_ADDR 73 // uint16_t PreambleTxLength
GregCr 0:e5420f1a8a1a 60 #define PAK_GFSK_PR_MIN_DET_EEPROM_ADDR 75 // uint8_t PreambleMinDetect
GregCr 0:e5420f1a8a1a 61 #define PAK_GFSK_SYNC_LEN_EEPROM_ADDR 76 // uint8_t SyncWordLength
GregCr 0:e5420f1a8a1a 62 #define PAK_GFSK_ADDR_COMP_EEPROM_ADDR 77 // uint8_t AddrComp
GregCr 0:e5420f1a8a1a 63 #define PAK_GFSK_HEADERTYPE_EEPROM_ADDR 78 // uint8_t HeaderType
GregCr 0:e5420f1a8a1a 64 #define PAK_GFSK_PL_LEN_EEPROM_ADDR 79 // uint8_t PayloadLength
GregCr 0:e5420f1a8a1a 65 #define PAK_GFSK_CRC_LEN_EEPROM_ADDR 80 // uint8_t CrcLength
GregCr 0:e5420f1a8a1a 66 #define PAK_GFSK_DC_FREE_EEPROM_ADDR 81 // uint8_t DCFree
GregCr 0:e5420f1a8a1a 67
GregCr 0:e5420f1a8a1a 68 #define RFU_9 82
GregCr 0:e5420f1a8a1a 69 #define RFU_10 84
GregCr 0:e5420f1a8a1a 70 #define RFU_11 85
GregCr 0:e5420f1a8a1a 71 #define RFU_12 86
GregCr 0:e5420f1a8a1a 72 #define RFU_13 87
GregCr 0:e5420f1a8a1a 73 #define RFU_14 88
GregCr 0:e5420f1a8a1a 74 #define RFU_15 89
GregCr 0:e5420f1a8a1a 75 #define RFU_16 90
GregCr 0:e5420f1a8a1a 76
GregCr 0:e5420f1a8a1a 77 #define RFU_17 91
GregCr 0:e5420f1a8a1a 78 #define RFU_18 93
GregCr 0:e5420f1a8a1a 79 #define RFU_19 94
GregCr 0:e5420f1a8a1a 80 #define RFU_20 95
GregCr 0:e5420f1a8a1a 81 #define RFU_21 96
GregCr 0:e5420f1a8a1a 82 #define RFU_22 97
GregCr 0:e5420f1a8a1a 83 #define RFU_23 98
GregCr 0:e5420f1a8a1a 84 #define RFU_24 99
GregCr 0:e5420f1a8a1a 85
GregCr 0:e5420f1a8a1a 86 #define PAK_LORA_PREAMBLE_LEN_EEPROM_ADDR 100 // PreambleLength
GregCr 0:e5420f1a8a1a 87 #define PAK_LORA_HEADERTYPE_EEPROM_ADDR 102 // HeaderType
GregCr 0:e5420f1a8a1a 88 #define PAK_LORA_PL_LEN_EEPROM_ADDR 103 // PayloadLength
GregCr 0:e5420f1a8a1a 89 #define PAK_LORA_CRC_MODE_EEPROM_ADDR 104 // CrcMode
GregCr 0:e5420f1a8a1a 90 #define PAK_LORA_IQ_INV_EEPROM_ADDR 105 // InvertIQ
GregCr 0:e5420f1a8a1a 91 #define EEPROM_LAST_DEVICE_CONNECTED 106 // uint8
GregCr 0:e5420f1a8a1a 92 #define EEPROM_CRC_EEPROM_ADDR 107 // uint16
GregCr 0:e5420f1a8a1a 93
GregCr 0:e5420f1a8a1a 94 /*!
GregCr 0:e5420f1a8a1a 95 * \brief Eeprom buffer size. Cf. above.
GregCr 0:e5420f1a8a1a 96 */
GregCr 0:e5420f1a8a1a 97 #define EEPROM_BUFFER_SIZE 109
GregCr 0:e5420f1a8a1a 98
GregCr 0:e5420f1a8a1a 99 /*!
GregCr 0:e5420f1a8a1a 100 * \brief Part of EEPROM to save or restore
GregCr 0:e5420f1a8a1a 101 */
GregCr 0:e5420f1a8a1a 102 typedef enum
GregCr 0:e5420f1a8a1a 103 {
GregCr 0:e5420f1a8a1a 104 ALL_DATA,
GregCr 0:e5420f1a8a1a 105 SCREEN_DATA,
GregCr 0:e5420f1a8a1a 106 DEMO_SETTINGS,
GregCr 0:e5420f1a8a1a 107 RADIO_GFSK_PARAMS,
GregCr 0:e5420f1a8a1a 108 RADIO_LORA_PARAMS,
GregCr 0:e5420f1a8a1a 109 }EepromDataSet_t;
GregCr 0:e5420f1a8a1a 110
GregCr 0:e5420f1a8a1a 111 /*!
GregCr 0:e5420f1a8a1a 112 * \brief EepromData structure
GregCr 0:e5420f1a8a1a 113 */
GregCr 0:e5420f1a8a1a 114 typedef struct
GregCr 0:e5420f1a8a1a 115 {
GregCr 0:e5420f1a8a1a 116 MenuSettings_t MenuSettings;
GregCr 0:e5420f1a8a1a 117 DemoSettings_t DemoSettings;
GregCr 0:e5420f1a8a1a 118 ModulationParams_t ModulationParams;
GregCr 0:e5420f1a8a1a 119 PacketParams_t PacketParams;
GregCr 0:e5420f1a8a1a 120 uint16_t CheckSum;
GregCr 0:e5420f1a8a1a 121 }EepromData_t;
GregCr 0:e5420f1a8a1a 122
GregCr 0:e5420f1a8a1a 123 /*!
GregCr 0:e5420f1a8a1a 124 * \brief Eeprom structure
GregCr 0:e5420f1a8a1a 125 */
GregCr 0:e5420f1a8a1a 126 typedef struct
GregCr 0:e5420f1a8a1a 127 {
GregCr 0:e5420f1a8a1a 128 EepromData_t EepromData;
GregCr 0:e5420f1a8a1a 129 // Allows for the checksum to be carried out
GregCr 0:e5420f1a8a1a 130 uint8_t Buffer[EEPROM_BUFFER_SIZE];
GregCr 0:e5420f1a8a1a 131 }Eeprom_t;
GregCr 0:e5420f1a8a1a 132
GregCr 0:e5420f1a8a1a 133 /*!
GregCr 0:e5420f1a8a1a 134 * \brief Local copy of Eeprom. (defined in Eeprom.cpp)
GregCr 0:e5420f1a8a1a 135 */
GregCr 0:e5420f1a8a1a 136 extern Eeprom_t Eeprom;
GregCr 0:e5420f1a8a1a 137
GregCr 0:e5420f1a8a1a 138 /*!
GregCr 0:e5420f1a8a1a 139 * \brief Initialises the contents of EepromData
GregCr 0:e5420f1a8a1a 140 *
GregCr 0:e5420f1a8a1a 141 * \param [in] deviceConnected Device currently connected
GregCr 1:b96176a4ccb8 142 * \param [in] matchingFreq matching frequency
GregCr 0:e5420f1a8a1a 143 */
GregCr 1:b96176a4ccb8 144 void EepromInit( uint8_t deviceConnected, uint8_t matchingFreq );
GregCr 0:e5420f1a8a1a 145
GregCr 0:e5420f1a8a1a 146 /*!
GregCr 0:e5420f1a8a1a 147 * \brief Read Eeprom from emulated EEPROM (in fact in Flash " higher address).
GregCr 0:e5420f1a8a1a 148 *
GregCr 0:e5420f1a8a1a 149 * \param [in] addr address of data (EEPROM offset not to be include)
GregCr 0:e5420f1a8a1a 150 * \param [in] buffer buffer to use for copy
GregCr 0:e5420f1a8a1a 151 * \param [in] size size of data to copy
GregCr 0:e5420f1a8a1a 152 *
GregCr 0:e5420f1a8a1a 153 * \retval status Status of operation (SUCCESS, ..)
GregCr 0:e5420f1a8a1a 154 */
GregCr 0:e5420f1a8a1a 155 uint8_t EepromMcuReadBuffer( uint16_t addr, uint8_t *buffer, uint16_t size );
GregCr 0:e5420f1a8a1a 156
GregCr 0:e5420f1a8a1a 157 /*!
GregCr 0:e5420f1a8a1a 158 * \brief Writes the EepromData to emulated EEPROM
GregCr 0:e5420f1a8a1a 159 *
GregCr 0:e5420f1a8a1a 160 * \param [in] dataSet Set of data to save or restore
GregCr 0:e5420f1a8a1a 161 */
GregCr 0:e5420f1a8a1a 162 void EepromSaveSettings( EepromDataSet_t dataSet);
GregCr 0:e5420f1a8a1a 163
GregCr 0:e5420f1a8a1a 164 /*!
GregCr 0:e5420f1a8a1a 165 * \brief Loads EepromData from emulated EEPROM
GregCr 0:e5420f1a8a1a 166 */
GregCr 0:e5420f1a8a1a 167 void EepromLoadGeneralSettings ( void );
GregCr 0:e5420f1a8a1a 168
GregCr 0:e5420f1a8a1a 169 /*!
GregCr 0:e5420f1a8a1a 170 * \brief Loads EepromData with updated modulation and packet parameters
GregCr 0:e5420f1a8a1a 171 *
GregCr 0:e5420f1a8a1a 172 * \param [in] modulation modulation type to select for mod. & packet params
GregCr 0:e5420f1a8a1a 173 */
GregCr 0:e5420f1a8a1a 174 void EepromLoadSettings( RadioPacketTypes_t modulation );
GregCr 0:e5420f1a8a1a 175
GregCr 0:e5420f1a8a1a 176 /*!
GregCr 0:e5420f1a8a1a 177 * \brief Initialises the contents of flash to default values & save to EEPROM
GregCr 0:e5420f1a8a1a 178 *
GregCr 0:e5420f1a8a1a 179 * \param [in] deviceConnected Device currently connected
GregCr 1:b96176a4ccb8 180 * \param [in] matchingFreq board matching frequency
GregCr 0:e5420f1a8a1a 181 */
GregCr 1:b96176a4ccb8 182 void EepromSetDefaultSettings( uint8_t deviceConnected, uint8_t matchingFreq );
GregCr 1:b96176a4ccb8 183
GregCr 1:b96176a4ccb8 184 /*!
GregCr 1:b96176a4ccb8 185 * \brief Erase the data checksum to reset the radio to default parameters
GregCr 1:b96176a4ccb8 186 *
GregCr 1:b96176a4ccb8 187 */
GregCr 1:b96176a4ccb8 188 void EepromEraseCheckSum( void );
GregCr 0:e5420f1a8a1a 189
GregCr 0:e5420f1a8a1a 190 #endif //EEPROM_H