Hi,
I have a PCA10040 connected with some wires to an external I2C device and I need to poll data from the I2C device and send it over BLE, also updating the advertisement packet contents. At the moment I have a very simple setup:
APP TIMER HANDLER (at desired polling freq) -> START GET DATA COMMAND FROM I2C DEVICE
I2C IRQ CALLBACK -> ble_advdata_set()
To make it short, ble_advdata_set() crashes. I was somewhat expecting this, since calling SoftDevice stuff from IRQ context may require some attention. First fix was trivial: reducing I2C interrupt priority from APP_IRQ_PRIORITY_HIGH to APP_IRQ_PRIORITY_LOW. As happy as I am, I am asking myself if this is enough and will be a wise choice considering how the project will evolve in complexity (I also have to log I2C data to external flash using SPI, plus some other tings to do). Leaving I2C at lower priority is not a problem, but I am also considering using the scheduler or the task libs and move to something less tricky because I fear that as I will use more and more nrf52 peripherals doing stuff from IRQs and managing IRQ levels will be a nightmare. I don't have strict realtime requirements.
What's the advice from experts here?
1. Read the SD carefully and continue juggling IRQs
2. Use the scheduler and events
3. Use the experimental Task stuff
I understand that there are different factors to consider, but I was wondering if there are some hard lessons learned that may help me out to decide.
Thanks!