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

nrfx and twis samples

I wasn't able to find sample code showing how to use the nrfx sdk to perform TWI slave.

Can you point me to some examples ?

Parents
  • Hi,

    Do you mean nRF5 SDK? nrfx is the separate driver package, which is used both in nRF5 SDK and nRF Connect SDK (NCS).

    TWI Slave example is available in the SDK. The example is using the legacy driver APIs, but if you want to use nrfx APIs you can follow the migration guide.

    Best regards,
    Jørgen.

  • I still need some clarifications in nrfx usage for twis:

    * evt_write_req and evt_write_done seems to be per write request, is there a way to prepare multiple time the dma rx buffer inside the same write request ? (for example a 2 bytes buffer used for the i2c register, and next allocate the right amount of memory for the following write in the same request)

    * I would like to perform some cleanup when the i2c transaction is stopped, but I don't see an event for that in the nrfx_twis_evt_type_t , is there a way to do it.  (start write / data / start read / data / stop <wanted_callback_here>)

  • Stephane D'Alu said:
    is there a way to prepare multiple time the dma rx buffer inside the same write request

    No, the TWIS peripheral is designed to allow reading/writing without CPU intervention, in case the CPU is busy with handling timing-critical radio events. It will only allow you to prepare one TX and one RX buffer. Is the TWI master not able to do this in two separate requests?

    Stephane D'Alu said:
    I would like to perform some cleanup when the i2c transaction is stopped, but I don't see an event for that in the nrfx_twis_evt_type_t , is there a way to do it.

    If by stopped you mean after you trigger the STOP_TASK as discussed before? The driver does not provide any events for this, as it is not expected behavior in the driver. In fact, triggering the STOP_TASK while the driver is active may leave the driver state-machine in an unknown state. The driver only provides events for transfer done and detected errors. If you want an event in the driver for the STOPPED event, you need to catch this in the interrupt handler in the TWIS driver and pass a custom-defined event to the application.

Reply
  • Stephane D'Alu said:
    is there a way to prepare multiple time the dma rx buffer inside the same write request

    No, the TWIS peripheral is designed to allow reading/writing without CPU intervention, in case the CPU is busy with handling timing-critical radio events. It will only allow you to prepare one TX and one RX buffer. Is the TWI master not able to do this in two separate requests?

    Stephane D'Alu said:
    I would like to perform some cleanup when the i2c transaction is stopped, but I don't see an event for that in the nrfx_twis_evt_type_t , is there a way to do it.

    If by stopped you mean after you trigger the STOP_TASK as discussed before? The driver does not provide any events for this, as it is not expected behavior in the driver. In fact, triggering the STOP_TASK while the driver is active may leave the driver state-machine in an unknown state. The driver only provides events for transfer done and detected errors. If you want an event in the driver for the STOPPED event, you need to catch this in the interrupt handler in the TWIS driver and pass a custom-defined event to the application.

Children
No Data
Related