legacy macro for i2c read and write
legacy macro for i2c read and write
I'm programming the ulp processor using legacy macros. I looked at ulp.h. I don't see a macro defined for i2c_rd and i2c_wr. I assume it would be I_I2C_RD and I_I2C_WR. I see the opcode bit definitions in ulp_insn_t but no macros. Did I miss something?
Re: legacy macro for i2c read and write
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?
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 } }
Who is online
Users browsing this forum: No registered users and 133 guests