ISD94100 Series Technical Reference Manual
Sep 9, 2019
Page
632
of 928
Rev1.09
IS
D
9
410
0
S
ER
IE
S
T
E
C
HN
ICA
L
RE
F
E
RE
NCE
M
AN
U
AL
code will be 0xA0. User could follow the action for status code 0x88 as shown in the above figure
when getting 0xA0 status.
If I
2
C is still transmitting data in addressed Slave mode but got a STOP or Repeat START, the
status code will be 0xA0. User could follow the action for status code 0xC8 as shown in the above
figure when getting 0xA0 status.
Note:
After slave gets status of 0x88, 0xC8, 0xC0 and 0xA0, slave can switch to not address mode
and own SLA will not be recognized. If entering this status, slave will not receive any I
2
C signal or
address from master. At this status, I
2
C should enter into idle mode.
Sample code for Figure 6.13-15, I2C slave mode control flow:
/* ------ in main routine, slave mode initialization ------ */
…
I2C_Open(I2C0, 100000);
/* Open I2C0 and set clock to 100k */
/* Set I2C0 4 Slave Addresses */
I2C_SetSlaveAddr(I2C0, 0, 0x15, I2C_GCMODE_DISABLE); /* Slave Address : 0x15 */
I2C_SetSlaveAddr(I2C0, 1, 0x35, I2C_GCMODE_DISABLE); /* Slave Address : 0x35 */
I2C_SetSlaveAddr(I2C0, 2, 0x55, I2C_GCMODE_DISABLE); /* Slave Address : 0x55 */
I2C_SetSlaveAddr(I2C0, 3, 0x75, I2C_GCMODE_DISABLE); /* Slave Address : 0x75 */
I2C_EnableInt(I2C0);
NVIC_EnableIRQ(I2C0_IRQn);
I2C_SET_CONTROL_REG(I2C0, I2C_SI | I2C_AA);
/* I2C enters addressed slave mode */
s_I2C0HandlerFn=I2C_SlaveTRx;
/* entry point for slave mode ISR function */
... /* now waits for the I2C interrupt */
…
/* ------- I2C slave mode interrupt service routine: I2C_SlaveTRx ------ */
u32Status = I2C_GET_STATUS(I2C0);
if (u32Status == 0x60) {
/* detected matching address, and sent ACK to master */
…
I2C_SET_CONTROL_REG(I2C0, I2C_SI | I2C_AA);
/* clear interrupt and prepare for next ACK */
}
else if (u32Status == 0x80) { /* got data from master, and returned ACK to master */
g_au8RxData[g_u8DataLen] = I2C_GET_DATA(I2C0); /* read data from I2C_DAT register*/
g_u8+;
…
I2C_SET_CONTROL_REG(I2C0, I2C_SI | I2C_AA);
}
else if(u32Status == 0xA8) {
/* sent address to master, and returned ACK to master */
I2C_SET_DATA(I2C0, g_u8SlvData[slave_buff_addr]); /* continue sending next address byte */
slave_bu+;
I2C_SET_CONTROL_REG(I2C0, I2C_SI | I2C_AA);
}
else if (u32Status == 0xC0) { /* Data byte or last data in I2CDAT has been transmitted,
and received NACK */
I2C_SET_CONTROL_REG(I2C0, I2C_SI | I2C_AA);