AnsweredAssumed Answered

I2C slave transmitter HAL code

Question asked by Chin.Andrew on Mar 20, 2017

Going through HAL code, I see this


static HAL_StatusTypeDef I2C_SlaveTransmit_TXE(I2C_HandleTypeDef *hi2c)
/* Declaration of temporary variables to prevent undefined behavior of volatile usage */
uint32_t CurrentState = hi2c->State;

if(hi2c->XferCount != 0U)
/* Write data to DR */
hi2c->Instance->DR = (*hi2c->pBuffPtr++);

if((hi2c->XferCount == 0U) && (CurrentState == HAL_I2C_STATE_BUSY_TX_LISTEN))
/* Last Byte is received, disable Interrupt */

/* Set state at HAL_I2C_STATE_LISTEN */
hi2c->PreviousState = I2C_STATE_SLAVE_BUSY_TX;
hi2c->State = HAL_I2C_STATE_LISTEN;

/* Call the Tx complete callback to inform upper layer of the end of receive process */
return HAL_OK;


I am not sure how this approaches the problem with multiple bytes. Since it is just "if statements", wouldn't that mean I would need it an interrupt to occur for each byte?