weston-embedded/uC-LIB

Mem_OutputUsage calling out_fnct from inside a critical region

Closed this issue · 1 comments

I ran into the following issue: the function Mem_OutputUsage is calling the provided out_fnct from within a critical region. The out_fnct I was providing was writing to the serial port. The STM32 BSP implements the serial code using a semaphore that gets signalled in an interrupt. This code doesn't work if it is called from inside a critical region, causing weird issues like OSSemPend returning without an error when the semaphore was not signalled yet, eventually causing the code to hang.

Since using a semaphore to synchronise with an interrupt is a common pattern for implementing IO drivers, I feel the implementation in Mem_OutputUsage should not do IO from within the critical region.

This sounds like a BSP implementation issue. Which STM32 BSP are you referring to?