IS31IO8972 EVB user guide
APPENDIX Ⅱ: Basic APIs for accessing IIC mode (with CS8961)
void I2C_write_1(unsigned char addr, unsigned char wr_dat)
{
unsigned char i;
I2CMCR = 0x04; while((I2CMCR & 0x01)); // STOP
I2CMSA = SLAVE_ADDR|0x00;
I2CMBUF = addr;
I2CMCR = 0x03; while((I2CMCR & 0x01));
I2CMBUF = wr_dat;
I2CMCR = 0x05; while((I2CMCR & 0x01));
for (i=0;i<0xFF;i++)
{
_nop_();
}
}
//==============================================================================
// write n bytes
void I2C_write_n(uchar addr, uchar length, uchar* local_data)
{
unsigned char i;
for(i=0;i<length;i++)
{
I2C_write_1(addr,local_data[i]);
addr++;
}
}
//==============================================================================
unsigned char I2C_read_1(unsigned char addr)
{
unsigned char i;
unsigned char ReadData;
I2CMCR = 0x04; while((I2CMCR & 0x01)); // STOP
I2CMSA = SLAVE_ADDR|0x00;
I2CMBUF = addr;
I2CMCR = 0x03; while((I2CMCR & 0x01)); // START+SEND
I2CMSA = SLAVE_ADDR|0x01;
I2CMCR = 0x07; while((I2CMCR & 0x01)); // START+RECEIVE+STOP
for (i=0;i<0xFF;i++)
{
_nop_();
}
ReadData = I2CMBUF;
return ReadData;
}
//==============================================================================
void I2C_read_n(uchar addr, uchar length, uchar* rd_buffer)
{
unsigned char i;
for(i=0;i<length;i++)
{
rd_buffer[i] = I2C_read_1(addr);
addr++;
}
}
Integrated Silicon Solution, Inc. – www.issi.com
Rev. A, 14/03/2019
// START+SEND
// SEND+STOP
13
Need help?
Do you have a question about the IS31IO8972 EVB and is the answer not in the manual?
Questions and answers