@@ -73,6 +73,8 @@ static void i2c_write_flash_callback(uint8_t* pData, uint8_t size);
73
73
static void i2c_read_flash_callback (uint8_t * pData , uint8_t size );
74
74
75
75
static void i2c_slave_callback (I2C_Type * base , i2c_slave_transfer_t * xfer , void * userData ) {
76
+ i2cCommand_t i2cResponse = {0 };
77
+
76
78
switch (xfer -> event )
77
79
{
78
80
/* Address match event */
@@ -101,6 +103,13 @@ static void i2c_slave_callback(I2C_Type *base, i2c_slave_transfer_t *xfer, void
101
103
xfer -> data = g_slave_RX_buff ;
102
104
xfer -> dataSize = I2C_DATA_LENGTH ;
103
105
g_SlaveRxFlag = true;
106
+
107
+ // Clear transmit Buffer in IRQ. It will be filled when the task attends the I2C event
108
+ i2c_clearBuffer ();
109
+ // Add busy error code
110
+ i2cResponse .cmdId = gErrorResponse_c ;
111
+ i2cResponse .cmdData .errorRspCmd .errorCode = gErrorBusy_c ;
112
+ i2c_fillBuffer ((uint8_t * ) & i2cResponse , 0 , sizeof (i2cResponse ));
104
113
break ;
105
114
106
115
/* Transfer done */
@@ -276,7 +285,7 @@ static void i2c_write_comms_callback(uint8_t* pData, uint8_t size) {
276
285
memcpy (& i2cResponse .cmdData .readRspCmd .data , & board_id_hex , sizeof (board_id_hex ));
277
286
break ;
278
287
case gI2CProtocolVersion_c : {
279
- uint16_t i2c_version = 1 ;
288
+ uint16_t i2c_version = 2 ;
280
289
i2cResponse .cmdData .readRspCmd .dataSize = sizeof (i2c_version );
281
290
memcpy (& i2cResponse .cmdData .readRspCmd .data , & i2c_version , sizeof (i2c_version ));
282
291
}
0 commit comments