ADI iSensor FX3 Firmware  v2.9.4-pub
Firmware for the Analog Devices EVAL-ADIS-FX3 IMU Evaluation Platform. This firmware can be compiled using the Cypress EZ USB Suite IDE
main.h
Go to the documentation of this file.
1 
19 #ifndef MAIN_H
20 #define MAIN_H
21 
22 /*
23  * This macro is used to set verbose mode during compile time.
24  * Ensure that it is commented out for release versions.
25  */
26 //#define VERBOSE_MODE (0)
27 
28 /* Include all needed Cypress libraries */
29 #include "cyu3types.h"
30 #include "cyu3usbconst.h"
31 #include "cyu3externcstart.h"
32 #include "cyu3system.h"
33 #include "cyu3os.h"
34 #include "cyu3dma.h"
35 #include "cyu3error.h"
36 #include "cyu3usb.h"
37 #include "cyu3i2c.h"
38 #include "cyu3spi.h"
39 #include "cyu3uart.h"
40 #include "cyu3utils.h"
41 #include "cyu3gpio.h"
42 #include "cyu3vic.h"
43 #include "cyu3pib.h"
44 #include "stdlib.h"
45 #include "sys/unistd.h"
46 
47 /* Include all Analog Devices produced project header files */
48 #include "AppThread.h"
49 #include "PinFunctions.h"
50 #include "SpiFunctions.h"
51 #include "StreamFunctions.h"
52 #include "StreamThread.h"
53 #include "Flash.h"
54 #include "ErrorLog.h"
55 #include "I2cFunctions.h"
56 #include "HelperFunctions.h"
57 
58 /* Lower level register access includes */
59 #include "gpio_regs.h"
60 #include "spi_regs.h"
61 #include "gctlaon_regs.h"
62 
64 typedef enum FX3BoardType
65 {
68 
71 
74 
77 
80 
83 
86 
89 
92 
94 
96 typedef enum PartTye
97 {
100 
103 
106 
109 
111  LegacyIMU
112 
114 
116 typedef struct FX3PinMap
117 {
119  uint16_t ADI_PIN_RESET;
120 
122  uint16_t ADI_PIN_DIO1;
123 
125  uint16_t ADI_PIN_DIO2;
126 
128  uint16_t ADI_PIN_DIO3;
129 
131  uint16_t ADI_PIN_DIO4;
132 
134  uint16_t FX3_PIN_GPIO1;
135 
137  uint16_t FX3_PIN_GPIO2;
138 
140  uint16_t FX3_PIN_GPIO3;
141 
143  uint16_t FX3_PIN_GPIO4;
145 
147 typedef struct BoardState
148 {
150  CyU3PSpiConfig_t SpiConfig;
151 
154 
156  uint16_t UsbBufferSize;
157 
159  CyBool_t AppActive;
160 
162  uint32_t TimerPinConfig;
163 
165  uint32_t StallTime;
166 
168  uint16_t DrPin;
169 
171  CyBool_t DrActive;
172 
174  CyBool_t DrPolarity;
175 
177  CyBool_t WatchDogEnabled;
178 
181 
183  uint32_t WatchDogTicks;
184 
186  uint32_t BootTime;
187 
190 
193 
195  uint32_t I2CBitRate;
196 
198  uint16_t I2CRetryCount;
199 
201 
203 typedef struct StreamState
204 {
206  uint32_t BytesPerFrame;
207 
209  CyBool_t PinExitEnable;
210 
212  CyBool_t PinStartEnable;
213 
216 
219 
222 
225 
227  uint32_t NumCaptures;
228 
230  uint32_t NumBuffers;
231 
233  uint16_t BytesPerBuffer;
234 
236  uint8_t *RegList;
237 
240 
242  CyU3PI2cPreamble_t I2CStreamPreamble;
243 
245 
246 /*
247  * Vendor Command Request Code Definitions
248  */
249 
251 #define ADI_I2C_SET_BIT_RATE (0x10)
252 
254 #define ADI_I2C_READ_BYTES (0x11)
255 
257 #define ADI_I2C_WRITE_BYTES (0x12)
258 
260 #define ADI_I2C_READ_STREAM (0x13)
261 
263 #define ADI_I2C_RETRY_COUNT (0x14)
264 
266 #define ADI_FIRMWARE_ID_CHECK (0xB0)
267 
269 #define ADI_HARD_RESET (0xB1)
270 
272 #define ADI_SET_SPI_CONFIG (0xB2)
273 
275 #define ADI_READ_SPI_CONFIG (0xB3)
276 
278 #define ADI_GET_STATUS (0xB4)
279 
281 #define ADI_SERIAL_NUMBER_CHECK (0xB5)
282 
284 #define ADI_WARM_RESET (0xB6)
285 
287 #define ADI_SET_DUT_SUPPLY (0xB7)
288 
290 #define ADI_GET_BUILD_DATE (0xB8)
291 
293 #define ADI_SET_BOOT_TIME (0xB9)
294 
296 #define ADI_GET_BOARD_TYPE (0xBA)
297 
299 #define ADI_STREAM_GENERIC_DATA (0xC0)
300 
302 #define ADI_STREAM_BURST_DATA (0xC1)
303 
305 #define ADI_READ_PIN (0xC3)
306 
308 #define ADI_READ_TIMER_VALUE (0xC4)
309 
311 #define ADI_PULSE_DRIVE (0xC5)
312 
314 #define ADI_PULSE_WAIT (0xC6)
315 
317 #define ADI_SET_PIN (0xC7)
318 
320 #define ADI_MEASURE_DR (0xC8)
321 
323 #define ADI_PIN_DELAY_MEASURE (0xCF)
324 
326 #define ADI_STREAM_REALTIME (0xD0)
327 
329 #define ADI_NULL_COMMAND (0xD1)
330 
332 #define ADI_SET_PIN_RESISTOR (0xD2)
333 
335 #define ADI_READ_BYTES (0xF0)
336 
338 #define ADI_WRITE_BYTE (0xF1)
339 
341 #define ADI_CLEAR_FLASH_LOG (0xF2)
342 
344 #define ADI_READ_FLASH (0xF3)
345 
347 #define ADI_TRANSFER_BYTES (0xCA)
348 
350 #define ADI_TRANSFER_STREAM (0xCC)
351 
353 #define ADI_PWM_CMD (0xC9)
354 
356 #define ADI_BUSY_MEASURE (0xCB)
357 
359 #define ADI_BITBANG_SPI (0xCD)
360 
362 #define ADI_RESET_SPI (0xCE)
363 
364 /*
365  * Clock defines
366  */
367 
369 #define S_TO_TICKS_MULT (10078400)
370 
372 #define MS_TO_TICKS_MULT (10078)
373 
375 #define ADI_GENERIC_STALL_OFFSET (25)
376 
378 #define ADI_MICROSECONDS_SLEEP_OFFSET (14)
379 
381 #define ADI_TIMER_PIN_INDEX (0x0)
382 
383 /*
384  * Endpoint Related Defines
385  */
386 
388 #define ADI_STREAMING_ENDPOINT (0x81)
389 
391 #define ADI_FROM_PC_ENDPOINT (0x1)
392 
394 #define ADI_TO_PC_ENDPOINT (0x82)
395 
397 #define CY_FX_BULK_BURST (8)
398 
399 /*
400  * FX3 control registers
401  */
402 
404 #define GCTL_WPD_CFG (*(uvint32_t *)(0xE0051028))
405 
407 #define GCTL_WPD_CFG_UPPR (*(uvint32_t *)(0xE0051028 + 0x4))
408 
410 #define GCTL_WPU_CFG (*(uvint32_t *)(0xE0051020))
411 
413 #define GCTL_WPU_CFG_UPPR (*(uvint32_t *)(0xE0051020 + 0x4))
414 
416 #define EFUSE_DIE_ID (uvint32_t *)0xE0055010
417 
418 /*
419  * USB Descriptor buffers
420  */
421 extern const uint8_t CyFxUSB20DeviceDscr[];
422 extern const uint8_t CyFxUSB30DeviceDscr[];
423 extern const uint8_t CyFxUSBDeviceQualDscr[];
424 extern const uint8_t CyFxUSBFSConfigDscr[];
425 extern const uint8_t CyFxUSBHSConfigDscr[];
426 extern const uint8_t CyFxUSBBOSDscr[];
427 extern const uint8_t CyFxUSBSSConfigDscr[];
428 extern const uint8_t CyFxUSBStringLangIDDscr[];
429 extern const uint8_t CyFxUSBManufactureDscr[];
430 extern const uint8_t CyFxUSBProductDscr[];
431 extern uint8_t CyFxUSBSerialNumDesc[];
432 
433 /* Initialization and configuration functions. */
434 void AdiAppStart();
435 void AdiAppStop();
436 void AdiAppErrorHandler (CyU3PReturnStatus_t status);
438 
439 /* Event Handlers */
440 CyBool_t AdiControlEndpointHandler(uint32_t setupdat0, uint32_t setupdat1);
441 void AdiBulkEndpointHandler(CyU3PUsbEpEvtType evType,CyU3PUSBSpeed_t usbSpeed, uint8_t epNum);
442 void AdiUSBEventHandler(CyU3PUsbEventType_t evtype, uint16_t evdata);
443 CyBool_t AdiLPMRequestHandler(CyU3PUsbLinkPowerMode link_mode);
444 void AdiGPIOEventHandler(uint8_t gpioId);
445 
447 #define UNUSED(x) (void)(x)
448 
449 #include <cyu3externcend.h>
450 
451 #endif
ADI_STREAM_START_CMD
#define ADI_STREAM_START_CMD
Definition: StreamFunctions.h:61
ADI_TRANSFER_STREAM_STOP
#define ADI_TRANSFER_STREAM_STOP
Definition: AppThread.h:81
AdiReadRegBytes
CyU3PReturnStatus_t AdiReadRegBytes(uint16_t addr)
This function reads a single 16 bit SPI word from a slave device.
Definition: SpiFunctions.c:710
iSensorFX3Board_D
@ iSensorFX3Board_D
Definition: main.h:79
ADI_TRANSFER_STREAM
#define ADI_TRANSFER_STREAM
Definition: main.h:350
ADI_HARD_RESET
#define ADI_HARD_RESET
Definition: main.h:269
FX3_GPIO4_INTERRUPT_FLAG
#define FX3_GPIO4_INTERRUPT_FLAG
Definition: PinFunctions.h:131
iSensorFX3Board_B
@ iSensorFX3Board_B
Definition: main.h:73
ADI_I2C_SET_BIT_RATE
#define ADI_I2C_SET_BIT_RATE
Definition: main.h:251
ADI_STREAM_DONE_CMD
#define ADI_STREAM_DONE_CMD
Definition: StreamFunctions.h:58
AdiAppThreadEntry
void AdiAppThreadEntry(uint32_t input)
This is the entry point for the primary iSensors firmware application thread.
Definition: AppThread.c:272
ADI_GENERIC_STREAM_STOP
#define ADI_GENERIC_STREAM_STOP
Definition: AppThread.h:57
FirmwareID
const uint8_t FirmwareID((aligned(32)))
PinState
PinState
Definition: PinFunctions.h:41
AdiGPIOEventHandler
void AdiGPIOEventHandler(uint8_t gpioId)
This function handles GPIO interrupts and sets the appropriate flag in GpioHandler.
Definition: main.c:755
ADI_I2C_STREAM_START
#define ADI_I2C_STREAM_START
Definition: AppThread.h:90
iSensorFX3Board_H
@ iSensorFX3Board_H
Definition: main.h:91
ADI_SET_DUT_SUPPLY
#define ADI_SET_DUT_SUPPLY
Definition: main.h:287
BoardState
struct BoardState BoardState
Struct to store the current board state (SPI config, USB speed, etc)
BoardState::DrPolarity
CyBool_t DrPolarity
Definition: main.h:174
BoardState::DrActive
CyBool_t DrActive
Definition: main.h:171
ADI_DIO3_INTERRUPT_FLAG
#define ADI_DIO3_INTERRUPT_FLAG
Definition: PinFunctions.h:116
SpiDmaBuffer
CyU3PDmaBuffer_t SpiDmaBuffer
Definition: main.c:95
AdiFlashReadHandler
void AdiFlashReadHandler(uint32_t Address, uint16_t NumBytes)
Handles flash read requests from control endpoint.
Definition: Flash.c:198
AdiPinRead
CyU3PReturnStatus_t AdiPinRead(uint16_t pin)
This function handles Pin read control end point requests.
Definition: PinFunctions.c:1147
ADI_READ_BYTES
#define ADI_READ_BYTES
Definition: main.h:335
Main_c
@ Main_c
Definition: ErrorLog.h:42
FX3PinMap::ADI_PIN_DIO1
uint16_t ADI_PIN_DIO1
Definition: main.h:122
ADI_PIN_DELAY_MEASURE
#define ADI_PIN_DELAY_MEASURE
Definition: main.h:323
STREAMTHREAD_STACK
#define STREAMTHREAD_STACK
Definition: StreamThread.h:29
AdiUSBEventHandler
void AdiUSBEventHandler(CyU3PUsbEventType_t evtype, uint16_t evdata)
This is a callback function to handle generic USB events.
Definition: main.c:698
FX3_GPIO2_INTERRUPT_FLAG
#define FX3_GPIO2_INTERRUPT_FLAG
Definition: PinFunctions.h:125
ADI_RT_STREAM_STOP
#define ADI_RT_STREAM_STOP
Definition: AppThread.h:45
StreamState::RegList
uint8_t * RegList
Definition: main.h:236
LegacyIMU
@ LegacyIMU
Definition: main.h:111
GpioHandler
CyU3PEvent GpioHandler
Definition: main.c:63
AdiBitBangSpiHandler
CyU3PReturnStatus_t AdiBitBangSpiHandler()
This function handles bit bang SPI requests from the control endpoint.
Definition: SpiFunctions.c:221
FX3PinMap::ADI_PIN_DIO3
uint16_t ADI_PIN_DIO3
Definition: main.h:128
BoardState::I2CBitRate
uint32_t I2CBitRate
Definition: main.h:195
iSensorFX3Board_C
@ iSensorFX3Board_C
Definition: main.h:76
ADI_STREAM_GENERIC_DATA
#define ADI_STREAM_GENERIC_DATA
Definition: main.h:299
ADI_READ_FLASH
#define ADI_READ_FLASH
Definition: main.h:344
FX3_GPIO3_INTERRUPT_FLAG
#define FX3_GPIO3_INTERRUPT_FLAG
Definition: PinFunctions.h:128
ADI_BURST_STREAM_DONE
#define ADI_BURST_STREAM_DONE
Definition: AppThread.h:72
BoardState::WatchDogEnabled
CyBool_t WatchDogEnabled
Definition: main.h:177
BoardState::TimerPinConfig
uint32_t TimerPinConfig
Definition: main.h:162
StreamThread
CyU3PThread StreamThread
Definition: main.c:54
FX3PinMap::FX3_PIN_GPIO1
uint16_t FX3_PIN_GPIO1
Definition: main.h:134
AdiGetFX3BoardType
FX3BoardType AdiGetFX3BoardType()
This function determines the type of the connected FX3 board.
Definition: main.c:1322
StreamState::TransferWordLength
uint16_t TransferWordLength
Definition: main.h:218
GCTL_WPU_CFG_UPPR
#define GCTL_WPU_CFG_UPPR
Definition: main.h:413
FX3PinMap::FX3_PIN_GPIO3
uint16_t FX3_PIN_GPIO3
Definition: main.h:140
ADI_I2C_RETRY_COUNT
#define ADI_I2C_RETRY_COUNT
Definition: main.h:263
FX3_GPIO1_INTERRUPT_FLAG
#define FX3_GPIO1_INTERRUPT_FLAG
Definition: PinFunctions.h:122
ADI_TRANSFER_STREAM_DONE
#define ADI_TRANSFER_STREAM_DONE
Definition: AppThread.h:84
ADI_TRANSFER_STREAM_START
#define ADI_TRANSFER_STREAM_START
Definition: AppThread.h:78
AdiGetBuildDate
void AdiGetBuildDate(uint8_t *outBuf)
Gets the firmware build date, followed by the build time.
Definition: HelperFunctions.c:158
ADI_GET_STATUS
#define ADI_GET_STATUS
Definition: main.h:278
AdiPulseDrive
CyU3PReturnStatus_t AdiPulseDrive()
This function drives a GPIO pin for a specified number of milliseconds, then returns it to the starti...
Definition: PinFunctions.c:781
ADI_ID_PIN_1
#define ADI_ID_PIN_1
Definition: PinFunctions.h:85
StreamFunctions.h
Header file for all data streaming functions (generic, burst, ADcm real time, transfer).
AdiBulkEndpointHandler
void AdiBulkEndpointHandler(CyU3PUsbEpEvtType evType, CyU3PUSBSpeed_t usbSpeed, uint8_t epNum)
This function handles events generated by the bulk endpoint.
Definition: main.c:681
serial_number
char serial_number((aligned(32)))
AdiPulseWait
CyU3PReturnStatus_t AdiPulseWait(uint16_t transferLength)
This function waits for a pin to reach a selected logic level. The PulseWait parameters are passed in...
Definition: PinFunctions.c:899
ADI_TO_PC_ENDPOINT
#define ADI_TO_PC_ENDPOINT
Definition: main.h:394
BoardState::DutType
PartType DutType
Definition: main.h:153
ManualDMABuffer
CyU3PDmaBuffer_t ManualDMABuffer
Definition: main.c:92
ADI_SERIAL_NUMBER_CHECK
#define ADI_SERIAL_NUMBER_CHECK
Definition: main.h:281
AdiAppStart
void AdiAppStart()
This function sets up the necessary resources to start the ADI application.
Definition: main.c:891
AdiAppStop
void AdiAppStop()
This function is called to shut down the application.
Definition: main.c:827
ADI_SET_PIN_RESISTOR
#define ADI_SET_PIN_RESISTOR
Definition: main.h:332
BoardState::AppActive
CyBool_t AppActive
Definition: main.h:159
ADI_DIO2_INTERRUPT_FLAG
#define ADI_DIO2_INTERRUPT_FLAG
Definition: PinFunctions.h:113
HelperFunctions.h
Header file for a set of general purpose iSensor FX3 helper functions.
Low
@ Low
Definition: PinFunctions.h:43
FX3PinMap::FX3_PIN_GPIO4
uint16_t FX3_PIN_GPIO4
Definition: main.h:143
ADI_I2C_STREAM_DONE
#define ADI_I2C_STREAM_DONE
Definition: AppThread.h:96
ADI_MEASURE_DR
#define ADI_MEASURE_DR
Definition: main.h:320
ADI_BITBANG_SPI
#define ADI_BITBANG_SPI
Definition: main.h:359
BoardState::BoardType
FX3BoardType BoardType
Definition: main.h:189
AdiSpiUpdate
CyBool_t AdiSpiUpdate(uint16_t index, uint16_t value, uint16_t length)
This function handles a vendor command request to update the SPI/DR Pin configuration.
Definition: SpiFunctions.c:931
High
@ High
Definition: PinFunctions.h:46
I2cFunctions.h
Header file for USB-I2C interfacing module.
DutVoltage
DutVoltage
Definition: HelperFunctions.h:26
StreamState
Struct to store the current data stream state information.
Definition: main.h:204
ADI_I2C_READ_STREAM
#define ADI_I2C_READ_STREAM
Definition: main.h:260
AdiControlEndpointHandler
CyBool_t AdiControlEndpointHandler(uint32_t setupdat0, uint32_t setupdat1)
This function handles events generated by the control endpoint. All vendor requests are handled in th...
Definition: main.c:215
AdiSetPinResistor
CyU3PReturnStatus_t AdiSetPinResistor(uint16_t pin, PinResistorSetting setting)
Configure GPIO input stage pull up / pull down resistor.
Definition: PinFunctions.c:151
AdiGetSpiSettings
CyU3PReturnStatus_t AdiGetSpiSettings()
This function handles vendor commands to get the current SPI configuration from the FX3.
Definition: SpiFunctions.c:886
AdiI2CWriteHandler
CyU3PReturnStatus_t AdiI2CWriteHandler(uint16_t RequestLength)
Handler for I2C write command from control endpoint.
Definition: I2cFunctions.c:91
AdiLPMRequestHandler
CyBool_t AdiLPMRequestHandler(CyU3PUsbLinkPowerMode link_mode)
This is a callback function to handle Link Power Management (LPM) requests.
Definition: main.c:736
Flash.h
Header file for FX3 flash interfacing module.
AdiReadTimerValue
CyU3PReturnStatus_t AdiReadTimerValue()
Reads the current value from the complex GPIO timer and then sends the value over the control endpoin...
Definition: PinFunctions.c:1223
StreamState::NumCaptures
uint32_t NumCaptures
Definition: main.h:227
StreamState::NumBuffers
uint32_t NumBuffers
Definition: main.h:230
ADI_NULL_COMMAND
#define ADI_NULL_COMMAND
Definition: main.h:329
ADI_FLASH_WRITE_ENABLE_PIN
#define ADI_FLASH_WRITE_ENABLE_PIN
Definition: PinFunctions.h:88
ADI_TIMER_PIN
#define ADI_TIMER_PIN
Definition: PinFunctions.h:103
ChannelFromPC
CyU3PDmaChannel ChannelFromPC
Definition: main.c:73
CyFxApplicationDefine
void CyFxApplicationDefine(void)
This function is called by the RTOS kernel after booting and creates all the user threads.
Definition: main.c:1397
BulkBuffer
uint8_t BulkBuffer((aligned(32)))
ADI_5V_EN
#define ADI_5V_EN
Definition: PinFunctions.h:79
FX3PinMap
Pin map for translating FX3 GPIO pins to iSensor eval board functional pins.
Definition: main.h:117
gctlaon_regs.h
Global Control Always-On registers for the EZ-USB FX3 Device.
FX3PinMap::ADI_PIN_DIO2
uint16_t ADI_PIN_DIO2
Definition: main.h:125
ADI_STREAMING_ENDPOINT
#define ADI_STREAMING_ENDPOINT
Definition: main.h:388
ADI_DIO4_INTERRUPT_FLAG
#define ADI_DIO4_INTERRUPT_FLAG
Definition: PinFunctions.h:119
ADI_STREAM_REALTIME
#define ADI_STREAM_REALTIME
Definition: main.h:326
AdiGetPinState
PinState AdiGetPinState(uint16_t pin)
Determine state of an input pin (high, low, high Z)
Definition: PinFunctions.c:77
ADI_PWM_CMD
#define ADI_PWM_CMD
Definition: main.h:353
AdiMeasurePinFreq
CyU3PReturnStatus_t AdiMeasurePinFreq()
Measure the data ready frequency for a user specified pin.
Definition: PinFunctions.c:1255
AdiGetBoardPinInfo
void AdiGetBoardPinInfo(uint8_t *outBuf)
Gets the programmed board type and pin mapping info.
Definition: PinFunctions.c:37
ErrorLog.h
Header file for the FX3 flash error logging module.
ADI_TRANSFER_BYTES
#define ADI_TRANSFER_BYTES
Definition: main.h:347
AdiStreamThreadEntry
void AdiStreamThreadEntry(uint32_t input)
The entry point function for the StreamThread. Handles all streaming data captures.
Definition: StreamThread.c:47
StreamState::BytesPerFrame
uint32_t BytesPerFrame
Definition: main.h:206
BoardState::StallTime
uint32_t StallTime
Definition: main.h:165
StreamState::BytesPerBuffer
uint16_t BytesPerBuffer
Definition: main.h:233
ADI_BURST_STREAM_STOP
#define ADI_BURST_STREAM_STOP
Definition: AppThread.h:69
iSensorFX3Board_G
@ iSensorFX3Board_G
Definition: main.h:88
BoardState
Struct to store the current board state (SPI config, USB speed, etc)
Definition: main.h:148
AdiAppErrorHandler
void AdiAppErrorHandler(CyU3PReturnStatus_t status)
This function handles critical errors generated by the ADI application.
Definition: main.c:801
BoardState::BootTime
uint32_t BootTime
Definition: main.h:186
ADcmXL2021
@ ADcmXL2021
Definition: main.h:102
ADI_WARM_RESET
#define ADI_WARM_RESET
Definition: main.h:284
ADI_3_3V_EN
#define ADI_3_3V_EN
Definition: PinFunctions.h:76
USBBuffer
uint8_t USBBuffer((aligned(32)))
AdiAppStart
void AdiAppStart()
This function sets up the necessary resources to start the ADI application.
Definition: main.c:891
AdiAppStop
void AdiAppStop()
This function is called to shut down the application.
Definition: main.c:827
AdiMeasureBusyPulse
CyU3PReturnStatus_t AdiMeasureBusyPulse(uint16_t transferLength)
Sets a user configurable trigger condition and then measures the following GPIO pulse.
Definition: PinFunctions.c:434
ADI_STREAM_STOP_CMD
#define ADI_STREAM_STOP_CMD
Definition: StreamFunctions.h:64
ADI_WRITE_BYTE
#define ADI_WRITE_BYTE
Definition: main.h:338
ADI_I2C_READ_BYTES
#define ADI_I2C_READ_BYTES
Definition: main.h:254
ADI_GET_BOARD_TYPE
#define ADI_GET_BOARD_TYPE
Definition: main.h:296
ADI_FROM_PC_ENDPOINT
#define ADI_FROM_PC_ENDPOINT
Definition: main.h:391
AdiSetDutSupply
CyU3PReturnStatus_t AdiSetDutSupply(DutVoltage SupplyMode)
This function configures the DUT supply voltage.
Definition: HelperFunctions.c:94
PartTye
PartTye
Definition: main.h:97
BoardState::WatchDogTicks
uint32_t WatchDogTicks
Definition: main.h:183
UNUSED
#define UNUSED(x)
Definition: main.h:447
BoardState::PinMap
FX3PinMap PinMap
Definition: main.h:192
ADcmXL1021
@ ADcmXL1021
Definition: main.h:99
ADI_USER_LED_PIN
#define ADI_USER_LED_PIN
Definition: PinFunctions.h:100
ADI_RT_STREAM_START
#define ADI_RT_STREAM_START
Definition: AppThread.h:42
FX3PinMap::ADI_PIN_RESET
uint16_t ADI_PIN_RESET
Definition: main.h:119
ADI_I2C_WRITE_BYTES
#define ADI_I2C_WRITE_BYTES
Definition: main.h:257
StreamState::I2CStreamPreamble
CyU3PI2cPreamble_t I2CStreamPreamble
Definition: main.h:242
FX3BoardType
FX3BoardType
Definition: main.h:65
ADI_PULSE_WAIT
#define ADI_PULSE_WAIT
Definition: main.h:314
AdiGPIOEventHandler
void AdiGPIOEventHandler(uint8_t gpioId)
This function handles GPIO interrupts and sets the appropriate flag in GpioHandler.
Definition: main.c:755
ADI_GENERIC_STREAM_DONE
#define ADI_GENERIC_STREAM_DONE
Definition: AppThread.h:60
iSensorFX3Board_E
@ iSensorFX3Board_E
Definition: main.h:82
PartType
enum PartTye PartType
BoardState::SpiConfig
CyU3PSpiConfig_t SpiConfig
Definition: main.h:150
ADI_BUSY_MEASURE
#define ADI_BUSY_MEASURE
Definition: main.h:356
ADI_READ_SPI_CONFIG
#define ADI_READ_SPI_CONFIG
Definition: main.h:275
BoardState::WatchDogPeriodMs
uint32_t WatchDogPeriodMs
Definition: main.h:180
FX3PinMap::ADI_PIN_DIO4
uint16_t ADI_PIN_DIO4
Definition: main.h:131
ADI_READ_PIN
#define ADI_READ_PIN
Definition: main.h:305
ADcmXL3021
@ ADcmXL3021
Definition: main.h:105
main
int main(void)
This is the main entry point function for the iSensor FX3 application firmware.
Definition: main.c:133
BoardState::DrPin
uint16_t DrPin
Definition: main.h:168
AdiBulkEndpointHandler
void AdiBulkEndpointHandler(CyU3PUsbEpEvtType evType, CyU3PUSBSpeed_t usbSpeed, uint8_t epNum)
This function handles events generated by the bulk endpoint.
Definition: main.c:681
MemoryToSPI
CyU3PDmaChannel MemoryToSPI
Definition: main.c:79
BoardState::UsbBufferSize
uint16_t UsbBufferSize
Definition: main.h:156
STREAMTHREAD_PRIORITY
#define STREAMTHREAD_PRIORITY
Definition: StreamThread.h:32
APPTHREAD_STACK
#define APPTHREAD_STACK
Definition: AppThread.h:29
AppThread
CyU3PThread AppThread
Definition: main.c:57
AdiConfigurePWM
CyU3PReturnStatus_t AdiConfigurePWM(CyBool_t EnablePWM)
This function configures the FX3 PWM outputs (enable or disable).
Definition: PinFunctions.c:669
ADI_PULSE_DRIVE
#define ADI_PULSE_DRIVE
Definition: main.h:311
IMU
@ IMU
Definition: main.h:108
AdiUSBEventHandler
void AdiUSBEventHandler(CyU3PUsbEventType_t evtype, uint16_t evdata)
This is a callback function to handle generic USB events.
Definition: main.c:698
FX3State
BoardState FX3State
Definition: main.c:112
ADI_STREAM_BURST_DATA
#define ADI_STREAM_BURST_DATA
Definition: main.h:302
PinFunctions.h
Header file for all the pin I/O and timing related functions.
ChannelToPC
CyU3PDmaChannel ChannelToPC
Definition: main.c:76
main.h
Main header file for the Analog Devices iSensor FX3 Demonstration Platform firmware.
ADI_I2C_STREAM_STOP
#define ADI_I2C_STREAM_STOP
Definition: AppThread.h:93
ADI_RT_STREAM_DONE
#define ADI_RT_STREAM_DONE
Definition: AppThread.h:48
iSensorFX3Board_A
@ iSensorFX3Board_A
Definition: main.h:70
AdiAppErrorHandler
void AdiAppErrorHandler(CyU3PReturnStatus_t status)
This function handles critical errors generated by the ADI application.
Definition: main.c:801
StreamState::TransferByteLength
uint32_t TransferByteLength
Definition: main.h:221
StreamThreadState
StreamState StreamThreadState
Definition: main.c:122
ADI_RESET_SPI
#define ADI_RESET_SPI
Definition: main.h:362
ADI_FIRMWARE_ID_CHECK
#define ADI_FIRMWARE_ID_CHECK
Definition: main.h:266
WriteErrorLogCount
void WriteErrorLogCount(uint32_t count)
Sets the error log count value in flash.
Definition: ErrorLog.c:87
CypressFX3Board
@ CypressFX3Board
Definition: main.h:67
ADI_GET_BUILD_DATE
#define ADI_GET_BUILD_DATE
Definition: main.h:290
ADI_GENERIC_STREAM_START
#define ADI_GENERIC_STREAM_START
Definition: AppThread.h:54
StreamState::PinExitEnable
CyBool_t PinExitEnable
Definition: main.h:209
AdiTransferBytes
CyU3PReturnStatus_t AdiTransferBytes(uint32_t writeData)
This function performs a protocol agnostic SPI bi-directional SPI transfer of (1, 2,...
Definition: SpiFunctions.c:671
AdiLPMRequestHandler
CyBool_t AdiLPMRequestHandler(CyU3PUsbLinkPowerMode link_mode)
This is a callback function to handle Link Power Management (LPM) requests.
Definition: main.c:736
AdiSendStatus
void AdiSendStatus(uint32_t status, uint16_t count, CyBool_t isControlEndpoint)
Sends status back to PC over control endpoint or manual bulk in endpoint.
Definition: HelperFunctions.c:191
FX3PinMap
struct FX3PinMap FX3PinMap
Pin map for translating FX3 GPIO pins to iSensor eval board functional pins.
ADI_SET_PIN
#define ADI_SET_PIN
Definition: main.h:317
ADI_TIMER_PIN_INDEX
#define ADI_TIMER_PIN_INDEX
Definition: main.h:381
AdiGetFX3BoardType
FX3BoardType AdiGetFX3BoardType()
This function determines the type of the connected FX3 board.
Definition: main.c:1322
ADI_SET_SPI_CONFIG
#define ADI_SET_SPI_CONFIG
Definition: main.h:272
APPTHREAD_PRIORITY
#define APPTHREAD_PRIORITY
Definition: AppThread.h:32
AdiI2CReadHandler
CyU3PReturnStatus_t AdiI2CReadHandler(uint16_t RequestLength)
Handler for I2C read command from control endpoint.
Definition: I2cFunctions.c:38
ADI_BURST_STREAM_START
#define ADI_BURST_STREAM_START
Definition: AppThread.h:66
AdiMeasurePinDelay
CyU3PReturnStatus_t AdiMeasurePinDelay(uint16_t transferLength)
Measures the delay from a trigger pin edge (sync) to a busy pin edge.
Definition: PinFunctions.c:271
AdiWriteRegByte
CyU3PReturnStatus_t AdiWriteRegByte(uint16_t addr, uint8_t data)
This function writes a single byte of data over the SPI bus.
Definition: SpiFunctions.c:763
ADI_SET_BOOT_TIME
#define ADI_SET_BOOT_TIME
Definition: main.h:293
ADI_READ_TIMER_VALUE
#define ADI_READ_TIMER_VALUE
Definition: main.h:308
AdiFlashDeInit
void AdiFlashDeInit()
De-init the flash memory interfacing module.
Definition: Flash.c:128
ADI_DIO1_INTERRUPT_FLAG
#define ADI_DIO1_INTERRUPT_FLAG
Definition: PinFunctions.h:110
AdiSetPin
CyU3PReturnStatus_t AdiSetPin(uint16_t pinNumber, CyBool_t polarity)
This function configures the specified pin as an output and drives it with the desired value.
Definition: PinFunctions.c:1043
ADI_CLEAR_FLASH_LOG
#define ADI_CLEAR_FLASH_LOG
Definition: main.h:341
StreamThread.h
Header file for the streaming thread.
KillStreamEarly
volatile CyBool_t KillStreamEarly
Definition: main.c:119
HighZ
@ HighZ
Definition: PinFunctions.h:49
AppThread.h
Header file for all the primary application thread functions.
StreamState::PinStartEnable
CyBool_t PinStartEnable
Definition: main.h:212
BoardState::I2CRetryCount
uint16_t I2CRetryCount
Definition: main.h:198
EventHandler
CyU3PEvent EventHandler
Definition: main.c:60
FX3PinMap::FX3_PIN_GPIO2
uint16_t FX3_PIN_GPIO2
Definition: main.h:137
AdiI2CInit
CyU3PReturnStatus_t AdiI2CInit(uint32_t BitRate, CyBool_t isDMA)
Init I2C peripheral.
Definition: I2cFunctions.c:130
SpiFunctions.h
Header file for all SPI related functions.
StreamState::NumRealTimeCaptures
uint32_t NumRealTimeCaptures
Definition: main.h:215
AdiRestartSpi
CyU3PReturnStatus_t AdiRestartSpi()
This function restarts the SPI controller.
Definition: SpiFunctions.c:188
iSensorFX3Board_F
@ iSensorFX3Board_F
Definition: main.h:85
AdiLogError
void AdiLogError(FileIdentifier File, uint32_t Line, uint32_t ErrorCode)
Logs a firmware error to flash memory for later examination.
Definition: ErrorLog.c:51
AdiControlEndpointHandler
CyBool_t AdiControlEndpointHandler(uint32_t setupdat0, uint32_t setupdat1)
This function handles events generated by the control endpoint. All vendor requests are handled in th...
Definition: main.c:215
StreamState::BytesPerUsbPacket
uint16_t BytesPerUsbPacket
Definition: main.h:239
StreamState
struct StreamState StreamState
Struct to store the current data stream state information.
StreamingChannel
CyU3PDmaChannel StreamingChannel
Definition: main.c:70
StreamState::RoundedByteTransferLength
uint16_t RoundedByteTransferLength
Definition: main.h:224
ADI_ID_PIN_0
#define ADI_ID_PIN_0
Definition: PinFunctions.h:82