i2c.h File Reference

I2C software routines. More...

#include "config.h"
#include "pic_utils.h"
Include dependency graph for i2c.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define __i2c_h   defined
#define i2c_read_sda()   set_bit(tris_array[i2c_sda_port - PORTA], i2c_sda_pin);
#define i2c_setup()   i2c_setup_io()
#define i2c_write_sda()   clear_bit(tris_array[i2c_sda_port - PORTA], i2c_sda_pin);

Functions

uns8 i2c_read_eeprom (uns8 device_address, uns8 mem_address)
 Read an 8 bit byte over I2C buss.
uns16 i2c_read_eeprom_16bit (uns8 device_address, uns8 mem_address)
 Read 16 bits of data over I2C buss.
uns8 i2c_receive_byte ()
 Receive byte from I2C buss.
void i2c_send_ack (void)
 Send an ACK.
void i2c_send_byte (uns8 data)
 Send a byte to I2C buss.
void i2c_setup_io ()
 Setup ports and pins for I2C communication.
void i2c_start (void)
 Send start signal to I2C buss.
void i2c_stop (void)
 Send stop signal to I2C buss.
void i2c_write_eeprom (uns8 device_address, uns8 mem_address, uns8 data)
 Write an 8 bit byte ove I2C buss.
void i2c_write_eeprom_16bit (uns8 device_address, uns8 mem_address, uns16 data)
 Write a 16 bit value over I2C buss.

Detailed Description

I2C communication routines. Although all standard functions are provided, you should only need to use i2c_setup, i2c_read_eeprom and i2c_write_eeprom

Definition in file i2c.h.


Define Documentation

#define __i2c_h   defined

Definition at line 45 of file i2c.h.

 
#define i2c_read_sda (  )     set_bit(tris_array[i2c_sda_port - PORTA], i2c_sda_pin);

Change SDA line to read mode

Definition at line 70 of file i2c.h.

Referenced by i2c_receive_byte(), and i2c_send_byte().

 
#define i2c_setup (  )     i2c_setup_io()

Definition at line 140 of file i2c.h.

Referenced by ar1000_setup_io(), ds1631_setup(), lm75_setup(), and tmp75_setup().

 
#define i2c_write_sda (  )     clear_bit(tris_array[i2c_sda_port - PORTA], i2c_sda_pin);

Change SDA line to write mode

Definition at line 68 of file i2c.h.

Referenced by i2c_read_eeprom(), i2c_read_eeprom_16bit(), i2c_send_ack(), i2c_send_byte(), i2c_start(), and i2c_stop().


Function Documentation

uns8 i2c_read_eeprom ( uns8  device_address,
uns8  mem_address 
)

Read an 8 bit byte from the specified device at the memory address

Definition at line 76 of file i2c.c.

References clear_pin, DELAY_AMOUNT, i2c_receive_byte(), i2c_send_byte(), i2c_start(), i2c_stop(), i2c_write_sda, set_pin, and uns8.

Referenced by ds1631_get_config(), lm75_get_config(), rtc_get_config(), rtc_get_date(), rtc_get_day(), rtc_get_dow(), rtc_get_hours(), rtc_get_minutes(), rtc_get_month(), rtc_get_register(), rtc_get_seconds(), rtc_get_year(), rtc_set_hours(), rtc_set_seconds(), rtc_start_clock(), and rtc_stop_clock().

Here is the call graph for this function:

Here is the caller graph for this function:

uns16 i2c_read_eeprom_16bit ( uns8  device_address,
uns8  mem_address 
)

Read a 16 bit chunk of data from the given device and memory address

Definition at line 103 of file i2c.c.

References clear_pin, DELAY_AMOUNT, i2c_receive_byte(), i2c_send_byte(), i2c_start(), i2c_stop(), i2c_write_sda, set_pin, and uns16.

Referenced by ar1000_read_register(), ar1000_seek(), ar1000_seek_more(), ar1000_test(), ar1000_tune(), ds1631_get_temp(), and lm75_get_temp().

Here is the call graph for this function:

Here is the caller graph for this function:

uns8 i2c_receive_byte (  ) 

Clock in a byte over I2C lines. Note that an acknowledge is not sent/received

Definition at line 186 of file i2c.c.

References clear_pin, DELAY_AMOUNT, i2c_read_sda, set_pin, test_pin, and uns8.

Referenced by hmc6352_get_data(), hmc6352_read_eeprom(), hmc6352_read_ram(), i2c_read_eeprom(), i2c_read_eeprom_16bit(), tmp75_read(), and tmp75_read_16bit().

Here is the caller graph for this function:

void i2c_send_ack ( void   ) 

Sends an I2C acknowledge (bit)

Definition at line 140 of file i2c.c.

References clear_pin, DELAY_AMOUNT, i2c_write_sda, and set_pin.

Referenced by hmc6352_get_data(), hmc6352_read_eeprom(), hmc6352_read_ram(), and tmp75_read_16bit().

Here is the caller graph for this function:

void i2c_send_byte ( uns8  data  ) 
void i2c_setup_io (  ) 

Set port and pins correctly for I2C communication

Definition at line 231 of file i2c.c.

void i2c_start ( void   ) 
void i2c_stop ( void   ) 
void i2c_write_eeprom ( uns8  device_address,
uns8  mem_address,
uns8  data 
)

Write a byte to a given device address at the memory address

Definition at line 51 of file i2c.c.

References i2c_send_byte(), i2c_start(), and i2c_stop().

Referenced by ds1631_set_config(), lm75_set_config(), rtc_set_config(), rtc_set_date(), rtc_set_day(), rtc_set_hours(), rtc_set_minutes(), rtc_set_month(), rtc_set_register(), rtc_set_seconds(), rtc_set_year(), rtc_start_clock(), and rtc_stop_clock().

Here is the call graph for this function:

Here is the caller graph for this function:

void i2c_write_eeprom_16bit ( uns8  device_address,
uns8  mem_address,
uns16  data 
)

Write a byte to a given device address at the memory address

Definition at line 63 of file i2c.c.

References i2c_send_byte(), i2c_start(), and i2c_stop().

Referenced by ar1000_init(), ar1000_seek(), ar1000_test(), ar1000_tune(), and ar1000_write_register().

Here is the call graph for this function:

Here is the caller graph for this function:


Generated on Wed Dec 8 13:47:14 2010 for Pic Pack by  doxygen 1.6.1