Provides Propeller specific functions for I2C.
More...
#include <stdint.h>
#include "i2c_driver.h"
Go to the source code of this file.
|
I2C * | i2cOpen (I2C_COGDRIVER *dev, int scl, int sda, int freq) |
| Open an I2C device. More...
|
|
void * | i2cGetCogBuffer (void) |
| Return a pointer to the I2C COG driver image. More...
|
|
I2C * | simple_i2cOpen (I2C_SIMPLE *dev, int scl, int sda) |
| Open an I2C device. More...
|
|
I2C * | i2cBootOpen (void) |
| Open the boot i2c bus on Propeller pins 28/29. More...
|
|
void * | i2cBootBuffer (void) |
| Get the address of the boot i2c bus COG driver. More...
|
|
static int | i2cClose (I2C *dev) |
| Close an I2C device. More...
|
|
static int | i2cWrite (I2C *dev, int address, uint8_t *buffer, int count, int stop) |
| Write to an I2C device. More...
|
|
static int | i2cWriteMore (I2C *dev, uint8_t *buffer, int count, int stop) |
| Write more to an I2C device. More...
|
|
static int | i2cRead (I2C *dev, int address, uint8_t *buffer, int count, int stop) |
| Read from an I2C device. More...
|
|
static int | i2cReadMore (I2C *dev, uint8_t *buffer, int count, int stop) |
| Read more from an I2C device. More...
|
|
int | cog_i2cRead (I2C *dev, int address, uint8_t *buffer, int count, int stop) |
|
int | cog_i2cReadMore (I2C *dev, uint8_t *buffer, int count, int stop) |
|
int | cog_i2cWrite (I2C *dev, int address, uint8_t *buffer, int count, int stop) |
|
int | cog_i2cWriteMore (I2C *dev, uint8_t *buffer, int count, int stop) |
|
Provides Propeller specific functions for I2C.
Definition in file i2c.h.
◆ I2C
Definition at line 50 of file i2c.h.
◆ I2C_COGDRIVER
Definition at line 54 of file i2c.h.
◆ I2C_SIMPLE
Definition at line 60 of file i2c.h.
Class Members |
I2C |
i2c |
|
uint32_t |
scl_mask |
|
uint32_t |
sda_mask |
|
◆ I2C
forward type declarations
Definition at line 38 of file i2c.h.
◆ i2cBootBuffer()
void* i2cBootBuffer |
( |
void |
| ) |
|
Get the address of the boot i2c bus COG driver.
Once the boot i2c bus has been opened with i2cBootOpen, by loading a COG using either cognewFromBootEeprom or coginitFromBootEeprom, or calling readBootEeprom or writeBootEeprom, it is possible to reuse the hub memory space used by the boot i2c driver. However, once this is done it will no longer be possible to load the boot i2c driver again so after closing the boot i2c buss, calls to i2cBootOpen, cognewFromBootEeprom, or coginitFromBootEeprom will fail.
- Returns
- a pointer to the boot i2c driver COG image for use as a buffer.
◆ i2cBootOpen()
I2C* i2cBootOpen |
( |
void |
| ) |
|
Open the boot i2c bus on Propeller pins 28/29.
Use this function to open the i2c bus on pins 28/29 used by the Propeller to boot from EEPROM.
- Returns
- a pointer to an I2C structure for the bus or NULL on failure.
◆ i2cClose()
static int i2cClose |
( |
I2C * |
dev | ) |
|
|
static |
Close an I2C device.
Close an I2C device that was opened with either i2cOpen or simple_i2cOpen.
- Parameters
-
- Returns
- 0 on success, -1 on failure.
Definition at line 145 of file i2c.h.
◆ i2cGetCogBuffer()
void* i2cGetCogBuffer |
( |
void |
| ) |
|
Return a pointer to the I2C COG driver image.
Returns a pointer to the I2C COG driver image. This allows the space that was occupied by the COG driver to be reused after the driver has been loaded. Call this only after the final call to i2cOpen.
- Returns
- a pointer to the I2C COG driver image.
◆ i2cOpen()
Open an I2C device.
Open an I2C device using a COG driver.
- Parameters
-
dev | I2C device structure to initialize |
scl | SCL pin number |
sda | SDA pin number |
freq | Bus frequency |
- Returns
- a pointer to the device on success, NULL on failure.
◆ i2cRead()
static int i2cRead |
( |
I2C * |
dev, |
|
|
int |
address, |
|
|
uint8_t * |
buffer, |
|
|
int |
count, |
|
|
int |
stop |
|
) |
| |
|
static |
Read from an I2C device.
Read from an I2C device at the specified address. The address should be the device address in bits 7:1 and a zero in bit 0. Set the stop parameter to TRUE to cause an I2C stop sequence to be emitted after the data. Setting it to FALSE omits the stop sequence.
- Parameters
-
dev | I2C device to read from |
address | I2C address in bits 7:1, zero in bit 0 |
buffer | Address of the buffer to receive data |
count | Number of bytes of data to receive |
stop | TRUE to send a stop sequence after the data |
- Returns
- 0 on success, -1 on failure.
Definition at line 214 of file i2c.h.
◆ i2cReadMore()
static int i2cReadMore |
( |
I2C * |
dev, |
|
|
uint8_t * |
buffer, |
|
|
int |
count, |
|
|
int |
stop |
|
) |
| |
|
static |
Read more from an I2C device.
Read more from an I2C device. This can only be used following a call to i2cRead that specifies FALSE for the stop parameter. Set the stop parameter to TRUE to cause an I2C stop sequence to be emitted after the data. Setting it to FALSE omits the stop sequence.
- Parameters
-
dev | I2C device to read from |
address | I2C address in bits 7:1, zero in bit 0 |
buffer | Address of the buffer to receive data |
count | Number of bytes of data to receive |
stop | TRUE to send a stop sequence after the data |
- Returns
- 0 on success, -1 on failure.
Definition at line 237 of file i2c.h.
◆ i2cWrite()
static int i2cWrite |
( |
I2C * |
dev, |
|
|
int |
address, |
|
|
uint8_t * |
buffer, |
|
|
int |
count, |
|
|
int |
stop |
|
) |
| |
|
static |
Write to an I2C device.
Write to an I2C device at the specified address. The address should be the device address in bits 7:1 and a zero in bit 0. If count is zero only the address byte will be sent. Set the stop parameter to TRUE to cause an I2C stop sequence to be emitted after the data. Setting it to FALSE omits the stop sequence.
- Parameters
-
dev | I2C device to write to |
address | I2C address in bits 7:1, zero in bit 0 |
buffer | Address of the buffer containing data to write |
count | Number of bytes of data to write |
stop | TRUE to send a stop sequence after the data |
- Returns
- 0 on success, -1 on failure.
Definition at line 169 of file i2c.h.
◆ i2cWriteMore()
static int i2cWriteMore |
( |
I2C * |
dev, |
|
|
uint8_t * |
buffer, |
|
|
int |
count, |
|
|
int |
stop |
|
) |
| |
|
static |
Write more to an I2C device.
Write more to an I2C device. This can only be used following a call to i2cWrite that specifies FALSE for the stop parameter. Set the stop parameter to TRUE to cause an I2C stop sequence to be emitted after the data. Setting it to FALSE omits the stop sequence.
- Parameters
-
dev | I2C device to write to |
buffer | Address of the buffer containing data to write |
count | Number of bytes of data to write |
stop | TRUE to send a stop sequence after the data |
- Returns
- 0 on success, -1 on failure.
Definition at line 191 of file i2c.h.
◆ simple_i2cOpen()
Open an I2C device.
Open an I2C device using a simple driver that runs on the COG of the caller.
- Parameters
-
dev | I2C device structure to initialize |
scl | SCL pin number |
sda | SDA pin number |
- Returns
- a pointer to the device on success, NULL on failure.