I am working on a relatively big embedded system (about 7/8 external peripherals connected via i2c/spi/sdio/uart/usb/…), on a single core mcu (cortex-m4)
It seems that when a context switch occurs, if I am performing something with a hardware bus for example, then it will fail. It is not surprising. But I am not sure what would be the best way to solve this problem. Should I have 1 single mutex, that guards every hardware resource? Or should I just use the functions vTaskSuspendAll and xTaskResumeAll instead? Or even worst, taskENTER_CRITICAL? (i don’t think hardware interrupts break my hardware depend code, because they are so quick and the processing happens in another task)
I am a bit lost and some guidance would be very much appreciated. I kind of feel that with what ever solution I have above, there is always the same problem, is that 95% of my code will be guarded. And then, I don’t know where to put the calls to take/give, in my hardware drivers them selves? Or in my application code before calling hardware functions?