Skip to content

Commit d09f2ff

Browse files
committed
I2C: remove useless parameter in onReceiveService()
With introduction of 'I2C multi instances: Remove static qualifier on TwoWire attributes' parameters 'inBytes' and 'numBytes' become useless as they are part of new obj structure parameter.
1 parent 0b7dbae commit d09f2ff

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

libraries/Wire/src/Wire.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,8 +394,11 @@ void TwoWire::flush(void)
394394
}
395395

396396
// behind the scenes function that is called when data is received
397-
void TwoWire::onReceiveService(i2c_t *obj, uint8_t *inBytes, int numBytes)
397+
void TwoWire::onReceiveService(i2c_t *obj)
398398
{
399+
uint8_t *inBytes = (uint8_t *) obj->i2cTxRxBuffer;
400+
int numBytes = obj->slaveRxNbData;
401+
399402
TwoWire *TW = (TwoWire *)(obj->__this);
400403

401404
// don't bother if user hasn't registered a callback

libraries/Wire/src/Wire.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class TwoWire : public Stream {
5656
void (*user_onRequest)(void);
5757
void (*user_onReceive)(int);
5858
static void onRequestService(i2c_t *);
59-
static void onReceiveService(i2c_t *, uint8_t *, int);
59+
static void onReceiveService(i2c_t *);
6060

6161
void allocateRxBuffer(size_t length);
6262
void allocateTxBuffer(size_t length);

libraries/Wire/src/utility/twi.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -948,7 +948,7 @@ i2c_t *get_i2c_obj(I2C_HandleTypeDef *hi2c)
948948
* @param function: callback function to use
949949
* @retval None
950950
*/
951-
void i2c_attachSlaveRxEvent(i2c_t *obj, void (*function)(i2c_t *, uint8_t *, int))
951+
void i2c_attachSlaveRxEvent(i2c_t *obj, void (*function)(i2c_t *))
952952
{
953953
if ((obj != NULL) && (function != NULL)) {
954954
obj->i2c_onSlaveReceive = function;
@@ -1026,7 +1026,7 @@ void HAL_I2C_ListenCpltCallback(I2C_HandleTypeDef *hi2c)
10261026
/* Previous master transaction now ended, so inform upper layer if needed
10271027
* then prepare for listening to next request */
10281028
if ((obj->slaveMode == SLAVE_MODE_RECEIVE) && (obj->slaveRxNbData != 0)) {
1029-
obj->i2c_onSlaveReceive(obj, (uint8_t *) obj->i2cTxRxBuffer, obj->slaveRxNbData);
1029+
obj->i2c_onSlaveReceive(obj);
10301030
}
10311031
obj->slaveMode = SLAVE_MODE_LISTEN;
10321032
obj->slaveRxNbData = 0;

libraries/Wire/src/utility/twi.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ struct i2c_s {
107107
IRQn_Type irqER;
108108
#endif /* !STM32F0xx && !STM32G0xx && !STM32L0xx */
109109
volatile int slaveRxNbData; // Number of accumulated bytes received in Slave mode
110-
void (*i2c_onSlaveReceive)(i2c_t *, uint8_t *, int);
110+
void (*i2c_onSlaveReceive)(i2c_t *);
111111
void (*i2c_onSlaveTransmit)(i2c_t *);
112112
volatile uint8_t i2cTxRxBuffer[I2C_TXRX_BUFFER_SIZE];
113113
volatile uint8_t i2cTxRxBufferSize;
@@ -139,7 +139,7 @@ i2c_status_e i2c_master_read(i2c_t *obj, uint8_t dev_address, uint8_t *data, uin
139139

140140
i2c_status_e i2c_IsDeviceReady(i2c_t *obj, uint8_t devAddr, uint32_t trials);
141141

142-
void i2c_attachSlaveRxEvent(i2c_t *obj, void (*function)(i2c_t *, uint8_t *, int));
142+
void i2c_attachSlaveRxEvent(i2c_t *obj, void (*function)(i2c_t *));
143143
void i2c_attachSlaveTxEvent(i2c_t *obj, void (*function)(i2c_t *));
144144

145145
#ifdef __cplusplus

0 commit comments

Comments
 (0)