mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
Run wpiformat on merged repo (#1021)
This commit is contained in:
committed by
Peter Johnson
parent
0babbf317c
commit
6729a7d6b1
@@ -1,19 +1,20 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2016. All Rights Reserved. */
|
||||
/* Copyright (c) 2016-2018 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <jni.h>
|
||||
#include "HAL/cpp/Log.h"
|
||||
|
||||
#include "edu_wpi_first_wpilibj_hal_SPIJNI.h"
|
||||
#include <cassert>
|
||||
|
||||
#include <wpi/jni_util.h>
|
||||
|
||||
#include "HAL/SPI.h"
|
||||
#include "HAL/cpp/Log.h"
|
||||
#include "HALUtil.h"
|
||||
#include "wpi/jni_util.h"
|
||||
#include "edu_wpi_first_wpilibj_hal_SPIJNI.h"
|
||||
|
||||
using namespace frc;
|
||||
using namespace wpi::java;
|
||||
@@ -25,7 +26,7 @@ TLogLevel spiJNILogLevel = logWARNING;
|
||||
if (level > spiJNILogLevel) \
|
||||
; \
|
||||
else \
|
||||
Log().Get(level)
|
||||
Log().Get(level)
|
||||
|
||||
extern "C" {
|
||||
|
||||
@@ -34,8 +35,10 @@ extern "C" {
|
||||
* Method: spiInitialize
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiInitialize(
|
||||
JNIEnv *env, jclass, jint port) {
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiInitialize
|
||||
(JNIEnv* env, jclass, jint port)
|
||||
{
|
||||
SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiInitialize";
|
||||
SPIJNI_LOG(logDEBUG) << "Port = " << (jint)port;
|
||||
int32_t status = 0;
|
||||
@@ -47,23 +50,27 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiInitialize(
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_SPIJNI
|
||||
* Method: spiTransaction
|
||||
* Signature: (ILjava/nio/ByteBuffer;Ljava/nio/ByteBuffer;B)I
|
||||
* Signature: (ILjava/lang/Object;Ljava/lang/Object;B)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiTransaction(
|
||||
JNIEnv *env, jclass, jint port, jobject dataToSend, jobject dataReceived,
|
||||
jbyte size) {
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiTransaction
|
||||
(JNIEnv* env, jclass, jint port, jobject dataToSend, jobject dataReceived,
|
||||
jbyte size)
|
||||
{
|
||||
SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiTransaction";
|
||||
SPIJNI_LOG(logDEBUG) << "Port = " << (jint)port;
|
||||
uint8_t *dataToSendPtr = nullptr;
|
||||
uint8_t* dataToSendPtr = nullptr;
|
||||
if (dataToSend != 0) {
|
||||
dataToSendPtr = (uint8_t *)env->GetDirectBufferAddress(dataToSend);
|
||||
dataToSendPtr =
|
||||
reinterpret_cast<uint8_t*>(env->GetDirectBufferAddress(dataToSend));
|
||||
}
|
||||
uint8_t *dataReceivedPtr =
|
||||
(uint8_t *)env->GetDirectBufferAddress(dataReceived);
|
||||
uint8_t* dataReceivedPtr =
|
||||
reinterpret_cast<uint8_t*>(env->GetDirectBufferAddress(dataReceived));
|
||||
SPIJNI_LOG(logDEBUG) << "Size = " << (jint)size;
|
||||
SPIJNI_LOG(logDEBUG) << "DataToSendPtr = " << dataToSendPtr;
|
||||
SPIJNI_LOG(logDEBUG) << "DataReceivedPtr = " << dataReceivedPtr;
|
||||
jint retVal = HAL_TransactionSPI(static_cast<HAL_SPIPort>(port), dataToSendPtr, dataReceivedPtr, size);
|
||||
jint retVal = HAL_TransactionSPI(static_cast<HAL_SPIPort>(port),
|
||||
dataToSendPtr, dataReceivedPtr, size);
|
||||
SPIJNI_LOG(logDEBUG) << "ReturnValue = " << (jint)retVal;
|
||||
return retVal;
|
||||
}
|
||||
@@ -73,9 +80,11 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiTransaction(
|
||||
* Method: spiTransactionB
|
||||
* Signature: (I[B[BB)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiTransactionB(
|
||||
JNIEnv *env, jclass, jint port, jbyteArray dataToSend, jbyteArray dataReceived,
|
||||
jbyte size) {
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiTransactionB
|
||||
(JNIEnv* env, jclass, jint port, jbyteArray dataToSend,
|
||||
jbyteArray dataReceived, jbyte size)
|
||||
{
|
||||
SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiTransactionB";
|
||||
SPIJNI_LOG(logDEBUG) << "Port = " << (jint)port;
|
||||
SPIJNI_LOG(logDEBUG) << "Size = " << (jint)size;
|
||||
@@ -83,11 +92,11 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiTransactionB(
|
||||
recvBuf.resize(size);
|
||||
jint retVal =
|
||||
HAL_TransactionSPI(static_cast<HAL_SPIPort>(port),
|
||||
reinterpret_cast<const uint8_t *>(
|
||||
reinterpret_cast<const uint8_t*>(
|
||||
JByteArrayRef(env, dataToSend).array().data()),
|
||||
recvBuf.data(), size);
|
||||
env->SetByteArrayRegion(dataReceived, 0, size,
|
||||
reinterpret_cast<const jbyte *>(recvBuf.data()));
|
||||
reinterpret_cast<const jbyte*>(recvBuf.data()));
|
||||
SPIJNI_LOG(logDEBUG) << "ReturnValue = " << (jint)retVal;
|
||||
return retVal;
|
||||
}
|
||||
@@ -95,19 +104,23 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiTransactionB(
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_SPIJNI
|
||||
* Method: spiWrite
|
||||
* Signature: (ILjava/nio/ByteBuffer;B)I
|
||||
* Signature: (ILjava/lang/Object;B)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiWrite(
|
||||
JNIEnv *env, jclass, jint port, jobject dataToSend, jbyte size) {
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiWrite
|
||||
(JNIEnv* env, jclass, jint port, jobject dataToSend, jbyte size)
|
||||
{
|
||||
SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiWrite";
|
||||
SPIJNI_LOG(logDEBUG) << "Port = " << (jint)port;
|
||||
uint8_t *dataToSendPtr = nullptr;
|
||||
uint8_t* dataToSendPtr = nullptr;
|
||||
if (dataToSend != 0) {
|
||||
dataToSendPtr = (uint8_t *)env->GetDirectBufferAddress(dataToSend);
|
||||
dataToSendPtr =
|
||||
reinterpret_cast<uint8_t*>(env->GetDirectBufferAddress(dataToSend));
|
||||
}
|
||||
SPIJNI_LOG(logDEBUG) << "Size = " << (jint)size;
|
||||
SPIJNI_LOG(logDEBUG) << "DataToSendPtr = " << dataToSendPtr;
|
||||
jint retVal = HAL_WriteSPI(static_cast<HAL_SPIPort>(port), dataToSendPtr, size);
|
||||
jint retVal =
|
||||
HAL_WriteSPI(static_cast<HAL_SPIPort>(port), dataToSendPtr, size);
|
||||
SPIJNI_LOG(logDEBUG) << "ReturnValue = " << (jint)retVal;
|
||||
return retVal;
|
||||
}
|
||||
@@ -117,13 +130,15 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiWrite(
|
||||
* Method: spiWriteB
|
||||
* Signature: (I[BB)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiWriteB(
|
||||
JNIEnv *env, jclass, jint port, jbyteArray dataToSend, jbyte size) {
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiWriteB
|
||||
(JNIEnv* env, jclass, jint port, jbyteArray dataToSend, jbyte size)
|
||||
{
|
||||
SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiWriteB";
|
||||
SPIJNI_LOG(logDEBUG) << "Port = " << (jint)port;
|
||||
SPIJNI_LOG(logDEBUG) << "Size = " << (jint)size;
|
||||
jint retVal = HAL_WriteSPI(static_cast<HAL_SPIPort>(port),
|
||||
reinterpret_cast<const uint8_t *>(
|
||||
reinterpret_cast<const uint8_t*>(
|
||||
JByteArrayRef(env, dataToSend).array().data()),
|
||||
size);
|
||||
SPIJNI_LOG(logDEBUG) << "ReturnValue = " << (jint)retVal;
|
||||
@@ -133,24 +148,29 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiWriteB(
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_SPIJNI
|
||||
* Method: spiRead
|
||||
* Signature: (IZLjava/nio/ByteBuffer;B)I
|
||||
* Signature: (IZLjava/lang/Object;B)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiRead(
|
||||
JNIEnv *env, jclass, jint port, jboolean initiate, jobject dataReceived, jbyte size) {
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiRead
|
||||
(JNIEnv* env, jclass, jint port, jboolean initiate, jobject dataReceived,
|
||||
jbyte size)
|
||||
{
|
||||
SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiRead";
|
||||
SPIJNI_LOG(logDEBUG) << "Port = " << (jint)port;
|
||||
SPIJNI_LOG(logDEBUG) << "Initiate = " << (jboolean)initiate;
|
||||
uint8_t *dataReceivedPtr =
|
||||
(uint8_t *)env->GetDirectBufferAddress(dataReceived);
|
||||
uint8_t* dataReceivedPtr =
|
||||
reinterpret_cast<uint8_t*>(env->GetDirectBufferAddress(dataReceived));
|
||||
SPIJNI_LOG(logDEBUG) << "Size = " << (jint)size;
|
||||
SPIJNI_LOG(logDEBUG) << "DataReceivedPtr = " << dataReceivedPtr;
|
||||
jint retVal;
|
||||
if (initiate) {
|
||||
wpi::SmallVector<uint8_t, 128> sendBuf;
|
||||
sendBuf.resize(size);
|
||||
retVal = HAL_TransactionSPI(static_cast<HAL_SPIPort>(port), sendBuf.data(), dataReceivedPtr, size);
|
||||
retVal = HAL_TransactionSPI(static_cast<HAL_SPIPort>(port), sendBuf.data(),
|
||||
dataReceivedPtr, size);
|
||||
} else {
|
||||
retVal = HAL_ReadSPI(static_cast<HAL_SPIPort>(port), (uint8_t *)dataReceivedPtr, size);
|
||||
retVal = HAL_ReadSPI(static_cast<HAL_SPIPort>(port),
|
||||
reinterpret_cast<uint8_t*>(dataReceivedPtr), size);
|
||||
}
|
||||
SPIJNI_LOG(logDEBUG) << "ReturnValue = " << (jint)retVal;
|
||||
return retVal;
|
||||
@@ -161,8 +181,11 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiRead(
|
||||
* Method: spiReadB
|
||||
* Signature: (IZ[BB)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiReadB(
|
||||
JNIEnv *env, jclass, jint port, jboolean initiate, jbyteArray dataReceived, jbyte size) {
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiReadB
|
||||
(JNIEnv* env, jclass, jint port, jboolean initiate, jbyteArray dataReceived,
|
||||
jbyte size)
|
||||
{
|
||||
SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiReadB";
|
||||
SPIJNI_LOG(logDEBUG) << "Port = " << (jint)port;
|
||||
SPIJNI_LOG(logDEBUG) << "Initiate = " << (jboolean)initiate;
|
||||
@@ -173,12 +196,13 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiReadB(
|
||||
if (initiate) {
|
||||
wpi::SmallVector<uint8_t, 128> sendBuf;
|
||||
sendBuf.resize(size);
|
||||
retVal = HAL_TransactionSPI(static_cast<HAL_SPIPort>(port), sendBuf.data(), recvBuf.data(), size);
|
||||
retVal = HAL_TransactionSPI(static_cast<HAL_SPIPort>(port), sendBuf.data(),
|
||||
recvBuf.data(), size);
|
||||
} else {
|
||||
retVal = HAL_ReadSPI(static_cast<HAL_SPIPort>(port), recvBuf.data(), size);
|
||||
}
|
||||
env->SetByteArrayRegion(dataReceived, 0, size,
|
||||
reinterpret_cast<const jbyte *>(recvBuf.data()));
|
||||
reinterpret_cast<const jbyte*>(recvBuf.data()));
|
||||
SPIJNI_LOG(logDEBUG) << "ReturnValue = " << (jint)retVal;
|
||||
return retVal;
|
||||
}
|
||||
@@ -189,7 +213,9 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiReadB(
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiClose(JNIEnv *, jclass, jint port) {
|
||||
Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiClose
|
||||
(JNIEnv*, jclass, jint port)
|
||||
{
|
||||
SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiClose";
|
||||
SPIJNI_LOG(logDEBUG) << "Port = " << (jint)port;
|
||||
HAL_CloseSPI(static_cast<HAL_SPIPort>(port));
|
||||
@@ -200,8 +226,10 @@ Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiClose(JNIEnv *, jclass, jint port) {
|
||||
* Method: spiSetSpeed
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiSetSpeed(
|
||||
JNIEnv *, jclass, jint port, jint speed) {
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiSetSpeed
|
||||
(JNIEnv*, jclass, jint port, jint speed)
|
||||
{
|
||||
SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiSetSpeed";
|
||||
SPIJNI_LOG(logDEBUG) << "Port = " << (jint)port;
|
||||
SPIJNI_LOG(logDEBUG) << "Speed = " << (jint)speed;
|
||||
@@ -213,15 +241,18 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiSetSpeed(
|
||||
* Method: spiSetOpts
|
||||
* Signature: (IIII)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiSetOpts(
|
||||
JNIEnv *, jclass, jint port, jint msb_first, jint sample_on_trailing,
|
||||
jint clk_idle_high) {
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiSetOpts
|
||||
(JNIEnv*, jclass, jint port, jint msb_first, jint sample_on_trailing,
|
||||
jint clk_idle_high)
|
||||
{
|
||||
SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiSetOpts";
|
||||
SPIJNI_LOG(logDEBUG) << "Port = " << (jint)port;
|
||||
SPIJNI_LOG(logDEBUG) << "msb_first = " << msb_first;
|
||||
SPIJNI_LOG(logDEBUG) << "sample_on_trailing = " << sample_on_trailing;
|
||||
SPIJNI_LOG(logDEBUG) << "clk_idle_high = " << clk_idle_high;
|
||||
HAL_SetSPIOpts(static_cast<HAL_SPIPort>(port), msb_first, sample_on_trailing, clk_idle_high);
|
||||
HAL_SetSPIOpts(static_cast<HAL_SPIPort>(port), msb_first, sample_on_trailing,
|
||||
clk_idle_high);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -230,8 +261,9 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiSetOpts(
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiSetChipSelectActiveHigh(
|
||||
JNIEnv *env, jclass, jint port) {
|
||||
Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiSetChipSelectActiveHigh
|
||||
(JNIEnv* env, jclass, jint port)
|
||||
{
|
||||
SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiSetCSActiveHigh";
|
||||
SPIJNI_LOG(logDEBUG) << "Port = " << (jint)port;
|
||||
int32_t status = 0;
|
||||
@@ -246,8 +278,9 @@ Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiSetChipSelectActiveHigh(
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiSetChipSelectActiveLow(
|
||||
JNIEnv *env, jclass, jint port) {
|
||||
Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiSetChipSelectActiveLow
|
||||
(JNIEnv* env, jclass, jint port)
|
||||
{
|
||||
SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiSetCSActiveLow";
|
||||
SPIJNI_LOG(logDEBUG) << "Port = " << (jint)port;
|
||||
int32_t status = 0;
|
||||
@@ -261,8 +294,10 @@ Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiSetChipSelectActiveLow(
|
||||
* Method: spiInitAuto
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiInitAuto
|
||||
(JNIEnv *env, jclass, jint port, jint bufferSize) {
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiInitAuto
|
||||
(JNIEnv* env, jclass, jint port, jint bufferSize)
|
||||
{
|
||||
SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiInitAuto";
|
||||
SPIJNI_LOG(logDEBUG) << "Port = " << port;
|
||||
SPIJNI_LOG(logDEBUG) << "BufferSize = " << bufferSize;
|
||||
@@ -277,8 +312,10 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiInitAuto
|
||||
* Method: spiFreeAuto
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiFreeAuto
|
||||
(JNIEnv *env, jclass, jint port) {
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiFreeAuto
|
||||
(JNIEnv* env, jclass, jint port)
|
||||
{
|
||||
SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiFreeAuto";
|
||||
SPIJNI_LOG(logDEBUG) << "Port = " << port;
|
||||
int32_t status = 0;
|
||||
@@ -292,8 +329,10 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiFreeAuto
|
||||
* Method: spiStartAutoRate
|
||||
* Signature: (ID)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiStartAutoRate
|
||||
(JNIEnv *env, jclass, jint port, jdouble period) {
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiStartAutoRate
|
||||
(JNIEnv* env, jclass, jint port, jdouble period)
|
||||
{
|
||||
SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiStartAutoRate";
|
||||
SPIJNI_LOG(logDEBUG) << "Port = " << port;
|
||||
SPIJNI_LOG(logDEBUG) << "Period = " << period;
|
||||
@@ -308,8 +347,11 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiStartAutoRate
|
||||
* Method: spiStartAutoTrigger
|
||||
* Signature: (IIIZZ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiStartAutoTrigger
|
||||
(JNIEnv *env, jclass, jint port, jint digitalSourceHandle, jint analogTriggerType, jboolean triggerRising, jboolean triggerFalling) {
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiStartAutoTrigger
|
||||
(JNIEnv* env, jclass, jint port, jint digitalSourceHandle,
|
||||
jint analogTriggerType, jboolean triggerRising, jboolean triggerFalling)
|
||||
{
|
||||
SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiStartAutoTrigger";
|
||||
SPIJNI_LOG(logDEBUG) << "Port = " << port;
|
||||
SPIJNI_LOG(logDEBUG) << "DigitalSourceHandle = " << digitalSourceHandle;
|
||||
@@ -318,8 +360,8 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiStartAutoTrigger
|
||||
SPIJNI_LOG(logDEBUG) << "TriggerFalling = " << (jint)triggerFalling;
|
||||
int32_t status = 0;
|
||||
HAL_StartSPIAutoTrigger(static_cast<HAL_SPIPort>(port), digitalSourceHandle,
|
||||
static_cast<HAL_AnalogTriggerType>(analogTriggerType), triggerRising,
|
||||
triggerFalling, &status);
|
||||
static_cast<HAL_AnalogTriggerType>(analogTriggerType),
|
||||
triggerRising, triggerFalling, &status);
|
||||
SPIJNI_LOG(logDEBUG) << "Status = " << status;
|
||||
CheckStatus(env, status);
|
||||
}
|
||||
@@ -329,8 +371,10 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiStartAutoTrigger
|
||||
* Method: spiStopAuto
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiStopAuto
|
||||
(JNIEnv *env, jclass, jint port) {
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiStopAuto
|
||||
(JNIEnv* env, jclass, jint port)
|
||||
{
|
||||
SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiStopAuto";
|
||||
SPIJNI_LOG(logDEBUG) << "Port = " << port;
|
||||
int32_t status = 0;
|
||||
@@ -344,14 +388,17 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiStopAuto
|
||||
* Method: spiSetAutoTransmitData
|
||||
* Signature: (I[BI)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiSetAutoTransmitData
|
||||
(JNIEnv *env, jclass, jint port, jbyteArray dataToSend, jint zeroSize) {
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiSetAutoTransmitData
|
||||
(JNIEnv* env, jclass, jint port, jbyteArray dataToSend, jint zeroSize)
|
||||
{
|
||||
SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiSetAutoTransmitData";
|
||||
SPIJNI_LOG(logDEBUG) << "Port = " << port;
|
||||
SPIJNI_LOG(logDEBUG) << "ZeroSize = " << zeroSize;
|
||||
JByteArrayRef jarr(env, dataToSend);
|
||||
int32_t status = 0;
|
||||
HAL_SetSPIAutoTransmitData(static_cast<HAL_SPIPort>(port),
|
||||
HAL_SetSPIAutoTransmitData(
|
||||
static_cast<HAL_SPIPort>(port),
|
||||
reinterpret_cast<const uint8_t*>(jarr.array().data()),
|
||||
jarr.array().size(), zeroSize, &status);
|
||||
SPIJNI_LOG(logDEBUG) << "Status = " << status;
|
||||
@@ -363,8 +410,10 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiSetAutoTransmitD
|
||||
* Method: spiForceAutoRead
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiForceAutoRead
|
||||
(JNIEnv *env, jclass, jint port) {
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiForceAutoRead
|
||||
(JNIEnv* env, jclass, jint port)
|
||||
{
|
||||
SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiForceAutoRead";
|
||||
SPIJNI_LOG(logDEBUG) << "Port = " << port;
|
||||
int32_t status = 0;
|
||||
@@ -376,17 +425,22 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiForceAutoRead
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_SPIJNI
|
||||
* Method: spiReadAutoReceivedData
|
||||
* Signature: (ILjava/nio/ByteBuffer;ID)I
|
||||
* Signature: (ILjava/lang/Object;ID)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiReadAutoReceivedData__ILjava_nio_ByteBuffer_2ID
|
||||
(JNIEnv *env, jclass, jint port, jobject buffer, jint numToRead, jdouble timeout) {
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiReadAutoReceivedData__ILjava_nio_ByteBuffer_2ID
|
||||
(JNIEnv* env, jclass, jint port, jobject buffer, jint numToRead,
|
||||
jdouble timeout)
|
||||
{
|
||||
SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiReadAutoReceivedData";
|
||||
SPIJNI_LOG(logDEBUG) << "Port = " << port;
|
||||
SPIJNI_LOG(logDEBUG) << "NumToRead = " << numToRead;
|
||||
SPIJNI_LOG(logDEBUG) << "Timeout = " << timeout;
|
||||
uint8_t *recvBuf = (uint8_t *)env->GetDirectBufferAddress(buffer);
|
||||
uint8_t* recvBuf =
|
||||
reinterpret_cast<uint8_t*>(env->GetDirectBufferAddress(buffer));
|
||||
int32_t status = 0;
|
||||
jint retval = HAL_ReadSPIAutoReceivedData(static_cast<HAL_SPIPort>(port), recvBuf, numToRead, timeout, &status);
|
||||
jint retval = HAL_ReadSPIAutoReceivedData(
|
||||
static_cast<HAL_SPIPort>(port), recvBuf, numToRead, timeout, &status);
|
||||
SPIJNI_LOG(logDEBUG) << "Status = " << status;
|
||||
SPIJNI_LOG(logDEBUG) << "Return = " << retval;
|
||||
CheckStatus(env, status);
|
||||
@@ -398,8 +452,11 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiReadAutoReceived
|
||||
* Method: spiReadAutoReceivedData
|
||||
* Signature: (I[BID)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiReadAutoReceivedData__I_3BID
|
||||
(JNIEnv *env, jclass, jint port, jbyteArray buffer, jint numToRead, jdouble timeout) {
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiReadAutoReceivedData__I_3BID
|
||||
(JNIEnv* env, jclass, jint port, jbyteArray buffer, jint numToRead,
|
||||
jdouble timeout)
|
||||
{
|
||||
SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiReadAutoReceivedData";
|
||||
SPIJNI_LOG(logDEBUG) << "Port = " << port;
|
||||
SPIJNI_LOG(logDEBUG) << "NumToRead = " << numToRead;
|
||||
@@ -407,13 +464,15 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiReadAutoReceived
|
||||
wpi::SmallVector<uint8_t, 128> recvBuf;
|
||||
recvBuf.resize(numToRead);
|
||||
int32_t status = 0;
|
||||
jint retval = HAL_ReadSPIAutoReceivedData(static_cast<HAL_SPIPort>(port), recvBuf.data(), numToRead, timeout, &status);
|
||||
jint retval =
|
||||
HAL_ReadSPIAutoReceivedData(static_cast<HAL_SPIPort>(port),
|
||||
recvBuf.data(), numToRead, timeout, &status);
|
||||
SPIJNI_LOG(logDEBUG) << "Status = " << status;
|
||||
SPIJNI_LOG(logDEBUG) << "Return = " << retval;
|
||||
if (!CheckStatus(env, status)) return retval;
|
||||
if (numToRead > 0) {
|
||||
env->SetByteArrayRegion(buffer, 0, numToRead,
|
||||
reinterpret_cast<const jbyte *>(recvBuf.data()));
|
||||
reinterpret_cast<const jbyte*>(recvBuf.data()));
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
@@ -423,12 +482,15 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiReadAutoReceived
|
||||
* Method: spiGetAutoDroppedCount
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiGetAutoDroppedCount
|
||||
(JNIEnv *env, jclass, jint port) {
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiGetAutoDroppedCount
|
||||
(JNIEnv* env, jclass, jint port)
|
||||
{
|
||||
SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiGetAutoDroppedCount";
|
||||
SPIJNI_LOG(logDEBUG) << "Port = " << port;
|
||||
int32_t status = 0;
|
||||
auto retval = HAL_GetSPIAutoDroppedCount(static_cast<HAL_SPIPort>(port), &status);
|
||||
auto retval =
|
||||
HAL_GetSPIAutoDroppedCount(static_cast<HAL_SPIPort>(port), &status);
|
||||
SPIJNI_LOG(logDEBUG) << "Status = " << status;
|
||||
SPIJNI_LOG(logDEBUG) << "Return = " << retval;
|
||||
CheckStatus(env, status);
|
||||
|
||||
Reference in New Issue
Block a user