001/* 002 * Software License Agreement 003 * 004 * Copyright (C) Cross The Road Electronics. All rights 005 * reserved. 006 * 007 * Cross The Road Electronics (CTRE) licenses to you the right to 008 * use, publish, and distribute copies of CRF (Cross The Road) firmware files (*.crf) and Software 009 * API Libraries ONLY when in use with Cross The Road Electronics hardware products. 010 * 011 * THE SOFTWARE AND DOCUMENTATION ARE PROVIDED "AS IS" WITHOUT 012 * WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT 013 * LIMITATION, ANY WARRANTY OF MERCHANTABILITY, FITNESS FOR A 014 * PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL 015 * CROSS THE ROAD ELECTRONICS BE LIABLE FOR ANY INCIDENTAL, SPECIAL, 016 * INDIRECT OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF 017 * PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY OR SERVICES, ANY CLAIMS 018 * BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE 019 * THEREOF), ANY CLAIMS FOR INDEMNITY OR CONTRIBUTION, OR OTHER 020 * SIMILAR COSTS, WHETHER ASSERTED ON THE BASIS OF CONTRACT, TORT 021 * (INCLUDING NEGLIGENCE), BREACH OF WARRANTY, OR OTHERWISE 022 */ 023 package com.ctre.phoenix; 024 025 public class CANifierJNI extends CTREJNIWrapper { 026 027 public enum GeneralPin 028 { 029 QUAD_IDX(0), 030 QUAD_B (1), 031 QUAD_A (2), 032 LIMR (3), 033 LIMF (4), 034 SDA (5), 035 SCL (6), 036 SPI_CS (7), 037 SPI_MISO_PWM2P (8), 038 SPI_MOSI_PWM1P (9), 039 SPI_CLK_PWM0P (10); 040 041 final public int value; 042 043 GeneralPin(int value) { 044 this.value = value; 045 } 046 } 047 048 public static native long JNI_new_CANifier(int deviceNumber); 049 050 public static native int JNI_destroy_CANifier(long handle); 051 052 //public static native int JNI_destroy_AllCANifiers(long handle); 053 054 public static native void JNI_SetLEDOutput(long handle, int dutyCycle, int ledChannel); 055 056 public static native void JNI_SetGeneralOutputs(long handle, int outputBits, int isOutputBits); 057 058 public static native void JNI_SetGeneralOutput(long handle, int outputPin, boolean outputValue, 059 boolean outputEnable); 060 061 public static native void JNI_SetPWMOutput(long handle, int pwmChannel, int dutyCycle); 062 063 public static native void JNI_EnablePWMOutput(long handle, int pwmChannel, boolean bEnable); 064 065 public static native void JNI_GetGeneralInputs(long handle, boolean[] allPins); 066 067 public static native boolean JNI_GetGeneralInput(long handl, int inputPin); 068 069 public static native void JNI_GetPWMInput(long handle, int pwmChannel, double pulseWidthAndPeriod[]); 070 071 public static native int JNI_GetLastError(long handle); 072 073 public static native double JNI_GetBatteryVoltage(long handle); 074 075 public static native int JNI_GetQuadraturePosition(long handle); 076 077 public static native int JNI_SetQuadraturePosition(long handle, int newPosition, int timeoutMs); 078 079 public static native int JNI_GetQuadratureVelocity(long handle); 080 081 public static native int JNI_ConfigVelocityMeasurementPeriod(long handle, int period, int timeoutMs); 082 083 public static native int JNI_ConfigVelocityMeasurementWindow(long handle, int windowSize, int timeoutMs); 084 085 public static native int JNI_ConfigClearPositionOnLimitF(long handle, boolean clearPositionOnLimitF, int timeoutMs); 086 087 public static native int JNI_ConfigClearPositionOnLimitR(long handle, boolean clearPositionOnLimitR, int timeoutMs); 088 089 public static native int JNI_ConfigClearPositionOnQuadIdx(long handle, boolean clearPositionOnQuadIdx, int timeoutMs); 090 091 public static native int JNI_ConfigSetCustomParam(long handle, int newValue, int paramIndex, int timeoutMs); 092 093 public static native int JNI_ConfigGetCustomParam(long handle, int paramIndex, int timoutMs); 094 095 public static native int JNI_ConfigSetParameter(long handle, int param, double value, int subValue, int ordinal, 096 int timeoutMs); 097 098 public static native double JNI_ConfigGetParameter(long handle, int param, int ordinal, int timeoutMs); 099 100 public static native int JNI_ConfigFactoryDefault(long handle, int timeoutMs); 101 102 public static native int JNI_SetStatusFramePeriod(long handle, int statusFrame, int periodMs, int timeoutMs); 103 104 public static native int JNI_GetStatusFramePeriod(long handle, int frame, int timeoutMs); 105 106 public static native int JNI_SetControlFramePeriod(long handle, int frame, int periodMs); 107 108 public static native int JNI_GetFirmwareVersion(long handle); 109 110 public static native boolean JNI_HasResetOccurred(long handle); 111 112 public static native int JNI_GetFaults(long handle); 113 114 public static native int JNI_GetStickyFaults(long handle); 115 116 public static native int JNI_ClearStickyFaults(long handle, int timeoutMs); 117 118 public static native double JNI_GetBusVoltage(long handle); 119 }