Master Read ( without sub address of Slave device )
I2CMR = IICEN+INTEN; // start generate
I2CDR = Slave Address + Read mode; // load target Salve Address
I2CMR |= SRT; // generate start condition
-------------------------------------------------------------------
[I2C Interrupt Service]
If (Master mode) and ( TMODE)
If( ACK and GCALL )
I2CMR |= ACKEN // After receive data, generate ACK
I2CSR = 0xFF; // Byte transmit start
ELSE
if ACK and TEND )
If ( Not End of Data )
If(LAST Data)
I2CMR &= ~ACKEN // After receive data, generate ACK
I2C_buffer = I2CDR // read
I2CSR = 0xFF; // Byte transmit start
ELSE
If( ~ACK and TEND)
I2CMR = IICEN+INTEN+STP; // STOP generation
I2CSR = 0xFF; // Byte transmit start
ELSE
Initialize I2C block // if have ACK error, any error
End of I2C interrupt service