PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
|
Provides simple i2c start, stop, read, and write functions. See simpletools library for additional I2C functions. More...
#include <propeller.h>
Go to the source code of this file.
Classes | |
struct | i2c_st |
Typedefs | |
typedef struct i2c_st | i2c |
Functions | |
HUBTEXT i2c * | i2c_open (i2c *bus, int sclPin, int sdaPin, int sclDrive) |
Open an i2c device. More... | |
HUBTEXT void | i2c_start (i2c *bus) |
Signal i2c start condition on bus. More... | |
HUBTEXT void | i2c_stop (i2c *bus) |
Send Signal i2c stop condition on bus. More... | |
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 if i2c device opened using sclDrive = 1. More... | |
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 opened using sclDrive = 1. More... | |
HUBTEXT int | i2c_writeData (i2c *bus, const unsigned char *data, int count) |
Send a block of i2c data. Does not set start or stop. More... | |
HUBTEXT int | i2c_readData (i2c *bus, unsigned char *data, int count) |
Receive a block of i2c data. Does not send start or stop conditions. More... | |
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 is responding or starting a new i2c packet. No stop is sent. More... | |
Provides simple i2c start, stop, read, and write functions. See simpletools library for additional I2C functions.
Copyright (c) 2013, Parallax Inc.
Definition in file simplei2c.h.
struct i2c_st |
Definition at line 25 of file simplei2c.h.
Class Members | ||
---|---|---|
int | drivescl | |
volatile int | scl_mask | |
volatile int | scl_mask_inv | |
int | sda_mask | |
int | sda_mask_inv |
Open an i2c device.
[in] | *bus | is a pointer to an i2c storage variable. |
sclPin | is the number of the Propeller I/O pin connected to the I2C bus' SCL line. | |
sdaPin | is the number of the Propeller I/O pin connected to the I2C bus' SDA line. | |
sclDrive | says drive SCL (1) or not (0). No SCL drive is by far the most common arrangement. Some Propeller boards do not apply a pull- up resistor to the EEPROM's SCL line, and driving the SCL pin is useful in for communicating with EEPROMs on those particular boards. |
Definition at line 60 of file simplei2c.c.
Send i2c start and addr byte. Looks for ACK (0) or NACK (1). This is useful for checking if a device is responding or starting a new i2c packet. No stop is sent.
*bus | is the bus pointer returned by i2c_open. |
addr | is the I2C device address. |
Definition at line 227 of file simplei2c.c.
Receive i2c byte and reply with ack state. Does not set start or stop. Drives SCL line if i2c device opened using sclDrive = 1.
*bus | is the bus pointer returned by i2c_open. |
ackState | sets or clears the acknowledge bit that follows the data byte in I2C. Acknowledge is ACK = 0, and no-acknowledge (NACK = 1). |
Definition at line 175 of file simplei2c.c.
Receive a block of i2c data. Does not send start or stop conditions.
The Propeller replies with ACK after each byte received. After the last byte, it replies with NACK to tell the I2C device that it's done receiving bytes.
Drive scl if i2c device opened using sclDrive.
*bus | is the bus pointer returned by i2c_open. |
data | is a pointer to an array of unsigned char bytes. |
count | is the number of bytes to receive. |
Definition at line 216 of file simplei2c.c.
Signal i2c start condition on bus.
*bus | is the bus pointer returned by i2c_open. |
Definition at line 71 of file simplei2c.c.
Send Signal i2c stop condition on bus.
*bus | is the bus pointer returned by i2c_open. |
Definition at line 78 of file simplei2c.c.
Send i2c byte and return acknowledgement from device. Does not set start or stop.
Drives SCL line if i2c device opened using sclDrive = 1.
*bus | is the bus pointer returned by i2c_open. |
byte | is the data byte the Propeller chip sends to the I2C device. |
Definition at line 151 of file simplei2c.c.
Send a block of i2c data. Does not set start or stop.
If the device replies with NACK after receiving a particular data byte, the transmit will terminate.
Drive scl if i2c device opened using sclDrive.
*bus | is the bus pointer returned by i2c_open. |
*data | is a pointer to the array of data to send. |
count | is the number of bytes to send. |
Definition at line 203 of file simplei2c.c.