cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC™ Creator & Designer

Anonymous
Not applicable

When I read the datasheet of I2C(I2CHW in PSoC Creator), I found when we use Slave mode, the function "uint8 I2C_SlaveStatus(void)" will be used to check the status for I2C Slave, and also, we can see the example code in the datasheet as below:

uint8 wrBuf[10];
uint8 userArray[10];
uint8 byteCnt;
I2C_SlaveInitWriteBuf((uint8 *) wrBuf, 10);
/* Wait for I2C master to complete a write */
for(;1 /* loop forever */
{
/* Wait for I2C master to complete a write */
if(I2C_SlaveStatus( ) & I2C_SSTAT_RD_CMPT )
{
byteCnt = I2C_SlaveGetWriteBufSize( );
I2C_SlaveClearReadStatus( );
For(i=0; I < byteCnt; i++)
{
userArray = wrBuf; /* Transfer data */
}
I2C_SlaveClearWriteBuf( );
}
}



Why we can use the I2C_SSTAT_RD_CMPT to indicate the I2C Master has complete a write?
And I don't know when the I2C_SSTAT_RD_CMPT will be set?(if the I2C_SSTAT_RD_CMPT is set when we finished read the buffer, and when the last byte is transmitted, we will also read the wrBuf[], but then, the content in the buffer is not written by the Master?)

0 Likes
0 Replies