00001 #ifndef __i2c_h
00002 #define __i2c_h defined
00003
00004 #include "config.h"
00005
00014 #include "pic_utils.h"
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00032 #define i2c_write_sda() clear_bit(tris_array[i2c_sda_port - PORTA], i2c_sda_pin); // output
00033
00034 #define i2c_read_sda() set_bit(tris_array[i2c_sda_port - PORTA], i2c_sda_pin); // input
00035
00040 void i2c_start(void);
00041
00047 void i2c_stop(void);
00048
00055 uns8 i2c_receive_byte();
00056
00063 void i2c_send_byte(uns8 data);
00064
00070 uns8 i2c_read_eeprom(uns8 device_address, uns8 mem_address);
00071
00076 void i2c_write_eeprom(uns8 device_address, uns8 mem_address, uns8 data);
00077
00083 uns16 i2c_read_eeprom_16bit(uns8 device_address, uns8 mem_address);
00084
00090 void i2c_setup();
00091
00092 #ifndef i2c_scl_port
00093 #error "You haven't defined i2c_scl_port in your config.h!"
00094 #endif
00095
00096 #ifndef i2c_sda_port
00097 #error "You haven't defined i2c_sda_port in your config.h!"
00098 #endif
00099
00100 #ifndef i2c_scl_pin
00101 #error "You haven't defined i2c_scl_pin in your config.h!"
00102 #endif
00103
00104 #ifndef i2c_sda_pin
00105 #error "You haven't defined i2c_sda_pin in your config.h!"
00106 #endif
00107
00108
00109
00110 #endif