I think you problem is that you has NULL as param in the
xSemaphoreGiveFromISR(li2cmutex, NULL) function…
In the ISR yo need to supply the pxHigherPriorityTaskWoken parameter
That should not cause it to hard fault, but it will mean that a switch
to a task that was waiting for the mutex being returned will not occur
until the next tick interrupt – or until the task that is currently
running yields (because it blocked or manually called task Yield).
From the original post:
But the mutex
give/take functions cannot be called from ISR context.
The give function can be called, but the take cannot (who would be the
mutex owner if an ISR took a mutex?). There are some test
tasks/interrupts that do just that:
How this works depends slightly on your FreeRTOS version. Which version
are you using?
However, the code you posted is using a binary semaphore, not a mutex.
You also have not stated which chip you are using. Depending on the
chip the most common cause of such an issue is an incorrect priority
Please post your FreeRTOS version and the chip you are using.