How to use I2C receive continue in Zephyr without restarting the transaction (without another start bit)?

I was trying to receive some data using "i2c_transfer" then continue the receiving without starting a new transaction. 

Stop bit was sent if I configured to use it or not. and if I try to continue the receiving the start bit and slave address will be sent again and start a new transaction.

Is there any API I can use to continue the receiving without starting a new transaction?

Parents
  • Hi Abdelrahman, 
    In theory if you set the flag I2C_MSG_STOP it should therefore set the flag NRFX_TWIM_FLAG_TX_NO_STOP in nrfx_twim driver. Then instead of connecting the SHORT LAST_TX to STOP task, it will connect the shot LAST_TX to SUSPEND task instead. 
    Could you show how you do it in the code ? Maybe provide us a simple application so we can try to reproduce the issue here. 
    Another option is to use nrfx driver directly, the samples can be found in \modules\hal\nordic\nrfx\samples\src\nrfx_twim_twis

  • Thanks for the clarification! I’d love to see how you implement the I2C_MSG_STOP flag in your code. A simple example would really help us troubleshoot! sprunki phase 3

  • There is my implementation
                    gsi2c_msg.buf = (char *)pu8_buf;
                    gsi2c_msg.len = (uint32_t) u16_len;
                    gsi2c_msg.flags = I2C_MSG_WRITE | (b_stop ? I2C_MSG_STOP : 0);
                    printf("I2C Sending to 0x%X: ", u16_addr);
                    for (uint16_t i = 0; i < u16_len; i++)
                    {
                        printf("0x%02X ", pu8_buf[i]);
                    }
                    printf("\n");
                    s32_retval = i2c_transfer(gpstr_internal_i2c_dev , &gsi2c_msg , 1 , u16_addr);
    b_stop is used for choosing to send stop bit or not.
    I sent the first byte with b_stop = 0
    then the second byte with b_stop = 1
    after the first byte the transaction stop:
    Is that mean "i2c_transfer" will always stop the transaction?
    Is there any API I can use to continue the receiving without starting a new transaction?
Reply
  • There is my implementation
                    gsi2c_msg.buf = (char *)pu8_buf;
                    gsi2c_msg.len = (uint32_t) u16_len;
                    gsi2c_msg.flags = I2C_MSG_WRITE | (b_stop ? I2C_MSG_STOP : 0);
                    printf("I2C Sending to 0x%X: ", u16_addr);
                    for (uint16_t i = 0; i < u16_len; i++)
                    {
                        printf("0x%02X ", pu8_buf[i]);
                    }
                    printf("\n");
                    s32_retval = i2c_transfer(gpstr_internal_i2c_dev , &gsi2c_msg , 1 , u16_addr);
    b_stop is used for choosing to send stop bit or not.
    I sent the first byte with b_stop = 0
    then the second byte with b_stop = 1
    after the first byte the transaction stop:
    Is that mean "i2c_transfer" will always stop the transaction?
    Is there any API I can use to continue the receiving without starting a new transaction?
Children
Related