Open Garden  0.10.1-21
i2c.h
Go to the documentation of this file.
1 /* Copyright (C) 2011 Enrico Rossi
2  *
3  * This program is free software: you can redistribute it and/or modify
4  * it under the terms of the GNU Lesser General Public License as
5  * published by the Free Software Foundation, either version 3 of the
6  * License, or (at your option) any later version.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public
14  * License along with this program.
15  * If not, see <http://www.gnu.org/licenses/>.
16  */
17 
20 #ifndef I2C_DEF
21 #define I2C_DEF
22 
24 #define START 1
25 
26 #define STOP 2
27 
28 #define SLA 3
29 
30 #define DATA 4
31 
32 #define ACK 5
33 
34 #define NACK 6
35 
37 #define WRITE 0
38 
39 #define READ 1
40 
41 uint8_t i2c_send(const uint8_t code, const uint8_t data);
42 void i2c_init(void);
43 void i2c_shut(void);
44 uint8_t i2c_master_send_b(const uint8_t addr, const uint8_t data);
45 uint8_t i2c_master_send_w(const uint8_t addr, const uint8_t msb, const uint8_t lsb);
46 uint8_t i2c_master_read_b(const uint8_t addr, uint8_t *byte);
47 uint8_t i2c_master_read_w(const uint8_t addr, uint16_t *code);
48 
49 #endif
uint8_t i2c_master_read_b(const uint8_t addr, uint8_t *byte)
i2c master read byte.
Definition: i2c.c:144
uint8_t i2c_master_send_b(const uint8_t addr, const uint8_t data)
Definition: i2c.c:86
void i2c_init(void)
Definition: i2c.c:69
void i2c_shut(void)
Definition: i2c.c:76
uint8_t i2c_send(const uint8_t code, const uint8_t data)
Definition: i2c.c:31
uint8_t i2c_master_send_w(const uint8_t addr, const uint8_t msb, const uint8_t lsb)
i2c master send a word. Send a word to the i2c slave with stop at the end.
Definition: i2c.c:113
uint8_t i2c_master_read_w(const uint8_t addr, uint16_t *code)
Definition: i2c.c:174