Only call LogI2cError() if the passed status is an actual I2C error, otherwise it slows the mouse pointer down.

This commit is contained in:
László Monda
2018-01-06 02:04:47 +01:00
parent f6b66283a7
commit 5a986d367e
3 changed files with 7 additions and 6 deletions

View File

@@ -5,10 +5,6 @@ i2c_slave_error_counter_t I2cSlaveErrorCounters[MAX_SLAVE_COUNT];
void LogI2cError(uint8_t slaveId, status_t status)
{
if (!(kStatus_I2C_Busy <= status && status <= kStatus_I2C_Timeout)) {
return;
}
i2c_slave_error_counter_t *i2cSlaveErrorCounter = I2cSlaveErrorCounters + slaveId;
uint8_t errorIdx;

View File

@@ -61,7 +61,9 @@ static void slaveSchedulerCallback(I2C_Type *base, i2c_master_handle_t *handle,
uhk_slave_t *currentSlave = Slaves + currentSlaveId;
previousSlave->previousStatus = previousStatus;
LogI2cError(previousSlaveId, previousStatus);
if (IS_STATUS_I2C_ERROR(previousStatus)) {
LogI2cError(previousSlaveId, previousStatus);
}
if (isFirstIteration) {
bool wasPreviousSlaveConnected = previousSlave->isConnected;
@@ -77,7 +79,9 @@ static void slaveSchedulerCallback(I2C_Type *base, i2c_master_handle_t *handle,
}
status_t currentStatus = currentSlave->update(currentSlave->perDriverId);
LogI2cError(currentSlaveId, currentStatus);
if (IS_STATUS_I2C_ERROR(currentStatus)) {
LogI2cError(currentSlaveId, currentStatus);
}
isTransferScheduled = currentStatus != kStatus_Uhk_IdleSlave && currentStatus != kStatus_Uhk_NoTransfer;
if (isTransferScheduled) {
currentSlave->isConnected = true;

View File

@@ -11,6 +11,7 @@
#define SLAVE_COUNT (sizeof(Slaves) / sizeof(uhk_slave_t))
#define MAX_SLAVE_COUNT 6
#define IS_VALID_SLAVE_ID(slaveId) (0 <= slaveId && slaveId <= MAX_SLAVE_COUNT)
#define IS_STATUS_I2C_ERROR(status) (kStatus_I2C_Busy <= status && status <= kStatus_I2C_Timeout)
// Typedefs: