001/*----------------------------------------------------------------------------*/ 002/* Copyright (c) FIRST 2016-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.hal; 009 010public class InterruptJNI extends JNIWrapper { 011 public static final int HalInvalidHandle = 0; 012 013 public interface InterruptJNIHandlerFunction { 014 void apply(int interruptAssertedMask, Object param); 015 } 016 017 public static native int initializeInterrupts(boolean watcher); 018 019 public static native void cleanInterrupts(int interruptHandle); 020 021 public static native int waitForInterrupt(int interruptHandle, double timeout, 022 boolean ignorePrevious); 023 024 public static native void enableInterrupts(int interruptHandle); 025 026 public static native void disableInterrupts(int interruptHandle); 027 028 public static native double readInterruptRisingTimestamp(int interruptHandle); 029 030 public static native double readInterruptFallingTimestamp(int interruptHandle); 031 032 public static native void requestInterrupts(int interruptHandle, int digitalSourceHandle, 033 int analogTriggerType); 034 035 public static native void attachInterruptHandler(int interruptHandle, 036 InterruptJNIHandlerFunction handler, 037 Object param); 038 039 public static native void setInterruptUpSourceEdge(int interruptHandle, boolean risingEdge, 040 boolean fallingEdge); 041}