ISD94100 Series Technical Reference Manual
Sep 9, 2019
Page
628
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
if (u32Status == 0x08) {
/* START has been transmitted */
I2C_SET_DATA(I2C0, g_u8DeviceAddr << 1);
/* Write SLA+W to Register I2CDAT */
I2C_SET_CONTROL_REG(I2C0, I2C_SI);
/* Write 1 to SI to clear the I2C interrupt flag */
}
else if (u32Status == 0x18) {
/* SLA+W has been transmitted and ACK has been received */
I2C_SET_DATA(I2C0, g_au8TxData[g_u8+]); /* Write data into I2C_DAT register, */
/* and the I2C module will start the transmission */
I2C_SET_CONTROL_REG(I2C0, I2C_SI);
}
else if (u32Status == 0x20) {
/* SLA+W has been transmitted and NACK has been received */
I2C_SET_CONTROL_REG(I2C0, I2C_STA | I2C_STO | I2C_SI);
}
else if (u32Status == 0x28) { /* DATA has been transmitted and ACK has been received */
if (g_u8DataLen != 3) {
I2C_SET_DATA(I2C0, g_au8TxData[g_u8+]);
/* continue writing the rest of the data */
I2C_SET_CONTROL_REG(I2C0, I2C_SI);
}
else {
I2C_SET_CONTROL_REG(I2C0, I2C_STO | I2C_SI); /* data writing completed, issue STOP condition */
…
}
}
else {
/* To be added: handling for other status code, such Arbitration lost 0x38, etc. */
}