Skip to content

Commit 169f42d

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

File tree

1 file changed

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

1 file changed

+3
-2
lines changed

libraries/Wire/src/utility/twi.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -846,10 +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-
obj->i2cTxRxBufferSize = size;
852+
obj->i2cTxRxBufferSize += size;
853853
}
854854
return ret;
855855
}
@@ -986,6 +986,7 @@ void HAL_I2C_AddrCallback(I2C_HandleTypeDef *hi2c, uint8_t TransferDirection, ui
986986
obj->slaveMode = SLAVE_MODE_TRANSMIT;
987987

988988
if (obj->i2c_onSlaveTransmit != NULL) {
989+
obj->i2cTxRxBufferSize = 0;
989990
obj->i2c_onSlaveTransmit(obj);
990991
}
991992
#if defined(STM32F0xx) || defined(STM32F1xx) || defined(STM32F2xx) || defined(STM32F3xx) ||\

0 commit comments

Comments
 (0)