LTlib LaurTec Library  4.0.3
Open Source C Library for Microchip Microcontrollers based on XC8 Compiler
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
I2C_EEPROM.h
Go to the documentation of this file.
1 /*******************************************************************************
2 
3 Author : Mauro Laurenti
4 Version : 1.5
5 
6 Created on Date : 04/09/2006
7 Last update : 16/03/2016
8 
9 CopyRight 2006-2015 all rights are reserved
10 
11 ********************************************************
12 SOFTWARE LICENSE AGREEMENT
13 ********************************************************
14 
15 The usage of the supplied software imply the acceptance of the following license.
16 
17 The software supplied herewith by Mauro Laurenti (the Author) is intended for
18 use solely and exclusively on Microchip PIC Microcontroller (registered mark).
19 The software is owned by the Author, and is protected under applicable
20 copyright laws. All rights are reserved.
21 Any use in violation of the foregoing restrictions may subject the
22 user to criminal sanctions under applicable laws, as well as to civil liability
23 for the breach of the terms and conditions of this license.
24 Commercial use is forbidden without a written acknowledgement with the Author.
25 Personal or educational use is allowed if the application containing the
26 following software doesn't aim to commercial use or monetary earning of any kind.
27 
28 THIS SOFTWARE IS PROVIDED IN AN "AS IS" CONDITION. NO WARRANTIES,
29 WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED
30 TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
31 PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE AUTHOR SHALL NOT,
32 IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
33 CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
34 
35 
36 ********************************************************
37 PURPOSES
38 ********************************************************
39 
40 These functions allow the user to read/write inside the eeprom
41 that requires 2 address bytes such as the 24LC512.
42 
43 ********************************************************************************/
44 
45 #ifndef LTLIB_I2C_EEPROM_H
46 #define LTLIB_I2C_EEPROM_H
47 
48 #ifdef __XC8
49  #include <xc.h>
50 #endif
51 
52 //*****************************************
53 // Library Test
54 //*****************************************
55 #include "LTlib.h"
56 
57 #ifndef LTLIB_DELAY_H
58  #error The I2C_EEPROM Library requires the "delay" library to be included.
59 #endif
60 
61 #ifndef LTLIB_I2C_MODULE_H
62  #error The I2C_EEPROM Library requires the "module_I2C" library to be included.
63 #endif
64 
65 
66 //*****************************************
67 // I2C Module Switch
68 //*****************************************
69 
70 #if defined (EEPROM_I2C_MODULE_1) || defined (EEPROM_I2C_MODULE_2)
71 
72 #else
73  #define EEPROM_I2C_MODULE_1
74 #endif
75 
76 
77 #ifdef EEPROM_I2C_MODULE_1
78  #define EEPROM_I2C_open I2C1_open
79  #define EEPROM_I2C_baud_rate I2C1_baud_rate
80  #define EEPROM_I2C_wait_bus_IDLE I2C1_wait_bus_IDLE
81  #define EEPROM_I2C_start_bit I2C1_start_bit
82  #define EEPROM_I2C_stop_bit I2C1_stop_bit
83  #define EEPROM_I2C_write_byte I2C1_write_byte
84  #define EEPROM_I2C_check_bus_collision I2C1_check_bus_collision
85  #define EEPROM_I2C_check_ACK I2C1_check_ACK
86  #define EEPROM_I2C_negative_ACK I2C1_negative_ACK
87  #define EEPROM_I2C_set_master_as_receiver I2C1_set_master_as_receiver
88  #define EEPROM_I2C_read_byte I2C1_read_byte
89  #define EEPROM_I2C_restart_communication I2C1_restart_communication
90 #endif
91 
92 #ifdef EEPROM_I2C_MODULE_2
93  #define EEPROM_I2C_open I2C2_open
94  #define EEPROM_I2C_baud_rate I2C2_baud_rate
95  #define EEPROM_I2C_wait_bus_IDLE I2C2_wait_bus_IDLE
96  #define EEPROM_I2C_start_bit I2C2_start_bit
97  #define EEPROM_I2C_stop_bit I2C2_stop_bit
98  #define EEPROM_I2C_write_byte I2C2_write_byte
99  #define EEPROM_I2C_check_bus_collision I2C2_check_bus_collision
100  #define EEPROM_I2C_check_ACK I2C2_check_ACK
101  #define EEPROM_I2C_negative_ACK I2C2_negative_ACK
102  #define EEPROM_I2C_set_master_as_receiver I2C2_set_master_as_receiver
103  #define EEPROM_I2C_read_byte I2C2_read_byte
104  #define EEPROM_I2C_restart_communication I2C2_restart_communication
105 #endif
106 
107 
120 void I2C_EEPROM_initialize (unsigned int baud_rate_KHz);
121 #define initialize_I2C_EEPROM I2C_EEPROM_initialize
122 
123 
141 signed char I2C_EEPROM_write_byte (unsigned char control, unsigned int address, unsigned char data );
142 #define write_I2C_EEPROM I2C_EEPROM_write_byte
143 #define I2C_EEPROM_write I2C_EEPROM_write_byte
144 
145 
166 signed char I2C_EEPROM_write_byte_check ( unsigned char control, unsigned int address, unsigned char data );
167 #define write_I2C_EEPROM_check I2C_EEPROM_write_byte_check
168 #define I2C_EEPROM_write_check I2C_EEPROM_write_byte_check
169 
189 signed char I2C_EEPROM_read_byte ( unsigned char control, unsigned int address, unsigned char *data );
190 #define read_I2C_EEPROM I2C_EEPROM_read_byte
191 #define I2C_EEPROM_read I2C_EEPROM_read_byte
192 
193 #endif