Out-of-office display, GFX
Main Page
Modules
Classes
Files
Examples
File List
File Members
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
25
#ifndef _I2CDRIVER_H
26
#define _I2CDRIVER_H
27
28
#include <stdbool.h>
29
#include <stddef.h>
30
36
#define I2C_NO 1
37
41
#define I2C_TRX_BUFFER_SIZE 32
42
46
enum
i2c_states
47
{
49
I2C_STATE_idle
,
51
I2C_STATE_sendingStart
,
53
I2C_STATE_dataTX
,
55
I2C_STATE_sendingRestart
,
57
I2C_STATE_sendingStop
,
59
I2C_STATE_dataRX
,
61
I2C_STATE_ack
,
73
I2C_STATE_error
,
75
I2C_STATE_disabled
,
76
};
77
83
extern
volatile
enum
i2c_states
i2c_state
;
84
96
extern
volatile
bool
i2c_stayInErrorState
;
97
101
enum
i2c_errors
102
{
104
I2C_ERR_noError
= 0,
106
I2C_ERR_internal
= -1,
108
I2C_ERR_inErrorState
= -2,
110
I2C_ERR_busy
= -3,
112
I2C_ERR_TXBufferOverflow
= -4,
115
I2C_ERR_RXBufferOverflow
= -5,
117
I2C_ERR_slaveNACK
= -6,
119
I2C_ERR_nothingReceived
= -7,
121
I2C_ERR_collisionDetected
= -8,
123
I2C_ERR_disabled
= -9,
124
};
125
131
extern
volatile
enum
i2c_errors
i2c_error
;
132
136
void
i2c_reset
();
137
143
bool
i2c_busy
();
144
152
void
i2c_init
(
int
brg,
bool
enableSlewRateControl,
int
priority );
153
160
void
i2c_disable
();
161
169
void
i2c_enable
();
170
187
int
i2c_putc
(
unsigned
char
address,
unsigned
char
reg,
unsigned
char
data );
188
207
int
i2c_puts
(
unsigned
char
address,
unsigned
char
reg,
unsigned
char
*data,
208
size_t
len );
209
226
int
i2c_getc
(
unsigned
char
address,
unsigned
char
reg );
227
246
int
i2c_gets
(
unsigned
char
address,
unsigned
char
reg,
size_t
len );
247
266
int
i2c_getData
(
unsigned
char
*data,
size_t
len );
267
268
269
#endif // _I2CDRIVER_H
270
Generated on Mon Jul 8 2013 01:04:59 for Out-of-office display, GFX by
1.8.1.2