mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-29 02:21:44 +00:00
Switches SPI and I2C to use enums in the HAL for ports (#531)
Closes #397
This commit is contained in:
committed by
Peter Johnson
parent
67d62ba164
commit
b2f3479692
@@ -9,19 +9,21 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
enum HAL_I2CPort : int32_t { HAL_I2C_kOnboard = 0, HAL_I2C_kMXP };
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void HAL_InitializeI2C(int32_t port, int32_t* status);
|
||||
int32_t HAL_TransactionI2C(int32_t port, int32_t deviceAddress,
|
||||
void HAL_InitializeI2C(HAL_I2CPort port, int32_t* status);
|
||||
int32_t HAL_TransactionI2C(HAL_I2CPort port, int32_t deviceAddress,
|
||||
uint8_t* dataToSend, int32_t sendSize,
|
||||
uint8_t* dataReceived, int32_t receiveSize);
|
||||
int32_t HAL_WriteI2C(int32_t port, int32_t deviceAddress, uint8_t* dataToSend,
|
||||
int32_t sendSize);
|
||||
int32_t HAL_ReadI2C(int32_t port, int32_t deviceAddress, uint8_t* buffer,
|
||||
int32_t HAL_WriteI2C(HAL_I2CPort port, int32_t deviceAddress,
|
||||
uint8_t* dataToSend, int32_t sendSize);
|
||||
int32_t HAL_ReadI2C(HAL_I2CPort port, int32_t deviceAddress, uint8_t* buffer,
|
||||
int32_t count);
|
||||
void HAL_CloseI2C(int32_t port);
|
||||
void HAL_CloseI2C(HAL_I2CPort port);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -11,40 +11,49 @@
|
||||
|
||||
#include "HAL/Types.h"
|
||||
|
||||
enum HAL_SPIPort : int32_t {
|
||||
HAL_SPI_kOnboardCS0 = 0,
|
||||
HAL_SPI_kOnboardCS1,
|
||||
HAL_SPI_kOnboardCS2,
|
||||
HAL_SPI_kOnboardCS3,
|
||||
HAL_SPI_kMXP
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void HAL_InitializeSPI(int32_t port, int32_t* status);
|
||||
int32_t HAL_TransactionSPI(int32_t port, uint8_t* dataToSend,
|
||||
void HAL_InitializeSPI(HAL_SPIPort port, int32_t* status);
|
||||
int32_t HAL_TransactionSPI(HAL_SPIPort port, uint8_t* dataToSend,
|
||||
uint8_t* dataReceived, int32_t size);
|
||||
int32_t HAL_WriteSPI(int32_t port, uint8_t* dataToSend, int32_t sendSize);
|
||||
int32_t HAL_ReadSPI(int32_t port, uint8_t* buffer, int32_t count);
|
||||
void HAL_CloseSPI(int32_t port);
|
||||
void HAL_SetSPISpeed(int32_t port, int32_t speed);
|
||||
void HAL_SetSPIOpts(int32_t port, HAL_Bool msbFirst, HAL_Bool sampleOnTrailing,
|
||||
HAL_Bool clkIdleHigh);
|
||||
void HAL_SetSPIChipSelectActiveHigh(int32_t port, int32_t* status);
|
||||
void HAL_SetSPIChipSelectActiveLow(int32_t port, int32_t* status);
|
||||
int32_t HAL_GetSPIHandle(int32_t port);
|
||||
void HAL_SetSPIHandle(int32_t port, int32_t handle);
|
||||
int32_t HAL_WriteSPI(HAL_SPIPort port, uint8_t* dataToSend, int32_t sendSize);
|
||||
int32_t HAL_ReadSPI(HAL_SPIPort port, uint8_t* buffer, int32_t count);
|
||||
void HAL_CloseSPI(HAL_SPIPort port);
|
||||
void HAL_SetSPISpeed(HAL_SPIPort port, int32_t speed);
|
||||
void HAL_SetSPIOpts(HAL_SPIPort port, HAL_Bool msbFirst,
|
||||
HAL_Bool sampleOnTrailing, HAL_Bool clkIdleHigh);
|
||||
void HAL_SetSPIChipSelectActiveHigh(HAL_SPIPort port, int32_t* status);
|
||||
void HAL_SetSPIChipSelectActiveLow(HAL_SPIPort port, int32_t* status);
|
||||
int32_t HAL_GetSPIHandle(HAL_SPIPort port);
|
||||
void HAL_SetSPIHandle(HAL_SPIPort port, int32_t handle);
|
||||
|
||||
void HAL_InitSPIAccumulator(int32_t port, int32_t period, int32_t cmd,
|
||||
void HAL_InitSPIAccumulator(HAL_SPIPort port, int32_t period, int32_t cmd,
|
||||
int32_t xferSize, int32_t validMask,
|
||||
int32_t validValue, int32_t dataShift,
|
||||
int32_t dataSize, HAL_Bool isSigned,
|
||||
HAL_Bool bigEndian, int32_t* status);
|
||||
void HAL_FreeSPIAccumulator(int32_t port, int32_t* status);
|
||||
void HAL_ResetSPIAccumulator(int32_t port, int32_t* status);
|
||||
void HAL_SetSPIAccumulatorCenter(int32_t port, int32_t center, int32_t* status);
|
||||
void HAL_SetSPIAccumulatorDeadband(int32_t port, int32_t deadband,
|
||||
int32_t* status);
|
||||
int32_t HAL_GetSPIAccumulatorLastValue(int32_t port, int32_t* status);
|
||||
int64_t HAL_GetSPIAccumulatorValue(int32_t port, int32_t* status);
|
||||
int64_t HAL_GetSPIAccumulatorCount(int32_t port, int32_t* status);
|
||||
double HAL_GetSPIAccumulatorAverage(int32_t port, int32_t* status);
|
||||
void HAL_GetSPIAccumulatorOutput(int32_t port, int64_t* value, int64_t* count,
|
||||
void HAL_FreeSPIAccumulator(HAL_SPIPort port, int32_t* status);
|
||||
void HAL_ResetSPIAccumulator(HAL_SPIPort port, int32_t* status);
|
||||
void HAL_SetSPIAccumulatorCenter(HAL_SPIPort port, int32_t center,
|
||||
int32_t* status);
|
||||
void HAL_SetSPIAccumulatorDeadband(HAL_SPIPort port, int32_t deadband,
|
||||
int32_t* status);
|
||||
int32_t HAL_GetSPIAccumulatorLastValue(HAL_SPIPort port, int32_t* status);
|
||||
int64_t HAL_GetSPIAccumulatorValue(HAL_SPIPort port, int32_t* status);
|
||||
int64_t HAL_GetSPIAccumulatorCount(HAL_SPIPort port, int32_t* status);
|
||||
double HAL_GetSPIAccumulatorAverage(HAL_SPIPort port, int32_t* status);
|
||||
void HAL_GetSPIAccumulatorOutput(HAL_SPIPort port, int64_t* value,
|
||||
int64_t* count, int32_t* status);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -31,7 +31,7 @@ extern "C" {
|
||||
* If opening the MXP port, also sets up the channel functions appropriately
|
||||
* @param port The port to open, 0 for the on-board, 1 for the MXP.
|
||||
*/
|
||||
void HAL_InitializeI2C(int32_t port, int32_t* status) {
|
||||
void HAL_InitializeI2C(HAL_I2CPort port, int32_t* status) {
|
||||
initializeDigital(status);
|
||||
if (*status != 0) return;
|
||||
|
||||
@@ -80,7 +80,7 @@ void HAL_InitializeI2C(int32_t port, int32_t* status) {
|
||||
* @param receiveSize Number of bytes to read from the device.
|
||||
* @return >= 0 on success or -1 on transfer abort.
|
||||
*/
|
||||
int32_t HAL_TransactionI2C(int32_t port, int32_t deviceAddress,
|
||||
int32_t HAL_TransactionI2C(HAL_I2CPort port, int32_t deviceAddress,
|
||||
uint8_t* dataToSend, int32_t sendSize,
|
||||
uint8_t* dataReceived, int32_t receiveSize) {
|
||||
if (port > 1) {
|
||||
@@ -112,8 +112,8 @@ int32_t HAL_TransactionI2C(int32_t port, int32_t deviceAddress,
|
||||
* @param data The byte to write to the register on the device.
|
||||
* @return >= 0 on success or -1 on transfer abort.
|
||||
*/
|
||||
int32_t HAL_WriteI2C(int32_t port, int32_t deviceAddress, uint8_t* dataToSend,
|
||||
int32_t sendSize) {
|
||||
int32_t HAL_WriteI2C(HAL_I2CPort port, int32_t deviceAddress,
|
||||
uint8_t* dataToSend, int32_t sendSize) {
|
||||
if (port > 1) {
|
||||
// Set port out of range error here
|
||||
return -1;
|
||||
@@ -142,7 +142,7 @@ int32_t HAL_WriteI2C(int32_t port, int32_t deviceAddress, uint8_t* dataToSend,
|
||||
* device.
|
||||
* @return >= 0 on success or -1 on transfer abort.
|
||||
*/
|
||||
int32_t HAL_ReadI2C(int32_t port, int32_t deviceAddress, uint8_t* buffer,
|
||||
int32_t HAL_ReadI2C(HAL_I2CPort port, int32_t deviceAddress, uint8_t* buffer,
|
||||
int32_t count) {
|
||||
if (port > 1) {
|
||||
// Set port out of range error here
|
||||
@@ -159,7 +159,7 @@ int32_t HAL_ReadI2C(int32_t port, int32_t deviceAddress, uint8_t* buffer,
|
||||
}
|
||||
}
|
||||
|
||||
void HAL_CloseI2C(int32_t port) {
|
||||
void HAL_CloseI2C(HAL_I2CPort port) {
|
||||
if (port > 1) {
|
||||
// Set port out of range error here
|
||||
return;
|
||||
|
||||
@@ -40,7 +40,7 @@ static HAL_DigitalHandle digitalHandles[9]{HAL_kInvalidHandle};
|
||||
* @param port The number of the port to use. 0-3 for Onboard CS0-CS2, 4 for MXP
|
||||
* @return The semaphore for the SPI port.
|
||||
*/
|
||||
static priority_recursive_mutex& spiGetMutex(int32_t port) {
|
||||
static priority_recursive_mutex& spiGetMutex(HAL_SPIPort port) {
|
||||
if (port < 4)
|
||||
return spiOnboardMutex;
|
||||
else
|
||||
@@ -68,7 +68,7 @@ struct SPIAccumulator {
|
||||
int32_t dataMsbMask; // data field MSB mask (for signed)
|
||||
uint8_t dataShift; // data field shift right amount, in bits
|
||||
uint8_t xferSize; // SPI transfer size, in bytes (up to 4)
|
||||
uint8_t port;
|
||||
HAL_SPIPort port;
|
||||
bool isSigned; // is data field signed?
|
||||
bool bigEndian; // is response big endian?
|
||||
};
|
||||
@@ -111,14 +111,14 @@ static void CommonSPIPortFree() {
|
||||
* If opening the MXP port, also sets up the channel functions appropriately
|
||||
* @param port The number of the port to use. 0-3 for Onboard CS0-CS3, 4 for MXP
|
||||
*/
|
||||
void HAL_InitializeSPI(int32_t port, int32_t* status) {
|
||||
void HAL_InitializeSPI(HAL_SPIPort port, int32_t* status) {
|
||||
if (HAL_GetSPIHandle(port) != 0) return;
|
||||
switch (port) {
|
||||
case 0:
|
||||
CommonSPIPortInit(status);
|
||||
if (*status != 0) return;
|
||||
// CS0 is not a DIO port, so nothing to allocate
|
||||
HAL_SetSPIHandle(0, spilib_open("/dev/spidev0.0"));
|
||||
HAL_SetSPIHandle(HAL_SPI_kOnboardCS0, spilib_open("/dev/spidev0.0"));
|
||||
break;
|
||||
case 1:
|
||||
CommonSPIPortInit(status);
|
||||
@@ -131,7 +131,7 @@ void HAL_InitializeSPI(int32_t port, int32_t* status) {
|
||||
CommonSPIPortFree();
|
||||
return;
|
||||
}
|
||||
HAL_SetSPIHandle(1, spilib_open("/dev/spidev0.1"));
|
||||
HAL_SetSPIHandle(HAL_SPI_kOnboardCS1, spilib_open("/dev/spidev0.1"));
|
||||
break;
|
||||
case 2:
|
||||
CommonSPIPortInit(status);
|
||||
@@ -144,7 +144,7 @@ void HAL_InitializeSPI(int32_t port, int32_t* status) {
|
||||
CommonSPIPortFree();
|
||||
return;
|
||||
}
|
||||
HAL_SetSPIHandle(2, spilib_open("/dev/spidev0.2"));
|
||||
HAL_SetSPIHandle(HAL_SPI_kOnboardCS2, spilib_open("/dev/spidev0.2"));
|
||||
break;
|
||||
case 3:
|
||||
CommonSPIPortInit(status);
|
||||
@@ -157,7 +157,7 @@ void HAL_InitializeSPI(int32_t port, int32_t* status) {
|
||||
CommonSPIPortFree();
|
||||
return;
|
||||
}
|
||||
HAL_SetSPIHandle(3, spilib_open("/dev/spidev0.3"));
|
||||
HAL_SetSPIHandle(HAL_SPI_kOnboardCS3, spilib_open("/dev/spidev0.3"));
|
||||
break;
|
||||
case 4:
|
||||
initializeDigital(status);
|
||||
@@ -194,7 +194,7 @@ void HAL_InitializeSPI(int32_t port, int32_t* status) {
|
||||
}
|
||||
digitalSystem->writeEnableMXPSpecialFunction(
|
||||
digitalSystem->readEnableMXPSpecialFunction(status) | 0x00F0, status);
|
||||
HAL_SetSPIHandle(4, spilib_open("/dev/spidev1.0"));
|
||||
HAL_SetSPIHandle(HAL_SPI_kMXP, spilib_open("/dev/spidev1.0"));
|
||||
break;
|
||||
default:
|
||||
*status = PARAMETER_OUT_OF_RANGE;
|
||||
@@ -215,7 +215,7 @@ void HAL_InitializeSPI(int32_t port, int32_t* status) {
|
||||
* @param size Number of bytes to transfer. [0..7]
|
||||
* @return Number of bytes transferred, -1 for error
|
||||
*/
|
||||
int32_t HAL_TransactionSPI(int32_t port, uint8_t* dataToSend,
|
||||
int32_t HAL_TransactionSPI(HAL_SPIPort port, uint8_t* dataToSend,
|
||||
uint8_t* dataReceived, int32_t size) {
|
||||
std::lock_guard<priority_recursive_mutex> sync(spiGetMutex(port));
|
||||
return spilib_writeread(
|
||||
@@ -233,7 +233,7 @@ int32_t HAL_TransactionSPI(int32_t port, uint8_t* dataToSend,
|
||||
* @param sendSize The number of bytes to be written
|
||||
* @return The number of bytes written. -1 for an error
|
||||
*/
|
||||
int32_t HAL_WriteSPI(int32_t port, uint8_t* dataToSend, int32_t sendSize) {
|
||||
int32_t HAL_WriteSPI(HAL_SPIPort port, uint8_t* dataToSend, int32_t sendSize) {
|
||||
std::lock_guard<priority_recursive_mutex> sync(spiGetMutex(port));
|
||||
return spilib_write(HAL_GetSPIHandle(port),
|
||||
reinterpret_cast<const char*>(dataToSend),
|
||||
@@ -253,7 +253,7 @@ int32_t HAL_WriteSPI(int32_t port, uint8_t* dataToSend, int32_t sendSize) {
|
||||
* @param count The number of bytes to read in the transaction. [1..7]
|
||||
* @return Number of bytes read. -1 for error.
|
||||
*/
|
||||
int32_t HAL_ReadSPI(int32_t port, uint8_t* buffer, int32_t count) {
|
||||
int32_t HAL_ReadSPI(HAL_SPIPort port, uint8_t* buffer, int32_t count) {
|
||||
std::lock_guard<priority_recursive_mutex> sync(spiGetMutex(port));
|
||||
return spilib_read(HAL_GetSPIHandle(port), reinterpret_cast<char*>(buffer),
|
||||
static_cast<int32_t>(count));
|
||||
@@ -264,7 +264,7 @@ int32_t HAL_ReadSPI(int32_t port, uint8_t* buffer, int32_t count) {
|
||||
*
|
||||
* @param port The number of the port to use. 0-3 for Onboard CS0-CS2, 4 for MXP
|
||||
*/
|
||||
void HAL_CloseSPI(int32_t port) {
|
||||
void HAL_CloseSPI(HAL_SPIPort port) {
|
||||
std::lock_guard<priority_recursive_mutex> sync(spiGetMutex(port));
|
||||
if (spiAccumulators[port]) {
|
||||
int32_t status = 0;
|
||||
@@ -304,7 +304,7 @@ void HAL_CloseSPI(int32_t port) {
|
||||
* @param port The number of the port to use. 0-3 for Onboard CS0-CS2, 4 for MXP
|
||||
* @param speed The speed in Hz (0-1MHz)
|
||||
*/
|
||||
void HAL_SetSPISpeed(int32_t port, int32_t speed) {
|
||||
void HAL_SetSPISpeed(HAL_SPIPort port, int32_t speed) {
|
||||
std::lock_guard<priority_recursive_mutex> sync(spiGetMutex(port));
|
||||
spilib_setspeed(HAL_GetSPIHandle(port), speed);
|
||||
}
|
||||
@@ -319,8 +319,8 @@ void HAL_SetSPISpeed(int32_t port, int32_t speed) {
|
||||
* @param clkIdleHigh True to set the clock to active low, False to set the
|
||||
* clock active high
|
||||
*/
|
||||
void HAL_SetSPIOpts(int32_t port, HAL_Bool msbFirst, HAL_Bool sampleOnTrailing,
|
||||
HAL_Bool clkIdleHigh) {
|
||||
void HAL_SetSPIOpts(HAL_SPIPort port, HAL_Bool msbFirst,
|
||||
HAL_Bool sampleOnTrailing, HAL_Bool clkIdleHigh) {
|
||||
std::lock_guard<priority_recursive_mutex> sync(spiGetMutex(port));
|
||||
spilib_setopts(HAL_GetSPIHandle(port), msbFirst, sampleOnTrailing,
|
||||
clkIdleHigh);
|
||||
@@ -331,7 +331,7 @@ void HAL_SetSPIOpts(int32_t port, HAL_Bool msbFirst, HAL_Bool sampleOnTrailing,
|
||||
*
|
||||
* @param port The number of the port to use. 0-3 for Onboard CS0-CS2, 4 for MXP
|
||||
*/
|
||||
void HAL_SetSPIChipSelectActiveHigh(int32_t port, int32_t* status) {
|
||||
void HAL_SetSPIChipSelectActiveHigh(HAL_SPIPort port, int32_t* status) {
|
||||
std::lock_guard<priority_recursive_mutex> sync(spiGetMutex(port));
|
||||
if (port < 4) {
|
||||
spiSystem->writeChipSelectActiveHigh_Hdr(
|
||||
@@ -346,7 +346,7 @@ void HAL_SetSPIChipSelectActiveHigh(int32_t port, int32_t* status) {
|
||||
*
|
||||
* @param port The number of the port to use. 0-3 for Onboard CS0-CS2, 4 for MXP
|
||||
*/
|
||||
void HAL_SetSPIChipSelectActiveLow(int32_t port, int32_t* status) {
|
||||
void HAL_SetSPIChipSelectActiveLow(HAL_SPIPort port, int32_t* status) {
|
||||
std::lock_guard<priority_recursive_mutex> sync(spiGetMutex(port));
|
||||
if (port < 4) {
|
||||
spiSystem->writeChipSelectActiveHigh_Hdr(
|
||||
@@ -362,7 +362,7 @@ void HAL_SetSPIChipSelectActiveLow(int32_t port, int32_t* status) {
|
||||
* @param port The number of the port to use. 0-3 for Onboard CS0-CS2, 4 for MXP
|
||||
* @return The stored handle for the SPI port. 0 represents no stored handle.
|
||||
*/
|
||||
int32_t HAL_GetSPIHandle(int32_t port) {
|
||||
int32_t HAL_GetSPIHandle(HAL_SPIPort port) {
|
||||
std::lock_guard<priority_recursive_mutex> sync(spiGetMutex(port));
|
||||
switch (port) {
|
||||
case 0:
|
||||
@@ -387,7 +387,7 @@ int32_t HAL_GetSPIHandle(int32_t port) {
|
||||
* MXP.
|
||||
* @param handle The value of the handle for the port.
|
||||
*/
|
||||
void HAL_SetSPIHandle(int32_t port, int32_t handle) {
|
||||
void HAL_SetSPIHandle(HAL_SPIPort port, int32_t handle) {
|
||||
std::lock_guard<priority_recursive_mutex> sync(spiGetMutex(port));
|
||||
switch (port) {
|
||||
case 0:
|
||||
@@ -482,7 +482,7 @@ static void spiAccumulatorProcess(uint64_t currentTime,
|
||||
* @param isSigned Is data field signed?
|
||||
* @param bigEndian Is device big endian?
|
||||
*/
|
||||
void HAL_InitSPIAccumulator(int32_t port, int32_t period, int32_t cmd,
|
||||
void HAL_InitSPIAccumulator(HAL_SPIPort port, int32_t period, int32_t cmd,
|
||||
int32_t xferSize, int32_t validMask,
|
||||
int32_t validValue, int32_t dataShift,
|
||||
int32_t dataSize, HAL_Bool isSigned,
|
||||
@@ -515,6 +515,7 @@ void HAL_InitSPIAccumulator(int32_t port, int32_t period, int32_t cmd,
|
||||
accum->dataMsbMask = (1 << (dataSize - 1));
|
||||
accum->isSigned = isSigned;
|
||||
accum->bigEndian = bigEndian;
|
||||
accum->port = port;
|
||||
if (!accum->notifier) {
|
||||
accum->notifier =
|
||||
HAL_InitializeNotifier(spiAccumulatorProcess, accum, status);
|
||||
@@ -527,7 +528,7 @@ void HAL_InitSPIAccumulator(int32_t port, int32_t period, int32_t cmd,
|
||||
/**
|
||||
* Frees a SPI accumulator.
|
||||
*/
|
||||
void HAL_FreeSPIAccumulator(int32_t port, int32_t* status) {
|
||||
void HAL_FreeSPIAccumulator(HAL_SPIPort port, int32_t* status) {
|
||||
std::lock_guard<priority_recursive_mutex> sync(spiGetMutex(port));
|
||||
SPIAccumulator* accum = spiAccumulators[port].get();
|
||||
if (!accum) {
|
||||
@@ -542,7 +543,7 @@ void HAL_FreeSPIAccumulator(int32_t port, int32_t* status) {
|
||||
/**
|
||||
* Resets the accumulator to zero.
|
||||
*/
|
||||
void HAL_ResetSPIAccumulator(int32_t port, int32_t* status) {
|
||||
void HAL_ResetSPIAccumulator(HAL_SPIPort port, int32_t* status) {
|
||||
std::lock_guard<priority_recursive_mutex> sync(spiGetMutex(port));
|
||||
SPIAccumulator* accum = spiAccumulators[port].get();
|
||||
if (!accum) {
|
||||
@@ -563,7 +564,7 @@ void HAL_ResetSPIAccumulator(int32_t port, int32_t* status) {
|
||||
* integration work
|
||||
* and to take the device offset into account when integrating.
|
||||
*/
|
||||
void HAL_SetSPIAccumulatorCenter(int32_t port, int32_t center,
|
||||
void HAL_SetSPIAccumulatorCenter(HAL_SPIPort port, int32_t center,
|
||||
int32_t* status) {
|
||||
std::lock_guard<priority_recursive_mutex> sync(spiGetMutex(port));
|
||||
SPIAccumulator* accum = spiAccumulators[port].get();
|
||||
@@ -577,7 +578,7 @@ void HAL_SetSPIAccumulatorCenter(int32_t port, int32_t center,
|
||||
/**
|
||||
* Set the accumulator's deadband.
|
||||
*/
|
||||
void HAL_SetSPIAccumulatorDeadband(int32_t port, int32_t deadband,
|
||||
void HAL_SetSPIAccumulatorDeadband(HAL_SPIPort port, int32_t deadband,
|
||||
int32_t* status) {
|
||||
std::lock_guard<priority_recursive_mutex> sync(spiGetMutex(port));
|
||||
SPIAccumulator* accum = spiAccumulators[port].get();
|
||||
@@ -591,7 +592,7 @@ void HAL_SetSPIAccumulatorDeadband(int32_t port, int32_t deadband,
|
||||
/**
|
||||
* Read the last value read by the accumulator engine.
|
||||
*/
|
||||
int32_t HAL_GetSPIAccumulatorLastValue(int32_t port, int32_t* status) {
|
||||
int32_t HAL_GetSPIAccumulatorLastValue(HAL_SPIPort port, int32_t* status) {
|
||||
std::lock_guard<priority_recursive_mutex> sync(spiGetMutex(port));
|
||||
SPIAccumulator* accum = spiAccumulators[port].get();
|
||||
if (!accum) {
|
||||
@@ -606,7 +607,7 @@ int32_t HAL_GetSPIAccumulatorLastValue(int32_t port, int32_t* status) {
|
||||
*
|
||||
* @return The 64-bit value accumulated since the last Reset().
|
||||
*/
|
||||
int64_t HAL_GetSPIAccumulatorValue(int32_t port, int32_t* status) {
|
||||
int64_t HAL_GetSPIAccumulatorValue(HAL_SPIPort port, int32_t* status) {
|
||||
std::lock_guard<priority_recursive_mutex> sync(spiGetMutex(port));
|
||||
SPIAccumulator* accum = spiAccumulators[port].get();
|
||||
if (!accum) {
|
||||
@@ -624,7 +625,7 @@ int64_t HAL_GetSPIAccumulatorValue(int32_t port, int32_t* status) {
|
||||
*
|
||||
* @return The number of times samples from the channel were accumulated.
|
||||
*/
|
||||
int64_t HAL_GetSPIAccumulatorCount(int32_t port, int32_t* status) {
|
||||
int64_t HAL_GetSPIAccumulatorCount(HAL_SPIPort port, int32_t* status) {
|
||||
std::lock_guard<priority_recursive_mutex> sync(spiGetMutex(port));
|
||||
SPIAccumulator* accum = spiAccumulators[port].get();
|
||||
if (!accum) {
|
||||
@@ -639,7 +640,7 @@ int64_t HAL_GetSPIAccumulatorCount(int32_t port, int32_t* status) {
|
||||
*
|
||||
* @return The accumulated average value (value / count).
|
||||
*/
|
||||
double HAL_GetSPIAccumulatorAverage(int32_t port, int32_t* status) {
|
||||
double HAL_GetSPIAccumulatorAverage(HAL_SPIPort port, int32_t* status) {
|
||||
int64_t value;
|
||||
int64_t count;
|
||||
HAL_GetSPIAccumulatorOutput(port, &value, &count, status);
|
||||
@@ -656,8 +657,8 @@ double HAL_GetSPIAccumulatorAverage(int32_t port, int32_t* status) {
|
||||
* @param value Pointer to the 64-bit accumulated output.
|
||||
* @param count Pointer to the number of accumulation cycles.
|
||||
*/
|
||||
void HAL_GetSPIAccumulatorOutput(int32_t port, int64_t* value, int64_t* count,
|
||||
int32_t* status) {
|
||||
void HAL_GetSPIAccumulatorOutput(HAL_SPIPort port, int64_t* value,
|
||||
int64_t* count, int32_t* status) {
|
||||
std::lock_guard<priority_recursive_mutex> sync(spiGetMutex(port));
|
||||
SPIAccumulator* accum = spiAccumulators[port].get();
|
||||
if (!accum) {
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
|
||||
#include "SensorBase.h"
|
||||
|
||||
enum HAL_I2CPort : int32_t;
|
||||
|
||||
namespace frc {
|
||||
|
||||
/**
|
||||
@@ -20,7 +22,7 @@ namespace frc {
|
||||
*/
|
||||
class I2C : SensorBase {
|
||||
public:
|
||||
enum Port { kOnboard, kMXP };
|
||||
enum Port { kOnboard = 0, kMXP };
|
||||
|
||||
I2C(Port port, int deviceAddress);
|
||||
virtual ~I2C();
|
||||
@@ -39,7 +41,7 @@ class I2C : SensorBase {
|
||||
bool VerifySensor(int registerAddress, int count, const uint8_t* expected);
|
||||
|
||||
private:
|
||||
Port m_port;
|
||||
HAL_I2CPort m_port;
|
||||
int m_deviceAddress;
|
||||
};
|
||||
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
|
||||
#include "SensorBase.h"
|
||||
|
||||
enum HAL_SPIPort : int32_t;
|
||||
|
||||
namespace frc {
|
||||
|
||||
class DigitalOutput;
|
||||
@@ -23,8 +25,8 @@ class DigitalInput;
|
||||
*/
|
||||
class SPI : public SensorBase {
|
||||
public:
|
||||
enum Port { kOnboardCS0, kOnboardCS1, kOnboardCS2, kOnboardCS3, kMXP };
|
||||
explicit SPI(Port SPIport);
|
||||
enum Port { kOnboardCS0 = 0, kOnboardCS1, kOnboardCS2, kOnboardCS3, kMXP };
|
||||
explicit SPI(Port port);
|
||||
virtual ~SPI();
|
||||
|
||||
SPI(const SPI&) = delete;
|
||||
@@ -62,7 +64,7 @@ class SPI : public SensorBase {
|
||||
void GetAccumulatorOutput(int64_t& value, int64_t& count) const;
|
||||
|
||||
protected:
|
||||
int m_port;
|
||||
HAL_SPIPort m_port;
|
||||
bool m_msbFirst = false; // default little-endian
|
||||
bool m_sampleOnTrailing = false; // default data updated on falling edge
|
||||
bool m_clk_idle_high = false; // default clock active high
|
||||
|
||||
@@ -20,7 +20,7 @@ using namespace frc;
|
||||
* @param deviceAddress The address of the device on the I2C bus.
|
||||
*/
|
||||
I2C::I2C(Port port, int deviceAddress)
|
||||
: m_port(port), m_deviceAddress(deviceAddress) {
|
||||
: m_port(static_cast<HAL_I2CPort>(port)), m_deviceAddress(deviceAddress) {
|
||||
int32_t status = 0;
|
||||
HAL_InitializeI2C(m_port, &status);
|
||||
// wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
|
||||
@@ -19,10 +19,9 @@ using namespace frc;
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param SPIport the physical SPI port
|
||||
* @param port the physical SPI port
|
||||
*/
|
||||
SPI::SPI(Port SPIport) {
|
||||
m_port = SPIport;
|
||||
SPI::SPI(Port port) : m_port(static_cast<HAL_SPIPort>(port)) {
|
||||
int32_t status = 0;
|
||||
HAL_InitializeSPI(m_port, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
|
||||
@@ -30,14 +30,14 @@ extern "C" {
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_I2CJNI
|
||||
* Method: i2cInitialize
|
||||
* Signature: (B)V
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_I2CJNI_i2CInitialize(
|
||||
JNIEnv* env, jclass, jbyte value) {
|
||||
JNIEnv* env, jclass, jint port) {
|
||||
I2CJNI_LOG(logDEBUG) << "Calling I2CJNI i2CInititalize";
|
||||
I2CJNI_LOG(logDEBUG) << "Port: " << (jint)value;
|
||||
I2CJNI_LOG(logDEBUG) << "Port: " << port;
|
||||
int32_t status = 0;
|
||||
HAL_InitializeI2C(value, &status);
|
||||
HAL_InitializeI2C(static_cast<HAL_I2CPort>(port), &status);
|
||||
I2CJNI_LOG(logDEBUG) << "Status = " << status;
|
||||
CheckStatusForceThrow(env, status);
|
||||
}
|
||||
@@ -45,13 +45,13 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_I2CJNI_i2CInitialize(
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_I2CJNI
|
||||
* Method: i2CTransaction
|
||||
* Signature: (BBLjava/nio/ByteBuffer;BLjava/nio/ByteBuffer;B)I
|
||||
* Signature: (IBLjava/nio/ByteBuffer;BLjava/nio/ByteBuffer;B)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_I2CJNI_i2CTransaction(
|
||||
JNIEnv* env, jclass, jbyte port, jbyte address, jobject dataToSend,
|
||||
JNIEnv* env, jclass, jint port, jbyte address, jobject dataToSend,
|
||||
jbyte sendSize, jobject dataReceived, jbyte receiveSize) {
|
||||
I2CJNI_LOG(logDEBUG) << "Calling I2CJNI i2CTransaction";
|
||||
I2CJNI_LOG(logDEBUG) << "Port = " << (jint)port;
|
||||
I2CJNI_LOG(logDEBUG) << "Port = " << port;
|
||||
I2CJNI_LOG(logDEBUG) << "Address = " << (jint)address;
|
||||
uint8_t* dataToSendPtr = nullptr;
|
||||
if (dataToSend != 0) {
|
||||
@@ -63,7 +63,7 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_I2CJNI_i2CTransaction(
|
||||
(uint8_t*)env->GetDirectBufferAddress(dataReceived);
|
||||
I2CJNI_LOG(logDEBUG) << "DataReceivedPtr = " << (jint*)dataReceivedPtr;
|
||||
I2CJNI_LOG(logDEBUG) << "ReceiveSize = " << (jint)receiveSize;
|
||||
jint returnValue = HAL_TransactionI2C(port, address, dataToSendPtr, sendSize,
|
||||
jint returnValue = HAL_TransactionI2C(static_cast<HAL_I2CPort>(port), address, dataToSendPtr, sendSize,
|
||||
dataReceivedPtr, receiveSize);
|
||||
I2CJNI_LOG(logDEBUG) << "ReturnValue = " << returnValue;
|
||||
return returnValue;
|
||||
@@ -72,13 +72,13 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_I2CJNI_i2CTransaction(
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_I2CJNI
|
||||
* Method: i2CWrite
|
||||
* Signature: (BBLjava/nio/ByteBuffer;B)I
|
||||
* Signature: (IBLjava/nio/ByteBuffer;B)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_I2CJNI_i2CWrite(
|
||||
JNIEnv* env, jclass, jbyte port, jbyte address, jobject dataToSend,
|
||||
JNIEnv* env, jclass, jint port, jbyte address, jobject dataToSend,
|
||||
jbyte sendSize) {
|
||||
I2CJNI_LOG(logDEBUG) << "Calling I2CJNI i2CWrite";
|
||||
I2CJNI_LOG(logDEBUG) << "Port = " << (jint)port;
|
||||
I2CJNI_LOG(logDEBUG) << "Port = " << port;
|
||||
I2CJNI_LOG(logDEBUG) << "Address = " << (jint)address;
|
||||
uint8_t* dataToSendPtr = nullptr;
|
||||
|
||||
@@ -87,7 +87,7 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_I2CJNI_i2CWrite(
|
||||
}
|
||||
I2CJNI_LOG(logDEBUG) << "DataToSendPtr = " << dataToSendPtr;
|
||||
I2CJNI_LOG(logDEBUG) << "SendSize = " << (jint)dataToSend;
|
||||
jint returnValue = HAL_WriteI2C(port, address, dataToSendPtr, sendSize);
|
||||
jint returnValue = HAL_WriteI2C(static_cast<HAL_I2CPort>(port), address, dataToSendPtr, sendSize);
|
||||
I2CJNI_LOG(logDEBUG) << "ReturnValue = " << (jint)returnValue;
|
||||
return returnValue;
|
||||
}
|
||||
@@ -95,10 +95,10 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_I2CJNI_i2CWrite(
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_I2CJNI
|
||||
* Method: i2CRead
|
||||
* Signature: (BBLjava/nio/ByteBuffer;B)I
|
||||
* Signature: (IBLjava/nio/ByteBuffer;B)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_I2CJNI_i2CRead(
|
||||
JNIEnv* env, jclass, jbyte port, jbyte address, jobject dataReceived,
|
||||
JNIEnv* env, jclass, jint port, jbyte address, jobject dataReceived,
|
||||
jbyte receiveSize) {
|
||||
I2CJNI_LOG(logDEBUG) << "Calling I2CJNI i2CRead";
|
||||
I2CJNI_LOG(logDEBUG) << "Port = " << port;
|
||||
@@ -107,7 +107,7 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_I2CJNI_i2CRead(
|
||||
(uint8_t*)env->GetDirectBufferAddress(dataReceived);
|
||||
I2CJNI_LOG(logDEBUG) << "DataReceivedPtr = " << dataReceivedPtr;
|
||||
I2CJNI_LOG(logDEBUG) << "ReceiveSize = " << receiveSize;
|
||||
jint returnValue = HAL_ReadI2C(port, address, dataReceivedPtr, receiveSize);
|
||||
jint returnValue = HAL_ReadI2C(static_cast<HAL_I2CPort>(port), address, dataReceivedPtr, receiveSize);
|
||||
I2CJNI_LOG(logDEBUG) << "ReturnValue = " << returnValue;
|
||||
return returnValue;
|
||||
}
|
||||
@@ -115,12 +115,12 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_I2CJNI_i2CRead(
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_I2CJNI
|
||||
* Method: i2CClose
|
||||
* Signature: (B)V
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_wpilibj_hal_I2CJNI_i2CClose(JNIEnv*, jclass, jbyte value) {
|
||||
Java_edu_wpi_first_wpilibj_hal_I2CJNI_i2CClose(JNIEnv*, jclass, jint port) {
|
||||
I2CJNI_LOG(logDEBUG) << "Calling I2CJNI i2CClose";
|
||||
HAL_CloseI2C(value);
|
||||
HAL_CloseI2C(static_cast<HAL_I2CPort>(port));
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
|
||||
@@ -30,14 +30,14 @@ extern "C" {
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_SPIJNI
|
||||
* Method: spiInitialize
|
||||
* Signature: (B)V
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiInitialize(
|
||||
JNIEnv *env, jclass, jbyte port) {
|
||||
JNIEnv *env, jclass, jint port) {
|
||||
SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiInitialize";
|
||||
SPIJNI_LOG(logDEBUG) << "Port = " << (jint)port;
|
||||
int32_t status = 0;
|
||||
HAL_InitializeSPI(port, &status);
|
||||
HAL_InitializeSPI(static_cast<HAL_SPIPort>(port), &status);
|
||||
SPIJNI_LOG(logDEBUG) << "Status = " << status;
|
||||
CheckStatusForceThrow(env, status);
|
||||
}
|
||||
@@ -45,10 +45,10 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiInitialize(
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_SPIJNI
|
||||
* Method: spiTransaction
|
||||
* Signature: (BLjava/nio/ByteBuffer;Ljava/nio/ByteBuffer;B)I
|
||||
* Signature: (ILjava/nio/ByteBuffer;Ljava/nio/ByteBuffer;B)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiTransaction(
|
||||
JNIEnv *env, jclass, jbyte port, jobject dataToSend, jobject dataReceived,
|
||||
JNIEnv *env, jclass, jint port, jobject dataToSend, jobject dataReceived,
|
||||
jbyte size) {
|
||||
SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiTransaction";
|
||||
SPIJNI_LOG(logDEBUG) << "Port = " << (jint)port;
|
||||
@@ -61,7 +61,7 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiTransaction(
|
||||
SPIJNI_LOG(logDEBUG) << "Size = " << (jint)size;
|
||||
SPIJNI_LOG(logDEBUG) << "DataToSendPtr = " << dataToSendPtr;
|
||||
SPIJNI_LOG(logDEBUG) << "DataReceivedPtr = " << dataReceivedPtr;
|
||||
jint retVal = HAL_TransactionSPI(port, dataToSendPtr, dataReceivedPtr, size);
|
||||
jint retVal = HAL_TransactionSPI(static_cast<HAL_SPIPort>(port), dataToSendPtr, dataReceivedPtr, size);
|
||||
SPIJNI_LOG(logDEBUG) << "ReturnValue = " << (jint)retVal;
|
||||
return retVal;
|
||||
}
|
||||
@@ -69,10 +69,10 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiTransaction(
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_SPIJNI
|
||||
* Method: spiWrite
|
||||
* Signature: (BLjava/nio/ByteBuffer;B)I
|
||||
* Signature: (ILjava/nio/ByteBuffer;B)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiWrite(
|
||||
JNIEnv *env, jclass, jbyte port, jobject dataToSend, jbyte size) {
|
||||
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;
|
||||
@@ -81,7 +81,7 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiWrite(
|
||||
}
|
||||
SPIJNI_LOG(logDEBUG) << "Size = " << (jint)size;
|
||||
SPIJNI_LOG(logDEBUG) << "DataToSendPtr = " << dataToSendPtr;
|
||||
jint retVal = HAL_WriteSPI(port, dataToSendPtr, size);
|
||||
jint retVal = HAL_WriteSPI(static_cast<HAL_SPIPort>(port), dataToSendPtr, size);
|
||||
SPIJNI_LOG(logDEBUG) << "ReturnValue = " << (jint)retVal;
|
||||
return retVal;
|
||||
}
|
||||
@@ -89,17 +89,17 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiWrite(
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_SPIJNI
|
||||
* Method: spiRead
|
||||
* Signature: (BLjava/nio/ByteBuffer;B)I
|
||||
* Signature: (ILjava/nio/ByteBuffer;B)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiRead(
|
||||
JNIEnv *env, jclass, jbyte port, jobject dataReceived, jbyte size) {
|
||||
JNIEnv *env, jclass, jint port, jobject dataReceived, jbyte size) {
|
||||
SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiRead";
|
||||
SPIJNI_LOG(logDEBUG) << "Port = " << (jint)port;
|
||||
uint8_t *dataReceivedPtr =
|
||||
(uint8_t *)env->GetDirectBufferAddress(dataReceived);
|
||||
SPIJNI_LOG(logDEBUG) << "Size = " << (jint)size;
|
||||
SPIJNI_LOG(logDEBUG) << "DataReceivedPtr = " << dataReceivedPtr;
|
||||
jint retVal = HAL_ReadSPI(port, (uint8_t *)dataReceivedPtr, size);
|
||||
jint retVal = HAL_ReadSPI(static_cast<HAL_SPIPort>(port), (uint8_t *)dataReceivedPtr, size);
|
||||
SPIJNI_LOG(logDEBUG) << "ReturnValue = " << (jint)retVal;
|
||||
return retVal;
|
||||
}
|
||||
@@ -107,56 +107,56 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiRead(
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_SPIJNI
|
||||
* Method: spiClose
|
||||
* Signature: (B)V
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiClose(JNIEnv *, jclass, jbyte 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(port);
|
||||
HAL_CloseSPI(static_cast<HAL_SPIPort>(port));
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_SPIJNI
|
||||
* Method: spiSetSpeed
|
||||
* Signature: (BI)V
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiSetSpeed(
|
||||
JNIEnv *, jclass, jbyte port, jint speed) {
|
||||
JNIEnv *, jclass, jint port, jint speed) {
|
||||
SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiSetSpeed";
|
||||
SPIJNI_LOG(logDEBUG) << "Port = " << (jint)port;
|
||||
SPIJNI_LOG(logDEBUG) << "Speed = " << (jint)speed;
|
||||
HAL_SetSPISpeed(port, speed);
|
||||
HAL_SetSPISpeed(static_cast<HAL_SPIPort>(port), speed);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_SPIJNI
|
||||
* Method: spiSetOpts
|
||||
* Signature: (BIII)V
|
||||
* Signature: (IIII)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiSetOpts(
|
||||
JNIEnv *, jclass, jbyte port, jint msb_first, jint sample_on_trailing,
|
||||
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(port, msb_first, sample_on_trailing, clk_idle_high);
|
||||
HAL_SetSPIOpts(static_cast<HAL_SPIPort>(port), msb_first, sample_on_trailing, clk_idle_high);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_SPIJNI
|
||||
* Method: spiSetChipSelectActiveHigh
|
||||
* Signature: (B)V
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiSetChipSelectActiveHigh(
|
||||
JNIEnv *env, jclass, jbyte port) {
|
||||
JNIEnv *env, jclass, jint port) {
|
||||
SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiSetCSActiveHigh";
|
||||
SPIJNI_LOG(logDEBUG) << "Port = " << (jint)port;
|
||||
int32_t status = 0;
|
||||
HAL_SetSPIChipSelectActiveHigh(port, &status);
|
||||
HAL_SetSPIChipSelectActiveHigh(static_cast<HAL_SPIPort>(port), &status);
|
||||
SPIJNI_LOG(logDEBUG) << "Status = " << status;
|
||||
CheckStatus(env, status);
|
||||
}
|
||||
@@ -164,15 +164,15 @@ Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiSetChipSelectActiveHigh(
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_SPIJNI
|
||||
* Method: spiSetChipSelectActiveLow
|
||||
* Signature: (B)V
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiSetChipSelectActiveLow(
|
||||
JNIEnv *env, jclass, jbyte port) {
|
||||
JNIEnv *env, jclass, jint port) {
|
||||
SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiSetCSActiveLow";
|
||||
SPIJNI_LOG(logDEBUG) << "Port = " << (jint)port;
|
||||
int32_t status = 0;
|
||||
HAL_SetSPIChipSelectActiveLow(port, &status);
|
||||
HAL_SetSPIChipSelectActiveLow(static_cast<HAL_SPIPort>(port), &status);
|
||||
SPIJNI_LOG(logDEBUG) << "Status = " << status;
|
||||
CheckStatus(env, status);
|
||||
}
|
||||
@@ -180,10 +180,10 @@ Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiSetChipSelectActiveLow(
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_SPIJNI
|
||||
* Method: spiInitAccumulator
|
||||
* Signature: (BIIBIIBBZZ)V
|
||||
* Signature: (IIIBIIBBZZ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiInitAccumulator(
|
||||
JNIEnv *env, jclass, jbyte port, jint period, jint cmd, jbyte xferSize,
|
||||
JNIEnv *env, jclass, jint port, jint period, jint cmd, jbyte xferSize,
|
||||
jint validMask, jint validValue, jbyte dataShift, jbyte dataSize,
|
||||
jboolean isSigned, jboolean bigEndian) {
|
||||
SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiInitAccumulator";
|
||||
@@ -198,7 +198,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiInitAccumulator(
|
||||
SPIJNI_LOG(logDEBUG) << "IsSigned = " << (jint)isSigned;
|
||||
SPIJNI_LOG(logDEBUG) << "BigEndian = " << (jint)bigEndian;
|
||||
int32_t status = 0;
|
||||
HAL_InitSPIAccumulator(port, period, cmd, xferSize, validMask, validValue,
|
||||
HAL_InitSPIAccumulator(static_cast<HAL_SPIPort>(port), period, cmd, xferSize, validMask, validValue,
|
||||
dataShift, dataSize, isSigned, bigEndian, &status);
|
||||
SPIJNI_LOG(logDEBUG) << "Status = " << status;
|
||||
CheckStatus(env, status);
|
||||
@@ -207,14 +207,14 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiInitAccumulator(
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_SPIJNI
|
||||
* Method: spiFreeAccumulator
|
||||
* Signature: (B)V
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiFreeAccumulator(
|
||||
JNIEnv *env, jclass, jbyte port) {
|
||||
JNIEnv *env, jclass, jint port) {
|
||||
SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiFreeAccumulator";
|
||||
SPIJNI_LOG(logDEBUG) << "Port = " << (jint)port;
|
||||
int32_t status = 0;
|
||||
HAL_FreeSPIAccumulator(port, &status);
|
||||
HAL_FreeSPIAccumulator(static_cast<HAL_SPIPort>(port), &status);
|
||||
SPIJNI_LOG(logDEBUG) << "Status = " << status;
|
||||
CheckStatus(env, status);
|
||||
}
|
||||
@@ -222,15 +222,15 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiFreeAccumulator(
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_SPIJNI
|
||||
* Method: spiResetAccumulator
|
||||
* Signature: (B)V
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiResetAccumulator(
|
||||
JNIEnv *env, jclass, jbyte port) {
|
||||
JNIEnv *env, jclass, jint port) {
|
||||
SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiResetAccumulator";
|
||||
SPIJNI_LOG(logDEBUG) << "Port = " << (jint)port;
|
||||
int32_t status = 0;
|
||||
HAL_ResetSPIAccumulator(port, &status);
|
||||
HAL_ResetSPIAccumulator(static_cast<HAL_SPIPort>(port), &status);
|
||||
SPIJNI_LOG(logDEBUG) << "Status = " << status;
|
||||
CheckStatus(env, status);
|
||||
}
|
||||
@@ -238,16 +238,16 @@ Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiResetAccumulator(
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_SPIJNI
|
||||
* Method: spiSetAccumulatorCenter
|
||||
* Signature: (BI)V
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiSetAccumulatorCenter(
|
||||
JNIEnv *env, jclass, jbyte port, jint center) {
|
||||
JNIEnv *env, jclass, jint port, jint center) {
|
||||
SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiSetAccumulatorCenter";
|
||||
SPIJNI_LOG(logDEBUG) << "Port = " << (jint)port;
|
||||
SPIJNI_LOG(logDEBUG) << "Center = " << center;
|
||||
int32_t status = 0;
|
||||
HAL_SetSPIAccumulatorCenter(port, center, &status);
|
||||
HAL_SetSPIAccumulatorCenter(static_cast<HAL_SPIPort>(port), center, &status);
|
||||
SPIJNI_LOG(logDEBUG) << "Status = " << status;
|
||||
CheckStatus(env, status);
|
||||
}
|
||||
@@ -255,16 +255,16 @@ Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiSetAccumulatorCenter(
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_SPIJNI
|
||||
* Method: spiSetAccumulatorDeadband
|
||||
* Signature: (BI)V
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiSetAccumulatorDeadband(
|
||||
JNIEnv *env, jclass, jbyte port, jint deadband) {
|
||||
JNIEnv *env, jclass, jint port, jint deadband) {
|
||||
SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiSetAccumulatorDeadband";
|
||||
SPIJNI_LOG(logDEBUG) << "Port = " << (jint)port;
|
||||
SPIJNI_LOG(logDEBUG) << "Deadband = " << deadband;
|
||||
int32_t status = 0;
|
||||
HAL_SetSPIAccumulatorDeadband(port, deadband, &status);
|
||||
HAL_SetSPIAccumulatorDeadband(static_cast<HAL_SPIPort>(port), deadband, &status);
|
||||
SPIJNI_LOG(logDEBUG) << "Status = " << status;
|
||||
CheckStatus(env, status);
|
||||
}
|
||||
@@ -272,15 +272,15 @@ Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiSetAccumulatorDeadband(
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_SPIJNI
|
||||
* Method: spiGetAccumulatorLastValue
|
||||
* Signature: (B)I
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiGetAccumulatorLastValue(
|
||||
JNIEnv *env, jclass, jbyte port) {
|
||||
JNIEnv *env, jclass, jint port) {
|
||||
SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiGetAccumulatorLastValue";
|
||||
SPIJNI_LOG(logDEBUG) << "Port = " << (jint)port;
|
||||
int32_t status = 0;
|
||||
jint retVal = HAL_GetSPIAccumulatorLastValue(port, &status);
|
||||
jint retVal = HAL_GetSPIAccumulatorLastValue(static_cast<HAL_SPIPort>(port), &status);
|
||||
SPIJNI_LOG(logDEBUG) << "Status = " << status;
|
||||
SPIJNI_LOG(logDEBUG) << "ReturnValue = " << retVal;
|
||||
CheckStatus(env, status);
|
||||
@@ -290,15 +290,15 @@ Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiGetAccumulatorLastValue(
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_SPIJNI
|
||||
* Method: spiGetAccumulatorValue
|
||||
* Signature: (B)J
|
||||
* Signature: (I)J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL
|
||||
Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiGetAccumulatorValue(
|
||||
JNIEnv *env, jclass, jbyte port) {
|
||||
JNIEnv *env, jclass, jint port) {
|
||||
SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiGetAccumulatorValue";
|
||||
SPIJNI_LOG(logDEBUG) << "Port = " << (jint)port;
|
||||
int32_t status = 0;
|
||||
jlong retVal = HAL_GetSPIAccumulatorValue(port, &status);
|
||||
jlong retVal = HAL_GetSPIAccumulatorValue(static_cast<HAL_SPIPort>(port), &status);
|
||||
SPIJNI_LOG(logDEBUG) << "Status = " << status;
|
||||
SPIJNI_LOG(logDEBUG) << "ReturnValue = " << retVal;
|
||||
CheckStatus(env, status);
|
||||
@@ -308,15 +308,15 @@ Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiGetAccumulatorValue(
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_SPIJNI
|
||||
* Method: spiGetAccumulatorCount
|
||||
* Signature: (B)I
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiGetAccumulatorCount(
|
||||
JNIEnv *env, jclass, jbyte port) {
|
||||
JNIEnv *env, jclass, jint port) {
|
||||
SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiGetAccumulatorCount";
|
||||
SPIJNI_LOG(logDEBUG) << "Port = " << (jint)port;
|
||||
int32_t status = 0;
|
||||
jint retVal = HAL_GetSPIAccumulatorCount(port, &status);
|
||||
jint retVal = HAL_GetSPIAccumulatorCount(static_cast<HAL_SPIPort>(port), &status);
|
||||
SPIJNI_LOG(logDEBUG) << "Status = " << status;
|
||||
SPIJNI_LOG(logDEBUG) << "ReturnValue = " << retVal;
|
||||
CheckStatus(env, status);
|
||||
@@ -326,15 +326,15 @@ Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiGetAccumulatorCount(
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_SPIJNI
|
||||
* Method: spiGetAccumulatorAverage
|
||||
* Signature: (B)D
|
||||
* Signature: (I)D
|
||||
*/
|
||||
JNIEXPORT jdouble JNICALL
|
||||
Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiGetAccumulatorAverage(
|
||||
JNIEnv *env, jclass, jbyte port) {
|
||||
JNIEnv *env, jclass, jint port) {
|
||||
SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiGetAccumulatorAverage";
|
||||
SPIJNI_LOG(logDEBUG) << "Port = " << (jint)port;
|
||||
int32_t status = 0;
|
||||
jdouble retVal = HAL_GetSPIAccumulatorAverage(port, &status);
|
||||
jdouble retVal = HAL_GetSPIAccumulatorAverage(static_cast<HAL_SPIPort>(port), &status);
|
||||
SPIJNI_LOG(logDEBUG) << "Status = " << status;
|
||||
SPIJNI_LOG(logDEBUG) << "ReturnValue = " << retVal;
|
||||
CheckStatus(env, status);
|
||||
@@ -344,11 +344,11 @@ Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiGetAccumulatorAverage(
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_SPIJNI
|
||||
* Method: spiGetAccumulatorOutput
|
||||
* Signature: (BLjava/nio/LongBuffer;Ljava/nio/LongBuffer;)V
|
||||
* Signature: (ILjava/nio/LongBuffer;Ljava/nio/LongBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiGetAccumulatorOutput(
|
||||
JNIEnv *env, jclass, jbyte port, jobject value, jobject count) {
|
||||
JNIEnv *env, jclass, jint port, jobject value, jobject count) {
|
||||
SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiGetAccumulatorOutput";
|
||||
SPIJNI_LOG(logDEBUG) << "Port = " << (jint)port;
|
||||
int32_t status = 0;
|
||||
@@ -356,7 +356,7 @@ Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiGetAccumulatorOutput(
|
||||
jlong *valuePtr = (jlong *)env->GetDirectBufferAddress(value);
|
||||
jlong *countPtr = (jlong *)env->GetDirectBufferAddress(count);
|
||||
|
||||
HAL_GetSPIAccumulatorOutput(port, valuePtr, countPtr, &status);
|
||||
HAL_GetSPIAccumulatorOutput(static_cast<HAL_SPIPort>(port), valuePtr, countPtr, &status);
|
||||
|
||||
SPIJNI_LOG(logDEBUG) << "Status = " << status;
|
||||
SPIJNI_LOG(logDEBUG) << "Value = " << *valuePtr;
|
||||
|
||||
@@ -32,7 +32,7 @@ public class I2C extends SensorBase {
|
||||
}
|
||||
}
|
||||
|
||||
private final Port m_port;
|
||||
private final int m_port;
|
||||
private final int m_deviceAddress;
|
||||
|
||||
/**
|
||||
@@ -42,7 +42,7 @@ public class I2C extends SensorBase {
|
||||
* @param deviceAddress The address of the device on the I2C bus.
|
||||
*/
|
||||
public I2C(Port port, int deviceAddress) {
|
||||
m_port = port;
|
||||
m_port = port.value;
|
||||
m_deviceAddress = deviceAddress;
|
||||
|
||||
I2CJNI.i2CInitialize((byte) port.value);
|
||||
@@ -78,7 +78,7 @@ public class I2C extends SensorBase {
|
||||
}
|
||||
ByteBuffer dataReceivedBuffer = ByteBuffer.allocateDirect(receiveSize);
|
||||
|
||||
status = I2CJNI.i2CTransaction((byte) m_port.value, (byte) m_deviceAddress, dataToSendBuffer,
|
||||
status = I2CJNI.i2CTransaction(m_port, (byte) m_deviceAddress, dataToSendBuffer,
|
||||
(byte) sendSize, dataReceivedBuffer, (byte) receiveSize);
|
||||
if (receiveSize > 0 && dataReceived != null) {
|
||||
dataReceivedBuffer.get(dataReceived);
|
||||
@@ -116,7 +116,7 @@ public class I2C extends SensorBase {
|
||||
"dataReceived is too small, must be at least " + receiveSize);
|
||||
}
|
||||
|
||||
return I2CJNI.i2CTransaction((byte) m_port.value, (byte) m_deviceAddress, dataToSend,
|
||||
return I2CJNI.i2CTransaction(m_port, (byte) m_deviceAddress, dataToSend,
|
||||
(byte) sendSize, dataReceived, (byte) receiveSize) < 0;
|
||||
}
|
||||
|
||||
@@ -149,7 +149,7 @@ public class I2C extends SensorBase {
|
||||
ByteBuffer dataToSendBuffer = ByteBuffer.allocateDirect(2);
|
||||
dataToSendBuffer.put(buffer);
|
||||
|
||||
return I2CJNI.i2CWrite((byte) m_port.value, (byte) m_deviceAddress, dataToSendBuffer,
|
||||
return I2CJNI.i2CWrite(m_port, (byte) m_deviceAddress, dataToSendBuffer,
|
||||
(byte) buffer.length) < 0;
|
||||
}
|
||||
|
||||
@@ -165,7 +165,7 @@ public class I2C extends SensorBase {
|
||||
ByteBuffer dataToSendBuffer = ByteBuffer.allocateDirect(data.length);
|
||||
dataToSendBuffer.put(data);
|
||||
|
||||
return I2CJNI.i2CWrite((byte) m_port.value, (byte) m_deviceAddress, dataToSendBuffer,
|
||||
return I2CJNI.i2CWrite(m_port, (byte) m_deviceAddress, dataToSendBuffer,
|
||||
(byte) data.length) < 0;
|
||||
}
|
||||
|
||||
@@ -186,7 +186,7 @@ public class I2C extends SensorBase {
|
||||
"buffer is too small, must be at least " + size);
|
||||
}
|
||||
|
||||
return I2CJNI.i2CWrite((byte) m_port.value, (byte) m_deviceAddress, data, (byte) size) < 0;
|
||||
return I2CJNI.i2CWrite(m_port, (byte) m_deviceAddress, data, (byte) size) < 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -264,7 +264,7 @@ public class I2C extends SensorBase {
|
||||
|
||||
ByteBuffer dataReceivedBuffer = ByteBuffer.allocateDirect(count);
|
||||
|
||||
int retVal = I2CJNI.i2CRead((byte) m_port.value, (byte) m_deviceAddress, dataReceivedBuffer,
|
||||
int retVal = I2CJNI.i2CRead(m_port, (byte) m_deviceAddress, dataReceivedBuffer,
|
||||
(byte) count);
|
||||
dataReceivedBuffer.get(buffer);
|
||||
return retVal < 0;
|
||||
@@ -293,7 +293,7 @@ public class I2C extends SensorBase {
|
||||
throw new IllegalArgumentException("buffer is too small, must be at least " + count);
|
||||
}
|
||||
|
||||
return I2CJNI.i2CRead((byte) m_port.value, (byte) m_deviceAddress, buffer, (byte) count)
|
||||
return I2CJNI.i2CRead(m_port, (byte) m_deviceAddress, buffer, (byte) count)
|
||||
< 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ public class SPI extends SensorBase {
|
||||
|
||||
private static int devices = 0;
|
||||
|
||||
private byte m_port;
|
||||
private int m_port;
|
||||
private int m_bitOrder;
|
||||
private int m_clockPolarity;
|
||||
private int m_dataOnTrailing;
|
||||
|
||||
@@ -11,15 +11,15 @@ import java.nio.ByteBuffer;
|
||||
|
||||
@SuppressWarnings("AbbreviationAsWordInName")
|
||||
public class I2CJNI extends JNIWrapper {
|
||||
public static native void i2CInitialize(byte port);
|
||||
public static native void i2CInitialize(int port);
|
||||
|
||||
public static native int i2CTransaction(byte port, byte address, ByteBuffer dataToSend,
|
||||
public static native int i2CTransaction(int port, byte address, ByteBuffer dataToSend,
|
||||
byte sendSize, ByteBuffer dataReceived, byte receiveSize);
|
||||
|
||||
public static native int i2CWrite(byte port, byte address, ByteBuffer dataToSend, byte sendSize);
|
||||
public static native int i2CWrite(int port, byte address, ByteBuffer dataToSend, byte sendSize);
|
||||
|
||||
public static native int i2CRead(byte port, byte address, ByteBuffer dataRecieved,
|
||||
public static native int i2CRead(int port, byte address, ByteBuffer dataRecieved,
|
||||
byte receiveSize);
|
||||
|
||||
public static native void i2CClose(byte port);
|
||||
public static native void i2CClose(int port);
|
||||
}
|
||||
|
||||
@@ -12,46 +12,46 @@ import java.nio.LongBuffer;
|
||||
|
||||
@SuppressWarnings("AbbreviationAsWordInName")
|
||||
public class SPIJNI extends JNIWrapper {
|
||||
public static native void spiInitialize(byte port);
|
||||
public static native void spiInitialize(int port);
|
||||
|
||||
public static native int spiTransaction(byte port, ByteBuffer dataToSend,
|
||||
public static native int spiTransaction(int port, ByteBuffer dataToSend,
|
||||
ByteBuffer dataReceived, byte size);
|
||||
|
||||
public static native int spiWrite(byte port, ByteBuffer dataToSend, byte sendSize);
|
||||
public static native int spiWrite(int port, ByteBuffer dataToSend, byte sendSize);
|
||||
|
||||
public static native int spiRead(byte port, ByteBuffer dataReceived, byte size);
|
||||
public static native int spiRead(int port, ByteBuffer dataReceived, byte size);
|
||||
|
||||
public static native void spiClose(byte port);
|
||||
public static native void spiClose(int port);
|
||||
|
||||
public static native void spiSetSpeed(byte port, int speed);
|
||||
public static native void spiSetSpeed(int port, int speed);
|
||||
|
||||
public static native void spiSetOpts(byte port, int msbFirst, int sampleOnTrailing,
|
||||
public static native void spiSetOpts(int port, int msbFirst, int sampleOnTrailing,
|
||||
int clkIdleHigh);
|
||||
|
||||
public static native void spiSetChipSelectActiveHigh(byte port);
|
||||
public static native void spiSetChipSelectActiveHigh(int port);
|
||||
|
||||
public static native void spiSetChipSelectActiveLow(byte port);
|
||||
public static native void spiSetChipSelectActiveLow(int port);
|
||||
|
||||
public static native void spiInitAccumulator(byte port, int period, int cmd, byte xferSize,
|
||||
public static native void spiInitAccumulator(int port, int period, int cmd, byte xferSize,
|
||||
int validMask, int validValue, byte dataShift,
|
||||
byte dataSize, boolean isSigned, boolean bigEndian);
|
||||
|
||||
public static native void spiFreeAccumulator(byte port);
|
||||
public static native void spiFreeAccumulator(int port);
|
||||
|
||||
public static native void spiResetAccumulator(byte port);
|
||||
public static native void spiResetAccumulator(int port);
|
||||
|
||||
public static native void spiSetAccumulatorCenter(byte port, int center);
|
||||
public static native void spiSetAccumulatorCenter(int port, int center);
|
||||
|
||||
public static native void spiSetAccumulatorDeadband(byte port, int deadband);
|
||||
public static native void spiSetAccumulatorDeadband(int port, int deadband);
|
||||
|
||||
public static native int spiGetAccumulatorLastValue(byte port);
|
||||
public static native int spiGetAccumulatorLastValue(int port);
|
||||
|
||||
public static native long spiGetAccumulatorValue(byte port);
|
||||
public static native long spiGetAccumulatorValue(int port);
|
||||
|
||||
public static native int spiGetAccumulatorCount(byte port);
|
||||
public static native int spiGetAccumulatorCount(int port);
|
||||
|
||||
public static native double spiGetAccumulatorAverage(byte port);
|
||||
public static native double spiGetAccumulatorAverage(int port);
|
||||
|
||||
public static native void spiGetAccumulatorOutput(byte port, LongBuffer value,
|
||||
public static native void spiGetAccumulatorOutput(int port, LongBuffer value,
|
||||
LongBuffer count);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user