PIC software documentation
 All Classes Files Functions Variables Enumerations Enumerator Groups
i2cDriver.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2013 Andreas Misje
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
44 #ifndef I2CDRIVER_H
45 #define I2CDRIVER_H
46 
47 #include <stdbool.h>
48 #include <stddef.h>
49 
55 #define I2C_NO 1
56 
60 #define I2C_TRX_BUFFER_SIZE 32
61 
66 {
95 };
96 
102 extern volatile enum i2c_states i2c_state;
103 
115 extern volatile bool i2c_stayInErrorState;
116 
121 {
143 };
144 
150 extern volatile enum i2c_errors i2c_error;
151 
155 void i2c_reset();
156 
162 bool i2c_busy();
163 
171 void i2c_init( int brg, bool enableSlewRateControl, int priority );
172 
179 void i2c_disable();
180 
188 void i2c_enable();
189 
206 int i2c_putc( unsigned char address, unsigned char reg, unsigned char data );
207 
226 int i2c_puts( unsigned char address, unsigned char reg, unsigned char *data,
227  size_t len );
228 
245 int i2c_getc( unsigned char address, unsigned char reg );
246 
265 int i2c_gets( unsigned char address, unsigned char reg, size_t len );
266 
285 int i2c_getData( unsigned char *data, size_t len );
286 
287 
288 #endif // I2CDRIVER_H
289