PIC software documentation
Main Page
Modules
Classes
Files
File List
File Members
All
Classes
Files
Functions
Variables
Enumerations
Enumerator
Groups
pic24I2C
src
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
65
enum
i2c_states
66
{
68
I2C_STATE_idle
,
70
I2C_STATE_sendingStart
,
72
I2C_STATE_dataTX
,
74
I2C_STATE_sendingRestart
,
76
I2C_STATE_sendingStop
,
78
I2C_STATE_dataRX
,
80
I2C_STATE_ack
,
92
I2C_STATE_error
,
94
I2C_STATE_disabled
,
95
};
96
102
extern
volatile
enum
i2c_states
i2c_state
;
103
115
extern
volatile
bool
i2c_stayInErrorState
;
116
120
enum
i2c_errors
121
{
123
I2C_ERR_noError
= 0,
125
I2C_ERR_internal
= 1,
127
I2C_ERR_inErrorState
= 2,
129
I2C_ERR_busy
= 3,
131
I2C_ERR_TXBufferOverflow
= 4,
134
I2C_ERR_RXBufferOverflow
= 5,
136
I2C_ERR_slaveNACK
= 6,
138
I2C_ERR_nothingReceived
= 7,
140
I2C_ERR_collisionDetected
= 8,
142
I2C_ERR_disabled
= 9,
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
Generated on Fri Jul 19 2013 17:11:24 for PIC software documentation by
1.8.1.2