Move PWM allocation to HAL to allow for checking against DIO allocation

Re-number MXP DIO to match pinout (include SPI and I2C pins) (fixes artf2664)
Change PWM MXP mapping to accommodate DIO re-mapping
This re-implementation also fixes artf2668 for C++ and Java
Change the test bench to reflect this change also

Change-Id: If30bd6a85a9f1f619fbde06a4ecd595a15fd28f7
This commit is contained in:
Kevin O'Connor
2014-08-05 17:27:43 -04:00
committed by Thomas Clark
parent deb335d96d
commit 59473ab7a7
9 changed files with 105 additions and 41 deletions

View File

@@ -14,6 +14,43 @@ TLogLevel pwmJNILogLevel = logWARNING;
else Log().Get(level)
/*
* Class: edu_wpi_first_wpilibj_hal_PWMJNI
* Method: allocatePWMChannel
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)Z
*/
JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_PWMJNI_allocatePWMChannel
(JNIEnv * env, jclass, jobject id, jobject status)
{
PWMJNI_LOG(logDEBUG) << "Calling DIOJNI allocatePWMChannel";
void ** javaId = (void**)env->GetDirectBufferAddress(id);
PWMJNI_LOG(logDEBUG) << "Port Ptr = " << *javaId;
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
PWMJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr;
jbyte returnValue = allocatePWMChannel(*javaId, statusPtr);
PWMJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
PWMJNI_LOG(logDEBUG) << "allocatePWMChannelResult = " << (jint)returnValue;
return returnValue;
}
/*
* Class: edu_wpi_first_wpilibj_hal_PWMJNI
* Method: freePWMChannel
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_PWMJNI_freePWMChannel
(JNIEnv * env, jclass, jobject id, jobject status)
{
PWMJNI_LOG(logDEBUG) << "Calling DIOJNI freePWMChannel";
void ** javaId = (void**)env->GetDirectBufferAddress(id);
PWMJNI_LOG(logDEBUG) << "Port Ptr = " << *javaId;
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
PWMJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr;
freePWMChannel(*javaId, statusPtr);
PWMJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
}
/*
* Class: edu_wpi_first_wpilibj_hal_PWMJNI
* Method: setPWM