Add i2c_message_t and use it all across the codebase. This will allow handling variable-length I2C messages and validation with minimal effort. The test LED and brightness PWM update features got temporarily broken and will fix them soon.

This commit is contained in:
László Monda
2017-09-25 03:03:14 +02:00
parent ef9d9ee9a7
commit b88c6e4291
11 changed files with 93 additions and 60 deletions

View File

@@ -12,24 +12,19 @@
static void i2cSlaveCallback(I2C_Type *base, i2c_slave_transfer_t *xfer, void *userData)
{
switch (xfer->event)
{
switch (xfer->event) {
case kI2C_SlaveTransmitEvent:
SlaveProtocolHandler();
xfer->data = SlaveTxBuffer;
xfer->dataSize = SlaveTxSize;
xfer->data = (uint8_t*)&txMessage;
xfer->dataSize = txMessage.length+3;
break;
case kI2C_SlaveReceiveEvent:
xfer->data = (uint8_t*)&rxMessage;
// xfer->dataSize = I2C_BUFFER_MAX_LENGTH;
SlaveProtocolHandler();
xfer->data = SlaveRxBuffer;
xfer->dataSize = SLAVE_RX_BUFFER_SIZE;
break;
case kI2C_SlaveCompletionEvent:
xfer->data = NULL;
xfer->dataSize = 0;
break;
case kI2C_SlaveTransmitAckEvent:
break;
//SlaveProtocolHandler();
default:
break;
}