PropWare  3.0.0.229
C++ objects and CMake build system for Parallax Propeller
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 */
i2c_open
HUBTEXT i2c * i2c_open(i2c *bus, int sclPin, int sdaPin, int sclDrive)
Open an i2c device.
Definition: simplei2c.c:60
i2c_poll
HUBTEXT int i2c_poll(i2c *bus, int addr)
Send i2c start and addr byte. Looks for ACK (0) or NACK (1). This is useful for checking if a device ...
Definition: simplei2c.c:227
i2c_readByte
HUBTEXT int i2c_readByte(i2c *bus, int ackState)
Receive i2c byte and reply with ack state. Does not set start or stop. Drives SCL line if i2c device ...
Definition: simplei2c.c:175
i2c_start
HUBTEXT void i2c_start(i2c *bus)
Signal i2c start condition on bus.
Definition: simplei2c.c:71
count
long count(int pin, long duration)
Count number of low to high transitions an external input applies to an I/O pin over a certain period...
Definition: count.c:19
i2c_st
Definition: simplei2c.h:25
i2c_readData
HUBTEXT int i2c_readData(i2c *bus, unsigned char *data, int count)
Receive a block of i2c data. Does not send start or stop conditions.
Definition: simplei2c.c:216
i2c_writeByte
HUBTEXT int i2c_writeByte(i2c *bus, int byte)
Send i2c byte and return acknowledgement from device. Does not set start or stop. Drives SCL line i...
Definition: simplei2c.c:151
i2c_writeData
HUBTEXT int i2c_writeData(i2c *bus, const unsigned char *data, int count)
Send a block of i2c data. Does not set start or stop.
Definition: simplei2c.c:203
i2c_stop
HUBTEXT void i2c_stop(i2c *bus)
Send Signal i2c stop condition on bus.
Definition: simplei2c.c:78
HUBTEXT
#define HUBTEXT
HUBTEXT tells compiler to put code into HUB RAM section.
Definition: propeller.h:43