- Edited
@LiamDonovan Actually I am thinking that to write to the I2C device from a time-critical thread you may be able to simply the call to write()
in I2c_Codec::writeRegister
with rt_fprintf()
.
Alternatively, the proper "Xenomai" way of communicating between rt and non-rt threads is rt_pipe
. You would then need a "consumer" non-rt thread which reads from the pipe and writes to the I2C pseudo-file . Xenomai pipes allow bi-directional communication so you could use the same thread to read from I2C and send back.
The catch in these cases is always that you have a finite amount of memory pre-allocated, but that would be the same catch for any other rt implementation. So it is important that the user a) does not write too much data at once (and if they do they should increase the buffer size beforehand) and, b) the user checks for the return value of writeRegister()
.
I used pipes in the latest Midi https://github.com/BelaPlatform/Bela/blob/dev-midi/core/Midi.cpp but only in one-direction.