In my firmware I write to MicroSD in a background task, and I've got a lot of higher-priorities interrupts enabled, some of which can take several milliseconds.
So the writing/reading from SPI can be interrupted at any moment, and for writes that may not be such a problem (if SPI behaves anything like UART), but during reads I'm afraid that my hardware SPI FIFO's will overflow if the task just happens to be interupted while the MicroSD card is sending a datablock.
Now the obvious solution would be to decrease the time that the higher priority interrupts take, but this seems very hard, because sometimes they have to wait on other peripherals too, and too prevent that I have to rewrite a lot of code that does polling now, to an interrupt-structure, which would make the overall code much more complicated.
I think in modern OSes this is solved by letting all those tasks run synchronously at the same priority, and give them all an equal time slice. But I don't have any mechanisms for threading, or an OS, so what would be the simplest way to solve this?