@@ -73,6 +73,8 @@ static void i2c_write_flash_callback(uint8_t* pData, uint8_t size);
7373static void i2c_read_flash_callback (uint8_t * pData , uint8_t size );
7474
7575static void i2c_slave_callback (I2C_Type * base , i2c_slave_transfer_t * xfer , void * userData ) {
76+ i2cCommand_t i2cResponse = {0 };
77+
7678 switch (xfer -> event )
7779 {
7880 /* Address match event */
@@ -101,6 +103,13 @@ static void i2c_slave_callback(I2C_Type *base, i2c_slave_transfer_t *xfer, void
101103 xfer -> data = g_slave_RX_buff ;
102104 xfer -> dataSize = I2C_DATA_LENGTH ;
103105 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 ));
104113 break ;
105114
106115 /* Transfer done */
@@ -276,7 +285,7 @@ static void i2c_write_comms_callback(uint8_t* pData, uint8_t size) {
276285 memcpy (& i2cResponse .cmdData .readRspCmd .data , & board_id_hex , sizeof (board_id_hex ));
277286 break ;
278287 case gI2CProtocolVersion_c : {
279- uint16_t i2c_version = 1 ;
288+ uint16_t i2c_version = 2 ;
280289 i2cResponse .cmdData .readRspCmd .dataSize = sizeof (i2c_version );
281290 memcpy (& i2cResponse .cmdData .readRspCmd .data , & i2c_version , sizeof (i2c_version ));
282291 }
0 commit comments