I am in the initial phases of porting an arduino project using the NRF52832 to the Nordic SDK (14.2 for the moment) and am running into issues when using TWIM and an event handler. This stage of my port effort is based on the twi_sensor example and I have made the necessary changes to my sensor library to successfully read values from my accelerometer in blocking mode. I am now trying to implement the non-blocking operation and am having difficulty with the TWI event handler running to completion.
If I place a breakpoint in the event handler on NRF_DRV_TWI_EVT_DONE and the function I have initiating the TWI RX/TX operations and step through them I have noticed the following:
- The library function call to read from the sensor (consisting of both a TX and RX operation) first initiates a NRF_DRV_TWI_XFER_TX event xfer type and passes through the handler. This is expected.
- The subsequent RX operation to read the selected register from above is called, passes through the event handler, calls the data handler to output to the console, and returns. What I am seeing at this point of stepping through however is that I am not receiving values from the sensor. This process does run through the event handler though.
I have tried changing the event handler to handle RX and TX event separately and changed the interrupt priority in the TWI config to no avail. I suppose it is worth mentioning that I am using an Adafruit NRF52 board and Visual Studio + VisualGDB. As I mentioned before, I do have TWI working in blocking mode and have been getting expected readings from my sensor so I am hesitant to blame the board or the dev environment. I am planning to move to SDK15 as soon as a BSP is created for VisualGDB but I do not think that has any bearing on the issue I am facing. Relevant code is included below.
main.cpp
H3LIS331DL.cpp read and write functions. _twi_inst passed from main.