mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-28 02:11:43 +00:00
@@ -16,6 +16,7 @@
|
||||
|
||||
#include "DigitalInternal.h"
|
||||
#include "HALInitializer.h"
|
||||
#include "HALInternal.h"
|
||||
#include "hal/DIO.h"
|
||||
#include "hal/HAL.h"
|
||||
|
||||
@@ -46,7 +47,9 @@ void HAL_InitializeI2C(HAL_I2CPort port, int32_t* status) {
|
||||
}
|
||||
|
||||
if (port < 0 || port > 1) {
|
||||
// Set port out of range error here
|
||||
*status = RESOURCE_OUT_OF_RANGE;
|
||||
hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for I2C", 0, 1,
|
||||
port);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -92,7 +95,9 @@ int32_t HAL_TransactionI2C(HAL_I2CPort port, int32_t deviceAddress,
|
||||
const uint8_t* dataToSend, int32_t sendSize,
|
||||
uint8_t* dataReceived, int32_t receiveSize) {
|
||||
if (port < 0 || port > 1) {
|
||||
// Set port out of range error here
|
||||
int32_t status = 0;
|
||||
hal::SetLastErrorIndexOutOfRange(&status, "Invalid Index for I2C", 0, 1,
|
||||
port);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -122,7 +127,9 @@ int32_t HAL_TransactionI2C(HAL_I2CPort port, int32_t deviceAddress,
|
||||
int32_t HAL_WriteI2C(HAL_I2CPort port, int32_t deviceAddress,
|
||||
const uint8_t* dataToSend, int32_t sendSize) {
|
||||
if (port < 0 || port > 1) {
|
||||
// Set port out of range error here
|
||||
int32_t status = 0;
|
||||
hal::SetLastErrorIndexOutOfRange(&status, "Invalid Index for I2C", 0, 1,
|
||||
port);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -148,7 +155,9 @@ int32_t HAL_WriteI2C(HAL_I2CPort port, int32_t deviceAddress,
|
||||
int32_t HAL_ReadI2C(HAL_I2CPort port, int32_t deviceAddress, uint8_t* buffer,
|
||||
int32_t count) {
|
||||
if (port < 0 || port > 1) {
|
||||
// Set port out of range error here
|
||||
int32_t status = 0;
|
||||
hal::SetLastErrorIndexOutOfRange(&status, "Invalid Index for I2C", 0, 1,
|
||||
port);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -173,7 +182,9 @@ int32_t HAL_ReadI2C(HAL_I2CPort port, int32_t deviceAddress, uint8_t* buffer,
|
||||
|
||||
void HAL_CloseI2C(HAL_I2CPort port) {
|
||||
if (port < 0 || port > 1) {
|
||||
// Set port out of range error here
|
||||
int32_t status = 0;
|
||||
hal::SetLastErrorIndexOutOfRange(&status, "Invalid Index for I2C", 0, 1,
|
||||
port);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user