Contiki 2.5
i2c-drv.h
Go to the documentation of this file.
1 /* Copyright (c) 2010, Stephan Rottmann
2  *
3  * Permission is hereby granted, free of charge, to any person
4  * obtaining a copy of this software and associated documentation
5  * files (the "Software"), to deal in the Software without
6  * restriction, including without limitation the rights to use,
7  * copy, modify, merge, publish, distribute, sublicense, and/or sell
8  * copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following
10  * conditions:
11  *
12  * The above copyright notice and this permission notice shall be
13  * included in all copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19  * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22  * OTHER DEALINGS IN THE SOFTWARE.
23  */
24 
25 /**
26  * \addtogroup Drivers
27  * @{
28  *
29  * \defgroup i2c_driver I2C-Bus Driver
30  *
31  * <p></p>
32  * @{
33  *
34  */
35 
36 /**
37  * \file
38  * I2C driver definitions
39  * \author
40  * Stephan Rottman <rottmann@ibr.cs.tu-bs.de>
41  */
42 #include <avr/io.h>
43 
44 #ifndef I2CDRV_H_
45 #define I2CDRV_H_
46 
47 
48 #define I2C_HIGH_SPEED 0
49 
50 
51 #define I2C_START 0x08
52 #define I2C_REP_START 0x10
53 #define I2C_MT_SLA_ACK 0x18
54 #define I2C_MT_DATA_ACK 0x28
55 #define I2C_MR_SLA_ACK 0x40
56 #define I2C_MR_DATA_ACK 0x50
57 #define I2C_MR_DATA_NACK 0x58
58 
59 
60 void i2c_init(void);
61 void i2c_stop(void);
62 
63 int8_t i2c_start(uint8_t addr);
64 int8_t i2c_rep_start(uint8_t addr);
65 int8_t i2c_write(uint8_t data);
66 int8_t i2c_read(uint8_t *data, uint8_t ack);
67 int8_t i2c_read_ack(uint8_t *data);
68 int8_t i2c_read_nack(uint8_t *data);
69 
70 
71 #endif /* I2CDRV_H_ */