diff --git a/hal/include/HAL/Compressor.h b/hal/include/HAL/Compressor.h index 58b382114f..109eac7f35 100644 --- a/hal/include/HAL/Compressor.h +++ b/hal/include/HAL/Compressor.h @@ -17,13 +17,13 @@ bool HAL_CheckCompressorModule(uint8_t module); bool HAL_GetCompressor(HAL_CompressorHandle compressor_handle, int32_t* status); -void HAL_SetClosedLoopControl(HAL_CompressorHandle compressor_handle, - bool value, int32_t* status); -bool HAL_GetClosedLoopControl(HAL_CompressorHandle compressor_handle, - int32_t* status); +void HAL_SetCompressorClosedLoopControl(HAL_CompressorHandle compressor_handle, + bool value, int32_t* status); +bool HAL_GetCompressorClosedLoopControl(HAL_CompressorHandle compressor_handle, + int32_t* status); -bool HAL_GetPressureSwitch(HAL_CompressorHandle compressor_handle, - int32_t* status); +bool HAL_GetCompressorPressureSwitch(HAL_CompressorHandle compressor_handle, + int32_t* status); float HAL_GetCompressorCurrent(HAL_CompressorHandle compressor_handle, int32_t* status); @@ -39,6 +39,4 @@ bool HAL_GetCompressorNotConnectedStickyFault( HAL_CompressorHandle compressor_handle, int32_t* status); bool HAL_GetCompressorNotConnectedFault(HAL_CompressorHandle compressor_handle, int32_t* status); -void HAL_ClearAllPCMStickyFaults(HAL_CompressorHandle compressor_handle, - int32_t* status); } diff --git a/hal/include/HAL/I2C.h b/hal/include/HAL/I2C.h index fbb09e6ff0..1447d3a158 100644 --- a/hal/include/HAL/I2C.h +++ b/hal/include/HAL/I2C.h @@ -10,13 +10,13 @@ #include extern "C" { -void HAL_I2CInitialize(uint8_t port, int32_t* status); -int32_t HAL_I2CTransaction(uint8_t port, uint8_t deviceAddress, +void HAL_InitializeI2C(uint8_t port, int32_t* status); +int32_t HAL_TransactionI2C(uint8_t port, uint8_t deviceAddress, uint8_t* dataToSend, uint8_t sendSize, uint8_t* dataReceived, uint8_t receiveSize); -int32_t HAL_I2CWrite(uint8_t port, uint8_t deviceAddress, uint8_t* dataToSend, +int32_t HAL_WriteI2C(uint8_t port, uint8_t deviceAddress, uint8_t* dataToSend, uint8_t sendSize); -int32_t HAL_I2CRead(uint8_t port, uint8_t deviceAddress, uint8_t* buffer, +int32_t HAL_ReadI2C(uint8_t port, uint8_t deviceAddress, uint8_t* buffer, uint8_t count); -void HAL_I2CClose(uint8_t port); +void HAL_CloseI2C(uint8_t port); } diff --git a/hal/include/HAL/Interrupts.h b/hal/include/HAL/Interrupts.h index c775a6125e..0e3c13b64c 100644 --- a/hal/include/HAL/Interrupts.h +++ b/hal/include/HAL/Interrupts.h @@ -26,10 +26,10 @@ void HAL_EnableInterrupts(HAL_InterruptHandle interrupt_handle, int32_t* status); void HAL_DisableInterrupts(HAL_InterruptHandle interrupt_handle, int32_t* status); -double HAL_ReadRisingTimestamp(HAL_InterruptHandle interrupt_handle, - int32_t* status); -double HAL_ReadFallingTimestamp(HAL_InterruptHandle interrupt_handle, - int32_t* status); +double HAL_ReadInterruptRisingTimestamp(HAL_InterruptHandle interrupt_handle, + int32_t* status); +double HAL_ReadInterruptFallingTimestamp(HAL_InterruptHandle interrupt_handle, + int32_t* status); void HAL_RequestInterrupts(HAL_InterruptHandle interrupt_handle, HAL_Handle digitalSourceHandle, HAL_AnalogTriggerType analogTriggerType, diff --git a/hal/include/HAL/SPI.h b/hal/include/HAL/SPI.h index 834dc48d3a..e0e3ac5917 100644 --- a/hal/include/HAL/SPI.h +++ b/hal/include/HAL/SPI.h @@ -9,39 +9,35 @@ #include -#include "HAL/cpp/priority_mutex.h" - -priority_recursive_mutex& spiGetSemaphore(uint8_t port); - extern "C" { -void HAL_SpiInitialize(uint8_t port, int32_t* status); -int32_t HAL_SpiTransaction(uint8_t port, uint8_t* dataToSend, +void HAL_InitializeSPI(uint8_t port, int32_t* status); +int32_t HAL_TransactionSPI(uint8_t port, uint8_t* dataToSend, uint8_t* dataReceived, uint8_t size); -int32_t HAL_SpiWrite(uint8_t port, uint8_t* dataToSend, uint8_t sendSize); -int32_t HAL_SpiRead(uint8_t port, uint8_t* buffer, uint8_t count); -void HAL_SpiClose(uint8_t port); -void HAL_SpiSetSpeed(uint8_t port, uint32_t speed); -void HAL_SpiSetOpts(uint8_t port, int msb_first, int sample_on_trailing, +int32_t HAL_WriteSPI(uint8_t port, uint8_t* dataToSend, uint8_t sendSize); +int32_t HAL_ReadSPI(uint8_t port, uint8_t* buffer, uint8_t count); +void HAL_CloseSPI(uint8_t port); +void HAL_SetSPISpeed(uint8_t port, uint32_t speed); +void HAL_SetSPIOpts(uint8_t port, int msb_first, int sample_on_trailing, int clk_idle_high); -void HAL_SpiSetChipSelectActiveHigh(uint8_t port, int32_t* status); -void HAL_SpiSetChipSelectActiveLow(uint8_t port, int32_t* status); -int32_t HAL_SpiGetHandle(uint8_t port); -void HAL_SpiSetHandle(uint8_t port, int32_t handle); +void HAL_SetSPIChipSelectActiveHigh(uint8_t port, int32_t* status); +void HAL_SetSPIChipSelectActiveLow(uint8_t port, int32_t* status); +int32_t HAL_GetSPIHandle(uint8_t port); +void HAL_SetSPIHandle(uint8_t port, int32_t handle); -void HAL_SpiInitAccumulator(uint8_t port, uint32_t period, uint32_t cmd, +void HAL_InitSPIAccumulator(uint8_t port, uint32_t period, uint32_t cmd, uint8_t xfer_size, uint32_t valid_mask, uint32_t valid_value, uint8_t data_shift, uint8_t data_size, bool is_signed, bool big_endian, int32_t* status); -void HAL_SpiFreeAccumulator(uint8_t port, int32_t* status); -void HAL_SpiResetAccumulator(uint8_t port, int32_t* status); -void HAL_SpiSetAccumulatorCenter(uint8_t port, int32_t center, int32_t* status); -void HAL_SpiSetAccumulatorDeadband(uint8_t port, int32_t deadband, +void HAL_FreeSPIAccumulator(uint8_t port, int32_t* status); +void HAL_ResetSPIAccumulator(uint8_t port, int32_t* status); +void HAL_SetSPIAccumulatorCenter(uint8_t port, int32_t center, int32_t* status); +void HAL_SetSPIAccumulatorDeadband(uint8_t port, int32_t deadband, int32_t* status); -int32_t HAL_SpiGetAccumulatorLastValue(uint8_t port, int32_t* status); -int64_t HAL_SpiGetAccumulatorValue(uint8_t port, int32_t* status); -uint32_t HAL_SpiGetAccumulatorCount(uint8_t port, int32_t* status); -double HAL_SpiGetAccumulatorAverage(uint8_t port, int32_t* status); -void HAL_SpiGetAccumulatorOutput(uint8_t port, int64_t* value, uint32_t* count, +int32_t HAL_GetSPIAccumulatorLastValue(uint8_t port, int32_t* status); +int64_t HAL_GetSPIAccumulatorValue(uint8_t port, int32_t* status); +uint32_t HAL_GetSPIAccumulatorCount(uint8_t port, int32_t* status); +double HAL_GetSPIAccumulatorAverage(uint8_t port, int32_t* status); +void HAL_GetSPIAccumulatorOutput(uint8_t port, int64_t* value, uint32_t* count, int32_t* status); } diff --git a/hal/include/HAL/SerialPort.h b/hal/include/HAL/SerialPort.h index d0abcc97b7..a88770ac1e 100644 --- a/hal/include/HAL/SerialPort.h +++ b/hal/include/HAL/SerialPort.h @@ -10,25 +10,25 @@ #include extern "C" { -void HAL_SerialInitializePort(uint8_t port, int32_t* status); -void HAL_SerialSetBaudRate(uint8_t port, uint32_t baud, int32_t* status); -void HAL_SerialSetDataBits(uint8_t port, uint8_t bits, int32_t* status); -void HAL_SerialSetParity(uint8_t port, uint8_t parity, int32_t* status); -void HAL_SerialSetStopBits(uint8_t port, uint8_t stopBits, int32_t* status); -void HAL_SerialSetWriteMode(uint8_t port, uint8_t mode, int32_t* status); -void HAL_SerialSetFlowControl(uint8_t port, uint8_t flow, int32_t* status); -void HAL_SerialSetTimeout(uint8_t port, float timeout, int32_t* status); -void HAL_SerialEnableTermination(uint8_t port, char terminator, +void HAL_InitializeSerialPort(uint8_t port, int32_t* status); +void HAL_SetSerialBaudRate(uint8_t port, uint32_t baud, int32_t* status); +void HAL_SetSerialDataBits(uint8_t port, uint8_t bits, int32_t* status); +void HAL_SetSerialParity(uint8_t port, uint8_t parity, int32_t* status); +void HAL_SetSerialStopBits(uint8_t port, uint8_t stopBits, int32_t* status); +void HAL_SetSerialWriteMode(uint8_t port, uint8_t mode, int32_t* status); +void HAL_SetSerialFlowControl(uint8_t port, uint8_t flow, int32_t* status); +void HAL_SetSerialTimeout(uint8_t port, float timeout, int32_t* status); +void HAL_EnableSerialTermination(uint8_t port, char terminator, int32_t* status); -void HAL_SerialDisableTermination(uint8_t port, int32_t* status); -void HAL_SerialSetReadBufferSize(uint8_t port, uint32_t size, int32_t* status); -void HAL_SerialSetWriteBufferSize(uint8_t port, uint32_t size, int32_t* status); -int32_t HAL_SerialGetBytesReceived(uint8_t port, int32_t* status); -uint32_t HAL_SerialRead(uint8_t port, char* buffer, int32_t count, +void HAL_DisableSerialTermination(uint8_t port, int32_t* status); +void HAL_SetSerialReadBufferSize(uint8_t port, uint32_t size, int32_t* status); +void HAL_SetSerialWriteBufferSize(uint8_t port, uint32_t size, int32_t* status); +int32_t HAL_GetSerialBytesReceived(uint8_t port, int32_t* status); +uint32_t HAL_ReadSerial(uint8_t port, char* buffer, int32_t count, int32_t* status); -uint32_t HAL_SerialWrite(uint8_t port, const char* buffer, int32_t count, +uint32_t HAL_WriteSerial(uint8_t port, const char* buffer, int32_t count, int32_t* status); -void HAL_SerialFlush(uint8_t port, int32_t* status); -void HAL_SerialClear(uint8_t port, int32_t* status); -void HAL_SerialClose(uint8_t port, int32_t* status); +void HAL_FlushSerial(uint8_t port, int32_t* status); +void HAL_ClearSerial(uint8_t port, int32_t* status); +void HAL_CloseSerial(uint8_t port, int32_t* status); } diff --git a/hal/include/HAL/Solenoid.h b/hal/include/HAL/Solenoid.h index a4e6e1960d..3db367fe83 100644 --- a/hal/include/HAL/Solenoid.h +++ b/hal/include/HAL/Solenoid.h @@ -25,5 +25,5 @@ void HAL_SetSolenoid(HAL_SolenoidHandle solenoid_port_handle, bool value, int HAL_GetPCMSolenoidBlackList(uint8_t module, int32_t* status); bool HAL_GetPCMSolenoidVoltageStickyFault(uint8_t module, int32_t* status); bool HAL_GetPCMSolenoidVoltageFault(uint8_t module, int32_t* status); -void HAL_ClearAllPCMStickyFaults_sol(uint8_t module, int32_t* status); +void HAL_ClearAllPCMStickyFaults(uint8_t module, int32_t* status); } diff --git a/hal/lib/athena/Compressor.cpp b/hal/lib/athena/Compressor.cpp index 16095fa6d6..419b372ef3 100644 --- a/hal/lib/athena/Compressor.cpp +++ b/hal/lib/athena/Compressor.cpp @@ -52,8 +52,8 @@ bool HAL_GetCompressor(HAL_CompressorHandle compressor_handle, return value; } -void HAL_SetClosedLoopControl(HAL_CompressorHandle compressor_handle, - bool value, int32_t* status) { +void HAL_SetCompressorClosedLoopControl(HAL_CompressorHandle compressor_handle, + bool value, int32_t* status) { int16_t index = getHandleTypedIndex(compressor_handle, HAL_HandleEnum::Compressor); if (index == InvalidHandleIndex) { @@ -65,8 +65,8 @@ void HAL_SetClosedLoopControl(HAL_CompressorHandle compressor_handle, *status = module->SetClosedLoopControl(value); } -bool HAL_GetClosedLoopControl(HAL_CompressorHandle compressor_handle, - int32_t* status) { +bool HAL_GetCompressorClosedLoopControl(HAL_CompressorHandle compressor_handle, + int32_t* status) { int16_t index = getHandleTypedIndex(compressor_handle, HAL_HandleEnum::Compressor); if (index == InvalidHandleIndex) { @@ -81,8 +81,8 @@ bool HAL_GetClosedLoopControl(HAL_CompressorHandle compressor_handle, return value; } -bool HAL_GetPressureSwitch(HAL_CompressorHandle compressor_handle, - int32_t* status) { +bool HAL_GetCompressorPressureSwitch(HAL_CompressorHandle compressor_handle, + int32_t* status) { int16_t index = getHandleTypedIndex(compressor_handle, HAL_HandleEnum::Compressor); if (index == InvalidHandleIndex) { @@ -202,17 +202,4 @@ bool HAL_GetCompressorNotConnectedFault(HAL_CompressorHandle compressor_handle, return value; } -void HAL_ClearAllPCMStickyFaults(HAL_CompressorHandle compressor_handle, - int32_t* status) { - int16_t index = - getHandleTypedIndex(compressor_handle, HAL_HandleEnum::Compressor); - if (index == InvalidHandleIndex) { - *status = HAL_HANDLE_ERROR; - return; - } - PCM* module = PCM_modules[index]; - - *status = module->ClearStickyFaults(); -} - } // extern "C" diff --git a/hal/lib/athena/I2C.cpp b/hal/lib/athena/I2C.cpp index 0a81bd3faf..9f7b91ad09 100644 --- a/hal/lib/athena/I2C.cpp +++ b/hal/lib/athena/I2C.cpp @@ -31,7 +31,7 @@ extern "C" { * If opening the MXP port, also sets up the pin functions appropriately * @param port The port to open, 0 for the on-board, 1 for the MXP. */ -void HAL_I2CInitialize(uint8_t port, int32_t* status) { +void HAL_InitializeI2C(uint8_t port, int32_t* status) { initializeDigital(status); if (*status != 0) return; @@ -80,7 +80,7 @@ void HAL_I2CInitialize(uint8_t port, int32_t* status) { * @param receiveSize Number of bytes to read from the device. * @return The number of bytes read (>= 0) or -1 on transfer abort. */ -int32_t HAL_I2CTransaction(uint8_t port, uint8_t deviceAddress, +int32_t HAL_TransactionI2C(uint8_t port, uint8_t deviceAddress, uint8_t* dataToSend, uint8_t sendSize, uint8_t* dataReceived, uint8_t receiveSize) { if (port > 1) { @@ -111,7 +111,7 @@ int32_t HAL_I2CTransaction(uint8_t port, uint8_t deviceAddress, * @param data The byte to write to the register on the device. * @return The number of bytes written (>= 0) or -1 on transfer abort. */ -int32_t HAL_I2CWrite(uint8_t port, uint8_t deviceAddress, uint8_t* dataToSend, +int32_t HAL_WriteI2C(uint8_t port, uint8_t deviceAddress, uint8_t* dataToSend, uint8_t sendSize) { if (port > 1) { // Set port out of range error here @@ -141,7 +141,7 @@ int32_t HAL_I2CWrite(uint8_t port, uint8_t deviceAddress, uint8_t* dataToSend, * device. * @return The number of bytes read (>= 0) or -1 on transfer abort. */ -int32_t HAL_I2CRead(uint8_t port, uint8_t deviceAddress, uint8_t* buffer, +int32_t HAL_ReadI2C(uint8_t port, uint8_t deviceAddress, uint8_t* buffer, uint8_t count) { if (port > 1) { // Set port out of range error here @@ -157,7 +157,7 @@ int32_t HAL_I2CRead(uint8_t port, uint8_t deviceAddress, uint8_t* buffer, } } -void HAL_I2CClose(uint8_t port) { +void HAL_CloseI2C(uint8_t port) { if (port > 1) { // Set port out of range error here return; diff --git a/hal/lib/athena/Interrupts.cpp b/hal/lib/athena/Interrupts.cpp index 75f95f1a4b..34551f444e 100644 --- a/hal/lib/athena/Interrupts.cpp +++ b/hal/lib/athena/Interrupts.cpp @@ -124,8 +124,8 @@ void HAL_DisableInterrupts(HAL_InterruptHandle interrupt_handle, * This is in the same time domain as GetClock(). * @return Timestamp in seconds since boot. */ -double HAL_ReadRisingTimestamp(HAL_InterruptHandle interrupt_handle, - int32_t* status) { +double HAL_ReadInterruptRisingTimestamp(HAL_InterruptHandle interrupt_handle, + int32_t* status) { auto anInterrupt = interruptHandles.Get(interrupt_handle); if (anInterrupt == nullptr) { *status = HAL_HANDLE_ERROR; @@ -140,8 +140,8 @@ double HAL_ReadRisingTimestamp(HAL_InterruptHandle interrupt_handle, * This is in the same time domain as GetClock(). * @return Timestamp in seconds since boot. */ -double HAL_ReadFallingTimestamp(HAL_InterruptHandle interrupt_handle, - int32_t* status) { +double HAL_ReadInterruptFallingTimestamp(HAL_InterruptHandle interrupt_handle, + int32_t* status) { auto anInterrupt = interruptHandles.Get(interrupt_handle); if (anInterrupt == nullptr) { *status = HAL_HANDLE_ERROR; diff --git a/hal/lib/athena/SPI.cpp b/hal/lib/athena/SPI.cpp index 846170ffce..0aaf990bf6 100644 --- a/hal/lib/athena/SPI.cpp +++ b/hal/lib/athena/SPI.cpp @@ -12,6 +12,7 @@ #include "DigitalInternal.h" #include "HAL/DIO.h" #include "HAL/HAL.h" +#include "HAL/cpp/priority_mutex.h" #include "spilib/spi-lib.h" static_assert(sizeof(uint32_t) <= sizeof(void*), @@ -33,6 +34,19 @@ static HAL_DigitalHandle spiMXPDigitalHandle2 = HAL_kInvalidHandle; static HAL_DigitalHandle spiMXPDigitalHandle3 = HAL_kInvalidHandle; static HAL_DigitalHandle spiMXPDigitalHandle4 = HAL_kInvalidHandle; +/** + * Get the semaphore for a SPI port + * + * @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& spiGetSemaphore(uint8_t port) { + if (port < 4) + return spiOnboardSemaphore; + else + return spiMXPSemaphore; +} + extern "C" { struct SPIAccumulator { @@ -66,21 +80,21 @@ SPIAccumulator* spiAccumulators[5] = {nullptr, nullptr, nullptr, nullptr, * If opening the MXP port, also sets up the pin functions appropriately * @param port The number of the port to use. 0-3 for Onboard CS0-CS2, 4 for MXP */ -void HAL_SpiInitialize(uint8_t port, int32_t* status) { +void HAL_InitializeSPI(uint8_t port, int32_t* status) { if (spiSystem == nullptr) spiSystem = tSPI::create(status); - if (HAL_SpiGetHandle(port) != 0) return; + if (HAL_GetSPIHandle(port) != 0) return; switch (port) { case 0: - HAL_SpiSetHandle(0, spilib_open("/dev/spidev0.0")); + HAL_SetSPIHandle(0, spilib_open("/dev/spidev0.0")); break; case 1: - HAL_SpiSetHandle(1, spilib_open("/dev/spidev0.1")); + HAL_SetSPIHandle(1, spilib_open("/dev/spidev0.1")); break; case 2: - HAL_SpiSetHandle(2, spilib_open("/dev/spidev0.2")); + HAL_SetSPIHandle(2, spilib_open("/dev/spidev0.2")); break; case 3: - HAL_SpiSetHandle(3, spilib_open("/dev/spidev0.3")); + HAL_SetSPIHandle(3, spilib_open("/dev/spidev0.3")); break; case 4: initializeDigital(status); @@ -115,7 +129,7 @@ void HAL_SpiInitialize(uint8_t port, int32_t* status) { } digitalSystem->writeEnableMXPSpecialFunction( digitalSystem->readEnableMXPSpecialFunction(status) | 0x00F0, status); - HAL_SpiSetHandle(4, spilib_open("/dev/spidev1.0")); + HAL_SetSPIHandle(4, spilib_open("/dev/spidev1.0")); break; default: break; @@ -135,10 +149,10 @@ void HAL_SpiInitialize(uint8_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_SpiTransaction(uint8_t port, uint8_t* dataToSend, +int32_t HAL_TransactionSPI(uint8_t port, uint8_t* dataToSend, uint8_t* dataReceived, uint8_t size) { std::lock_guard sync(spiGetSemaphore(port)); - return spilib_writeread(HAL_SpiGetHandle(port), (const char*)dataToSend, + return spilib_writeread(HAL_GetSPIHandle(port), (const char*)dataToSend, (char*)dataReceived, (int32_t)size); } @@ -152,9 +166,9 @@ int32_t HAL_SpiTransaction(uint8_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_SpiWrite(uint8_t port, uint8_t* dataToSend, uint8_t sendSize) { +int32_t HAL_WriteSPI(uint8_t port, uint8_t* dataToSend, uint8_t sendSize) { std::lock_guard sync(spiGetSemaphore(port)); - return spilib_write(HAL_SpiGetHandle(port), (const char*)dataToSend, + return spilib_write(HAL_GetSPIHandle(port), (const char*)dataToSend, (int32_t)sendSize); } @@ -171,9 +185,9 @@ int32_t HAL_SpiWrite(uint8_t port, uint8_t* dataToSend, uint8_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_SpiRead(uint8_t port, uint8_t* buffer, uint8_t count) { +int32_t HAL_ReadSPI(uint8_t port, uint8_t* buffer, uint8_t count) { std::lock_guard sync(spiGetSemaphore(port)); - return spilib_read(HAL_SpiGetHandle(port), (char*)buffer, (int32_t)count); + return spilib_read(HAL_GetSPIHandle(port), (char*)buffer, (int32_t)count); } /** @@ -181,14 +195,14 @@ int32_t HAL_SpiRead(uint8_t port, uint8_t* buffer, uint8_t count) { * * @param port The number of the port to use. 0-3 for Onboard CS0-CS2, 4 for MXP */ -void HAL_SpiClose(uint8_t port) { +void HAL_CloseSPI(uint8_t port) { std::lock_guard sync(spiGetSemaphore(port)); if (spiAccumulators[port]) { int32_t status = 0; - HAL_SpiFreeAccumulator(port, &status); + HAL_FreeSPIAccumulator(port, &status); } - spilib_close(HAL_SpiGetHandle(port)); - HAL_SpiSetHandle(port, 0); + spilib_close(HAL_GetSPIHandle(port)); + HAL_SetSPIHandle(port, 0); if (port == 4) { HAL_FreeDIOPort(spiMXPDigitalHandle1); HAL_FreeDIOPort(spiMXPDigitalHandle2); @@ -204,9 +218,9 @@ void HAL_SpiClose(uint8_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_SpiSetSpeed(uint8_t port, uint32_t speed) { +void HAL_SetSPISpeed(uint8_t port, uint32_t speed) { std::lock_guard sync(spiGetSemaphore(port)); - spilib_setspeed(HAL_SpiGetHandle(port), speed); + spilib_setspeed(HAL_GetSPIHandle(port), speed); } /** @@ -219,10 +233,10 @@ void HAL_SpiSetSpeed(uint8_t port, uint32_t speed) { * @param clk_idle_high True to set the clock to active low, False to set the * clock active high */ -void HAL_SpiSetOpts(uint8_t port, int msb_first, int sample_on_trailing, +void HAL_SetSPIOpts(uint8_t port, int msb_first, int sample_on_trailing, int clk_idle_high) { std::lock_guard sync(spiGetSemaphore(port)); - spilib_setopts(HAL_SpiGetHandle(port), msb_first, sample_on_trailing, + spilib_setopts(HAL_GetSPIHandle(port), msb_first, sample_on_trailing, clk_idle_high); } @@ -231,7 +245,7 @@ void HAL_SpiSetOpts(uint8_t port, int msb_first, int sample_on_trailing, * * @param port The number of the port to use. 0-3 for Onboard CS0-CS2, 4 for MXP */ -void HAL_SpiSetChipSelectActiveHigh(uint8_t port, int32_t* status) { +void HAL_SetSPIChipSelectActiveHigh(uint8_t port, int32_t* status) { std::lock_guard sync(spiGetSemaphore(port)); if (port < 4) { spiSystem->writeChipSelectActiveHigh_Hdr( @@ -246,7 +260,7 @@ void HAL_SpiSetChipSelectActiveHigh(uint8_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_SpiSetChipSelectActiveLow(uint8_t port, int32_t* status) { +void HAL_SetSPIChipSelectActiveLow(uint8_t port, int32_t* status) { std::lock_guard sync(spiGetSemaphore(port)); if (port < 4) { spiSystem->writeChipSelectActiveHigh_Hdr( @@ -262,7 +276,7 @@ void HAL_SpiSetChipSelectActiveLow(uint8_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_SpiGetHandle(uint8_t port) { +int32_t HAL_GetSPIHandle(uint8_t port) { std::lock_guard sync(spiGetSemaphore(port)); switch (port) { case 0: @@ -287,7 +301,7 @@ int32_t HAL_SpiGetHandle(uint8_t port) { * MXP. * @param handle The value of the handle for the port. */ -void HAL_SpiSetHandle(uint8_t port, int32_t handle) { +void HAL_SetSPIHandle(uint8_t port, int32_t handle) { std::lock_guard sync(spiGetSemaphore(port)); switch (port) { case 0: @@ -310,26 +324,13 @@ void HAL_SpiSetHandle(uint8_t port, int32_t handle) { } } -/** - * Get the semaphore for a SPI port - * - * @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. - */ -extern "C++" priority_recursive_mutex& spiGetSemaphore(uint8_t port) { - if (port < 4) - return spiOnboardSemaphore; - else - return spiMXPSemaphore; -} - static void spiAccumulatorProcess(uint64_t currentTime, void* param) { SPIAccumulator* accum = (SPIAccumulator*)param; // perform SPI transaction uint8_t resp_b[4]; std::lock_guard sync(spiGetSemaphore(accum->port)); - spilib_writeread(HAL_SpiGetHandle(accum->port), (const char*)accum->cmd, + spilib_writeread(HAL_GetSPIHandle(accum->port), (const char*)accum->cmd, (char*)resp_b, (int32_t)accum->xfer_size); // convert from bytes @@ -390,7 +391,7 @@ static void spiAccumulatorProcess(uint64_t currentTime, void* param) { * @param is_signed Is data field signed? * @param big_endian Is device big endian? */ -void HAL_SpiInitAccumulator(uint8_t port, uint32_t period, uint32_t cmd, +void HAL_InitSPIAccumulator(uint8_t port, uint32_t period, uint32_t cmd, uint8_t xfer_size, uint32_t valid_mask, uint32_t valid_value, uint8_t data_shift, uint8_t data_size, bool is_signed, bool big_endian, @@ -434,7 +435,7 @@ void HAL_SpiInitAccumulator(uint8_t port, uint32_t period, uint32_t cmd, /** * Frees a SPI accumulator. */ -void HAL_SpiFreeAccumulator(uint8_t port, int32_t* status) { +void HAL_FreeSPIAccumulator(uint8_t port, int32_t* status) { std::lock_guard sync(spiGetSemaphore(port)); SPIAccumulator* accum = spiAccumulators[port]; if (!accum) { @@ -450,7 +451,7 @@ void HAL_SpiFreeAccumulator(uint8_t port, int32_t* status) { /** * Resets the accumulator to zero. */ -void HAL_SpiResetAccumulator(uint8_t port, int32_t* status) { +void HAL_ResetSPIAccumulator(uint8_t port, int32_t* status) { std::lock_guard sync(spiGetSemaphore(port)); SPIAccumulator* accum = spiAccumulators[port]; if (!accum) { @@ -471,7 +472,7 @@ void HAL_SpiResetAccumulator(uint8_t port, int32_t* status) { * integration work * and to take the device offset into account when integrating. */ -void HAL_SpiSetAccumulatorCenter(uint8_t port, int32_t center, +void HAL_SetSPIAccumulatorCenter(uint8_t port, int32_t center, int32_t* status) { std::lock_guard sync(spiGetSemaphore(port)); SPIAccumulator* accum = spiAccumulators[port]; @@ -485,7 +486,7 @@ void HAL_SpiSetAccumulatorCenter(uint8_t port, int32_t center, /** * Set the accumulator's deadband. */ -void HAL_SpiSetAccumulatorDeadband(uint8_t port, int32_t deadband, +void HAL_SetSPIAccumulatorDeadband(uint8_t port, int32_t deadband, int32_t* status) { std::lock_guard sync(spiGetSemaphore(port)); SPIAccumulator* accum = spiAccumulators[port]; @@ -499,7 +500,7 @@ void HAL_SpiSetAccumulatorDeadband(uint8_t port, int32_t deadband, /** * Read the last value read by the accumulator engine. */ -int32_t HAL_SpiGetAccumulatorLastValue(uint8_t port, int32_t* status) { +int32_t HAL_GetSPIAccumulatorLastValue(uint8_t port, int32_t* status) { std::lock_guard sync(spiGetSemaphore(port)); SPIAccumulator* accum = spiAccumulators[port]; if (!accum) { @@ -514,7 +515,7 @@ int32_t HAL_SpiGetAccumulatorLastValue(uint8_t port, int32_t* status) { * * @return The 64-bit value accumulated since the last Reset(). */ -int64_t HAL_SpiGetAccumulatorValue(uint8_t port, int32_t* status) { +int64_t HAL_GetSPIAccumulatorValue(uint8_t port, int32_t* status) { std::lock_guard sync(spiGetSemaphore(port)); SPIAccumulator* accum = spiAccumulators[port]; if (!accum) { @@ -532,7 +533,7 @@ int64_t HAL_SpiGetAccumulatorValue(uint8_t port, int32_t* status) { * * @return The number of times samples from the channel were accumulated. */ -uint32_t HAL_SpiGetAccumulatorCount(uint8_t port, int32_t* status) { +uint32_t HAL_GetSPIAccumulatorCount(uint8_t port, int32_t* status) { std::lock_guard sync(spiGetSemaphore(port)); SPIAccumulator* accum = spiAccumulators[port]; if (!accum) { @@ -547,10 +548,10 @@ uint32_t HAL_SpiGetAccumulatorCount(uint8_t port, int32_t* status) { * * @return The accumulated average value (value / count). */ -double HAL_SpiGetAccumulatorAverage(uint8_t port, int32_t* status) { +double HAL_GetSPIAccumulatorAverage(uint8_t port, int32_t* status) { int64_t value; uint32_t count; - HAL_SpiGetAccumulatorOutput(port, &value, &count, status); + HAL_GetAccumulatorOutput(port, &value, &count, status); if (count == 0) return 0.0; return ((double)value) / count; } @@ -564,7 +565,7 @@ double HAL_SpiGetAccumulatorAverage(uint8_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_SpiGetAccumulatorOutput(uint8_t port, int64_t* value, uint32_t* count, +void HAL_GetSPIAccumulatorOutput(uint8_t port, int64_t* value, uint32_t* count, int32_t* status) { std::lock_guard sync(spiGetSemaphore(port)); SPIAccumulator* accum = spiAccumulators[port]; diff --git a/hal/lib/athena/SerialPort.cpp b/hal/lib/athena/SerialPort.cpp index 71c825c1b8..530536694b 100644 --- a/hal/lib/athena/SerialPort.cpp +++ b/hal/lib/athena/SerialPort.cpp @@ -14,7 +14,7 @@ static uint32_t m_portHandle[2]; extern "C" { -void HAL_SerialInitializePort(uint8_t port, int32_t* status) { +void HAL_InitializeSerialPort(uint8_t port, int32_t* status) { char const* portName; if (m_resourceManagerHandle == 0) @@ -32,44 +32,44 @@ void HAL_SerialInitializePort(uint8_t port, int32_t* status) { if (*status > 0) *status = 0; } -void HAL_SerialSetBaudRate(uint8_t port, uint32_t baud, int32_t* status) { +void HAL_SetSerialBaudRate(uint8_t port, uint32_t baud, int32_t* status) { *status = viSetAttribute(m_portHandle[port], VI_ATTR_ASRL_BAUD, baud); if (*status > 0) *status = 0; } -void HAL_SerialSetDataBits(uint8_t port, uint8_t bits, int32_t* status) { +void HAL_SetSerialDataBits(uint8_t port, uint8_t bits, int32_t* status) { *status = viSetAttribute(m_portHandle[port], VI_ATTR_ASRL_DATA_BITS, bits); if (*status > 0) *status = 0; } -void HAL_SerialSetParity(uint8_t port, uint8_t parity, int32_t* status) { +void HAL_SetSerialParity(uint8_t port, uint8_t parity, int32_t* status) { *status = viSetAttribute(m_portHandle[port], VI_ATTR_ASRL_PARITY, parity); if (*status > 0) *status = 0; } -void HAL_SerialSetStopBits(uint8_t port, uint8_t stopBits, int32_t* status) { +void HAL_SetSerialStopBits(uint8_t port, uint8_t stopBits, int32_t* status) { *status = viSetAttribute(m_portHandle[port], VI_ATTR_ASRL_STOP_BITS, stopBits); if (*status > 0) *status = 0; } -void HAL_SerialSetWriteMode(uint8_t port, uint8_t mode, int32_t* status) { +void HAL_SetSerialWriteMode(uint8_t port, uint8_t mode, int32_t* status) { *status = viSetAttribute(m_portHandle[port], VI_ATTR_WR_BUF_OPER_MODE, mode); if (*status > 0) *status = 0; } -void HAL_SerialSetFlowControl(uint8_t port, uint8_t flow, int32_t* status) { +void HAL_SetSerialFlowControl(uint8_t port, uint8_t flow, int32_t* status) { *status = viSetAttribute(m_portHandle[port], VI_ATTR_ASRL_FLOW_CNTRL, flow); if (*status > 0) *status = 0; } -void HAL_SerialSetTimeout(uint8_t port, float timeout, int32_t* status) { +void HAL_SetSerialTimeout(uint8_t port, float timeout, int32_t* status) { *status = viSetAttribute(m_portHandle[port], VI_ATTR_TMO_VALUE, (uint32_t)(timeout * 1e3)); if (*status > 0) *status = 0; } -void HAL_SerialEnableTermination(uint8_t port, char terminator, +void HAL_EnableSerialTermination(uint8_t port, char terminator, int32_t* status) { viSetAttribute(m_portHandle[port], VI_ATTR_TERMCHAR_EN, VI_TRUE); viSetAttribute(m_portHandle[port], VI_ATTR_TERMCHAR, terminator); @@ -78,25 +78,25 @@ void HAL_SerialEnableTermination(uint8_t port, char terminator, if (*status > 0) *status = 0; } -void HAL_SerialDisableTermination(uint8_t port, int32_t* status) { +void HAL_DisableSerialTermination(uint8_t port, int32_t* status) { viSetAttribute(m_portHandle[port], VI_ATTR_TERMCHAR_EN, VI_FALSE); *status = viSetAttribute(m_portHandle[port], VI_ATTR_ASRL_END_IN, VI_ASRL_END_NONE); if (*status > 0) *status = 0; } -void HAL_SerialSetReadBufferSize(uint8_t port, uint32_t size, int32_t* status) { +void HAL_SetSerialReadBufferSize(uint8_t port, uint32_t size, int32_t* status) { *status = viSetBuf(m_portHandle[port], VI_READ_BUF, size); if (*status > 0) *status = 0; } -void HAL_SerialSetWriteBufferSize(uint8_t port, uint32_t size, +void HAL_SetSerialWriteBufferSize(uint8_t port, uint32_t size, int32_t* status) { *status = viSetBuf(m_portHandle[port], VI_WRITE_BUF, size); if (*status > 0) *status = 0; } -int32_t HAL_SerialGetBytesReceived(uint8_t port, int32_t* status) { +int32_t HAL_GetSerialBytesReceived(uint8_t port, int32_t* status) { int32_t bytes = 0; *status = viGetAttribute(m_portHandle[port], VI_ATTR_ASRL_AVAIL_NUM, &bytes); @@ -104,7 +104,7 @@ int32_t HAL_SerialGetBytesReceived(uint8_t port, int32_t* status) { return bytes; } -uint32_t HAL_SerialRead(uint8_t port, char* buffer, int32_t count, +uint32_t HAL_ReadSerial(uint8_t port, char* buffer, int32_t count, int32_t* status) { uint32_t retCount = 0; @@ -114,14 +114,14 @@ uint32_t HAL_SerialRead(uint8_t port, char* buffer, int32_t count, if (*status == VI_ERROR_IO || *status == VI_ERROR_ASRL_OVERRUN || *status == VI_ERROR_ASRL_FRAMING || *status == VI_ERROR_ASRL_PARITY) { int32_t localStatus = 0; - HAL_SerialClear(port, &localStatus); + HAL_ClearSerial(port, &localStatus); } if (*status == VI_ERROR_TMO || *status > 0) *status = 0; return retCount; } -uint32_t HAL_SerialWrite(uint8_t port, const char* buffer, int32_t count, +uint32_t HAL_WriteSerial(uint8_t port, const char* buffer, int32_t count, int32_t* status) { uint32_t retCount = 0; @@ -132,17 +132,17 @@ uint32_t HAL_SerialWrite(uint8_t port, const char* buffer, int32_t count, return retCount; } -void HAL_SerialFlush(uint8_t port, int32_t* status) { +void HAL_FlushSerial(uint8_t port, int32_t* status) { *status = viFlush(m_portHandle[port], VI_WRITE_BUF); if (*status > 0) *status = 0; } -void HAL_SerialClear(uint8_t port, int32_t* status) { +void HAL_ClearSerial(uint8_t port, int32_t* status) { *status = viClear(m_portHandle[port]); if (*status > 0) *status = 0; } -void HAL_SerialClose(uint8_t port, int32_t* status) { +void HAL_CloseSerial(uint8_t port, int32_t* status) { *status = viClose(m_portHandle[port]); if (*status > 0) *status = 0; } diff --git a/hal/lib/athena/Solenoid.cpp b/hal/lib/athena/Solenoid.cpp index 7d79eff687..089c277118 100644 --- a/hal/lib/athena/Solenoid.cpp +++ b/hal/lib/athena/Solenoid.cpp @@ -141,7 +141,7 @@ bool HAL_GetPCMSolenoidVoltageFault(uint8_t module, int32_t* status) { return value; } -void HAL_ClearAllPCMStickyFaults_sol(uint8_t module, int32_t* status) { +void HAL_ClearAllPCMStickyFaults(uint8_t module, int32_t* status) { if (module >= kNumPCMModules) { *status = PARAMETER_OUT_OF_RANGE; return; diff --git a/wpilibc/athena/include/Compressor.h b/wpilibc/athena/include/Compressor.h index f69ef63482..e551a54a3b 100644 --- a/wpilibc/athena/include/Compressor.h +++ b/wpilibc/athena/include/Compressor.h @@ -58,6 +58,7 @@ class Compressor : public SensorBase, private: void SetCompressor(bool on); + uint8_t m_module; std::shared_ptr m_table; }; diff --git a/wpilibc/athena/src/Compressor.cpp b/wpilibc/athena/src/Compressor.cpp index 73f04d6b12..ce8345baea 100644 --- a/wpilibc/athena/src/Compressor.cpp +++ b/wpilibc/athena/src/Compressor.cpp @@ -12,9 +12,9 @@ * * @param module The PCM ID to use (0-62) */ -Compressor::Compressor(uint8_t pcmID) { +Compressor::Compressor(uint8_t pcmID) : m_module(pcmID) { int32_t status = 0; - m_compressorHandle = HAL_InitializeCompressor(pcmID, &status); + m_compressorHandle = HAL_InitializeCompressor(m_module, &status); if (status != 0) { wpi_setErrorWithContext(status, HAL_GetErrorMessage(status)); return; @@ -69,7 +69,7 @@ bool Compressor::GetPressureSwitchValue() const { int32_t status = 0; bool value; - value = HAL_GetPressureSwitch(m_compressorHandle, &status); + value = HAL_GetCompressorPressureSwitch(m_compressorHandle, &status); if (status) { wpi_setWPIError(Timeout); @@ -108,7 +108,7 @@ void Compressor::SetClosedLoopControl(bool on) { if (StatusIsFatal()) return; int32_t status = 0; - HAL_SetClosedLoopControl(m_compressorHandle, on, &status); + HAL_SetCompressorClosedLoopControl(m_compressorHandle, on, &status); if (status) { wpi_setWPIError(Timeout); @@ -127,7 +127,7 @@ bool Compressor::GetClosedLoopControl() const { int32_t status = 0; bool value; - value = HAL_GetClosedLoopControl(m_compressorHandle, &status); + value = HAL_GetCompressorClosedLoopControl(m_compressorHandle, &status); if (status) { wpi_setWPIError(Timeout); @@ -282,7 +282,7 @@ void Compressor::ClearAllPCMStickyFaults() { if (StatusIsFatal()) return; int32_t status = 0; - HAL_ClearAllPCMStickyFaults(m_compressorHandle, &status); + HAL_ClearAllPCMStickyFaults(m_module, &status); if (status) { wpi_setWPIError(Timeout); diff --git a/wpilibc/athena/src/I2C.cpp b/wpilibc/athena/src/I2C.cpp index 817e01dee1..827469e782 100644 --- a/wpilibc/athena/src/I2C.cpp +++ b/wpilibc/athena/src/I2C.cpp @@ -18,7 +18,7 @@ I2C::I2C(Port port, uint8_t deviceAddress) : m_port(port), m_deviceAddress(deviceAddress) { int32_t status = 0; - HAL_I2CInitialize(m_port, &status); + HAL_InitializeI2C(m_port, &status); // wpi_setErrorWithContext(status, HAL_GetErrorMessage(status)); HAL_Report(HALUsageReporting::kResourceType_I2C, deviceAddress); @@ -27,7 +27,7 @@ I2C::I2C(Port port, uint8_t deviceAddress) /** * Destructor. */ -I2C::~I2C() { HAL_I2CClose(m_port); } +I2C::~I2C() { HAL_CloseI2C(m_port); } /** * Generic transaction. @@ -44,7 +44,7 @@ I2C::~I2C() { HAL_I2CClose(m_port); } bool I2C::Transaction(uint8_t* dataToSend, uint8_t sendSize, uint8_t* dataReceived, uint8_t receiveSize) { int32_t status = 0; - status = HAL_I2CTransaction(m_port, m_deviceAddress, dataToSend, sendSize, + status = HAL_TransactionI2C(m_port, m_deviceAddress, dataToSend, sendSize, dataReceived, receiveSize); // wpi_setErrorWithContext(status, HAL_GetErrorMessage(status)); return status < receiveSize; @@ -76,7 +76,7 @@ bool I2C::Write(uint8_t registerAddress, uint8_t data) { buffer[0] = registerAddress; buffer[1] = data; int32_t status = 0; - status = HAL_I2CWrite(m_port, m_deviceAddress, buffer, sizeof(buffer)); + status = HAL_WriteI2C(m_port, m_deviceAddress, buffer, sizeof(buffer)); return status < static_cast(sizeof(buffer)); } @@ -92,7 +92,7 @@ bool I2C::Write(uint8_t registerAddress, uint8_t data) { */ bool I2C::WriteBulk(uint8_t* data, uint8_t count) { int32_t status = 0; - status = HAL_I2CWrite(m_port, m_deviceAddress, data, count); + status = HAL_WriteI2C(m_port, m_deviceAddress, data, count); return status < count; } @@ -142,7 +142,7 @@ bool I2C::ReadOnly(uint8_t count, uint8_t* buffer) { return true; } int32_t status = 0; - status = HAL_I2CRead(m_port, m_deviceAddress, buffer, count); + status = HAL_ReadI2C(m_port, m_deviceAddress, buffer, count); return status < count; } diff --git a/wpilibc/athena/src/InterruptableSensorBase.cpp b/wpilibc/athena/src/InterruptableSensorBase.cpp index 4e48b58b8c..22d2c2ca81 100644 --- a/wpilibc/athena/src/InterruptableSensorBase.cpp +++ b/wpilibc/athena/src/InterruptableSensorBase.cpp @@ -146,7 +146,7 @@ double InterruptableSensorBase::ReadRisingTimestamp() { if (StatusIsFatal()) return 0.0; wpi_assert(m_interrupt != HAL_kInvalidHandle); int32_t status = 0; - double timestamp = HAL_ReadRisingTimestamp(m_interrupt, &status); + double timestamp = HAL_ReadInterruptRisingTimestamp(m_interrupt, &status); wpi_setErrorWithContext(status, HAL_GetErrorMessage(status)); return timestamp; } @@ -164,7 +164,7 @@ double InterruptableSensorBase::ReadFallingTimestamp() { if (StatusIsFatal()) return 0.0; wpi_assert(m_interrupt != HAL_kInvalidHandle); int32_t status = 0; - double timestamp = HAL_ReadFallingTimestamp(m_interrupt, &status); + double timestamp = HAL_ReadInterruptFallingTimestamp(m_interrupt, &status); wpi_setErrorWithContext(status, HAL_GetErrorMessage(status)); return timestamp; } diff --git a/wpilibc/athena/src/SPI.cpp b/wpilibc/athena/src/SPI.cpp index 15e1732b31..a0ec8f0663 100644 --- a/wpilibc/athena/src/SPI.cpp +++ b/wpilibc/athena/src/SPI.cpp @@ -20,7 +20,7 @@ SPI::SPI(Port SPIport) { m_port = SPIport; int32_t status = 0; - HAL_SpiInitialize(m_port, &status); + HAL_InitializeSPI(m_port, &status); wpi_setErrorWithContext(status, HAL_GetErrorMessage(status)); static int32_t instances = 0; @@ -31,7 +31,7 @@ SPI::SPI(Port SPIport) { /** * Destructor. */ -SPI::~SPI() { HAL_SpiClose(m_port); } +SPI::~SPI() { HAL_CloseSPI(m_port); } /** * Configure the rate of the generated clock signal. @@ -41,7 +41,7 @@ SPI::~SPI() { HAL_SpiClose(m_port); } * * @param hz The clock rate in Hertz. */ -void SPI::SetClockRate(double hz) { HAL_SpiSetSpeed(m_port, hz); } +void SPI::SetClockRate(double hz) { HAL_SetSPISpeed(m_port, hz); } /** * Configure the order that bits are sent and received on the wire @@ -49,7 +49,7 @@ void SPI::SetClockRate(double hz) { HAL_SpiSetSpeed(m_port, hz); } */ void SPI::SetMSBFirst() { m_msbFirst = true; - HAL_SpiSetOpts(m_port, (int)m_msbFirst, (int)m_sampleOnTrailing, + HAL_SetSPIOpts(m_port, (int)m_msbFirst, (int)m_sampleOnTrailing, (int)m_clk_idle_high); } @@ -59,7 +59,7 @@ void SPI::SetMSBFirst() { */ void SPI::SetLSBFirst() { m_msbFirst = false; - HAL_SpiSetOpts(m_port, (int)m_msbFirst, (int)m_sampleOnTrailing, + HAL_SetSPIOpts(m_port, (int)m_msbFirst, (int)m_sampleOnTrailing, (int)m_clk_idle_high); } @@ -69,7 +69,7 @@ void SPI::SetLSBFirst() { */ void SPI::SetSampleDataOnFalling() { m_sampleOnTrailing = true; - HAL_SpiSetOpts(m_port, (int)m_msbFirst, (int)m_sampleOnTrailing, + HAL_SetSPIOpts(m_port, (int)m_msbFirst, (int)m_sampleOnTrailing, (int)m_clk_idle_high); } @@ -79,7 +79,7 @@ void SPI::SetSampleDataOnFalling() { */ void SPI::SetSampleDataOnRising() { m_sampleOnTrailing = false; - HAL_SpiSetOpts(m_port, (int)m_msbFirst, (int)m_sampleOnTrailing, + HAL_SetSPIOpts(m_port, (int)m_msbFirst, (int)m_sampleOnTrailing, (int)m_clk_idle_high); } @@ -89,7 +89,7 @@ void SPI::SetSampleDataOnRising() { */ void SPI::SetClockActiveLow() { m_clk_idle_high = true; - HAL_SpiSetOpts(m_port, (int)m_msbFirst, (int)m_sampleOnTrailing, + HAL_SetSPIOpts(m_port, (int)m_msbFirst, (int)m_sampleOnTrailing, (int)m_clk_idle_high); } @@ -99,7 +99,7 @@ void SPI::SetClockActiveLow() { */ void SPI::SetClockActiveHigh() { m_clk_idle_high = false; - HAL_SpiSetOpts(m_port, (int)m_msbFirst, (int)m_sampleOnTrailing, + HAL_SetSPIOpts(m_port, (int)m_msbFirst, (int)m_sampleOnTrailing, (int)m_clk_idle_high); } @@ -108,7 +108,7 @@ void SPI::SetClockActiveHigh() { */ void SPI::SetChipSelectActiveHigh() { int32_t status = 0; - HAL_SpiSetChipSelectActiveHigh(m_port, &status); + HAL_SetSPIChipSelectActiveHigh(m_port, &status); wpi_setErrorWithContext(status, HAL_GetErrorMessage(status)); } @@ -117,7 +117,7 @@ void SPI::SetChipSelectActiveHigh() { */ void SPI::SetChipSelectActiveLow() { int32_t status = 0; - HAL_SpiSetChipSelectActiveLow(m_port, &status); + HAL_SetSPIChipSelectActiveLow(m_port, &status); wpi_setErrorWithContext(status, HAL_GetErrorMessage(status)); } @@ -130,7 +130,7 @@ void SPI::SetChipSelectActiveLow() { */ int32_t SPI::Write(uint8_t* data, uint8_t size) { int32_t retVal = 0; - retVal = HAL_SpiWrite(m_port, data, size); + retVal = HAL_WriteSPI(m_port, data, size); return retVal; } @@ -152,9 +152,9 @@ int32_t SPI::Read(bool initiate, uint8_t* dataReceived, uint8_t size) { if (initiate) { auto dataToSend = new uint8_t[size]; std::memset(dataToSend, 0, size); - retVal = HAL_SpiTransaction(m_port, dataToSend, dataReceived, size); + retVal = HAL_TransactionSPI(m_port, dataToSend, dataReceived, size); } else - retVal = HAL_SpiRead(m_port, dataReceived, size); + retVal = HAL_ReadSPI(m_port, dataReceived, size); return retVal; } @@ -168,7 +168,7 @@ int32_t SPI::Read(bool initiate, uint8_t* dataReceived, uint8_t size) { int32_t SPI::Transaction(uint8_t* dataToSend, uint8_t* dataReceived, uint8_t size) { int32_t retVal = 0; - retVal = HAL_SpiTransaction(m_port, dataToSend, dataReceived, size); + retVal = HAL_TransactionSPI(m_port, dataToSend, dataReceived, size); return retVal; } @@ -192,7 +192,7 @@ void SPI::InitAccumulator(double period, uint32_t cmd, uint8_t xfer_size, uint8_t data_shift, uint8_t data_size, bool is_signed, bool big_endian) { int32_t status = 0; - HAL_SpiInitAccumulator(m_port, (uint32_t)(period * 1e6), cmd, xfer_size, + HAL_InitSPIAccumulator(m_port, (uint32_t)(period * 1e6), cmd, xfer_size, valid_mask, valid_value, data_shift, data_size, is_signed, big_endian, &status); wpi_setErrorWithContext(status, HAL_GetErrorMessage(status)); @@ -203,7 +203,7 @@ void SPI::InitAccumulator(double period, uint32_t cmd, uint8_t xfer_size, */ void SPI::FreeAccumulator() { int32_t status = 0; - HAL_SpiFreeAccumulator(m_port, &status); + HAL_FreeSPIAccumulator(m_port, &status); wpi_setErrorWithContext(status, HAL_GetErrorMessage(status)); } @@ -212,7 +212,7 @@ void SPI::FreeAccumulator() { */ void SPI::ResetAccumulator() { int32_t status = 0; - HAL_SpiResetAccumulator(m_port, &status); + HAL_ResetSPIAccumulator(m_port, &status); wpi_setErrorWithContext(status, HAL_GetErrorMessage(status)); } @@ -226,7 +226,7 @@ void SPI::ResetAccumulator() { */ void SPI::SetAccumulatorCenter(int32_t center) { int32_t status = 0; - HAL_SpiSetAccumulatorCenter(m_port, center, &status); + HAL_SetSPIAccumulatorCenter(m_port, center, &status); wpi_setErrorWithContext(status, HAL_GetErrorMessage(status)); } @@ -235,7 +235,7 @@ void SPI::SetAccumulatorCenter(int32_t center) { */ void SPI::SetAccumulatorDeadband(int32_t deadband) { int32_t status = 0; - HAL_SpiSetAccumulatorDeadband(m_port, deadband, &status); + HAL_SetSPIAccumulatorDeadband(m_port, deadband, &status); wpi_setErrorWithContext(status, HAL_GetErrorMessage(status)); } @@ -244,7 +244,7 @@ void SPI::SetAccumulatorDeadband(int32_t deadband) { */ int32_t SPI::GetAccumulatorLastValue() const { int32_t status = 0; - int32_t retVal = HAL_SpiGetAccumulatorLastValue(m_port, &status); + int32_t retVal = HAL_GetSPIAccumulatorLastValue(m_port, &status); wpi_setErrorWithContext(status, HAL_GetErrorMessage(status)); return retVal; } @@ -256,7 +256,7 @@ int32_t SPI::GetAccumulatorLastValue() const { */ int64_t SPI::GetAccumulatorValue() const { int32_t status = 0; - int64_t retVal = HAL_SpiGetAccumulatorValue(m_port, &status); + int64_t retVal = HAL_GetSPIAccumulatorValue(m_port, &status); wpi_setErrorWithContext(status, HAL_GetErrorMessage(status)); return retVal; } @@ -271,7 +271,7 @@ int64_t SPI::GetAccumulatorValue() const { */ uint32_t SPI::GetAccumulatorCount() const { int32_t status = 0; - uint32_t retVal = HAL_SpiGetAccumulatorCount(m_port, &status); + uint32_t retVal = HAL_GetSPIAccumulatorCount(m_port, &status); wpi_setErrorWithContext(status, HAL_GetErrorMessage(status)); return retVal; } @@ -283,7 +283,7 @@ uint32_t SPI::GetAccumulatorCount() const { */ double SPI::GetAccumulatorAverage() const { int32_t status = 0; - double retVal = HAL_SpiGetAccumulatorAverage(m_port, &status); + double retVal = HAL_GetSPIAccumulatorAverage(m_port, &status); wpi_setErrorWithContext(status, HAL_GetErrorMessage(status)); return retVal; } @@ -299,6 +299,6 @@ double SPI::GetAccumulatorAverage() const { */ void SPI::GetAccumulatorOutput(int64_t& value, uint32_t& count) const { int32_t status = 0; - HAL_SpiGetAccumulatorOutput(m_port, &value, &count, &status); + HAL_GetSPIAccumulatorOutput(m_port, &value, &count, &status); wpi_setErrorWithContext(status, HAL_GetErrorMessage(status)); } diff --git a/wpilibc/athena/src/SerialPort.cpp b/wpilibc/athena/src/SerialPort.cpp index a62921e78e..007623ee6c 100644 --- a/wpilibc/athena/src/SerialPort.cpp +++ b/wpilibc/athena/src/SerialPort.cpp @@ -30,15 +30,15 @@ SerialPort::SerialPort(uint32_t baudRate, Port port, uint8_t dataBits, m_port = port; - HAL_SerialInitializePort(port, &status); + HAL_InitializeSerialPort(port, &status); wpi_setErrorWithContext(status, HAL_GetErrorMessage(status)); - HAL_SerialSetBaudRate(port, baudRate, &status); + HAL_SetSerialBaudRate(port, baudRate, &status); wpi_setErrorWithContext(status, HAL_GetErrorMessage(status)); - HAL_SerialSetDataBits(port, dataBits, &status); + HAL_SetSerialDataBits(port, dataBits, &status); wpi_setErrorWithContext(status, HAL_GetErrorMessage(status)); - HAL_SerialSetParity(port, parity, &status); + HAL_SetSerialParity(port, parity, &status); wpi_setErrorWithContext(status, HAL_GetErrorMessage(status)); - HAL_SerialSetStopBits(port, stopBits, &status); + HAL_SetSerialStopBits(port, stopBits, &status); wpi_setErrorWithContext(status, HAL_GetErrorMessage(status)); // Set the default timeout to 5 seconds. @@ -61,7 +61,7 @@ SerialPort::SerialPort(uint32_t baudRate, Port port, uint8_t dataBits, */ SerialPort::~SerialPort() { int32_t status = 0; - HAL_SerialClose(m_port, &status); + HAL_CloseSerial(m_port, &status); wpi_setErrorWithContext(status, HAL_GetErrorMessage(status)); } @@ -72,7 +72,7 @@ SerialPort::~SerialPort() { */ void SerialPort::SetFlowControl(SerialPort::FlowControl flowControl) { int32_t status = 0; - HAL_SerialSetFlowControl(m_port, flowControl, &status); + HAL_SetSerialFlowControl(m_port, flowControl, &status); wpi_setErrorWithContext(status, HAL_GetErrorMessage(status)); } @@ -87,7 +87,7 @@ void SerialPort::SetFlowControl(SerialPort::FlowControl flowControl) { */ void SerialPort::EnableTermination(char terminator) { int32_t status = 0; - HAL_SerialEnableTermination(m_port, terminator, &status); + HAL_EnableSerialTermination(m_port, terminator, &status); wpi_setErrorWithContext(status, HAL_GetErrorMessage(status)); } @@ -96,7 +96,7 @@ void SerialPort::EnableTermination(char terminator) { */ void SerialPort::DisableTermination() { int32_t status = 0; - HAL_SerialDisableTermination(m_port, &status); + HAL_DisableSerialTermination(m_port, &status); wpi_setErrorWithContext(status, HAL_GetErrorMessage(status)); } @@ -107,7 +107,7 @@ void SerialPort::DisableTermination() { */ int32_t SerialPort::GetBytesReceived() { int32_t status = 0; - int32_t retVal = HAL_SerialGetBytesReceived(m_port, &status); + int32_t retVal = HAL_GetSerialBytesReceived(m_port, &status); wpi_setErrorWithContext(status, HAL_GetErrorMessage(status)); return retVal; } @@ -121,7 +121,7 @@ int32_t SerialPort::GetBytesReceived() { */ uint32_t SerialPort::Read(char* buffer, int32_t count) { int32_t status = 0; - int32_t retVal = HAL_SerialRead(m_port, buffer, count, &status); + int32_t retVal = HAL_ReadSerial(m_port, buffer, count, &status); wpi_setErrorWithContext(status, HAL_GetErrorMessage(status)); return retVal; } @@ -135,7 +135,7 @@ uint32_t SerialPort::Read(char* buffer, int32_t count) { */ uint32_t SerialPort::Write(const std::string& buffer, int32_t count) { int32_t status = 0; - int32_t retVal = HAL_SerialWrite(m_port, buffer.c_str(), count, &status); + int32_t retVal = HAL_WriteSerial(m_port, buffer.c_str(), count, &status); wpi_setErrorWithContext(status, HAL_GetErrorMessage(status)); return retVal; } @@ -150,7 +150,7 @@ uint32_t SerialPort::Write(const std::string& buffer, int32_t count) { */ void SerialPort::SetTimeout(float timeout) { int32_t status = 0; - HAL_SerialSetTimeout(m_port, timeout, &status); + HAL_SetSerialTimeout(m_port, timeout, &status); wpi_setErrorWithContext(status, HAL_GetErrorMessage(status)); } @@ -168,7 +168,7 @@ void SerialPort::SetTimeout(float timeout) { */ void SerialPort::SetReadBufferSize(uint32_t size) { int32_t status = 0; - HAL_SerialSetReadBufferSize(m_port, size, &status); + HAL_SetSerialReadBufferSize(m_port, size, &status); wpi_setErrorWithContext(status, HAL_GetErrorMessage(status)); } @@ -182,7 +182,7 @@ void SerialPort::SetReadBufferSize(uint32_t size) { */ void SerialPort::SetWriteBufferSize(uint32_t size) { int32_t status = 0; - HAL_SerialSetWriteBufferSize(m_port, size, &status); + HAL_SetSerialWriteBufferSize(m_port, size, &status); wpi_setErrorWithContext(status, HAL_GetErrorMessage(status)); } @@ -199,7 +199,7 @@ void SerialPort::SetWriteBufferSize(uint32_t size) { */ void SerialPort::SetWriteBufferMode(SerialPort::WriteBufferMode mode) { int32_t status = 0; - HAL_SerialSetWriteMode(m_port, mode, &status); + HAL_SetSerialWriteMode(m_port, mode, &status); wpi_setErrorWithContext(status, HAL_GetErrorMessage(status)); } @@ -211,7 +211,7 @@ void SerialPort::SetWriteBufferMode(SerialPort::WriteBufferMode mode) { */ void SerialPort::Flush() { int32_t status = 0; - HAL_SerialFlush(m_port, &status); + HAL_FlushSerial(m_port, &status); wpi_setErrorWithContext(status, HAL_GetErrorMessage(status)); } @@ -222,6 +222,6 @@ void SerialPort::Flush() { */ void SerialPort::Reset() { int32_t status = 0; - HAL_SerialClear(m_port, &status); + HAL_ClearSerial(m_port, &status); wpi_setErrorWithContext(status, HAL_GetErrorMessage(status)); } diff --git a/wpilibc/athena/src/SolenoidBase.cpp b/wpilibc/athena/src/SolenoidBase.cpp index eed3d6a64a..05631f907b 100644 --- a/wpilibc/athena/src/SolenoidBase.cpp +++ b/wpilibc/athena/src/SolenoidBase.cpp @@ -75,5 +75,5 @@ bool SolenoidBase::GetPCMSolenoidVoltageFault(int module) const { */ void SolenoidBase::ClearAllPCMStickyFaults(int module) { int32_t status = 0; - return HAL_ClearAllPCMStickyFaults_sol(static_cast(module), &status); + return HAL_ClearAllPCMStickyFaults(static_cast(module), &status); } diff --git a/wpilibj/src/athena/cpp/lib/CompressorJNI.cpp b/wpilibj/src/athena/cpp/lib/CompressorJNI.cpp index f47bb19b91..9c18f85cc6 100644 --- a/wpilibj/src/athena/cpp/lib/CompressorJNI.cpp +++ b/wpilibj/src/athena/cpp/lib/CompressorJNI.cpp @@ -57,41 +57,41 @@ Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompressor( /* * Class: edu_wpi_first_wpilibj_hal_CompressorJNI - * Method: setClosedLoopControl + * Method: setCompressorClosedLoopControl * Signature: (JZ)V */ JNIEXPORT void JNICALL -Java_edu_wpi_first_wpilibj_hal_CompressorJNI_setClosedLoopControl( +Java_edu_wpi_first_wpilibj_hal_CompressorJNI_setCompressorClosedLoopControl( JNIEnv *env, jclass, jint compressor_handle, jboolean value) { int32_t status = 0; - HAL_SetClosedLoopControl((HAL_CompressorHandle)compressor_handle, value, &status); + HAL_SetCompressorClosedLoopControl((HAL_CompressorHandle)compressor_handle, value, &status); CheckStatus(env, status); } /* * Class: edu_wpi_first_wpilibj_hal_CompressorJNI - * Method: getClosedLoopControl + * Method: getCompressorClosedLoopControl * Signature: (J)Z */ JNIEXPORT jboolean JNICALL -Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getClosedLoopControl( +Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompressorClosedLoopControl( JNIEnv *env, jclass, jint compressor_handle) { int32_t status = 0; - bool val = HAL_GetClosedLoopControl((HAL_CompressorHandle)compressor_handle, &status); + bool val = HAL_GetCompressorClosedLoopControl((HAL_CompressorHandle)compressor_handle, &status); CheckStatus(env, status); return val; } /* * Class: edu_wpi_first_wpilibj_hal_CompressorJNI - * Method: getPressureSwitch + * Method: getCompressorPressureSwitch * Signature: (J)Z */ JNIEXPORT jboolean JNICALL -Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getPressureSwitch( +Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompressorPressureSwitch( JNIEnv *env, jclass, jint compressor_handle) { int32_t status = 0; - bool val = HAL_GetPressureSwitch((HAL_CompressorHandle)compressor_handle, &status); + bool val = HAL_GetCompressorPressureSwitch((HAL_CompressorHandle)compressor_handle, &status); CheckStatus(env, status); return val; } @@ -201,9 +201,9 @@ Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompressorNotConnectedFault( */ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CompressorJNI_clearAllPCMStickyFaults( - JNIEnv *env, jclass, jint compressor_handle) { + JNIEnv *env, jclass, jbyte module) { int32_t status = 0; - HAL_ClearAllPCMStickyFaults((HAL_CompressorHandle)compressor_handle, &status); + HAL_ClearAllPCMStickyFaults((uint8_t)module, &status); CheckStatus(env, status); } diff --git a/wpilibj/src/athena/cpp/lib/HALUtil.cpp b/wpilibj/src/athena/cpp/lib/HALUtil.cpp index 41bda579bf..b03a65fe42 100644 --- a/wpilibj/src/athena/cpp/lib/HALUtil.cpp +++ b/wpilibj/src/athena/cpp/lib/HALUtil.cpp @@ -128,7 +128,7 @@ void ThrowAllocationException(JNIEnv *env, int32_t status) { delete[] buf; } -void ThrowHAL_HandleException(JNIEnv *env, int32_t status) { +void ThrowHalHandleException(JNIEnv *env, int32_t status) { const char *message = HAL_GetErrorMessage(status); char *buf = new char[strlen(message) + 30]; sprintf(buf, " Code: $%d. %s", status, message); @@ -143,7 +143,7 @@ void ReportError(JNIEnv *env, int32_t status, bool do_throw) { ThrowAllocationException(env, status); } if (status == HAL_HANDLE_ERROR) { - ThrowHAL_HandleException(env, status); + ThrowHalHandleException(env, status); } const char *message = HAL_GetErrorMessage(status); if (do_throw && status < 0) { @@ -302,7 +302,7 @@ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) { if (!allocationExCls) return JNI_ERR; env->DeleteLocalRef(local); - local = env->FindClass("edu/wpi/first/wpilibj/util/HAL_HandleException"); + local = env->FindClass("edu/wpi/first/wpilibj/util/HalHandleException"); if (!local) return JNI_ERR; halHandleExCls = static_cast(env->NewGlobalRef(local)); if (!halHandleExCls) return JNI_ERR; diff --git a/wpilibj/src/athena/cpp/lib/I2CJNI.cpp b/wpilibj/src/athena/cpp/lib/I2CJNI.cpp index 1dafdf2570..63215d7153 100644 --- a/wpilibj/src/athena/cpp/lib/I2CJNI.cpp +++ b/wpilibj/src/athena/cpp/lib/I2CJNI.cpp @@ -35,7 +35,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_I2CJNI_i2CInitialize( I2CJNI_LOG(logDEBUG) << "Calling I2CJNI i2CInititalize"; I2CJNI_LOG(logDEBUG) << "Port: " << (jint)value; int32_t status = 0; - HAL_I2CInitialize(value, &status); + HAL_InitializeI2C(value, &status); I2CJNI_LOG(logDEBUG) << "Status = " << status; CheckStatus(env, status); } @@ -61,7 +61,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_I2CTransaction(port, address, dataToSendPtr, sendSize, + jint returnValue = HAL_TransactionI2C(port, address, dataToSendPtr, sendSize, dataReceivedPtr, receiveSize); I2CJNI_LOG(logDEBUG) << "ReturnValue = " << returnValue; return returnValue; @@ -85,7 +85,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_I2CWrite(port, address, dataToSendPtr, sendSize); + jint returnValue = HAL_WriteI2C(port, address, dataToSendPtr, sendSize); I2CJNI_LOG(logDEBUG) << "ReturnValue = " << (jint)returnValue; return returnValue; } @@ -105,7 +105,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_I2CRead(port, address, dataReceivedPtr, receiveSize); + jint returnValue = HAL_ReadI2C(port, address, dataReceivedPtr, receiveSize); I2CJNI_LOG(logDEBUG) << "ReturnValue = " << returnValue; return returnValue; } @@ -118,7 +118,7 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_I2CJNI_i2CRead( JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_I2CJNI_i2CClose(JNIEnv*, jclass, jbyte value) { I2CJNI_LOG(logDEBUG) << "Calling I2CJNI i2CClose"; - HAL_I2CClose(value); + HAL_CloseI2C(value); } } // extern "C" diff --git a/wpilibj/src/athena/cpp/lib/InterruptJNI.cpp b/wpilibj/src/athena/cpp/lib/InterruptJNI.cpp index 3ea76a4476..81822e4175 100644 --- a/wpilibj/src/athena/cpp/lib/InterruptJNI.cpp +++ b/wpilibj/src/athena/cpp/lib/InterruptJNI.cpp @@ -218,17 +218,17 @@ Java_edu_wpi_first_wpilibj_hal_InterruptJNI_disableInterrupts( /* * Class: edu_wpi_first_wpilibj_hal_InterruptJNI - * Method: readRisingTimestamp + * Method: readInterruptRisingTimestamp * Signature: (J)D */ JNIEXPORT jdouble JNICALL -Java_edu_wpi_first_wpilibj_hal_InterruptJNI_readRisingTimestamp( +Java_edu_wpi_first_wpilibj_hal_InterruptJNI_readInterruptRisingTimestamp( JNIEnv* env, jclass, jint interrupt_handle) { - INTERRUPTJNI_LOG(logDEBUG) << "Calling INTERRUPTJNI readRisingTimestamp"; + INTERRUPTJNI_LOG(logDEBUG) << "Calling INTERRUPTJNI readInterruptRisingTimestamp"; INTERRUPTJNI_LOG(logDEBUG) << "Interrupt Handle = " << (HAL_InterruptHandle)interrupt_handle; int32_t status = 0; - jdouble timeStamp = HAL_ReadRisingTimestamp((HAL_InterruptHandle)interrupt_handle, &status); + jdouble timeStamp = HAL_ReadInterruptRisingTimestamp((HAL_InterruptHandle)interrupt_handle, &status); INTERRUPTJNI_LOG(logDEBUG) << "Status = " << status; CheckStatus(env, status); @@ -237,17 +237,17 @@ Java_edu_wpi_first_wpilibj_hal_InterruptJNI_readRisingTimestamp( /* * Class: edu_wpi_first_wpilibj_hal_InterruptJNI - * Method: readFallingTimestamp + * Method: readInterruptFallingTimestamp * Signature: (J)D */ JNIEXPORT jdouble JNICALL -Java_edu_wpi_first_wpilibj_hal_InterruptJNI_readFallingTimestamp( +Java_edu_wpi_first_wpilibj_hal_InterruptJNI_readInterruptFallingTimestamp( JNIEnv* env, jclass, jint interrupt_handle) { - INTERRUPTJNI_LOG(logDEBUG) << "Calling INTERRUPTJNI readFallingTimestamp"; + INTERRUPTJNI_LOG(logDEBUG) << "Calling INTERRUPTJNI readInterruptFallingTimestamp"; INTERRUPTJNI_LOG(logDEBUG) << "Interrupt Handle = " << (HAL_InterruptHandle)interrupt_handle; int32_t status = 0; - jdouble timeStamp = HAL_ReadFallingTimestamp((HAL_InterruptHandle)interrupt_handle, &status); + jdouble timeStamp = HAL_ReadInterruptFallingTimestamp((HAL_InterruptHandle)interrupt_handle, &status); INTERRUPTJNI_LOG(logDEBUG) << "Status = " << status; CheckStatus(env, status); diff --git a/wpilibj/src/athena/cpp/lib/SPIJNI.cpp b/wpilibj/src/athena/cpp/lib/SPIJNI.cpp index 61cde1531a..fc2c521516 100644 --- a/wpilibj/src/athena/cpp/lib/SPIJNI.cpp +++ b/wpilibj/src/athena/cpp/lib/SPIJNI.cpp @@ -35,7 +35,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiInitialize( SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiInitialize"; SPIJNI_LOG(logDEBUG) << "Port = " << (jint)port; int32_t status = 0; - HAL_SpiInitialize(port, &status); + HAL_InitializeSPI(port, &status); SPIJNI_LOG(logDEBUG) << "Status = " << status; CheckStatus(env, status); } @@ -59,7 +59,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_SpiTransaction(port, dataToSendPtr, dataReceivedPtr, size); + jint retVal = HAL_TransactionSPI(port, dataToSendPtr, dataReceivedPtr, size); SPIJNI_LOG(logDEBUG) << "ReturnValue = " << (jint)retVal; return retVal; } @@ -79,7 +79,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_SpiWrite(port, dataToSendPtr, size); + jint retVal = HAL_WriteSPI(port, dataToSendPtr, size); SPIJNI_LOG(logDEBUG) << "ReturnValue = " << (jint)retVal; return retVal; } @@ -97,7 +97,7 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiRead( (uint8_t *)env->GetDirectBufferAddress(dataReceived); SPIJNI_LOG(logDEBUG) << "Size = " << (jint)size; SPIJNI_LOG(logDEBUG) << "DataReceivedPtr = " << dataReceivedPtr; - jint retVal = HAL_SpiRead(port, (uint8_t *)dataReceivedPtr, size); + jint retVal = HAL_ReadSPI(port, (uint8_t *)dataReceivedPtr, size); SPIJNI_LOG(logDEBUG) << "ReturnValue = " << (jint)retVal; return retVal; } @@ -111,7 +111,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiClose(JNIEnv *, jclass, jbyte port) { SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiClose"; SPIJNI_LOG(logDEBUG) << "Port = " << (jint)port; - HAL_SpiClose(port); + HAL_CloseSPI(port); } /* @@ -124,7 +124,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiSetSpeed( SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiSetSpeed"; SPIJNI_LOG(logDEBUG) << "Port = " << (jint)port; SPIJNI_LOG(logDEBUG) << "Speed = " << (jint)speed; - HAL_SpiSetSpeed(port, speed); + HAL_SetSPISpeed(port, speed); } /* @@ -140,7 +140,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiSetOpts( 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_SpiSetOpts(port, msb_first, sample_on_trailing, clk_idle_high); + HAL_SetSPIOpts(port, msb_first, sample_on_trailing, clk_idle_high); } /* @@ -154,7 +154,7 @@ Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiSetChipSelectActiveHigh( SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiSetCSActiveHigh"; SPIJNI_LOG(logDEBUG) << "Port = " << (jint)port; int32_t status = 0; - HAL_SpiSetChipSelectActiveHigh(port, &status); + HAL_SetSPIChipSelectActiveHigh(port, &status); SPIJNI_LOG(logDEBUG) << "Status = " << status; CheckStatus(env, status); } @@ -170,7 +170,7 @@ Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiSetChipSelectActiveLow( SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiSetCSActiveLow"; SPIJNI_LOG(logDEBUG) << "Port = " << (jint)port; int32_t status = 0; - HAL_SpiSetChipSelectActiveLow(port, &status); + HAL_SetSPIChipSelectActiveLow(port, &status); SPIJNI_LOG(logDEBUG) << "Status = " << status; CheckStatus(env, status); } @@ -196,7 +196,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_SpiInitAccumulator(port, period, cmd, xferSize, validMask, validValue, + HAL_InitSPIAccumulator(port, period, cmd, xferSize, validMask, validValue, dataShift, dataSize, isSigned, bigEndian, &status); SPIJNI_LOG(logDEBUG) << "Status = " << status; CheckStatus(env, status); @@ -212,7 +212,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiFreeAccumulator( SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiFreeAccumulator"; SPIJNI_LOG(logDEBUG) << "Port = " << (jint)port; int32_t status = 0; - HAL_SpiFreeAccumulator(port, &status); + HAL_FreeSPIAccumulator(port, &status); SPIJNI_LOG(logDEBUG) << "Status = " << status; CheckStatus(env, status); } @@ -228,7 +228,7 @@ Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiResetAccumulator( SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiResetAccumulator"; SPIJNI_LOG(logDEBUG) << "Port = " << (jint)port; int32_t status = 0; - HAL_SpiResetAccumulator(port, &status); + HAL_ResetSPIAccumulator(port, &status); SPIJNI_LOG(logDEBUG) << "Status = " << status; CheckStatus(env, status); } @@ -245,7 +245,7 @@ Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiSetAccumulatorCenter( SPIJNI_LOG(logDEBUG) << "Port = " << (jint)port; SPIJNI_LOG(logDEBUG) << "Center = " << center; int32_t status = 0; - HAL_SpiSetAccumulatorCenter(port, center, &status); + HAL_SetSPIAccumulatorCenter(port, center, &status); SPIJNI_LOG(logDEBUG) << "Status = " << status; CheckStatus(env, status); } @@ -262,7 +262,7 @@ Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiSetAccumulatorDeadband( SPIJNI_LOG(logDEBUG) << "Port = " << (jint)port; SPIJNI_LOG(logDEBUG) << "Deadband = " << deadband; int32_t status = 0; - HAL_SpiSetAccumulatorDeadband(port, deadband, &status); + HAL_SetSPIAccumulatorDeadband(port, deadband, &status); SPIJNI_LOG(logDEBUG) << "Status = " << status; CheckStatus(env, status); } @@ -278,7 +278,7 @@ Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiGetAccumulatorLastValue( SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiGetAccumulatorLastValue"; SPIJNI_LOG(logDEBUG) << "Port = " << (jint)port; int32_t status = 0; - jint retVal = HAL_SpiGetAccumulatorLastValue(port, &status); + jint retVal = HAL_GetSPIAccumulatorLastValue(port, &status); SPIJNI_LOG(logDEBUG) << "Status = " << status; SPIJNI_LOG(logDEBUG) << "ReturnValue = " << retVal; CheckStatus(env, status); @@ -296,7 +296,7 @@ Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiGetAccumulatorValue( SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiGetAccumulatorValue"; SPIJNI_LOG(logDEBUG) << "Port = " << (jint)port; int32_t status = 0; - jlong retVal = HAL_SpiGetAccumulatorValue(port, &status); + jlong retVal = HAL_GetSPIAccumulatorValue(port, &status); SPIJNI_LOG(logDEBUG) << "Status = " << status; SPIJNI_LOG(logDEBUG) << "ReturnValue = " << retVal; CheckStatus(env, status); @@ -314,7 +314,7 @@ Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiGetAccumulatorCount( SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiGetAccumulatorCount"; SPIJNI_LOG(logDEBUG) << "Port = " << (jint)port; int32_t status = 0; - jint retVal = HAL_SpiGetAccumulatorCount(port, &status); + jint retVal = HAL_GetSPIAccumulatorCount(port, &status); SPIJNI_LOG(logDEBUG) << "Status = " << status; SPIJNI_LOG(logDEBUG) << "ReturnValue = " << retVal; CheckStatus(env, status); @@ -332,7 +332,7 @@ Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiGetAccumulatorAverage( SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiGetAccumulatorAverage"; SPIJNI_LOG(logDEBUG) << "Port = " << (jint)port; int32_t status = 0; - jdouble retVal = HAL_SpiGetAccumulatorAverage(port, &status); + jdouble retVal = HAL_GetSPIAccumulatorAverage(port, &status); SPIJNI_LOG(logDEBUG) << "Status = " << status; SPIJNI_LOG(logDEBUG) << "ReturnValue = " << retVal; CheckStatus(env, status); @@ -354,7 +354,7 @@ Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiGetAccumulatorOutput( jlong *valuePtr = (jlong *)env->GetDirectBufferAddress(value); uint32_t *countPtr = (uint32_t *)env->GetDirectBufferAddress(count); - HAL_SpiGetAccumulatorOutput(port, valuePtr, countPtr, &status); + HAL_GetSPIAccumulatorOutput(port, valuePtr, countPtr, &status); SPIJNI_LOG(logDEBUG) << "Status = " << status; SPIJNI_LOG(logDEBUG) << "Value = " << *valuePtr; diff --git a/wpilibj/src/athena/cpp/lib/SerialPortJNI.cpp b/wpilibj/src/athena/cpp/lib/SerialPortJNI.cpp index c81e0ece22..58ae022087 100644 --- a/wpilibj/src/athena/cpp/lib/SerialPortJNI.cpp +++ b/wpilibj/src/athena/cpp/lib/SerialPortJNI.cpp @@ -36,7 +36,7 @@ Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialInitializePort( SERIALJNI_LOG(logDEBUG) << "Calling Serial Initialize"; SERIALJNI_LOG(logDEBUG) << "Port = " << (jint)port; int32_t status = 0; - HAL_SerialInitializePort(port, &status); + HAL_InitializeSerialPort(port, &status); SERIALJNI_LOG(logDEBUG) << "Status = " << status; CheckStatus(env, status); } @@ -52,7 +52,7 @@ Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialSetBaudRate( SERIALJNI_LOG(logDEBUG) << "Setting Serial Baud Rate"; SERIALJNI_LOG(logDEBUG) << "Baud: " << rate; int32_t status = 0; - HAL_SerialSetBaudRate(port, rate, &status); + HAL_SetSerialBaudRate(port, rate, &status); SERIALJNI_LOG(logDEBUG) << "Status = " << status; CheckStatus(env, status); } @@ -68,7 +68,7 @@ Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialSetDataBits( SERIALJNI_LOG(logDEBUG) << "Setting Serial Data Bits"; SERIALJNI_LOG(logDEBUG) << "Data Bits: " << bits; int32_t status = 0; - HAL_SerialSetDataBits(port, bits, &status); + HAL_SetSerialDataBits(port, bits, &status); SERIALJNI_LOG(logDEBUG) << "Status = " << status; CheckStatus(env, status); } @@ -84,7 +84,7 @@ Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialSetParity( SERIALJNI_LOG(logDEBUG) << "Setting Serial Parity"; SERIALJNI_LOG(logDEBUG) << "Parity: " << parity; int32_t status = 0; - HAL_SerialSetParity(port, parity, &status); + HAL_SetSerialParity(port, parity, &status); SERIALJNI_LOG(logDEBUG) << "Status = " << status; CheckStatus(env, status); } @@ -100,7 +100,7 @@ Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialSetStopBits( SERIALJNI_LOG(logDEBUG) << "Setting Serial Stop Bits"; SERIALJNI_LOG(logDEBUG) << "Stop Bits: " << bits; int32_t status = 0; - HAL_SerialSetStopBits(port, bits, &status); + HAL_SetSerialStopBits(port, bits, &status); SERIALJNI_LOG(logDEBUG) << "Status = " << status; CheckStatus(env, status); } @@ -116,7 +116,7 @@ Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialSetWriteMode( SERIALJNI_LOG(logDEBUG) << "Setting Serial Write Mode"; SERIALJNI_LOG(logDEBUG) << "Write mode: " << mode; int32_t status = 0; - HAL_SerialSetWriteMode(port, mode, &status); + HAL_SetSerialWriteMode(port, mode, &status); SERIALJNI_LOG(logDEBUG) << "Status = " << status; CheckStatus(env, status); } @@ -132,7 +132,7 @@ Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialSetFlowControl( SERIALJNI_LOG(logDEBUG) << "Setting Serial Flow Control"; SERIALJNI_LOG(logDEBUG) << "Flow Control: " << flow; int32_t status = 0; - HAL_SerialSetFlowControl(port, flow, &status); + HAL_SetSerialFlowControl(port, flow, &status); SERIALJNI_LOG(logDEBUG) << "Status = " << status; CheckStatus(env, status); } @@ -148,7 +148,7 @@ Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialSetTimeout( SERIALJNI_LOG(logDEBUG) << "Setting Serial Timeout"; SERIALJNI_LOG(logDEBUG) << "Timeout: " << timeout; int32_t status = 0; - HAL_SerialSetTimeout(port, timeout, &status); + HAL_SetSerialTimeout(port, timeout, &status); SERIALJNI_LOG(logDEBUG) << "Status = " << status; CheckStatus(env, status); } @@ -164,7 +164,7 @@ Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialEnableTermination( SERIALJNI_LOG(logDEBUG) << "Setting Serial Enable Termination"; SERIALJNI_LOG(logDEBUG) << "Terminator: " << terminator; int32_t status = 0; - HAL_SerialEnableTermination(port, terminator, &status); + HAL_EnableSerialTermination(port, terminator, &status); SERIALJNI_LOG(logDEBUG) << "Status = " << status; CheckStatus(env, status); } @@ -179,7 +179,7 @@ Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialDisableTermination( JNIEnv* env, jclass, jbyte port) { SERIALJNI_LOG(logDEBUG) << "Setting Serial Disable termination"; int32_t status = 0; - HAL_SerialDisableTermination(port, &status); + HAL_DisableSerialTermination(port, &status); SERIALJNI_LOG(logDEBUG) << "Status = " << status; CheckStatus(env, status); } @@ -195,7 +195,7 @@ Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialSetReadBufferSize( SERIALJNI_LOG(logDEBUG) << "Setting Serial Read Buffer Size"; SERIALJNI_LOG(logDEBUG) << "Size: " << size; int32_t status = 0; - HAL_SerialSetReadBufferSize(port, size, &status); + HAL_SetSerialReadBufferSize(port, size, &status); SERIALJNI_LOG(logDEBUG) << "Status = " << status; CheckStatus(env, status); } @@ -211,7 +211,7 @@ Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialSetWriteBufferSize( SERIALJNI_LOG(logDEBUG) << "Setting Serial Write Buffer Size"; SERIALJNI_LOG(logDEBUG) << "Size: " << size; int32_t status = 0; - HAL_SerialSetWriteBufferSize(port, size, &status); + HAL_SetSerialWriteBufferSize(port, size, &status); SERIALJNI_LOG(logDEBUG) << "Status = " << status; CheckStatus(env, status); } @@ -226,7 +226,7 @@ Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialGetBytesRecieved( JNIEnv* env, jclass, jbyte port) { SERIALJNI_LOG(logDEBUG) << "Serial Get Bytes Received"; int32_t status = 0; - jint retVal = HAL_SerialGetBytesReceived(port, &status); + jint retVal = HAL_GetSerialBytesReceived(port, &status); SERIALJNI_LOG(logDEBUG) << "Status = " << status; CheckStatus(env, status); return retVal; @@ -243,7 +243,7 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialRead( jbyte* dataReceivedPtr = nullptr; dataReceivedPtr = (jbyte*)env->GetDirectBufferAddress(dataReceived); int32_t status = 0; - jint retVal = HAL_SerialRead(port, (char*)dataReceivedPtr, size, &status); + jint retVal = HAL_ReadSerial(port, (char*)dataReceivedPtr, size, &status); SERIALJNI_LOG(logDEBUG) << "ReturnValue = " << retVal; SERIALJNI_LOG(logDEBUG) << "Status = " << status; CheckStatus(env, status); @@ -263,7 +263,7 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialWrite( dataToSendPtr = (jbyte*)env->GetDirectBufferAddress(dataToSend); } int32_t status = 0; - jint retVal = HAL_SerialWrite(port, (const char*)dataToSendPtr, size, &status); + jint retVal = HAL_WriteSerial(port, (const char*)dataToSendPtr, size, &status); SERIALJNI_LOG(logDEBUG) << "ReturnValue = " << retVal; SERIALJNI_LOG(logDEBUG) << "Status = " << status; CheckStatus(env, status); @@ -279,7 +279,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialFlush( JNIEnv* env, jclass, jbyte port) { SERIALJNI_LOG(logDEBUG) << "Serial Flush"; int32_t status = 0; - HAL_SerialFlush(port, &status); + HAL_FlushSerial(port, &status); SERIALJNI_LOG(logDEBUG) << "Status = " << status; CheckStatus(env, status); } @@ -293,7 +293,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialClear( JNIEnv* env, jclass, jbyte port) { SERIALJNI_LOG(logDEBUG) << "Serial Clear"; int32_t status = 0; - HAL_SerialClear(port, &status); + HAL_ClearSerial(port, &status); SERIALJNI_LOG(logDEBUG) << "Status = " << status; CheckStatus(env, status); } @@ -307,7 +307,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialClose( JNIEnv* env, jclass, jbyte port) { SERIALJNI_LOG(logDEBUG) << "Serial Close"; int32_t status = 0; - HAL_SerialClose(port, &status); + HAL_CloseSerial(port, &status); SERIALJNI_LOG(logDEBUG) << "Status = " << status; CheckStatus(env, status); } diff --git a/wpilibj/src/athena/cpp/lib/SolenoidJNI.cpp b/wpilibj/src/athena/cpp/lib/SolenoidJNI.cpp index c4132caf4e..9fbb42e300 100644 --- a/wpilibj/src/athena/cpp/lib/SolenoidJNI.cpp +++ b/wpilibj/src/athena/cpp/lib/SolenoidJNI.cpp @@ -153,7 +153,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SolenoidJNI_clearAllPCMStickyFaults( JNIEnv *env, jclass, jbyte module) { int32_t status = 0; - HAL_ClearAllPCMStickyFaults_sol(module, &status); + HAL_ClearAllPCMStickyFaults(module, &status); CheckStatus(env, status); } diff --git a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/Compressor.java b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/Compressor.java index b9c391d53c..b102e7c925 100644 --- a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/Compressor.java +++ b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/Compressor.java @@ -22,6 +22,7 @@ import edu.wpi.first.wpilibj.tables.ITable; */ public class Compressor extends SensorBase implements LiveWindowSendable { private int m_compressorHandle; + private byte m_module; /** * Constructor. @@ -33,6 +34,7 @@ public class Compressor extends SensorBase implements LiveWindowSendable { */ public Compressor(int module) { m_table = null; + m_module = (byte)module; m_compressorHandle = CompressorJNI.initializeCompressor((byte) module); } @@ -79,7 +81,7 @@ public class Compressor extends SensorBase implements LiveWindowSendable { * @return true if the pressure is low by reading the pressure switch that is plugged into the PCM */ public boolean getPressureSwitchValue() { - return CompressorJNI.getPressureSwitch(m_compressorHandle); + return CompressorJNI.getCompressorPressureSwitch(m_compressorHandle); } /** @@ -98,7 +100,7 @@ public class Compressor extends SensorBase implements LiveWindowSendable { * operation of the compressor is disabled. */ public void setClosedLoopControl(boolean on) { - CompressorJNI.setClosedLoopControl(m_compressorHandle, on); + CompressorJNI.setCompressorClosedLoopControl(m_compressorHandle, on); } /** @@ -107,7 +109,7 @@ public class Compressor extends SensorBase implements LiveWindowSendable { * @return true if compressor is operating on closed-loop mode, otherwise return false. */ public boolean getClosedLoopControl() { - return CompressorJNI.getClosedLoopControl(m_compressorHandle); + return CompressorJNI.getCompressorClosedLoopControl(m_compressorHandle); } /** @@ -174,7 +176,7 @@ public class Compressor extends SensorBase implements LiveWindowSendable { *

