I am looking basic idea to implement i2c Protocol in C programing. I am trying to make dummy code so it would help me to write original program
Consider: Master Transmit/Slave Receive
My program supposed to do following things.
I started to write the function required in program. This is only few I know I have to add others but I don't have any idea about that
I am bit confused, How to convert this two statement into program
Could any one help me with dummy I2C program in C ?
Note I have not mention controller and slave name because I am looking general idea for all device. It may be difficult to give me advice but I am expecting logic to implement program not original program
Consider: Master Transmit/Slave Receive
My program supposed to do following things.
- Master start the communication by generating a Start condition
- Master sends address to the Slave,
- After receiving data, Slave generate an ACK /NACK,
- Check If slave generate ACK, then again Master sends data to the Slave,
- check if slave generate NACK then Master closes the communication by generating a Stop condition.
Code:
void main (void)
{
void i2c_init(void) //I2C initilaization
int i2c_start() //I2C communication start
void i2c_stop(void) //Stop the I2C communication
}
I am bit confused, How to convert this two statement into program
- generate ACK or NACK.
- check ACK or NACK
Could any one help me with dummy I2C program in C ?
Note I have not mention controller and slave name because I am looking general idea for all device. It may be difficult to give me advice but I am expecting logic to implement program not original program
Last edited: