Hi,
I’m currently working on a project which implements the Gapuino development board with Mbed OS on the RISC-V GAP8 platform of PlatformIO.
In this project I have to sample at a constant rate without losses (by using a data ready interrupt) data coming from an SPI device (ADS1299). Batches of data has to be sent (with a much slower rate) to a computer via asynchronous UART using rosserial protocol.
The problem lies with the fact that I cannot know when the computer is gonna send messages (sync messages for example which are frequent) and thus this will cause a UART rx interrupt that will break the execution of SPI reads ending with the following error:
Assert failed: g_spiHandle[1], file: /home/gualor/.platformio/packages/framework-gap_sdk/mbed-os/targets/TARGET_GWT/TARGET_GAP8
I managed to reproduce this error without the presence of rosserial, by just having a thread which takes too long to complete (using wait) that will cause the data ready interrupt to overlap with the SPI reads (which normally does not happen) :
#include "mbed.h"
#include "ADS1299.h"
#include "Definitions.h"
InterruptIn DRDY(GPIO_A5_B40); // Setup interrupt pin
ADS1299 ads; // SPI device
osThreadId id;
// Data ready interrupt
void dataReadyISR(void)
{
osSignalSet(id, 0x05); // Signal when data is ready
}
int main()
{
wait(1);
id = ThisThread::get_id(); // Thread ID
DRDY.fall(callback(&dataReadyISR)); // Attach data ready ISR
while(1)
{
osSignalWait(0x05, osWaitForever); // Wait for data ready interrupt
ads.updateChannelData(); // Read data with SPI
// Used to slow down thread and cause
// interrupt to break SPI
wait_ms(10);
}
}
To go straight to the point, my question is:
"is there a way of making SPI interrupt safe without disabling UART rx interrupts? (losing incoming messages will cause a lost connection).
Thank you in advance for the support, any help will be greatly appreciated!