If no sticky faults are set then this call will have no effect. */ public void clearAllPCMStickyFaults() { - CompressorJNI.clearAllPCMStickyFaults(m_compressorHandle); + CompressorJNI.clearAllPCMStickyFaults(m_module); } @Override diff --git a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/InterruptableSensorBase.java b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/InterruptableSensorBase.java index 68223820fc..19b580cfc9 100644 --- a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/InterruptableSensorBase.java +++ b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/InterruptableSensorBase.java @@ -205,7 +205,7 @@ public abstract class InterruptableSensorBase extends SensorBase { if (m_interrupt == 0) { throw new IllegalStateException("The interrupt is not allocated."); } - return InterruptJNI.readRisingTimestamp(m_interrupt); + return InterruptJNI.readInterruptRisingTimestamp(m_interrupt); } /** @@ -219,7 +219,7 @@ public abstract class InterruptableSensorBase extends SensorBase { if (m_interrupt == 0) { throw new IllegalStateException("The interrupt is not allocated."); } - return InterruptJNI.readFallingTimestamp(m_interrupt); + return InterruptJNI.readInterruptFallingTimestamp(m_interrupt); } /** diff --git a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/hal/CompressorJNI.java b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/hal/CompressorJNI.java index ead9118f7e..6bd65f4b17 100644 --- a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/hal/CompressorJNI.java +++ b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/hal/CompressorJNI.java @@ -14,11 +14,11 @@ public class CompressorJNI extends JNIWrapper { public static native boolean getCompressor(int compressorHandle); - public static native void setClosedLoopControl(int compressorHandle, boolean value); + public static native void setCompressorClosedLoopControl(int compressorHandle, boolean value); - public static native boolean getClosedLoopControl(int compressorHandle); + public static native boolean getCompressorClosedLoopControl(int compressorHandle); - public static native boolean getPressureSwitch(int compressorHandle); + public static native boolean getCompressorPressureSwitch(int compressorHandle); public static native float getCompressorCurrent(int compressorHandle); @@ -34,5 +34,5 @@ public class CompressorJNI extends JNIWrapper { public static native boolean getCompressorNotConnectedFault(int compressorHandle); - public static native void clearAllPCMStickyFaults(int compressorHandle); + public static native void clearAllPCMStickyFaults(byte compressorModule); } diff --git a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/hal/InterruptJNI.java b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/hal/InterruptJNI.java index cfaa71e66b..a542fce3df 100644 --- a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/hal/InterruptJNI.java +++ b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/hal/InterruptJNI.java @@ -25,9 +25,9 @@ public class InterruptJNI extends JNIWrapper { public static native void disableInterrupts(int interruptHandle); - public static native double readRisingTimestamp(int interruptHandle); + public static native double readInterruptRisingTimestamp(int interruptHandle); - public static native double readFallingTimestamp(int interruptHandle); + public static native double readInterruptFallingTimestamp(int interruptHandle); public static native void requestInterrupts(int interruptHandle, int digitalSourceHandle, int analogTriggerType);