PropWare  3.0.0.229
C++ objects and CMake build system for Parallax Propeller
Classes | Typedefs | Functions
i2c.h File Reference

Provides Propeller specific functions for I2C. More...

#include <stdint.h>
#include "i2c_driver.h"
+ Include dependency graph for i2c.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  I2C_OPS
 
struct  I2C
 
struct  I2C_COGDRIVER
 
struct  I2C_SIMPLE
 

Typedefs

typedef struct I2C I2C
 

Functions

I2Ci2cOpen (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...
 
I2Csimple_i2cOpen (I2C_SIMPLE *dev, int scl, int sda)
 Open an I2C device. More...
 
I2Ci2cBootOpen (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)
 

Detailed Description

Provides Propeller specific functions for I2C.

Definition in file i2c.h.


Class Documentation

◆ I2C

struct I2C

Definition at line 50 of file i2c.h.

+ Collaboration diagram for I2C:
Class Members
I2C_OPS * ops

◆ I2C_COGDRIVER

struct I2C_COGDRIVER

Definition at line 54 of file i2c.h.

+ Collaboration diagram for I2C_COGDRIVER:
Class Members
int cog
I2C i2c
volatile I2C_MAILBOX mailbox

◆ I2C_SIMPLE

struct I2C_SIMPLE

Definition at line 60 of file i2c.h.

+ Collaboration diagram for I2C_SIMPLE:
Class Members
I2C i2c
uint32_t scl_mask
uint32_t sda_mask

Typedef Documentation

◆ I2C

typedef struct I2C I2C

forward type declarations

Definition at line 38 of file i2c.h.

Function Documentation

◆ 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
devI2C device to close
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()

I2C* i2cOpen ( I2C_COGDRIVER dev,
int  scl,
int  sda,
int  freq 
)

Open an I2C device.

Open an I2C device using a COG driver.

Parameters
devI2C device structure to initialize
sclSCL pin number
sdaSDA pin number
freqBus 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
devI2C device to read from
addressI2C address in bits 7:1, zero in bit 0
bufferAddress of the buffer to receive data
countNumber of bytes of data to receive
stopTRUE to send a stop sequence after the data
Returns
0 on success, -1 on failure.

Definition at line 214 of file i2c.h.

+ Here is the call graph for this function:

◆ 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
devI2C device to read from
addressI2C address in bits 7:1, zero in bit 0
bufferAddress of the buffer to receive data
countNumber of bytes of data to receive
stopTRUE to send a stop sequence after the data
Returns
0 on success, -1 on failure.

Definition at line 237 of file i2c.h.

+ Here is the call graph for this function:

◆ 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
devI2C device to write to
addressI2C address in bits 7:1, zero in bit 0
bufferAddress of the buffer containing data to write
countNumber of bytes of data to write
stopTRUE to send a stop sequence after the data
Returns
0 on success, -1 on failure.

Definition at line 169 of file i2c.h.

+ Here is the call graph for this function:

◆ 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
devI2C device to write to
bufferAddress of the buffer containing data to write
countNumber of bytes of data to write
stopTRUE to send a stop sequence after the data
Returns
0 on success, -1 on failure.

Definition at line 191 of file i2c.h.

+ Here is the call graph for this function:

◆ simple_i2cOpen()

I2C* simple_i2cOpen ( I2C_SIMPLE dev,
int  scl,
int  sda 
)

Open an I2C device.

Open an I2C device using a simple driver that runs on the COG of the caller.

Parameters
devI2C device structure to initialize
sclSCL pin number
sdaSDA pin number
Returns
a pointer to the device on success, NULL on failure.