I am trying to read multiply sensors on my teensy 4.1 using Teensyduino. Each sensor is on its own SPI port. The problem I am running into is that each sensor has its own rate that it runs at. For example I have one sensor that runs at a period of 5 ms and takes 250 us to read the data. I have another at 2000 hz and takes 150 us to read the data. And finally a third at 4000 hz that takes 20 us to read the data. I'd like to have an interrupt for each sensor and then run the data reading on some sort of prioritized thread but arduino/teensyduino doesn't seem to have that capability. I have looked at tons of third party schedulers, "threading" libraries but none of them allow me to interrupt the slower 5ms sensor that takes 250 us to read. It would make sense to be able to let that 5ms sensor begin reading the data and interrupt it to get the 4000 hz data and then continue reading the data. Has anyone done this using Teensyduino? Any recommendations?
Interrupt 1 ------+--------+---------+-------
ReadSensor ------- +++-----+++------+++-
Interrupt 2 --+--+--+--+--+--+--+--+--+--
ReadSensor---+--+--+--+--+--+--+--+--+-
Interrupt 1 ------+--------+---------+-------
ReadSensor ------- +++-----+++------+++-
Interrupt 2 --+--+--+--+--+--+--+--+--+--
ReadSensor---+--+--+--+--+--+--+--+--+-