PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
|
Creates an I2C slave device with 32-byte registers that an I2C master device can write to and read from with a 7-bit device ID, 1-bit read/write, 8-bit register address, and 8 bits of data.
More...
#include "simpletools.h"
Go to the source code of this file.
Classes | |
struct | i2cslave_struct |
Typedefs | |
typedef struct i2cslave_struct | i2cslave_t |
typedef i2cslave_t | i2cslave |
Functions | |
i2cslave_t * | i2cslave_open (int pin_clock, int pin_data, int address) |
Start an I2C slave processor in a new cog. More... | |
void | i2cslave_close (i2cslave_t *device) |
Stop the I2C slave processor and make cog and memory resources available for other uses. More... | |
char * | i2cslave_regAddr (i2cslave_t *device) |
Provides a pointer to the first of the I2C slave device's 32 byte registers. Applications can use this address to directly access the registers without making method calls. More... | |
int | i2cslave_checkForRegChange (i2cslave_t *device) |
Check if any registers have changed. If a register has changed, return its number. If more than one register has changed, return the highest address that has changed. If no registers have changed, return -1. More... | |
int | i2cslave_checkReg (i2cslave_t *device, int index) |
Get the register value if it has changed. More... | |
int | i2cslave_checkFlags (i2cslave_t *device) |
Check the flags register. Bits 31 to 0 indicate if data has changed in registers 31 to 0. More... | |
int | i2cslave_checkFlag (i2cslave_t *device, int index) |
Check a certain register's flag. More... | |
void | i2cslave_clearFlag (i2cslave_t *device, int index) |
Clear a certain register's flag. More... | |
char | i2cslave_getReg (i2cslave_t *device, int index) |
Get the value stored by a certain register. More... | |
void | i2cslave_putReg (i2cslave_t *device, int index, int value) |
Set the value of a register. More... | |
void | i2cslave_flush (i2cslave_t *device) |
Clear all register values and flags. More... | |
int | bitwiseEncode (int i) |
Find out the highest bit with a 1 in a 32 bit register. More... | |
Creates an I2C slave device with 32-byte registers that an I2C master device can write to and read from with a 7-bit device ID, 1-bit read/write, 8-bit register address, and 8 bits of data.
Definition in file i2cslave.h.
struct i2cslave_struct |
int bitwiseEncode | ( | int | i | ) |
Find out the highest bit with a 1 in a 32 bit register.
Definition at line 108 of file i2cslave.c.
int i2cslave_checkFlag | ( | i2cslave_t * | device, |
int | index | ||
) |
Check a certain register's flag.
*device | The i2slave process identifier returned by i2cslave_start. |
index | The index of the flag to be checked. |
Definition at line 75 of file i2cslave.c.
int i2cslave_checkFlags | ( | i2cslave_t * | device | ) |
Check the flags register. Bits 31 to 0 indicate if data has changed in registers 31 to 0.
*device | The i2slave process identifier returned by i2cslave_start. |
Definition at line 69 of file i2cslave.c.
int i2cslave_checkForRegChange | ( | i2cslave_t * | device | ) |
Check if any registers have changed. If a register has changed, return its number. If more than one register has changed, return the highest address that has changed. If no registers have changed, return -1.
*device | The i2slave process identifier returned by i2cslave_start. |
Definition at line 46 of file i2cslave.c.
int i2cslave_checkReg | ( | i2cslave_t * | device, |
int | index | ||
) |
Get the register value if it has changed.
*device | The i2slave process identifier returned by i2cslave_start. |
index | The index (0 to 31) of the register to check. |
Definition at line 54 of file i2cslave.c.
void i2cslave_clearFlag | ( | i2cslave_t * | device, |
int | index | ||
) |
Clear a certain register's flag.
*device | The i2slave process identifier returned by i2cslave_start. |
index | The index of the flag to be cleared. |
Definition at line 81 of file i2cslave.c.
void i2cslave_close | ( | i2cslave_t * | device | ) |
Stop the I2C slave processor and make cog and memory resources available for other uses.
*device | The i2slave process identifier returned by i2cslave_start. |
Definition at line 29 of file i2cslave.c.
void i2cslave_flush | ( | i2cslave_t * | device | ) |
Clear all register values and flags.
*device | The i2slave process identifier returned by i2cslave_start. |
Definition at line 101 of file i2cslave.c.
char i2cslave_getReg | ( | i2cslave_t * | device, |
int | index | ||
) |
Get the value stored by a certain register.
*device | The i2slave process identifier returned by i2cslave_start. |
index | The index of the register (0 to 31). |
Definition at line 87 of file i2cslave.c.
i2cslave_t* i2cslave_open | ( | int | pin_clock, |
int | pin_data, | ||
int | address | ||
) |
void i2cslave_putReg | ( | i2cslave_t * | device, |
int | index, | ||
int | value | ||
) |
Set the value of a register.
*device | The i2slave process identifier returned by i2cslave_start. |
index | The index of the register (0 to 31). |
value | The value stored by the register. |
Definition at line 95 of file i2cslave.c.
char* i2cslave_regAddr | ( | i2cslave_t * | device | ) |
Provides a pointer to the first of the I2C slave device's 32 byte registers. Applications can use this address to directly access the registers without making method calls.
Definition at line 40 of file i2cslave.c.