pito,
I wrapped the FIFO code in a C++ template so it is easy to use. Here is an example:
#include <NilRTOS.h>
#include <NilFIFO.h>
// FIFO with ten ints
NilFIFO<int, 10> fifo;
// Use tiny unbuffered NilRTOS NilSerial library.
#include <NilSerial.h>
#define Serial NilSerial
//------------------------------------------------------------------------------
NIL_WORKING_AREA(waThread1, 64);
NIL_THREAD(Thread1, arg) {
int n = 0;
while (TRUE) {
nilThdSleep(400);
int* p = fifo.waitFree(TIME_IMMEDIATE);
// continue if no free space
if (p == 0) continue;
*p = n++;
fifo.signalData();
}
}
//------------------------------------------------------------------------------
NIL_THREADS_TABLE_BEGIN()
NIL_THREADS_TABLE_ENTRY(NULL, Thread1, NULL, waThread1, sizeof(waThread1))
NIL_THREADS_TABLE_END()
//------------------------------------------------------------------------------
void setup() {
Serial.begin(9600);
// start kernel
nilSysBegin();
}
//------------------------------------------------------------------------------
void loop() {
int* p = fifo.waitData(TIME_IMMEDIATE);
// return if no data
if (p == 0) return;
int n = *p;
Serial.println(n);
fifo.signalFree();
if (n == 20) {
fifo.printStats(&Serial);
while(1);
}
}
Here are the last lines of output:
19
20
FIFO record count: 10
Minimum free count: 9
I attached the template as NilFIFO.h. It's not documented yet
I downloaded your new diagrams for a future update of the documentation.
The SD performance is interesting. SD controllers are impossible to understand since they are a trade top secret.
Users could benefit from your plots, I should write an article to include with SdFat. My to-do list is getting so long.
NilFIFO.h (1.3 KB)