Class DMAJNI


public class DMAJNI
extends JNIWrapper
DMA HAL JNI functions.
See Also:
"hal/DHA.h"
  • Nested Class Summary

    Nested classes/interfaces inherited from class edu.wpi.first.hal.JNIWrapper

    JNIWrapper.Helper
  • Constructor Summary

    Constructors 
    Constructor Description
    DMAJNI()  
  • Method Summary

    Modifier and Type Method Description
    static void addAnalogAccumulator​(int handle, int analogInputHandle)
    Adds accumulator data of an analog input to be collected by DMA.
    static void addAnalogInput​(int handle, int analogInputHandle)
    Adds an analog input to be collected by DMA.
    static void addAveragedAnalogInput​(int handle, int analogInputHandle)
    Adds averaged data of an analog input to be collected by DMA.
    static void addCounter​(int handle, int counterHandle)
    Adds position data for an counter to be collected by DMA.
    static void addCounterPeriod​(int handle, int counterHandle)
    Adds timer data for an counter to be collected by DMA.
    static void addDigitalSource​(int handle, int digitalSourceHandle)
    Adds a digital source to be collected by DMA.
    static void addDutyCycle​(int handle, int dutyCycleHandle)
    Adds a duty cycle input to be collected by DMA.
    static void addEncoder​(int handle, int encoderHandle)
    Adds position data for an encoder to be collected by DMA.
    static void addEncoderPeriod​(int handle, int encoderHandle)
    Adds timer data for an encoder to be collected by DMA.
    static void clearExternalTriggers​(int handle)
    Clear all external triggers from the DMA trigger list.
    static void clearSensors​(int handle)
    Clear all sensors from the DMA collection list.
    static void free​(int handle)
    Frees a DMA object.
    static edu.wpi.first.hal.DMAJNISample.BaseStore getSensorReadData​(int handle)
    Get the sensor DMA sample.
    static int initialize()
    Initializes an object for performing DMA transfers.
    static long readDMA​(int handle, double timeoutSeconds, int[] buffer, int[] sampleStore)
    Reads a DMA sample from the queue.
    static int setExternalTrigger​(int handle, int digitalSourceHandle, int analogTriggerType, boolean rising, boolean falling)
    Sets DMA transfers to occur on an external trigger.
    static void setPause​(int handle, boolean pause)
    Pauses or unpauses a DMA transfer.
    static void setTimedTrigger​(int handle, double periodSeconds)
    Sets DMA transfers to occur at a specific timed interval.
    static void setTimedTriggerCycles​(int handle, int cycles)
    Sets DMA transfers to occur at a specific timed interval in FPGA cycles.
    static void startDMA​(int handle, int queueDepth)
    Starts DMA Collection.
    static void stopDMA​(int handle)
    Stops DMA Collection.

    Methods inherited from class edu.wpi.first.hal.JNIWrapper

    forceLoad, suppressUnused

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • initialize

      public static int initialize()
      Initializes an object for performing DMA transfers.
      Returns:
      the created dma handle
      See Also:
      "HAL_InitializeDMA"
    • free

      public static void free​(int handle)
      Frees a DMA object.
      Parameters:
      handle - the dma handle
      See Also:
      "HAL_FreeDMA"
    • setPause

      public static void setPause​(int handle, boolean pause)
      Pauses or unpauses a DMA transfer.

      This can only be called while DMA is running.

      Parameters:
      handle - the dma handle
      pause - true to pause transfers, false to resume.
      See Also:
      "HAL_SetDMAPause"
    • setTimedTrigger

      public static void setTimedTrigger​(int handle, double periodSeconds)
      Sets DMA transfers to occur at a specific timed interval.

      This will remove any external triggers. Only timed or external is supported.

      Only 1 timed period is supported.

      This can only be called if DMA is not started.

      Parameters:
      handle - the dma handle
      periodSeconds - the period to trigger in seconds
      See Also:
      "HAL_SetDMATimedTrigger"
    • setTimedTriggerCycles

      public static void setTimedTriggerCycles​(int handle, int cycles)
      Sets DMA transfers to occur at a specific timed interval in FPGA cycles.

      This will remove any external triggers. Only timed or external is supported.

      Only 1 timed period is supported

      The FPGA currently runs at 40 MHz, but this can change. HAL_GetSystemClockTicksPerMicrosecond can be used to get a computable value for this.

      This can only be called if DMA is not started.

      Parameters:
      handle - the dma handle
      cycles - the period to trigger in FPGA cycles
      See Also:
      "HAL_SetDMATimedTriggerCycles"
    • addEncoder

      public static void addEncoder​(int handle, int encoderHandle)
      Adds position data for an encoder to be collected by DMA.

      This can only be called if DMA is not started.

      Parameters:
      handle - the dma handle
      encoderHandle - the encoder to add
      See Also:
      "HAL_AddDMAEncoder"
    • addEncoderPeriod

      public static void addEncoderPeriod​(int handle, int encoderHandle)
      Adds timer data for an encoder to be collected by DMA.

      This can only be called if DMA is not started.

      Parameters:
      handle - the dma handle
      encoderHandle - the encoder to add
      See Also:
      "HAL_AddDMAEncoderPeriod"
    • addCounter

      public static void addCounter​(int handle, int counterHandle)
      Adds position data for an counter to be collected by DMA.

      This can only be called if DMA is not started.

      Parameters:
      handle - the dma handle
      counterHandle - the counter to add
      See Also:
      "HAL_AddDMACounter"
    • addCounterPeriod

      public static void addCounterPeriod​(int handle, int counterHandle)
      Adds timer data for an counter to be collected by DMA.
      Parameters:
      handle - the dma handle
      counterHandle - the counter to add
      See Also:
      "HAL_AddDMACounterPeriod"
    • addDigitalSource

      public static void addDigitalSource​(int handle, int digitalSourceHandle)
      Adds a digital source to be collected by DMA.

      This can only be called if DMA is not started.

      Parameters:
      handle - the dma handle
      digitalSourceHandle - the digital source to add
      See Also:
      "HAL_AddDMADigitalSource"
    • addDutyCycle

      public static void addDutyCycle​(int handle, int dutyCycleHandle)
      Adds a duty cycle input to be collected by DMA.

      This can only be called if DMA is not started.

      Parameters:
      handle - the dma handle
      dutyCycleHandle - the duty cycle input to add
      See Also:
      "HAL_AddDMADutyCycle"
    • addAnalogInput

      public static void addAnalogInput​(int handle, int analogInputHandle)
      Adds an analog input to be collected by DMA.

      This can only be called if DMA is not started.

      Parameters:
      handle - the dma handle
      analogInputHandle - the analog input to add
      See Also:
      "HAL_AddDMAAnalogInput"
    • addAveragedAnalogInput

      public static void addAveragedAnalogInput​(int handle, int analogInputHandle)
      Adds averaged data of an analog input to be collected by DMA.

      This can only be called if DMA is not started.

      Parameters:
      handle - the dma handle
      analogInputHandle - the analog input to add
      See Also:
      "HAL_AddDMAAveragedAnalogInput"
    • addAnalogAccumulator

      public static void addAnalogAccumulator​(int handle, int analogInputHandle)
      Adds accumulator data of an analog input to be collected by DMA.

      This can only be called if DMA is not started.

      Parameters:
      handle - the dma handle
      analogInputHandle - the analog input to add
      See Also:
      "HAL_AddDMAAnalogAccumulator"
    • setExternalTrigger

      public static int setExternalTrigger​(int handle, int digitalSourceHandle, int analogTriggerType, boolean rising, boolean falling)
      Sets DMA transfers to occur on an external trigger.

      This will remove any timed trigger set. Only timed or external is supported.

      Up to 8 external triggers are currently supported.

      This can only be called if DMA is not started.

      Parameters:
      handle - the dma handle
      digitalSourceHandle - the digital source handle (either a HAL_AnalogTriggerHandle or a HAL_DigitalHandle)
      analogTriggerType - the analog trigger type if the source is an analog trigger
      rising - true to trigger on rising edge
      falling - true to trigger on falling edge
      Returns:
      the index of the trigger
      See Also:
      "HAL_SetDMAExternalTrigger"
    • clearSensors

      public static void clearSensors​(int handle)
      Clear all sensors from the DMA collection list.

      This can only be called if DMA is not started.

      Parameters:
      handle - the dma handle
      See Also:
      "HAL_ClearDMASensors"
    • clearExternalTriggers

      public static void clearExternalTriggers​(int handle)
      Clear all external triggers from the DMA trigger list.

      This can only be called if DMA is not started.

      Parameters:
      handle - the dma handle
      See Also:
      "HAL_ClearDMAExternalTriggers"
    • startDMA

      public static void startDMA​(int handle, int queueDepth)
      Starts DMA Collection.
      Parameters:
      handle - the dma handle
      queueDepth - the number of objects to be able to queue
      See Also:
      "HAL_StartDMA"
    • stopDMA

      public static void stopDMA​(int handle)
      Stops DMA Collection.
      Parameters:
      handle - the dma handle
      See Also:
      "HAL_StopDMA"
    • readDMA

      public static long readDMA​(int handle, double timeoutSeconds, int[] buffer, int[] sampleStore)
      Reads a DMA sample from the queue.
      Parameters:
      handle - the dma handle
      timeoutSeconds - the time to wait for data to be queued before timing out
      buffer - the sample object to place data into
      sampleStore - index 0-21 channelOffsets, index 22: capture size, index 23: triggerChannels (bitflags), index 24: remaining, index 25: read status
      Returns:
      timestamp of the DMA Sample
    • getSensorReadData

      public static edu.wpi.first.hal.DMAJNISample.BaseStore getSensorReadData​(int handle)
      Get the sensor DMA sample.
      Parameters:
      handle - the dma handle
      Returns:
      The DMA sample