mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-25 01:41:43 +00:00
Fix incorrect comments in the HAL I2C functions and incorrect return values for some I2C class member functions.
These issues were found and fixed while interfacing with an ITG3200 gyroscope. Fixes artf4173. Change-Id: Id3c6b34aa707650480e90605e98ae1b44d7a7b98
This commit is contained in:
@@ -48,7 +48,7 @@ bool I2C::Transaction(uint8_t *dataToSend, uint8_t sendSize,
|
||||
status = i2CTransaction(m_port, m_deviceAddress, dataToSend, sendSize,
|
||||
dataReceived, receiveSize);
|
||||
// wpi_setErrorWithContext(status, getHALErrorMessage(status));
|
||||
return status < 0;
|
||||
return status < receiveSize;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -60,9 +60,7 @@ bool I2C::Transaction(uint8_t *dataToSend, uint8_t sendSize,
|
||||
* @return Transfer Aborted... false for success, true for aborted.
|
||||
*/
|
||||
bool I2C::AddressOnly() {
|
||||
int32_t status = 0;
|
||||
status = Transaction(nullptr, 0, nullptr, 0);
|
||||
return status < 0;
|
||||
return Transaction(nullptr, 0, nullptr, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -82,7 +80,7 @@ bool I2C::Write(uint8_t registerAddress, uint8_t data) {
|
||||
buffer[1] = data;
|
||||
int32_t status = 0;
|
||||
status = i2CWrite(m_port, m_deviceAddress, buffer, sizeof(buffer));
|
||||
return status < 0;
|
||||
return status < static_cast<int32_t>(sizeof(buffer));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -98,7 +96,7 @@ bool I2C::Write(uint8_t registerAddress, uint8_t data) {
|
||||
bool I2C::WriteBulk(uint8_t *data, uint8_t count) {
|
||||
int32_t status = 0;
|
||||
status = i2CWrite(m_port, m_deviceAddress, data, count);
|
||||
return status < 0;
|
||||
return status < count;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -123,10 +121,7 @@ bool I2C::Read(uint8_t registerAddress, uint8_t count, uint8_t *buffer) {
|
||||
wpi_setWPIErrorWithContext(NullParameter, "buffer");
|
||||
return true;
|
||||
}
|
||||
int32_t status = 0;
|
||||
status =
|
||||
Transaction(®isterAddress, sizeof(registerAddress), buffer, count);
|
||||
return status < 0;
|
||||
return Transaction(®isterAddress, sizeof(registerAddress), buffer, count);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -153,7 +148,7 @@ bool I2C::ReadOnly(uint8_t count, uint8_t *buffer) {
|
||||
}
|
||||
int32_t status = 0;
|
||||
status = i2CRead(m_port, m_deviceAddress, buffer, count);
|
||||
return status < 0;
|
||||
return status < count;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user