I'm using a Bluefruit nRF52 with Arduino framework, and using Bluefruit library. It's connected to the Bluefruit connect app, but also acting as an SPI slave for another device (an stm32).
I'm having to bit-bang the SPI as the Arduino SPI library won't work as a slave (for nordic nrf52 devices), and using a GPIO from the nRF52 to tell the stm32 I'm ready to receive SPI (normally 5 to 10 bytes), after it detects SPI nCS assertion. To bitbang the SPI data, I'm then waiting on an interrupt on rising edge SPI CLK, at which point clock in the MOSI data.
It's mostly working except the odd message (1 in 5ish full transfers) gets missed. I've traced this to one SPI clk interrupt being missed during the transfer. (each transfer is 10 bytes).
As the nrf52 softdevice has higher priority than any user code, including interrupt handlers - I'm wondering if the irq is being missed because it happens during a period where the softdevice is in control. which is asynchronous.
So I'm wondering if I wait until soft device takes control, then wait till its done, then I signal that I'm ready to receive over SPI, that will give me the best chance to receive a full message.
Is there a way that I can poll some flag / variable / register to know that the softdevice has just been busy?
-
It has SPI Slave (SPIS) with EasyDMA so you could just use that instead. But I suppose you are afraid of events and tasks and that semaphoreKIIV– KIIV2023年12月20日 09:52:20 +00:00Commented Dec 20, 2023 at 9:52
-
Hi KIIV thanks for the reply. i can see the SPIS in the nordic low level files but its not implemented in the arduino SPI library. i tried to make my own version (SPI.h and SPI_nrf52832.cpp) to handle SPIS but couldnt get it to work.elMick– elMick2023年12月21日 13:54:37 +00:00Commented Dec 21, 2023 at 13:54