legacy macro for i2c read and write

pwiner99
Posts: 8
Joined: Tue Jun 05, 2018 1:51 pm

legacy macro for i2c read and write

Postby pwiner99 » Tue Jun 05, 2018 2:01 pm

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?

pwiner99
Posts: 8
Joined: Tue Jun 05, 2018 1:51 pm

Re: legacy macro for i2c read and write

Postby pwiner99 » Wed Jun 06, 2018 7:31 am

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 } }

Who is online

Users browsing this forum: Bing [Bot], mark.k92 and 135 guests