001/*----------------------------------------------------------------------------*/
002/* Copyright (c) FIRST 2008-2017. All Rights Reserved.                        */
003/* Open Source Software - may be modified and shared by FRC teams. The code   */
004/* must be accompanied by the FIRST BSD license file in the root directory of */
005/* the project.                                                               */
006/*----------------------------------------------------------------------------*/
007
008package edu.wpi.first.wpilibj;
009
010import edu.wpi.first.wpilibj.hal.HALUtil;
011
012/**
013 * Contains global utility functions.
014 */
015public final class Utility {
016
017  private Utility() {
018  }
019
020  /**
021   * Return the FPGA Version number. For now, expect this to be 2009.
022   *
023   * @return FPGA Version number.
024   */
025  @SuppressWarnings("AbbreviationAsWordInName")
026  int getFPGAVersion() {
027    return HALUtil.getFPGAVersion();
028  }
029
030  /**
031   * Return the FPGA Revision number. The format of the revision is 3 numbers. The 12 most
032   * significant bits are the Major Revision. the next 8 bits are the Minor Revision. The 12 least
033   * significant bits are the Build Number.
034   *
035   * @return FPGA Revision number.
036   */
037  @SuppressWarnings("AbbreviationAsWordInName")
038  long getFPGARevision() {
039    return (long) HALUtil.getFPGARevision();
040  }
041
042  /**
043   * Read the microsecond timer from the FPGA.
044   *
045   * @return The current time in microseconds according to the FPGA.
046   */
047  public static long getFPGATime() {
048    return HALUtil.getFPGATime();
049  }
050
051  /**
052   * Get the state of the "USER" button on the roboRIO.
053   *
054   * @return true if the button is currently pressed down
055   */
056  public static boolean getUserButton() {
057    return HALUtil.getFPGAButton();
058  }
059}