![]() |
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
|
This file contains all pin and timing function implementations. More...
#include "PinFunctions.h"
Functions | |
void | AdiGetBoardPinInfo (uint8_t *outBuf) |
Gets the programmed board type and pin mapping info. More... | |
PinState | AdiGetPinState (uint16_t pin) |
Determine state of an input pin (high, low, high Z) More... | |
CyU3PReturnStatus_t | AdiSetPinResistor (uint16_t pin, PinResistorSetting setting) |
Configure GPIO input stage pull up / pull down resistor. More... | |
CyBool_t | AdiIsValidGPIO (uint16_t GpioId) |
Determines if a GPIO pin is valid for the FX3 Application firmware to set. More... | |
CyU3PReturnStatus_t | AdiMeasurePinDelay (uint16_t transferLength) |
Measures the delay from a trigger pin edge (sync) to a busy pin edge. More... | |
CyU3PReturnStatus_t | AdiMeasureBusyPulse (uint16_t transferLength) |
Sets a user configurable trigger condition and then measures the following GPIO pulse. More... | |
CyU3PReturnStatus_t | AdiConfigurePWM (CyBool_t EnablePWM) |
This function configures the FX3 PWM outputs (enable or disable). More... | |
CyU3PReturnStatus_t | AdiPulseDrive () |
This function drives a GPIO pin for a specified number of milliseconds, then returns it to the starting polarity. More... | |
CyU3PReturnStatus_t | AdiPulseWait (uint16_t transferLength) |
This function waits for a pin to reach a selected logic level. The PulseWait parameters are passed in the USB buffer, and are retrieved with a call to GetEP0Data. More... | |
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. More... | |
CyU3PReturnStatus_t | AdiWaitForPin (uint32_t pinNumber, CyU3PGpioIntrMode_t interruptSetting, uint32_t timeoutTicks) |
This function blocks the execution of the current thread until an event happens on the specified GPIO pin. More... | |
uint32_t | AdiMStoTicks (uint32_t timeInMS) |
Converts milliseconds to number of ticks and adjusts the resulting offset if below the measurable minimum. More... | |
CyU3PReturnStatus_t | AdiPinRead (uint16_t pin) |
This function handles Pin read control end point requests. More... | |
uint32_t | AdiReadTimerRegValue () |
Reads the current value of the 10MHz timer (32 bit) More... | |
CyU3PReturnStatus_t | AdiReadTimerValue () |
Reads the current value from the complex GPIO timer and then sends the value over the control endpoint. More... | |
CyU3PReturnStatus_t | AdiMeasurePinFreq () |
Measure the data ready frequency for a user specified pin. More... | |
CyU3PReturnStatus_t | AdiConfigurePinInterrupt (uint16_t pin, CyBool_t polarity) |
configures the selected pin as an interrupt with edge triggering based on polarity More... | |
Variables | |
BoardState | FX3State |
CyU3PEvent | GpioHandler |
uint8_t | USBBuffer [4096] |
uint8_t | BulkBuffer [12288] |
This file contains all pin and timing function implementations.
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.
CyU3PReturnStatus_t AdiConfigurePinInterrupt | ( | uint16_t | pin, |
CyBool_t | polarity | ||
) |
configures the selected pin as an interrupt with edge triggering based on polarity
polarity | The edge to trigger on (true -> rising edge, false -> falling edge) |
pin | The GPIO pin number to configure |
CyU3PReturnStatus_t AdiConfigurePWM | ( | CyBool_t | EnablePWM | ) |
This function configures the FX3 PWM outputs (enable or disable).
EnablePWM | If the PWM should be enabled or disabled. |
The pin number, threshold value, and period are provided in the USBBuffer, and are calculated in the FX3Api. This mitigates any potential math/rounding errors. The PWM pins are driven by a 100MHz clock. The output is artificially capped at 10MHz.
void AdiGetBoardPinInfo | ( | uint8_t * | outBuf | ) |
Gets the programmed board type and pin mapping info.
outBuf | Byte array which pin map and board type are placed into |
outBuf contains BoardType(4), ResetPin(2), DIO(2 each), GPIO(2 each). Total size of 4 + 2 + 8 + 8 = 22 bytes
PinState AdiGetPinState | ( | uint16_t | pin | ) |
Determine state of an input pin (high, low, high Z)
pin | The GPIO matrix index for the pin to measure (0 - 31) |
This function first configures the selected pin to act as an input. It then enables a weak pull down resistor and records the value on the input stage of the pin. It enables a weak pull up resistor and records the value on the input stage of the pin. If both values match, then the pin is at that level (high/low). If the value changes to follow the pull up, then the pin is High-Z (tristated). The pin resistor is then disabled.
CyBool_t AdiIsValidGPIO | ( | uint16_t | GpioId | ) |
Determines if a GPIO pin is valid for the FX3 Application firmware to set.
GpioId | The GPIO matrix index for the pin to check |
This function is called before all interfacing functions. This prevents invalid GPIO access, or unintended modifications to the power supply management pins.
CyU3PReturnStatus_t AdiMeasureBusyPulse | ( | uint16_t | transferLength | ) |
Sets a user configurable trigger condition and then measures the following GPIO pulse.
transferLength | The amount of data (in bytes) to read from the USB buffer |
This function is accurate to approximately 1/10th a microsecond. It can be used for timing measurements which require a high degree of accuracy since it avoids the overhead of having a USB transaction (~100us) between the initial trigger condition and the pulse measurement. Note, this function utilizes the complex GPIO block on the FX3 to perform the busy pulse measurement. This gives very reliable accuracy of measurement, since the measurement is performed entirely by hardware. However, this does limit which pins can perform a busy pulse measurement, if there are PWM signals being driven which also use the complex GPIO block.
CyU3PReturnStatus_t AdiMeasurePinDelay | ( | uint16_t | transferLength | ) |
Measures the delay from a trigger pin edge (sync) to a busy pin edge.
transferLength | The amount of data (in bytes) to read from the USB buffer |
This function is approx. microsecond accurate. It can be used for timing measurements which require a high degree of accuracy since it avoids the overhead of having a USB transaction (200us) between the initial pin drive condition and the pulse measurement. This function is primarily intended to be used for measuring the latency between a sync edge and data ready toggle on the ADIS IMU series of products.
CyU3PReturnStatus_t AdiMeasurePinFreq | ( | ) |
Measure the data ready frequency for a user specified pin.
This function measures two data ready pulses on a user-specified pin and reports back the delta-time in ticks. The function also transmits the tick scale factor and a timeout counter to notify the interface of timeouts that may have occurred due to missing pulses. Data is transmitted over USB via the bulk endpoint. Inputs are provided through the control endpoint. This function can be expanded to capture as many samples as required. pin: The GPIO pin number to measure polarity: The polarity of the pin (1 - Low-to-High, 0 - High-to-Low) timeoutInMs: The specified timeout in milliseconds
uint32_t AdiMStoTicks | ( | uint32_t | timeInMS | ) |
Converts milliseconds to number of ticks and adjusts the resulting offset if below the measurable minimum.
timeInMS | The real stall time (in ms) desired. |
CyU3PReturnStatus_t AdiPinRead | ( | uint16_t | pin | ) |
This function handles Pin read control end point requests.
pin | The GPIO matrix number of the pin to read |
This function reads the value of a specified GPIO pin, and sends that value over the control endpoint to the host PC. The pin read status is also attached.
CyU3PReturnStatus_t AdiPulseDrive | ( | ) |
This function drives a GPIO pin for a specified number of milliseconds, then returns it to the starting polarity.
If the selected GPIO pin is not configured as an output, this function configures the pin. If you want the pin to stay at a given logic level, use AdiSetPin() instead. The arguments to this function are passed in through USBBuffer. pin: The GPIO pin number to drive polarity: The polarity of the pin (True - High, False - Low) driveTime: The number of milliseconds to drive the pin for
CyU3PReturnStatus_t AdiPulseWait | ( | uint16_t | transferLength | ) |
This function waits for a pin to reach a selected logic level. The PulseWait parameters are passed in the USB buffer, and are retrieved with a call to GetEP0Data.
transferLength | How many bytes to read from the USBBuffer. |
The time waited and status information are sent to the PC over the bulk out endpoint at the end of this function. If you want to collect very accurate timing measurements using the FX3, consider using the AdiMeasureBusyPulse function instead. pin is the GPIO pin number to poll polarity is the pin polarity which will trigger an exit condition delay is the wait time (in ms) from when the function starts before pin polling starts timeout is the time (in ms) to wait for the pin level before exiting
uint32_t AdiReadTimerRegValue | ( | ) |
Reads the current value of the 10MHz timer (32 bit)
CyU3PReturnStatus_t AdiReadTimerValue | ( | ) |
Reads the current value from the complex GPIO timer and then sends the value over the control endpoint.
This function handles timer read control endpoint requests specifically. May be changed to return the actual timer value eventually.
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.
pinNumber | The GPIO index of the pin to be set |
polarity | The polarity of the pin to be set (True - High, False - Low) |
Take care when using this function. If a valid GPIO which has not been configured as an output is selected, that pin will be forced to act as an output. This will cause pins which have functionality beyond just a simple GPIO can lose that functionality (e.g. UART Debug, SPI, etc).
CyU3PReturnStatus_t AdiSetPinResistor | ( | uint16_t | pin, |
PinResistorSetting | setting | ||
) |
Configure GPIO input stage pull up / pull down resistor.
pin | The GPIO matrix index for the pin to configure (0 - 63) |
setting | The PinResistorSetting to apply to the selected pin |
This function configures the "weak" pull up or pull down setting which the FX3 micro provides for each GPIO.
CyU3PReturnStatus_t AdiWaitForPin | ( | uint32_t | pinNumber, |
CyU3PGpioIntrMode_t | interruptSetting, | ||
uint32_t | timeoutTicks | ||
) |
This function blocks the execution of the current thread until an event happens on the specified GPIO pin.
pinNumber | The GPIO pin number to poll |
interruptSetting | The simple GPIO interrupt mode that the selected pin is configured with. |
timeoutTicks | The number of GPIO timer ticks (10MHz) to wait for before timing out and returning. |
|
extern |
Struct. which stores all run time configurable FX3 settings
|
extern |
ADI GPIO event structure (RTOS handles GPIO ISR)