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_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_byte (uns8 data)
 Send a byte to I2C buss.
void i2c_setup ()
 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.


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 2 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 34 of file i2c.h.

Referenced by i2c_receive_byte(), and i2c_send_byte().

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

Change SDA line to write mode

Definition at line 32 of file i2c.h.

Referenced by i2c_read_eeprom(), i2c_read_eeprom_16bit(), 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 27 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_hours(), rtc_get_minutes(), rtc_get_month(), rtc_get_seconds(), rtc_get_year(), 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 55 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 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 120 of file i2c.c.

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

Referenced by i2c_read_eeprom(), and i2c_read_eeprom_16bit().

Here is the caller graph for this function:

void i2c_send_byte ( uns8  data  ) 

Clock out a byte from the I2C buss. An acknowledge is "received" (although ignored).

Definition at line 142 of file i2c.c.

References change_pin, clear_pin, DELAY_AMOUNT, i2c_read_sda, i2c_write_sda, set_pin, and uns8.

Referenced by ds1631_convert_temp(), i2c_ack_polling(), i2c_read_eeprom(), i2c_read_eeprom_16bit(), and i2c_write_eeprom().

Here is the caller graph for this function:

void i2c_setup (  ) 

Set port and pins correctly for I2C communication

Definition at line 165 of file i2c.c.

References make_output.

Referenced by ds1631_setup(), lm75_setup(), and rtc_setup().

Here is the caller graph for this function:

void i2c_start ( void   ) 

Signals a start condition on the I2C buss.

Definition at line 95 of file i2c.c.

References clear_pin, DELAY_AMOUNT, and i2c_write_sda.

Referenced by ds1631_convert_temp(), i2c_ack_polling(), i2c_read_eeprom(), i2c_read_eeprom_16bit(), and i2c_write_eeprom().

Here is the caller graph for this function:

void i2c_stop ( void   ) 

Signals a stop condition on the I2C buss.

Definition at line 105 of file i2c.c.

References clear_pin, DELAY_AMOUNT, i2c_write_sda, and set_pin.

Referenced by ds1631_convert_temp(), i2c_ack_polling(), i2c_read_eeprom(), i2c_read_eeprom_16bit(), and i2c_write_eeprom().

Here is the caller graph for this function:

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 15 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_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:


Generated on Tue Jul 22 09:32:05 2008 for Pic Pack by  doxygen 1.5.5