Line 89: Line 89:
 
| Description || This fun is used to receive a byte on SDA line using I2C protocol.
 
| Description || This fun is used to receive a byte on SDA line using I2C protocol.
 
|-
 
|-
| Usage || <syntaxhightlight>
+
| Usage ||  
              void mian()
+
<syntaxhighlight  lang = "c">
 +
void mian()
 
{
 
{
*ptr_sec_u8 = I2C_Read(1);                // read second and return Positive ACK
+
    *ptr_sec_u8 = I2C_Read(1);                // read second and return Positive ACK
*ptr_min_u8 = I2C_Read(1);       // read minute and return Positive ACK
+
    *ptr_min_u8 = I2C_Read(1);       // read minute and return Positive ACK
*ptr_hour_u8 = I2C_Read(0);              // read hour and return Negative/No ACK
+
    *ptr_hour_u8 = I2C_Read(0);              // read hour and return Negative/No ACK
 
}
 
}
<syntaxhightlight/>
+
</syntaxhighlight>
 
|}
 
|}
 
 
  
 
==User_Guide==
 
==User_Guide==

Revision as of 10:20, 10 January 2015


I2C

I2C_Init

{{#Widget:LibTable}}
Defination void I2C_Init()
Input Arguments none
Return Value none
Description This function is used to initialize the I2C module.
Usage I2C_Init();


I2C_Start

{{#Widget:LibTable}}
Defination void I2C_Start()
Input Arguments none
Return Value none
Description This function is used to generate I2C Start Condition.
Start Condition: SDA goes low when SCL is High.
Usage I2C_Start();



I2C_Stop

{{#Widget:LibTable}}
Defination void I2C_Stop()
Input Arguments none
Return Value none
Description This function is used to generate I2C Stop Condition.
Stop Condition: SDA goes High when SCL is High.
Usage I2C_Stop();



I2C_Write

{{#Widget:LibTable}}
Defination void I2C_Write(uint8_t var_i2cData_u8)
Input Arguments uint8_t : 8-bit data to be transmitted.
Return Value none
Description This function is used to send a byte on SDA line using I2C protocol.
8bit data is sent bit-by-bit on each clock cycle.
MSB(bit) is sent first and LSB(bit) is sent at last.
Usage I2C_Write(0x05); //transmits 0x05 on I2C lines
I2C_Write(var_i2cData_u8); //Transmits 8bit data stored in var_i2cData_u8



I2C_Read

{{#Widget:LibTable}}
Defination uint8_t I2C_Read(uint8_t var_ackOption_u8)
Input Arguments uint8_t: Acknowledgement to be sent after data reception.
  • 1:Positive acknowledgement
  • 0:Negative acknowledgement
Return Value uint8_t: Data received form I2C lines.
Description This fun is used to receive a byte on SDA line using I2C protocol.
Usage
void mian()
{
    *ptr_sec_u8 = I2C_Read(1);                // read second and return Positive ACK
    *ptr_min_u8 = I2C_Read(1); 	       // read minute and return Positive ACK
    *ptr_hour_u8 = I2C_Read(0);               // read hour and return Negative/No ACK
}

User_Guide