Hi Nordic.
This is a general question and could as easily have been posted to stack overflow but I have found the members and staff of this community so helpful and adept in explaining things such that even I understand them and thus I hope this is a legit question for this forum.
Currently, I am using the nRF9160 to try out some accelerometers. They record data to a sd-card and send the data to a server via FTP.
The way things context switch is by using a large amount of primitive locks (simple 0 or 1 integers) and a total of 3 threads.
The threads control ftp transmission, memory writing and the last one deals with reading the sensors and calculating trigger values continuously.
A pseudo example of thread usage is this:
accThread()
while(1)
if(sensorvalue != 0)
write_lock = 0
thread_resume(memThread)
else
someother_lock = 0
thread_resume(memThread)
memThread()
while(1)
if(write_lock == 0)
SPI_write(...)
if(someother_lock == 0)
dosometingelse()
.
.
thread_sleep(memThread)
Using integer locks to choose which function to run in a thread and resuming/sleeping threads based on conditions does not seem effective nor safe.
My question is: What kind of architecture should be used to implement this? Surely it is interrupt driven but I cant figure out the schematics of what kind of locks and functions should be implemented for best practice. Is there a name for the structure I need?
I hope this made somewhat sense, english is not my first language. Please ask if you are as confused as I am.
Best of regards