File tree Expand file tree Collapse file tree 2 files changed +5
-6
lines changed Expand file tree Collapse file tree 2 files changed +5
-6
lines changed Original file line number Diff line number Diff line change @@ -539,7 +539,7 @@ void HAL_I2C_ListenCpltCallback(I2C_HandleTypeDef *hi2c)
539539
540540 if ((obj -> i2c_onSlaveReceive != NULL ) &&
541541 (obj -> slaveMode == SLAVE_MODE_RECEIVE )) {
542- nbData = I2C_TXRX_BUFFER_SIZE - obj -> handle .XferCount ;
542+ nbData = I2C_TXRX_BUFFER_SIZE - obj -> handle .XferSize ;
543543 if (nbData != 0 ) {
544544 obj -> i2c_onSlaveReceive (obj -> i2cTxRxBuffer , nbData );
545545 }
Original file line number Diff line number Diff line change @@ -381,13 +381,12 @@ void TwoWire::onReceiveService(uint8_t* inBytes, int numBytes)
381381 return ;
382382 }
383383
384+ allocateRxBuffer (numBytes);
385+ // error if no memory block available to allocate the buffer
384386 if (rxBuffer == nullptr ){
385- allocateRxBuffer (numBytes);
386- // error if no memory block available to allocate the buffer
387- if (rxBuffer == nullptr ){
388- Error_Handler ();
389- }
387+ Error_Handler ();
390388 }
389+
391390 // copy twi rx buffer into local read buffer
392391 // this enables new reads to happen in parallel
393392 memcpy (rxBuffer, inBytes, numBytes);
You can’t perform that action at this time.
0 commit comments