For what its worth here is the missing macros I defined. The i2c fields are defined in ulp.h. However when I run this opcode in the ulp it appears to stall and my ulp code does not wake up from deep sleep. I have tried setting things up the registers as per the technical reference.
Does anyone have example of code that uses i2c read and write instructions in the ulp coprocessor?
Code: Select all
//define the missing I2C macros
//I2C_RD Sub_addr, high, low, Slave_sel
//read value is returned in R0 high and low define bit mask
#define I_I2C_RD(sub_addr, high_bit, low_bit, slave_sel) {.i2c = {\
.i2c_addr = sub_addr, \
.data = 0,\
.low_bits = low_bit, \
.high_bits = high_bit, \
.i2c_sel = slave_sel,\
.unused = 0,\
.rw = 0,\
.opcode = OPCODE_I2C } }
//I2C_WR Sub_addr, Value, High, Low, Slave_sel
//value is writen to sub_addr register
#define I_I2C_WR(sub_addr, value, high_bit, low_bit, slave_sel) {.i2c = {\
.i2c_addr = sub_addr, \
.data = value,\
.low_bits = low_bit, \
.high_bits = high_bit, \
.i2c_sel = slave_sel,\
.unused = 0,\
.rw = 1,\
.opcode = OPCODE_I2C } }