simple i2c library v0.85 Covers I2C basics like start/stop conditions and byte & data send & receive

- Main Page
- Data Structures
- Files

- File List
- Globals

simplei2c.h
Go to the documentation of this file.
1
14 #ifndef __i2c_H
15 #define __i2c_H
16
17 #ifdef __cplusplus
18 extern "C"
19 {
20 #endif
21
22 #include <propeller.h>
23
24
25 typedef struct i2c_st
26 {
27 volatile int scl_mask;
28 volatile int scl_mask_inv;
29 int sda_mask;
30 int sda_mask_inv;
31 int drivescl; /* flag to force scl if non-zero */
32 } i2c;
33
47 HUBTEXT i2c *i2c_open(i2c *bus, int sclPin, int sdaPin, int sclDrive);
48
54 HUBTEXT void i2c_start(i2c *bus);
55
61 HUBTEXT void i2c_stop(i2c *bus);
62
73 HUBTEXT int i2c_writeByte(i2c *bus, int byte);
74
84 HUBTEXT int i2c_readByte(i2c *bus, int ackState);
85
98 HUBTEXT int i2c_writeData(i2c *bus, const unsigned char *data, int count);
99
113 HUBTEXT int i2c_readData(i2c *bus, unsigned char *data, int count);
114
124 HUBTEXT int i2c_poll(i2c *bus, int addr);
125
126 #ifdef __cplusplus
127 }
128 #endif
129
130 #endif
131 /* __i2c_H */
132
133 /*
134 +--------------------------------------------------------------------
135 | TERMS OF USE: MIT License
136 +--------------------------------------------------------------------
137 Permission is hereby granted, free of charge, to any person obtaining
138 a copy of this software and associated documentation files
139 (the "Software"), to deal in the Software without restriction,
140 including without limitation the rights to use, copy, modify, merge,
141 publish, distribute, sublicense, and/or sell copies of the Software,
142 and to permit persons to whom the Software is furnished to do so,
143 subject to the following conditions:
144
145 The above copyright notice and this permission notice shall be
146 included in all copies or substantial portions of the Software.
147
148 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
149 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
150 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
151 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
152 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
153 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
154 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
155 +--------------------------------------------------------------------
156 */