Hey all,
For some context, I’m allowing the user to interface with the device over serial. For example, the user may send a (firmware specific) recognized command like ‘print_data’ and the device would respond by sending some data over serial to the user. However, my issue stems from the serial communication tasks not running at the time data is actual transmitted over serial to the device.
My hope is that I can run an ISR to detect when data is sent over serial to then raise a flag and possibly intercept the serial data. I can then have another task set up to check if the flag is true and to have the data shared. This can then process the user’s requests in a more reliable fashion.
That being said, I’m looking for some examples/assistance in creating an interrupt service routine for when data is read over serial in the nRF52840 Sense board. I’ve read elsewhere that there is a function name specifically for UART Peripheral ISR with the nRF52480 processor, but haven’t had any luck in finding it.
Below is some pseudocode of what I’m trying to accomplish:
// Global vars
bool flag = false;
String serialBuffer;
void setup() {
xTaskCreate(TaskPrintData);
xTaskCreate(TaskOther);
xTaskCreate(TaskAnother);
xTaskCreate(TaskAndOneMore);
vTaskStartScheduler();
}
void loop() {
// Nothing here in FreeRTOS!
}
// Example implementation
void UART_ISR_Handler(void) {
flag = true;
serialBuffer = Serial.readString();
}
// Example data printing task
void TaskPrintData(void *PvParameters) {
(void)PvParameters;
for (;;) {
if (flag == true) {
if (serialBuffer == "print_data") {
Serial.println("flag is true");
}
}
flag = false;
serialBuffer = "";
}
}
void TaskOther(void *PvParameters) {
// code
}
void TaskAnother(void *PvParameters) {
// code
}
void TaskAndOneMore(void *PvParameters) {
// code
}
Any advice or assistance is greatly appreciated. Thank you in advance!