I'm working on a project that use sw_usb_audio 9.0.0.
I need to share the same i2c line with multiple tasks.
So far I've followed the preset route and I've something like:
Code: Select all
void Board_i2c_task(chanend c, client interface i2c_master_if i2c)
{
while(1)
{
select
{
case c :> unsigned cmd:
if(cmd == CMD_DAC_INIT)
{
unsafe
{
// Access i2c bus
}
}
else if(cmd == CMD_READ_IO_EXPANDER)
{
unsafe
{
// Access i2c bus
}
}
else if(cmd == CMD_WRITE_IO_EXPANDER)
{
unsafe
{
// Access i2c bus
}
}
else if(...)
// And so on with multiple commands
- A timed task (10Hz)
- A GPIO event task
- AudioHwConfig
If not what's a best practice to access the same i2c bus from multiple tasks?
Thanks everyone