![]() |
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
|
Entry point and setup functions for the Analog Devices iSensor FX3 Demonstration Platform firmware. More...
#include "main.h"
Functions | |
uint8_t | USBBuffer ((aligned(32))) |
uint8_t | BulkBuffer ((aligned(32))) |
const uint8_t | FirmwareID ((aligned(32))) |
char | serial_number ((aligned(32))) |
int | main (void) |
This is the main entry point function for the iSensor FX3 application firmware. More... | |
CyBool_t | AdiControlEndpointHandler (uint32_t setupdat0, uint32_t setupdat1) |
This function handles events generated by the control endpoint. All vendor requests are handled in this function. More... | |
void | AdiBulkEndpointHandler (CyU3PUsbEpEvtType evType, CyU3PUSBSpeed_t usbSpeed, uint8_t epNum) |
This function handles events generated by the bulk endpoint. More... | |
void | AdiUSBEventHandler (CyU3PUsbEventType_t evtype, uint16_t evdata) |
This is a callback function to handle generic USB events. More... | |
CyBool_t | AdiLPMRequestHandler (CyU3PUsbLinkPowerMode link_mode) |
This is a callback function to handle Link Power Management (LPM) requests. More... | |
void | AdiGPIOEventHandler (uint8_t gpioId) |
This function handles GPIO interrupts and sets the appropriate flag in GpioHandler. More... | |
void | AdiAppErrorHandler (CyU3PReturnStatus_t status) |
This function handles critical errors generated by the ADI application. More... | |
void | AdiAppStop () |
This function is called to shut down the application. More... | |
void | AdiAppStart () |
This function sets up the necessary resources to start the ADI application. More... | |
FX3BoardType | AdiGetFX3BoardType () |
This function determines the type of the connected FX3 board. More... | |
void | CyFxApplicationDefine (void) |
This function is called by the RTOS kernel after booting and creates all the user threads. More... | |
Variables | |
CyU3PThread | StreamThread = {0} |
CyU3PThread | AppThread = {0} |
CyU3PEvent | EventHandler = {0} |
CyU3PEvent | GpioHandler = {0} |
CyU3PDmaChannel | StreamingChannel = {0} |
CyU3PDmaChannel | ChannelFromPC = {0} |
CyU3PDmaChannel | ChannelToPC = {0} |
CyU3PDmaChannel | MemoryToSPI = {0} |
CyU3PDmaBuffer_t | ManualDMABuffer = {0} |
CyU3PDmaBuffer_t | SpiDmaBuffer = {0} |
BoardState | FX3State = {.SpiConfig = {0}, .PinMap = {0}} |
volatile CyBool_t | KillStreamEarly = CyFalse |
StreamState | StreamThreadState = {0} |
Entry point and setup functions for the Analog Devices iSensor FX3 Demonstration Platform firmware.
Copyright (c) 2018-2020 Analog Devices, Inc. All Rights Reserved. This software is proprietary to Analog Devices, Inc. and its licensors.
THIS SOFTWARE UTILIZES LIBRARIES DEVELOPED AND MAINTAINED BY CYPRESS INC. THE LICENSE INCLUDED IN THIS REPOSITORY DOES NOT EXTEND TO CYPRESS PROPERTY.
Use of this file is governed by the license agreement included in this repository.
void AdiAppErrorHandler | ( | CyU3PReturnStatus_t | status | ) |
This function handles critical errors generated by the ADI application.
status | The error code which corresponds with the fatal error encountered during startup. |
This function prints the error message to the debug console, waits five seconds, and performs a hard reset. Performing the hard reset will clear the SRAM and reboot the FX3 into the second stage iSensors FX3 bootloader. Could probably do something more intelligent, but at least this approach will not lock up the FX3 after a failed boot.
void AdiAppStart | ( | ) |
This function sets up the necessary resources to start the ADI application.
The application startup process configures all GPIO and timers used by the firmware, as well as the USB endpoints, DMA controller, and SPI hardware. After all configuration is performed, the AppActive flag is set to true.
GPIO Clock configuration: SYS_CLK = 403.2MHz GPIO Fast Clock = SYS_CLK / 2 -> 201.6MHz GPIO Slow Clock (Used for 10MHz timer) = Fast Clock / 20 -> 10.08MHz Simple GPIO Sample Clock = Fast Clock / 2 -> 100.8MHz
void AdiAppStop | ( | ) |
This function is called to shut down the application.
This function cleans up the resources used by the ADI application and prepares them for the next run. Since this function is intended to be called as part of the shut down process, no error handling is performed. Any transient errors should be resolved the next time the system boots (after this function call is finished).
void AdiBulkEndpointHandler | ( | CyU3PUsbEpEvtType | evType, |
CyU3PUSBSpeed_t | usbSpeed, | ||
uint8_t | epNum | ||
) |
This function handles events generated by the bulk endpoint.
evType | The type of the event being handled |
usbSpeed | The current connection speed |
epNum | The end point number |
This function is currently unused. All event management to the host PC is performed through the control endpoint.
CyBool_t AdiControlEndpointHandler | ( | uint32_t | setupdat0, |
uint32_t | setupdat1 | ||
) |
This function handles events generated by the control endpoint. All vendor requests are handled in this function.
setupdat0 | The first set of setup data. Contains of the request and value fields. |
setupdat1 | The second set of setup data. Contains the index and length fields. |
This function handles all USB events generated by the control endpoint. For the iSensor FX3 firmware, these events are a set of custom vendor commands. These vendor commands must be issued by the host PC. To ensure consistent behavior, all vendor commands should be issued using a function call in the FX3API. The FX3 API manages the control endpoint parameters to ensure valid behavior in all cases.
Fast enumeration is used. Only requests addressed to the interface, class, vendor and unknown control requests are received by this function.
FX3BoardType AdiGetFX3BoardType | ( | ) |
This function determines the type of the connected FX3 board.
This function works by measuring two ID pins which are assigned on the iSensor FX3 demonstration platform. These ID pins can be high, low, or tri-stated, allowing for 9 possible hardware ID configurations. The weak pull up / weak pull down functionality of the FX3 GPIO allows reliable differentiation between all three states.
void AdiGPIOEventHandler | ( | uint8_t | gpioId | ) |
This function handles GPIO interrupts and sets the appropriate flag in GpioHandler.
gpioId | The pin number of the pin which generated the interrupt |
This function is called by the RTOS whenever the GPIO interrupt vector is enabled and a GPIO interrupt is received. Instead of performing any work in this function, to improve system responsiveness, this function sets an RTOS event flag, to be handled by the application thread.
CyBool_t AdiLPMRequestHandler | ( | CyU3PUsbLinkPowerMode | link_mode | ) |
This is a callback function to handle Link Power Management (LPM) requests.
link_mode | The USB link power state that is being set |
void AdiUSBEventHandler | ( | CyU3PUsbEventType_t | evtype, |
uint16_t | evdata | ||
) |
This is a callback function to handle generic USB events.
evtype | The type of the event being handled |
evdata | The data from the USB event |
This function handles USB events by calling start/stop functions to manage the ADI application.
uint8_t BulkBuffer | ( | (aligned(32)) | ) |
12KB Generic bulk buffer. Used for when data is manually sent to or received from the PC via bulk endpoints.
void CyFxApplicationDefine | ( | void | ) |
This function is called by the RTOS kernel after booting and creates all the user threads.
After the ThreadX kernel is started by a call to CyU3PKernelEntry() in main, this function is called. It creates the AppThread (for general execution / handling vendor requests) and the StreamThread for handling high throughput data streaming from a DUT.
const uint8_t FirmwareID | ( | (aligned(32)) | ) |
Constant firmware ID string. Manually updated when releasing new version of the FX3 firmware. Must match FX3 API version number.
int main | ( | void | ) |
This is the main entry point function for the iSensor FX3 application firmware.
This firmware image is loaded into RAM over USB by the second-stange iSensor FX3 Bootloader when the Connect() function is called in the FX3 API. Once the full image has been loaded into SRAM, and the CRC verified, the iSensor FX3 bootloader jumps to this main function. Main initializes the device, memory, and IO matrix, and then boots the RTOS kernel.
char serial_number | ( | (aligned(32)) | ) |
FX3 unique serial number. Set at runtime during the initialization process.
uint8_t USBBuffer | ( | (aligned(32)) | ) |
4KB USB Data buffer. Used to receive data from the control endpoint
CyU3PThread AppThread = {0} |
RTOS thread handle for the main application
CyU3PDmaChannel ChannelFromPC = {0} |
DMA channel for BULK-OUT endpoint 0x1 (PC to FX3)
CyU3PDmaChannel ChannelToPC = {0} |
DMA channel for BULK-IN endpoint 0x82 (FX3 to PC)
CyU3PEvent EventHandler = {0} |
ADI event structure
BoardState FX3State = {.SpiConfig = {0}, .PinMap = {0}} |
Struct. which stores all run time configurable FX3 settings
CyU3PEvent GpioHandler = {0} |
ADI GPIO event structure (RTOS handles GPIO ISR)
volatile CyBool_t KillStreamEarly = CyFalse |
Signal data stream thread to kill data capture early (True = kill thread signaled, False = allow execution)
CyU3PDmaBuffer_t ManualDMABuffer = {0} |
DMA buffer structure for output buffer
CyU3PDmaChannel MemoryToSPI = {0} |
DMA channel for reading a memory location into a DMA consumer
CyU3PDmaBuffer_t SpiDmaBuffer = {0} |
DMA buffer structure for SPI transmit
CyU3PDmaChannel StreamingChannel = {0} |
DMA channel for real time streaming (SPI to USB BULK-IN 0x81)
CyU3PThread StreamThread = {0} |
RTOS thread handle for continuous data streaming functionality
StreamState StreamThreadState = {0} |
Struct of data used to synchronize the data streaming / app threads