Skip to content

Commit 8681386

Browse files
author
Daniel Liebler
committed
[Wire] modifying to be able to do multiple .write() calls in i2cRequestEvent() as Slave
1 parent 4aae4ed commit 8681386

File tree

1 file changed

+3
-1
lines changed
  • libraries/Wire/src/utility

1 file changed

+3
-1
lines changed

libraries/Wire/src/utility/twi.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -846,9 +846,10 @@ i2c_status_e i2c_slave_write_IT(i2c_t *obj, uint8_t *data, uint16_t size)
846846
} else {
847847
// Check the communication status
848848
for (i = 0; i < size; i++) {
849-
obj->i2cTxRxBuffer[i] = *(data + i);
849+
obj->i2cTxRxBuffer[obj->i2cTxRxBufferSize + i] = *(data + i);
850850
}
851851

852+
size = size + obj->i2cTxRxBufferSize;
852853
obj->i2cTxRxBufferSize = size;
853854
}
854855
return ret;
@@ -986,6 +987,7 @@ void HAL_I2C_AddrCallback(I2C_HandleTypeDef *hi2c, uint8_t TransferDirection, ui
986987
obj->slaveMode = SLAVE_MODE_TRANSMIT;
987988

988989
if (obj->i2c_onSlaveTransmit != NULL) {
990+
obj->i2cTxRxBufferSize = 0;
989991
obj->i2c_onSlaveTransmit(obj);
990992
}
991993
#if defined(STM32F0xx) || defined(STM32F1xx) || defined(STM32F2xx) || defined(STM32F3xx) ||\

0 commit comments

Comments
 (0)