mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-22 01:11:42 +00:00
WPILib Reorganization
This is a major restructuring of the WPILib repository to simply build procedures and remove the remnants of Maven from everything except the eclipse plugins. Gradle files have been largely simplified or rewritten, taking advantage of splitting up parts of the build into separate build files for ease of reading. The eclipse plugins are now in a separate project, as is ntcore. All dependencies are resolved via Maven dependencies, with the Jenkins-maintained WPILib repo. Project structures have also been simplified: we no longer have separate subprojects inside wpilibc and wpilibj. Where possible, these changes hav been done with git renames, to make sure we still have full history for all repositories. Other unrelated subprojects have also been broken out: OutlineViewer is now a separate project. Change-Id: Ib4e2a6e1a2f66427a14f16612b0e0d69ed661878
This commit is contained in:
197
wpilibj/src/athena/cpp/lib/DIOJNI.cpp
Normal file
197
wpilibj/src/athena/cpp/lib/DIOJNI.cpp
Normal file
@@ -0,0 +1,197 @@
|
||||
#include <jni.h>
|
||||
#include <assert.h>
|
||||
#include "Log.hpp"
|
||||
|
||||
#include "edu_wpi_first_wpilibj_hal_DIOJNI.h"
|
||||
|
||||
#include "HAL/Digital.hpp"
|
||||
#include "HALUtil.h"
|
||||
|
||||
// set the logging level
|
||||
TLogLevel dioJNILogLevel = logWARNING;
|
||||
|
||||
#define DIOJNI_LOG(level) \
|
||||
if (level > dioJNILogLevel) ; \
|
||||
else Log().Get(level)
|
||||
|
||||
extern "C" {
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_DIOJNI
|
||||
* Method: initializeDigitalPort
|
||||
* Signature: (J)J;
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_DIOJNI_initializeDigitalPort
|
||||
(JNIEnv * env, jclass, jlong id)
|
||||
{
|
||||
DIOJNI_LOG(logDEBUG) << "Calling DIOJNI initializeDigitalPort";
|
||||
DIOJNI_LOG(logDEBUG) << "Port Ptr = " << (void*)id;
|
||||
int32_t status = 0;
|
||||
void* dio = initializeDigitalPort((void*)id, &status);
|
||||
DIOJNI_LOG(logDEBUG) << "Status = " << status;
|
||||
DIOJNI_LOG(logDEBUG) << "DIO Ptr = " << dio;
|
||||
CheckStatus(env, status);
|
||||
return (jlong)dio;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_DIOJNI
|
||||
* Method: allocateDIO
|
||||
* Signature: (JZ)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_DIOJNI_allocateDIO
|
||||
(JNIEnv * env, jclass, jlong id, jboolean value)
|
||||
{
|
||||
DIOJNI_LOG(logDEBUG) << "Calling DIOJNI allocateDIO";
|
||||
DIOJNI_LOG(logDEBUG) << "Port Ptr = " << (void*)id;
|
||||
int32_t status = 0;
|
||||
jboolean returnValue = allocateDIO((void*)id, value, &status);
|
||||
DIOJNI_LOG(logDEBUG) << "Status = " << status;
|
||||
DIOJNI_LOG(logDEBUG) << "allocateDIOResult = " << (jint)returnValue;
|
||||
CheckStatus(env, status);
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_DIOJNI
|
||||
* Method: freeDIO
|
||||
* Signature: (J)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_DIOJNI_freeDIO
|
||||
(JNIEnv * env, jclass, jlong id)
|
||||
{
|
||||
DIOJNI_LOG(logDEBUG) << "Calling DIOJNI freeDIO";
|
||||
DIOJNI_LOG(logDEBUG) << "Port Ptr = " << (void*)id;
|
||||
int32_t status = 0;
|
||||
freeDIO((void*)id, &status);
|
||||
DIOJNI_LOG(logDEBUG) << "Status = " << status;
|
||||
CheckStatus(env, status);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_DIOJNI
|
||||
* Method: setDIO
|
||||
* Signature: (JS)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_DIOJNI_setDIO
|
||||
(JNIEnv *env, jclass, jlong id, jshort value)
|
||||
{
|
||||
//DIOJNI_LOG(logDEBUG) << "Calling DIOJNI setDIO";
|
||||
//DIOJNI_LOG(logDEBUG) << "Port Ptr = " << (void*)id;
|
||||
//DIOJNI_LOG(logDEBUG) << "Value = " << value;
|
||||
int32_t status = 0;
|
||||
setDIO((void*)id, value, &status);
|
||||
//DIOJNI_LOG(logDEBUG) << "Status = " << status;
|
||||
CheckStatus(env, status);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_DIOJNI
|
||||
* Method: getDIO
|
||||
* Signature: (J)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_DIOJNI_getDIO
|
||||
(JNIEnv * env, jclass, jlong id)
|
||||
{
|
||||
//DIOJNI_LOG(logDEBUG) << "Calling DIOJNI getDIO";
|
||||
//DIOJNI_LOG(logDEBUG) << "Port Ptr = " << (void*)id;
|
||||
int32_t status = 0;
|
||||
jboolean returnValue = getDIO((void*)id, &status);
|
||||
//DIOJNI_LOG(logDEBUG) << "Status = " << status;
|
||||
//DIOJNI_LOG(logDEBUG) << "getDIOResult = " << (jint)returnValue;
|
||||
CheckStatus(env, status);
|
||||
return returnValue;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_DIOJNI
|
||||
* Method: getDIODirection
|
||||
* Signature: (J)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_DIOJNI_getDIODirection
|
||||
(JNIEnv *env, jclass, jlong id)
|
||||
{
|
||||
DIOJNI_LOG(logDEBUG) << "Calling DIOJNI getDIODirection (RR upd)";
|
||||
//DIOJNI_LOG(logDEBUG) << "Port Ptr = " << (void*)id;
|
||||
int32_t status = 0;
|
||||
jboolean returnValue = getDIODirection((void*)id, &status);
|
||||
//DIOJNI_LOG(logDEBUG) << "Status = " << status;
|
||||
DIOJNI_LOG(logDEBUG) << "getDIODirectionResult = " << (jint)returnValue;
|
||||
CheckStatus(env, status);
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_DIOJNI
|
||||
* Method: pulse
|
||||
* Signature: (JD)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_DIOJNI_pulse
|
||||
(JNIEnv *env, jclass, jlong id, jdouble value)
|
||||
{
|
||||
DIOJNI_LOG(logDEBUG) << "Calling DIOJNI pulse (RR upd)";
|
||||
//DIOJNI_LOG(logDEBUG) << "Port Ptr = " << (void*)id;
|
||||
//DIOJNI_LOG(logDEBUG) << "Value = " << value;
|
||||
int32_t status = 0;
|
||||
pulse((void*)id, value, &status);
|
||||
DIOJNI_LOG(logDEBUG) << "Did it work? Status = " << status;
|
||||
CheckStatus(env, status);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_DIOJNI
|
||||
* Method: isPulsing
|
||||
* Signature: (J)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_DIOJNI_isPulsing
|
||||
(JNIEnv *env, jclass, jlong id)
|
||||
{
|
||||
DIOJNI_LOG(logDEBUG) << "Calling DIOJNI isPulsing (RR upd)";
|
||||
//DIOJNI_LOG(logDEBUG) << "Port Ptr = " << (void*)id;
|
||||
int32_t status = 0;
|
||||
jboolean returnValue = isPulsing((void*)id, &status);
|
||||
//DIOJNI_LOG(logDEBUG) << "Status = " << status;
|
||||
DIOJNI_LOG(logDEBUG) << "isPulsingResult = " << (jint)returnValue;
|
||||
CheckStatus(env, status);
|
||||
return returnValue;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_DIOJNI
|
||||
* Method: isAnyPulsing
|
||||
* Signature: ()Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_DIOJNI_isAnyPulsing
|
||||
(JNIEnv *env, jclass)
|
||||
{
|
||||
DIOJNI_LOG(logDEBUG) << "Calling DIOJNI isAnyPulsing (RR upd)";
|
||||
int32_t status = 0;
|
||||
jboolean returnValue = isAnyPulsing( &status );
|
||||
//DIOJNI_LOG(logDEBUG) << "Status = " << status;
|
||||
DIOJNI_LOG(logDEBUG) << "isAnyPulsingResult = " << (jint)returnValue;
|
||||
CheckStatus(env, status);
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_DIOJNI
|
||||
* Method: getLoopTiming
|
||||
* Signature: ()S
|
||||
*/
|
||||
JNIEXPORT jshort JNICALL Java_edu_wpi_first_wpilibj_hal_DIOJNI_getLoopTiming
|
||||
(JNIEnv * env, jclass)
|
||||
{
|
||||
DIOJNI_LOG(logDEBUG) << "Calling DIOJNI getLoopTimeing";
|
||||
int32_t status = 0;
|
||||
jshort returnValue = getLoopTiming( &status );
|
||||
DIOJNI_LOG(logDEBUG) << "Status = " << status;
|
||||
DIOJNI_LOG(logDEBUG) << "LoopTiming = " << returnValue;
|
||||
CheckStatus(env, status);
|
||||
return returnValue;
|
||||
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
Reference in New Issue
Block a user