This is a class which contains function to interface with the MLX75320
LidarSpi.h@13:ccf4ab73c33d, 2016-05-17 (annotated)
- Committer:
- TNU
- Date:
- Tue May 17 18:54:04 2016 +0000
- Revision:
- 13:ccf4ab73c33d
- Parent:
- 12:d1767e2bd3a8
Added documentation
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
TNU | 0:dfe498e03679 | 1 | #ifndef LIDARSPI_H |
TNU | 0:dfe498e03679 | 2 | #define LIDARSPI_H |
TNU | 0:dfe498e03679 | 3 | |
TNU | 0:dfe498e03679 | 4 | #include "mbed.h" |
TNU | 0:dfe498e03679 | 5 | #include "typeDef.h" |
TNU | 0:dfe498e03679 | 6 | #include "FunctionPointer.h" |
TNU | 0:dfe498e03679 | 7 | |
TNU | 13:ccf4ab73c33d | 8 | /** LidarSpi class |
TNU | 13:ccf4ab73c33d | 9 | * This class defines methods and structs to interface with the MLX75320 lidar sensing product |
TNU | 13:ccf4ab73c33d | 10 | * |
TNU | 13:ccf4ab73c33d | 11 | */ |
TNU | 6:748062f3de21 | 12 | |
TNU | 0:dfe498e03679 | 13 | class LidarSpi |
TNU | 0:dfe498e03679 | 14 | { |
TNU | 0:dfe498e03679 | 15 | public: |
TNU | 0:dfe498e03679 | 16 | |
TNU | 0:dfe498e03679 | 17 | // Type used to read/write register values. Here, it is 16 bits |
TNU | 0:dfe498e03679 | 18 | typedef uint16_t REGTYPE; |
TNU | 0:dfe498e03679 | 19 | typedef unsigned char uchar; |
TNU | 0:dfe498e03679 | 20 | |
TNU | 0:dfe498e03679 | 21 | static const uint16_t CRC_SZ = 2; // Bytes in SPI CRC field |
TNU | 0:dfe498e03679 | 22 | static const uint16_t SHORT_SZ = 8; // Bytes in short SPI packet |
TNU | 0:dfe498e03679 | 23 | static const uint16_t LONG_SZ = 300; // Bytes in long SPI packet |
TNU | 0:dfe498e03679 | 24 | static const uint16_t HDR_SZ = 2; // Bytes in SPI header field |
TNU | 0:dfe498e03679 | 25 | |
TNU | 0:dfe498e03679 | 26 | static const uint16_t MAXCH = 16; // Number of channels |
TNU | 0:dfe498e03679 | 27 | static const uint16_t MAXSET = 2; // Number of acquisition sets |
TNU | 0:dfe498e03679 | 28 | static const uint16_t MAXPTCNT = 64; // Max number of base points |
TNU | 0:dfe498e03679 | 29 | static const uint16_t MAXECH = 64 ; // Max echo count |
TNU | 0:dfe498e03679 | 30 | static const uint16_t MAXACCLOG = 10; // Max accumulation log2 |
TNU | 0:dfe498e03679 | 31 | static const uint16_t MAXOVRLOG = 3; // Max oversampling log2 |
TNU | 0:dfe498e03679 | 32 | static const uint16_t MAXLED = 16; // Max LED power |
TNU | 0:dfe498e03679 | 33 | static const uint16_t MAXACC = 1<<MAXACCLOG; |
TNU | 0:dfe498e03679 | 34 | static const uint16_t MAXOVR = 1<<MAXOVRLOG; |
TNU | 0:dfe498e03679 | 35 | static const uint16_t MAXTRCLEN = 74*8*MAXCH*2; // Max length of a trace in bytes (samples * MAXOVR * MAXCH * 2bytes) |
TNU | 0:dfe498e03679 | 36 | static const uint16_t BYTES_PER_ECH = 24; // Nb of bytes per echo |
TNU | 0:dfe498e03679 | 37 | static const uint16_t START_DELAY =10; |
TNU | 0:dfe498e03679 | 38 | |
TNU | 0:dfe498e03679 | 39 | // Used on header ADDR field to request all channels and as idx argument of GetTrace function |
TNU | 0:dfe498e03679 | 40 | static const uint16_t ADDR_ALLCH= 0x1F; |
TNU | 0:dfe498e03679 | 41 | |
TNU | 13:ccf4ab73c33d | 42 | |
TNU | 13:ccf4ab73c33d | 43 | // Structure for the processed data returned by the sensor |
TNU | 0:dfe498e03679 | 44 | struct Echo |
TNU | 0:dfe498e03679 | 45 | { |
TNU | 0:dfe498e03679 | 46 | uint32_t mDistance; |
TNU | 0:dfe498e03679 | 47 | uint32_t mAmplitude; |
TNU | 0:dfe498e03679 | 48 | uint32_t mBase; |
TNU | 0:dfe498e03679 | 49 | uint16_t mMaxIndex; |
TNU | 0:dfe498e03679 | 50 | uint8_t mChannelIndex; |
TNU | 0:dfe498e03679 | 51 | uint8_t mValid; |
TNU | 0:dfe498e03679 | 52 | uint32_t mAmplitudeLowScale; |
TNU | 0:dfe498e03679 | 53 | uint32_t mSaturationWidth; |
TNU | 0:dfe498e03679 | 54 | }; |
TNU | 0:dfe498e03679 | 55 | |
TNU | 0:dfe498e03679 | 56 | /// \enum eASICREG |
TNU | 0:dfe498e03679 | 57 | /// \brief Lists all registers. Enum value is directly the register address. |
TNU | 0:dfe498e03679 | 58 | /// Naming convention: REG_ + <name> + <L/H> + <#> |
TNU | 0:dfe498e03679 | 59 | /// <name> = name of register |
TNU | 0:dfe498e03679 | 60 | /// <L/H> = optional low or high register part |
TNU | 0:dfe498e03679 | 61 | /// <#> = optional number, either for acquisition source 0/1 or index |
TNU | 0:dfe498e03679 | 62 | typedef enum |
TNU | 0:dfe498e03679 | 63 | { |
TNU | 0:dfe498e03679 | 64 | REG_MEACL = 0x00, |
TNU | 0:dfe498e03679 | 65 | REG_MEACH, |
TNU | 0:dfe498e03679 | 66 | REG_CONTROL, |
TNU | 0:dfe498e03679 | 67 | REG_ACQCTL0, |
TNU | 0:dfe498e03679 | 68 | REG_ACQCTL1, |
TNU | 0:dfe498e03679 | 69 | REG_PTCNT, |
TNU | 0:dfe498e03679 | 70 | REG_SCANCTL, |
TNU | 0:dfe498e03679 | 71 | REG_TRIGCTL, |
TNU | 0:dfe498e03679 | 72 | REG_DELAY, |
TNU | 0:dfe498e03679 | 73 | REG_TMPSET, |
TNU | 0:dfe498e03679 | 74 | REG_TMPSHUT, |
TNU | 0:dfe498e03679 | 75 | REG_TMPIC, |
TNU | 0:dfe498e03679 | 76 | REG_TMPSRC, |
TNU | 0:dfe498e03679 | 77 | REG_GAIN0, |
TNU | 0:dfe498e03679 | 78 | REG_GAIN1, |
TNU | 0:dfe498e03679 | 79 | REG_GAIN2, |
TNU | 0:dfe498e03679 | 80 | REG_GAIN3, |
TNU | 0:dfe498e03679 | 81 | REG_CHANNEL, |
TNU | 0:dfe498e03679 | 82 | REG_PWMPERIOD0, |
TNU | 0:dfe498e03679 | 83 | REG_PWMPERIOD1, |
TNU | 0:dfe498e03679 | 84 | REG_PWMCOUNT, |
TNU | 0:dfe498e03679 | 85 | REG_PWMWIDTH0, |
TNU | 0:dfe498e03679 | 86 | REG_PWMWIDTH1 = REG_PWMWIDTH0 + 8, |
TNU | 0:dfe498e03679 | 87 | REG_FILTER0 = REG_PWMWIDTH1 + 8, |
TNU | 0:dfe498e03679 | 88 | REG_FILTER1 = REG_FILTER0 + 16, |
TNU | 0:dfe498e03679 | 89 | REG_THRNEARL0 = REG_FILTER1 + 16, |
TNU | 0:dfe498e03679 | 90 | REG_THRNEARH0, |
TNU | 0:dfe498e03679 | 91 | REG_THRMEDL0, |
TNU | 0:dfe498e03679 | 92 | REG_THRMEDH0, |
TNU | 0:dfe498e03679 | 93 | REG_THRFARL0, |
TNU | 0:dfe498e03679 | 94 | REG_THRFARH0, |
TNU | 0:dfe498e03679 | 95 | REG_THRNEARL1, |
TNU | 0:dfe498e03679 | 96 | REG_THRNEARH1, |
TNU | 0:dfe498e03679 | 97 | REG_THRMEDL1, |
TNU | 0:dfe498e03679 | 98 | REG_THRMEDH1, |
TNU | 0:dfe498e03679 | 99 | REG_THRFARL1, |
TNU | 0:dfe498e03679 | 100 | REG_THRFARH1, |
TNU | 0:dfe498e03679 | 101 | REG_NOISE0, |
TNU | 0:dfe498e03679 | 102 | REG_NOISE1, |
TNU | 0:dfe498e03679 | 103 | REG_OFFSETL0, |
TNU | 0:dfe498e03679 | 104 | REG_OFFSETH0 = REG_OFFSETL0 + 16, |
TNU | 0:dfe498e03679 | 105 | REG_OFFSETL1 = REG_OFFSETH0 + 16, |
TNU | 0:dfe498e03679 | 106 | REG_OFFSETH1 = REG_OFFSETL1 + 16, |
TNU | 0:dfe498e03679 | 107 | REG_SCALEL0 = REG_OFFSETH1 + 16, |
TNU | 0:dfe498e03679 | 108 | REG_SCALEH0, |
TNU | 0:dfe498e03679 | 109 | REG_SCALEL1, |
TNU | 0:dfe498e03679 | 110 | REG_SCALEH1, |
TNU | 0:dfe498e03679 | 111 | REG_FACTORY, |
TNU | 0:dfe498e03679 | 112 | REG_ASIL, |
TNU | 0:dfe498e03679 | 113 | REG_OTP0, |
TNU | 0:dfe498e03679 | 114 | REG_OTP1, |
TNU | 0:dfe498e03679 | 115 | REG_OTP2, |
TNU | 0:dfe498e03679 | 116 | REG_OTP3, |
TNU | 0:dfe498e03679 | 117 | REG_OTP4, |
TNU | 0:dfe498e03679 | 118 | REG_OTP5, |
TNU | 0:dfe498e03679 | 119 | REG_OTP6, |
TNU | 0:dfe498e03679 | 120 | REG_OTP7, |
TNU | 0:dfe498e03679 | 121 | REG_SOFTVER, |
TNU | 0:dfe498e03679 | 122 | REG_ASICVER, |
TNU | 0:dfe498e03679 | 123 | REG_WATCHDOGL, |
TNU | 0:dfe498e03679 | 124 | REG_WATCHDOGH, |
TNU | 0:dfe498e03679 | 125 | // Wai: Changed from REG_MAX |
TNU | 0:dfe498e03679 | 126 | REG_MAX = 0xFFFF // Number of registers |
TNU | 0:dfe498e03679 | 127 | } eASICREG; |
TNU | 0:dfe498e03679 | 128 | |
TNU | 13:ccf4ab73c33d | 129 | //Internal type used by low level functions: SPI packet type |
TNU | 0:dfe498e03679 | 130 | enum PackType |
TNU | 0:dfe498e03679 | 131 | { |
TNU | 0:dfe498e03679 | 132 | PACK_RREG = 0, ///< Read register request |
TNU | 0:dfe498e03679 | 133 | PACK_WREG, ///< Write register request |
TNU | 0:dfe498e03679 | 134 | PACK_RFIRM, ///< Read firmware request |
TNU | 0:dfe498e03679 | 135 | PACK_WFIRM, ///< Write firmware request |
TNU | 0:dfe498e03679 | 136 | PACK_STATUS_S, ///< Status short |
TNU | 0:dfe498e03679 | 137 | PACK_STATUS_L, ///< Status long |
TNU | 0:dfe498e03679 | 138 | PACK_RDATA_RESP_S, ///< Read data response short |
TNU | 0:dfe498e03679 | 139 | PACK_RDATA_RESP_L, ///< Read data response long |
TNU | 0:dfe498e03679 | 140 | PACK_WDATA_L, ///< Write data long |
TNU | 0:dfe498e03679 | 141 | }; |
TNU | 13:ccf4ab73c33d | 142 | //Internal type used by low level functions: SPI status status type |
TNU | 0:dfe498e03679 | 143 | enum StatusType |
TNU | 0:dfe498e03679 | 144 | { |
TNU | 0:dfe498e03679 | 145 | STAT_OK = 0, |
TNU | 0:dfe498e03679 | 146 | STAT_BUSY, |
TNU | 0:dfe498e03679 | 147 | STAT_CRC, |
TNU | 0:dfe498e03679 | 148 | STAT_INVALID_REQ, |
TNU | 0:dfe498e03679 | 149 | STAT_SEQ_NB, |
TNU | 0:dfe498e03679 | 150 | STAT_TIMEOUT, |
TNU | 0:dfe498e03679 | 151 | }; |
TNU | 13:ccf4ab73c33d | 152 | //Internal type used by low level functions: SPI firmware packet type |
TNU | 0:dfe498e03679 | 153 | enum FirmType |
TNU | 0:dfe498e03679 | 154 | { |
TNU | 0:dfe498e03679 | 155 | FW_OTP = 0, |
TNU | 0:dfe498e03679 | 156 | FW_PROCESSED, |
TNU | 0:dfe498e03679 | 157 | FW_RAW, |
TNU | 0:dfe498e03679 | 158 | FW_PATCH, |
TNU | 0:dfe498e03679 | 159 | FW_PRELOAD, |
TNU | 0:dfe498e03679 | 160 | FW_TEST, |
TNU | 0:dfe498e03679 | 161 | }; |
TNU | 0:dfe498e03679 | 162 | |
TNU | 0:dfe498e03679 | 163 | |
TNU | 13:ccf4ab73c33d | 164 | |
TNU | 13:ccf4ab73c33d | 165 | /*===================================================================================================================================== |
TNU | 13:ccf4ab73c33d | 166 | //===================================================================================================================================== |
TNU | 13:ccf4ab73c33d | 167 | _____ _ _ _ __ _ _ |
TNU | 13:ccf4ab73c33d | 168 | | __ \ | | | (_) / _| | | (_) |
TNU | 13:ccf4ab73c33d | 169 | | |__) | _| |__ | |_ ___ | |_ _ _ _ __ ___| |_ _ ___ _ __ ___ |
TNU | 13:ccf4ab73c33d | 170 | | ___/ | | | '_ \| | |/ __| | _| | | | '_ \ / __| __| |/ _ \| '_ \/ __| |
TNU | 13:ccf4ab73c33d | 171 | | | | |_| | |_) | | | (__ | | | |_| | | | | (__| |_| | (_) | | | \__ \ |
TNU | 13:ccf4ab73c33d | 172 | |_| \__,_|_.__/|_|_|\___| |_| \__,_|_| |_|\___|\__|_|\___/|_| |_|___/ |
TNU | 13:ccf4ab73c33d | 173 | |
TNU | 13:ccf4ab73c33d | 174 | //===================================================================================================================================== |
TNU | 13:ccf4ab73c33d | 175 | //====================================================================================================================================*/ |
TNU | 13:ccf4ab73c33d | 176 | |
TNU | 13:ccf4ab73c33d | 177 | |
TNU | 13:ccf4ab73c33d | 178 | /** Constructor |
TNU | 13:ccf4ab73c33d | 179 | * @param: pin names for mosi, miso, clk, chipselect, dataready, reset, trigger and sample*/ |
TNU | 3:9ed1d493c235 | 180 | LidarSpi(PinName mosi, PinName miso, PinName clk, PinName chipSelect, PinName dr, PinName rs, PinName tr, PinName smpl); |
TNU | 13:ccf4ab73c33d | 181 | |
TNU | 13:ccf4ab73c33d | 182 | /** SpiSetting |
TNU | 13:ccf4ab73c33d | 183 | * Change frequency and SPI mode(clock phase and polarity) |
TNU | 13:ccf4ab73c33d | 184 | * @param: frequency in Hz, mode ranging from 0 to 3, pointer to Serial interface for debugging |
TNU | 13:ccf4ab73c33d | 185 | * @return: 0 on success */ |
TNU | 0:dfe498e03679 | 186 | int SpiSetting(long freq, int mode, Serial* pc); |
TNU | 13:ccf4ab73c33d | 187 | |
TNU | 13:ccf4ab73c33d | 188 | /** ReadReg |
TNU | 13:ccf4ab73c33d | 189 | * Read register at address |
TNU | 13:ccf4ab73c33d | 190 | * @param: register address, pointer to variable to register valueresult |
TNU | 13:ccf4ab73c33d | 191 | * @return: 0 on success */ |
TNU | 13:ccf4ab73c33d | 192 | int ReadReg ( uint32_t reg, uint32_t *val); |
TNU | 13:ccf4ab73c33d | 193 | |
TNU | 13:ccf4ab73c33d | 194 | /** WriteReg |
TNU | 13:ccf4ab73c33d | 195 | * Write register to address |
TNU | 13:ccf4ab73c33d | 196 | * @param: register address, value to write |
TNU | 13:ccf4ab73c33d | 197 | * @return: 0 on success */ |
TNU | 13:ccf4ab73c33d | 198 | int WriteReg ( uint32_t reg, uint32_t val); |
TNU | 13:ccf4ab73c33d | 199 | |
TNU | 13:ccf4ab73c33d | 200 | |
TNU | 13:ccf4ab73c33d | 201 | /** GetEchoes |
TNU | 13:ccf4ab73c33d | 202 | * Perform measurement and read processed data |
TNU | 13:ccf4ab73c33d | 203 | * @param: pointer to Echo structure array to store measurement, structure array size (must be >=64) |
TNU | 13:ccf4ab73c33d | 204 | * @return: 0 on success */ |
TNU | 13:ccf4ab73c33d | 205 | int GetEchoes ( Echo *ech, uint16_t maxN); |
TNU | 13:ccf4ab73c33d | 206 | |
TNU | 13:ccf4ab73c33d | 207 | /** GetEchoes |
TNU | 13:ccf4ab73c33d | 208 | * Perform measurement and read processed data |
TNU | 13:ccf4ab73c33d | 209 | * @param: pointer to Echo structure array to store measurement, structure array size (must be >=64), pointer to serial interface for debugging |
TNU | 13:ccf4ab73c33d | 210 | * @return: 0 on success */ |
TNU | 13:ccf4ab73c33d | 211 | int GetEchoes ( Echo *ech, uint16_t maxN, Serial* pc); |
TNU | 13:ccf4ab73c33d | 212 | |
TNU | 13:ccf4ab73c33d | 213 | /** GetTrace |
TNU | 13:ccf4ab73c33d | 214 | * Perform measurement and read raw trace buffer |
TNU | 13:ccf4ab73c33d | 215 | * @param: pointer to int array to store trace buffer, structure array size (must be >=9472*2), pointer to serial interface for debugging |
TNU | 13:ccf4ab73c33d | 216 | * @return: 0 on success */ |
TNU | 13:ccf4ab73c33d | 217 | int GetTrace ( uint16_t *buf, uint16_t maxN, Serial* pc); |
TNU | 13:ccf4ab73c33d | 218 | |
TNU | 13:ccf4ab73c33d | 219 | /** LoadPatch |
TNU | 13:ccf4ab73c33d | 220 | * Load patch stored on mbed Flash memory in MLX75320 and enable patch |
TNU | 13:ccf4ab73c33d | 221 | * @param: path of patch.hex location, , pointer to serial interface for debugging |
TNU | 13:ccf4ab73c33d | 222 | * @return: 0 on success */ |
TNU | 13:ccf4ab73c33d | 223 | int LoadPatch (const char *patch, Serial *pc); |
TNU | 13:ccf4ab73c33d | 224 | |
TNU | 13:ccf4ab73c33d | 225 | /** SetTrace |
TNU | 13:ccf4ab73c33d | 226 | * Set a variety of registers according to the preset values for a raw data measurement |
TNU | 13:ccf4ab73c33d | 227 | * @return: 0 on success */ |
TNU | 13:ccf4ab73c33d | 228 | int setTrace(void); |
TNU | 13:ccf4ab73c33d | 229 | |
TNU | 13:ccf4ab73c33d | 230 | /** SetTrace |
TNU | 13:ccf4ab73c33d | 231 | * Set a variety of registers according to the preset values for a processed data measurement |
TNU | 13:ccf4ab73c33d | 232 | * @return: 0 on success */ |
TNU | 13:ccf4ab73c33d | 233 | int setEcho(void); |
TNU | 13:ccf4ab73c33d | 234 | |
TNU | 13:ccf4ab73c33d | 235 | /** SetLed |
TNU | 13:ccf4ab73c33d | 236 | * Set a variety of registers according to the preset values to either fire or don't fire the LEDs during a measurement |
TNU | 13:ccf4ab73c33d | 237 | * @param: True to enable LEDs, False to disable */ |
TNU | 13:ccf4ab73c33d | 238 | int setLed(bool state); |
TNU | 13:ccf4ab73c33d | 239 | |
TNU | 13:ccf4ab73c33d | 240 | |
TNU | 13:ccf4ab73c33d | 241 | /*===================================================================================================================================== |
TNU | 13:ccf4ab73c33d | 242 | //===================================================================================================================================== |
TNU | 13:ccf4ab73c33d | 243 | _____ _ _ _ _ _ __ _ _ |
TNU | 13:ccf4ab73c33d | 244 | |_ _| | | | | | | | | (_) / _| | | (_) |
TNU | 13:ccf4ab73c33d | 245 | | | _ __ | |_ ___ _ __ _ __ __ _| | ___ _ __ __| | ___| |__ _ _ __ _ __ _ _ _ __ __ _ | |_ _ _ _ __ ___| |_ _ ___ _ __ ___ |
TNU | 13:ccf4ab73c33d | 246 | | | | '_ \| __/ _ \ '__| '_ \ / _` | | / _ \| '__| / _` |/ _ \ '_ \| | | |/ _` |/ _` | | '_ \ / _` | | _| | | | '_ \ / __| __| |/ _ \| '_ \/ __| |
TNU | 13:ccf4ab73c33d | 247 | _| |_| | | | || __/ | | | | | (_| | | | (_) | | | (_| | __/ |_) | |_| | (_| | (_| | | | | | (_| | | | | |_| | | | | (__| |_| | (_) | | | \__ \ |
TNU | 13:ccf4ab73c33d | 248 | |_____|_| |_|\__\___|_| |_| |_|\__,_|_| \___/|_| \__,_|\___|_.__/ \__,_|\__, |\__, |_|_| |_|\__, | |_| \__,_|_| |_|\___|\__|_|\___/|_| |_|___/ |
TNU | 13:ccf4ab73c33d | 249 | __/ | __/ | __/ | |
TNU | 13:ccf4ab73c33d | 250 | |___/ |___/ |___/ |
TNU | 13:ccf4ab73c33d | 251 | //===================================================================================================================================== |
TNU | 13:ccf4ab73c33d | 252 | //====================================================================================================================================*/ |
TNU | 13:ccf4ab73c33d | 253 | |
TNU | 13:ccf4ab73c33d | 254 | |
TNU | 13:ccf4ab73c33d | 255 | |
TNU | 13:ccf4ab73c33d | 256 | /** ReadReg (overloaded) |
TNU | 13:ccf4ab73c33d | 257 | * Read register at address |
TNU | 13:ccf4ab73c33d | 258 | * @param: register address, pointer to variable to register valueresult, pointer to serial interface for debugging |
TNU | 13:ccf4ab73c33d | 259 | * @return: 0 on success */ |
TNU | 13:ccf4ab73c33d | 260 | int ReadReg(uint32_t reg, uint32_t *val, Serial* pc); |
TNU | 13:ccf4ab73c33d | 261 | |
TNU | 13:ccf4ab73c33d | 262 | /** WriteReg |
TNU | 13:ccf4ab73c33d | 263 | * Write register to address |
TNU | 13:ccf4ab73c33d | 264 | * @param: register address, value to write, pointer to serial interface for debugging |
TNU | 13:ccf4ab73c33d | 265 | * @return: 0 on success */ |
TNU | 13:ccf4ab73c33d | 266 | int WriteReg ( uint32_t reg, uint32_t val, Serial* pc); |
TNU | 13:ccf4ab73c33d | 267 | |
TNU | 13:ccf4ab73c33d | 268 | /** GetTraceOne |
TNU | 13:ccf4ab73c33d | 269 | * Perform measurement and read raw trace buffer, this method only reads back a single SPI packet |
TNU | 13:ccf4ab73c33d | 270 | * @param: pointer to int array to store trace buffer, structure array size (must be >=9472*2), pointer to serial interface for debugging |
TNU | 13:ccf4ab73c33d | 271 | * @return: 0 on success */ |
TNU | 13:ccf4ab73c33d | 272 | int GetTraceOne ( uint16_t *buf, uint16_t maxN, uint16_t nSam, uint16_t idx,int index , Serial* pc); |
TNU | 13:ccf4ab73c33d | 273 | |
TNU | 13:ccf4ab73c33d | 274 | /** Trigger |
TNU | 13:ccf4ab73c33d | 275 | * Change pin to high or low to use as trigger point for oscilloscope |
TNU | 13:ccf4ab73c33d | 276 | * @param: 1 or 0 to set voltage level */ |
TNU | 13:ccf4ab73c33d | 277 | void Trigger(int level); |
TNU | 13:ccf4ab73c33d | 278 | |
TNU | 13:ccf4ab73c33d | 279 | |
TNU | 13:ccf4ab73c33d | 280 | int PrintAllReg (uint16_t * regs, uint32_t * val, uint16_t size); |
TNU | 13:ccf4ab73c33d | 281 | |
TNU | 0:dfe498e03679 | 282 | int TxPacket(uint8_t* rData, uint16_t *rSz, uint8_t *tData, uint16_t tSz); |
TNU | 0:dfe498e03679 | 283 | int TxPacketWord(uint8_t* rData, uint16_t *rSz, uint8_t *tData, uint16_t tSz); |
TNU | 0:dfe498e03679 | 284 | int TxPacket(uint8_t* rData, uint16_t *rSz, uint8_t *tData, uint16_t tSz, Serial* pc); |
TNU | 0:dfe498e03679 | 285 | int TxPacketSlow(uint8_t* rData, uint16_t *rSz, uint8_t *tData, uint16_t tSz, uint16_t usDelay); |
TNU | 0:dfe498e03679 | 286 | int BasicRead(); |
TNU | 0:dfe498e03679 | 287 | int BasicTransfer(uint8_t* rData, uint16_t rSz, uint8_t *wData, uint16_t wSz, const event_callback_t callback); |
TNU | 0:dfe498e03679 | 288 | int WriteRegSpeed ( uint32_t reg, uint32_t val, uint16_t usDelay); |
TNU | 0:dfe498e03679 | 289 | int WriteRegSpeed ( uint32_t reg, uint32_t val, uint16_t usDelay, Serial* pc); |
TNU | 13:ccf4ab73c33d | 290 | |
TNU | 0:dfe498e03679 | 291 | //int SetConfig ( int configNum); |
TNU | 0:dfe498e03679 | 292 | //int SetAcqCfg ( uint16_t set, uint16_t led, uint16_t accLog, uint16_t ovrLog); |
TNU | 0:dfe498e03679 | 293 | //int Acquire ( uchar ab, uchar evGain, uchar evCh, uchar odGain, uchar odCh); |
TNU | 0:dfe498e03679 | 294 | //int GetFrame ( uint16_t *buf, uint16_t maxN, uint16_t nSam, uint16_t nFrm); |
TNU | 0:dfe498e03679 | 295 | |
TNU | 0:dfe498e03679 | 296 | |
TNU | 0:dfe498e03679 | 297 | |
TNU | 0:dfe498e03679 | 298 | |
TNU | 0:dfe498e03679 | 299 | private: |
TNU | 0:dfe498e03679 | 300 | SPI device; |
TNU | 0:dfe498e03679 | 301 | DigitalOut chipS; |
TNU | 0:dfe498e03679 | 302 | DigitalIn dataReady; |
TNU | 11:bd2dee9957a9 | 303 | DigitalOut resetPin; |
TNU | 4:534855b07d93 | 304 | DigitalOut trigger; |
TNU | 3:9ed1d493c235 | 305 | DigitalIn sampling; |
TNU | 0:dfe498e03679 | 306 | |
TNU | 6:748062f3de21 | 307 | int parse_hex_line(char *theline, uint8_t bytes[], uint16_t *addr, uint16_t *num, uint16_t *code); |
TNU | 6:748062f3de21 | 308 | int LoadPatchFragment(const char *patch, uint16_t *addrStart, uint16_t *startLine, uint16_t *nBytes, uint8_t *memory, Serial* pc); |
TNU | 0:dfe498e03679 | 309 | |
TNU | 0:dfe498e03679 | 310 | |
TNU | 0:dfe498e03679 | 311 | }; |
TNU | 0:dfe498e03679 | 312 | |
TNU | 0:dfe498e03679 | 313 | |
TNU | 0:dfe498e03679 | 314 | #endif |