Add SLAVE_COUNT

This commit is contained in:
László Monda
2018-01-04 23:16:48 +01:00
parent fa558abef3
commit 33e501cd83
2 changed files with 6 additions and 2 deletions

View File

@@ -84,7 +84,7 @@ static void slaveSchedulerCallback(I2C_Type *base, i2c_master_handle_t *handle,
previousSlaveId = currentSlaveId++;
}
if (currentSlaveId >= (sizeof(Slaves) / sizeof(uhk_slave_t))) {
if (currentSlaveId >= SLAVE_COUNT) {
currentSlaveId = 0;
}
} while (!isTransferScheduled);
@@ -95,7 +95,7 @@ void InitSlaveScheduler(void)
previousSlaveId = 0;
currentSlaveId = 0;
for (uint8_t i=0; i<sizeof(Slaves) / sizeof(uhk_slave_t); i++) {
for (uint8_t i=0; i<SLAVE_COUNT; i++) {
uhk_slave_t *currentSlave = Slaves + i;
currentSlave->isConnected = false;
}

View File

@@ -6,6 +6,10 @@
#include "fsl_common.h"
#include "config.h"
// Macros:
#define SLAVE_COUNT (sizeof(Slaves) / sizeof(uhk_slave_t))
// Typedefs:
typedef enum { // Slaves[] is meant to be indexed with these values