Make the I2C driver able to handle variable length messages by reading the first byte of the message (the message length) and update transfer.dataSize accordingly.

This commit is contained in:
László Monda
2017-09-25 03:00:37 +02:00
parent cd173f98d1
commit 7142722eed

View File

@@ -387,7 +387,12 @@ static status_t I2C_MasterTransferRunStateMachine(I2C_Type *base, i2c_master_han
}
/* Read the data byte into the transfer buffer. */
*handle->transfer.data = base->D;
uint8_t data = base->D;
if (handle->userData) {
handle->transfer.dataSize = 2 + data; // 2 byte hash length + payload length
handle->userData = NULL;
}
*handle->transfer.data = data;
handle->transfer.data++;
}
break;