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
Functions | Variables
PinFunctions.c File Reference

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]
 

Detailed Description

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.

Date
8/1/2019
Author
A. Nolan (alex..nosp@m.nola.nosp@m.n@ana.nosp@m.log..nosp@m.com)
J. Chong (juan..nosp@m.chon.nosp@m.g@ana.nosp@m.log..nosp@m.com)

Function Documentation

◆ AdiConfigurePinInterrupt()

CyU3PReturnStatus_t AdiConfigurePinInterrupt ( uint16_t  pin,
CyBool_t  polarity 
)

configures the selected pin as an interrupt with edge triggering based on polarity

Parameters
polarityThe edge to trigger on (true -> rising edge, false -> falling edge)
pinThe GPIO pin number to configure
Returns
The success of the pin configuration operation.

◆ AdiConfigurePWM()

CyU3PReturnStatus_t AdiConfigurePWM ( CyBool_t  EnablePWM)

This function configures the FX3 PWM outputs (enable or disable).

Parameters
EnablePWMIf the PWM should be enabled or disabled.
Returns
A status code indicating the success of the function.

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.

◆ AdiGetBoardPinInfo()

void AdiGetBoardPinInfo ( uint8_t *  outBuf)

Gets the programmed board type and pin mapping info.

Parameters
outBufByte array which pin map and board type are placed into
Returns
void

outBuf contains BoardType(4), ResetPin(2), DIO(2 each), GPIO(2 each). Total size of 4 + 2 + 8 + 8 = 22 bytes

◆ AdiGetPinState()

PinState AdiGetPinState ( uint16_t  pin)

Determine state of an input pin (high, low, high Z)

Parameters
pinThe GPIO matrix index for the pin to measure (0 - 31)
Returns
The current pin state, as a PinState

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.

◆ AdiIsValidGPIO()

CyBool_t AdiIsValidGPIO ( uint16_t  GpioId)

Determines if a GPIO pin is valid for the FX3 Application firmware to set.

Parameters
GpioIdThe GPIO matrix index for the pin to check
Returns
A boolean indicating if the GPIO is valid or not.

This function is called before all interfacing functions. This prevents invalid GPIO access, or unintended modifications to the power supply management pins.

◆ AdiMeasureBusyPulse()

CyU3PReturnStatus_t AdiMeasureBusyPulse ( uint16_t  transferLength)

Sets a user configurable trigger condition and then measures the following GPIO pulse.

Parameters
transferLengthThe amount of data (in bytes) to read from the USB buffer
Returns
A status code indicating the success of the measure pulse operation

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.

◆ AdiMeasurePinDelay()

CyU3PReturnStatus_t AdiMeasurePinDelay ( uint16_t  transferLength)

Measures the delay from a trigger pin edge (sync) to a busy pin edge.

Parameters
transferLengthThe amount of data (in bytes) to read from the USB buffer
Returns
A status code indicating the success of the pin delay measure operation

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.

◆ AdiMeasurePinFreq()

CyU3PReturnStatus_t AdiMeasurePinFreq ( )

Measure the data ready frequency for a user specified pin.

Returns
The status of the pin drive operation

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

◆ AdiMStoTicks()

uint32_t AdiMStoTicks ( uint32_t  timeInMS)

Converts milliseconds to number of ticks and adjusts the resulting offset if below the measurable minimum.

Parameters
timeInMSThe real stall time (in ms) desired.
Returns
The number of timer ticks representing that MS value.

◆ AdiPinRead()

CyU3PReturnStatus_t AdiPinRead ( uint16_t  pin)

This function handles Pin read control end point requests.

Parameters
pinThe GPIO matrix number of the pin to read
Returns
The success of the pin read operation

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.

◆ AdiPulseDrive()

CyU3PReturnStatus_t AdiPulseDrive ( )

This function drives a GPIO pin for a specified number of milliseconds, then returns it to the starting polarity.

Returns
A status code indicating the success of the function.

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

◆ 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 the USB buffer, and are retrieved with a call to GetEP0Data.

Parameters
transferLengthHow many bytes to read from the USBBuffer.
Returns
A status code indicating the success of the function.

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

◆ AdiReadTimerRegValue()

uint32_t AdiReadTimerRegValue ( )

Reads the current value of the 10MHz timer (32 bit)

Returns
The number of elapsed timer ticks

◆ AdiReadTimerValue()

CyU3PReturnStatus_t AdiReadTimerValue ( )

Reads the current value from the complex GPIO timer and then sends the value over the control endpoint.

Returns
The success of the timer read operation.

This function handles timer read control endpoint requests specifically. May be changed to return the actual timer value eventually.

◆ 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.

Parameters
pinNumberThe GPIO index of the pin to be set
polarityThe polarity of the pin to be set (True - High, False - Low)
Returns
A status code indicating the success of the pin set operation.

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).

◆ AdiSetPinResistor()

CyU3PReturnStatus_t AdiSetPinResistor ( uint16_t  pin,
PinResistorSetting  setting 
)

Configure GPIO input stage pull up / pull down resistor.

Parameters
pinThe GPIO matrix index for the pin to configure (0 - 63)
settingThe PinResistorSetting to apply to the selected pin
Returns
A status code indicating the success of the operation

This function configures the "weak" pull up or pull down setting which the FX3 micro provides for each GPIO.

◆ AdiWaitForPin()

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.

Parameters
pinNumberThe GPIO pin number to poll
interruptSettingThe simple GPIO interrupt mode that the selected pin is configured with.
timeoutTicksThe number of GPIO timer ticks (10MHz) to wait for before timing out and returning.
Returns
A status code indicating the success of the pin wait function.

Variable Documentation

◆ FX3State

BoardState FX3State
extern

Struct. which stores all run time configurable FX3 settings

◆ GpioHandler

CyU3PEvent GpioHandler
extern

ADI GPIO event structure (RTOS handles GPIO ISR)