|
PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
|
16 device->address = address;
17 device->pinSCL = pin_clock;
18 device->pinSDA = pin_data;
22 extern int binary_I2C_slave_v1_2_dat_start[];
23 device->cog = 1 +
cognew((
void*)binary_I2C_slave_v1_2_dat_start, (
void*)device);
42 return device->registers;
56 int mask = 1 << index;
57 if(mask & device->flags)
60 return device->registers[index];
77 return (device->flags >> index) & 1;
83 device->flags = device->flags & (!(1<<index));
89 int rval = (int) device->registers[index];
97 device->registers[index] = value;
104 memset(device->registers, 0, 32);
112 for(n = 32; n > 0; n--)
void i2cslave_clearFlag(i2cslave_t *device, int index)
Clear a certain register's flag.
void i2cslave_putReg(i2cslave_t *device, int index, int value)
Set the value of a register.
int i2cslave_checkFlag(i2cslave_t *device, int index)
Check a certain register's flag.
char * i2cslave_regAddr(i2cslave_t *device)
Provides a pointer to the first of the I2C slave device's 32 byte registers. Applications can use thi...
#define cognew(code, param)
Start a new Propeller PASM COG.
Creates an I2C slave device with 32-byte registers that an I2C master device can write to and read fr...
int i2cslave_checkForRegChange(i2cslave_t *device)
Check if any registers have changed. If a register has changed, return its number....
int bitwiseEncode(int i)
Find out the highest bit with a 1 in a 32 bit register.
void i2cslave_close(i2cslave_t *device)
Stop the I2C slave processor and make cog and memory resources available for other uses.
i2cslave_t * i2cslave_open(int pin_clock, int pin_data, int address)
Start an I2C slave processor in a new cog.
int i2cslave_checkReg(i2cslave_t *device, int index)
Get the register value if it has changed.
int i2cslave_checkFlags(i2cslave_t *device)
Check the flags register. Bits 31 to 0 indicate if data has changed in registers 31 to 0.
#define cogstop(a)
Stop a COG.
void i2cslave_flush(i2cslave_t *device)
Clear all register values and flags.
char i2cslave_getReg(i2cslave_t *device, int index)
Get the value stored by a certain register.