yukikami:
This is how my sketch works :
- I have a buffer with all the 8 bytes blocks of data that I need to send
And you have to send them before the next block but not necessarily all at once.
- in the loop, I empty this buffer and when it is empty, I just continuously update the values measured by 2 sensors
- on the other hand, I have 3 rotary encoders which all have their own interrupts, they all just increment an int, but in only one of them, I also add an 8 bytes piece of data (which represents all the current states of the sensors + encoders) in the buffer
Adding those 8 bytes should probably not happen inside the IRQ. The IRQ should set a flag that a routine inside of loop() should run if the flag is set (and first thing, clear the flag).
Maybe you're right about me being wrong the way my system works but that's the best way I found...
Setting up an SPI bus is not hard thanks to the libraries
I agree but I guess having another AVR will be somehow complicated, like some kind of multi-threading ?
Kind of like multi-threading is how we "do more than one thing at a time" on a single processor.
Adding processors takes it into parallel processing!
But really, it's no big deal unless you want to run really complicated tasks. Either way it saves time and code.
Could you see how much of this blog is new to you and how much you already know?
It's a simple and straightforward exposition on running multiple tasks on a time basis, and not blocking execution.
Once you get that down you will be ready for state machine code and be able to handle real time events.
Once you can handle RT events, the idea of multiple processors will seem much more natural.
I think that you know at least some if not most of it already, just maybe not in code but how you do normal things as Nick's blog explains with the 'cooking breakfast' example.
The whole Real Time Multiple Tasking Multiple Processors thing is a whole lot simple without an OS in the way. You don't need a degree in Windows (or Linux) to pull it off on Arduinos!