001// Copyright (c) FIRST and other WPILib contributors.
002// Open Source Software; you can modify and/or share it under the terms of
003// the WPILib BSD license file in the root directory of this project.
004
005package edu.wpi.first.hal;
006
007/**
008 * PWM JNI Functions.
009 *
010 * @see "hal/PWM.h"
011 */
012public class PWMJNI extends DIOJNI {
013  /**
014   * Initializes a PWM port.
015   *
016   * @param channel the smartio channel
017   * @return the created pwm handle
018   */
019  public static native int initializePWMPort(int channel);
020
021  /**
022   * Checks if a pwm channel is valid.
023   *
024   * @param channel the channel to check
025   * @return true if the channel is valid, otherwise false
026   */
027  public static native boolean checkPWMChannel(int channel);
028
029  /**
030   * Frees a PWM port.
031   *
032   * @param pwmPortHandle the pwm handle
033   */
034  public static native void freePWMPort(int pwmPortHandle);
035
036  /**
037   * Indicates the pwm is used by a simulated device.
038   *
039   * @param handle the pwm handle
040   * @param device simulated device handle
041   * @see "HAL_SetPWMSimDevice"
042   */
043  public static native void setPWMSimDevice(int handle, int device);
044
045  /**
046   * Sets a PWM channel to the desired pulse width in microseconds.
047   *
048   * @param pwmPortHandle the PWM handle
049   * @param microsecondPulseTime the PWM value to set
050   */
051  public static native void setPulseTimeMicroseconds(int pwmPortHandle, int microsecondPulseTime);
052
053  /**
054   * Gets the current microsecond pulse time from a PWM channel.
055   *
056   * @param pwmPortHandle the PWM handle
057   * @return the current PWM microsecond pulse time
058   */
059  public static native int getPulseTimeMicroseconds(int pwmPortHandle);
060
061  /**
062   * Sets the PWM output period.
063   *
064   * @param pwmPortHandle the PWM handle.
065   * @param period 0 for 5ms, 1 or 2 for 10ms, 3 for 20ms
066   */
067  public static native void setPWMOutputPeriod(int pwmPortHandle, int period);
068
069  /** Utility class. */
070  private PWMJNI() {}
071}