I2C software routines. More...
#include "config.h"
#include "pic_utils.h"
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. |
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 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().
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().
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().
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().
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().
void i2c_send_byte | ( | uns8 | data | ) |
Clock out a byte from the I2C buss. An acknowledge is "received" (although ignored).
Definition at line 206 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(), hmc6352_enter_cal(), hmc6352_exit_cal(), hmc6352_get_data(), hmc6352_read_eeprom(), hmc6352_read_ram(), hmc6352_save_op_mode(), hmc6352_sleep(), hmc6352_update_bridge_offsets(), hmc6352_wake(), hmc6352_write_eeprom(), hmc6352_write_ram(), i2c_ack_polling(), i2c_read_eeprom(), i2c_read_eeprom_16bit(), i2c_write_eeprom(), i2c_write_eeprom_16bit(), tmp75_read(), tmp75_read_16bit(), and tmp75_write().
void i2c_setup_io | ( | ) |
void i2c_start | ( | void | ) |
Signals a start condition on the I2C buss.
Definition at line 155 of file i2c.c.
References clear_pin, DELAY_AMOUNT, i2c_write_sda, and set_pin.
Referenced by ds1631_convert_temp(), hmc6352_enter_cal(), hmc6352_exit_cal(), hmc6352_get_data(), hmc6352_read_eeprom(), hmc6352_read_ram(), hmc6352_save_op_mode(), hmc6352_sleep(), hmc6352_update_bridge_offsets(), hmc6352_wake(), hmc6352_write_eeprom(), hmc6352_write_ram(), i2c_ack_polling(), i2c_read_eeprom(), i2c_read_eeprom_16bit(), i2c_write_eeprom(), i2c_write_eeprom_16bit(), tmp75_read(), tmp75_read_16bit(), and tmp75_write().
void i2c_stop | ( | void | ) |
Signals a stop condition on the I2C buss.
Definition at line 171 of file i2c.c.
References clear_pin, DELAY_AMOUNT, i2c_write_sda, and set_pin.
Referenced by ds1631_convert_temp(), hmc6352_enter_cal(), hmc6352_exit_cal(), hmc6352_get_data(), hmc6352_read_eeprom(), hmc6352_read_ram(), hmc6352_save_op_mode(), hmc6352_sleep(), hmc6352_update_bridge_offsets(), hmc6352_wake(), hmc6352_write_eeprom(), hmc6352_write_ram(), i2c_ack_polling(), i2c_read_eeprom(), i2c_read_eeprom_16bit(), i2c_write_eeprom(), i2c_write_eeprom_16bit(), tmp75_read(), tmp75_read_16bit(), and tmp75_write().
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().
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().