This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

TWIS read with repeated start

Hi all,

I have a problem with nRF52840 acting as TWI slave. I'm using TWIS. Typical scenario is:

1. Master writes request and ends transaction using stop condition.

2. Master starts read transaction, read some bytes, NAK last byte and perform repeated start

3. Master decides whether to go to step 2 or step 4 according do data read in step 2.

4. Master sends stop condition

My problem is with fact, that twis driver calls my callback with event type TWIS_EVT_READ_REQ with p_event->data.buf_req set to true, but in TWIS_EVT_READ_DONE p_event->data.tx_amount consistently shows the amount of the previous read transaction ended with stop condition. So I'm unable to return correct data as the index to data is wrong.

For example wanted scenario is like that:

start, addr_write, cmd, stop

start, addr_read, byte0-ack, byte1-ack, byte2-ack, byte3-nak stop

start, addr_read, byte4-ack, byte5-nak, repeated start addr_read, byte6-ack, byte7-ack, byte8-ack, byte9-nak, repeated start, stop

But after byte5-nak, the length given in TWIS_EVT_READ_DONE is 4 instead of 2.

Thank in advance for any clarification on confirmation that I have to split that into separate transactions with stop condition for every read chunk

Parents Reply Children
No Data
Related