I get following error while compiling FreeRTOS. This error occured after enabling configUSE_RECURSIVE_MUTEXES:
Error[Pe223]: function “xSemaphoreTake” declared implicitly …\FreeRTOS\Source\queue.c 670
After adding #include “semphr.h” in queue.c (on line 40) the error disappears, however we want to use ‘stock’ code, so altering this code in our implementation is not an option.
Is there some other way to get this working, or is a code change required?
When using FreeRTOS API functions you need to first include FreeRTOS.h
at the top of the file, then include the header file for the API
function being called. In your case you are using recursive mutexes, so
you need to include semphr.h. (the abbreviated name dates back to when
file names had to be in 8.3 format). Here is an example at the top of
the source file that demonstrates/tests recursive mutexes: https://sourceforge.net/p/freertos/code/HEAD/tree/tags/V10.2.0/FreeRTOS/Demo/Common/Minimal/recmutex.c#l66
Thanks for the swift reply, however I cannot follow your post. I understand I need to include FreeRTOS.h before all other includes.
I have done this in my application, and it compiles and run. Now I need to change one mutex to a recursive mutex.
So configUSE_RECURSIVE_MUTEXES is enabled in my config, but without changing my application code I get a compilation error at queue.c:670. When manually adding #include “semphr.h” in queue.c the code is compiling again.
That line is defining xSemphoreTake(), which is a public macro intended
for use by application code. Note this does not have the ‘Queue’ in the
name, so it is different to xQueueSemaphoreTake() which is not a
published API function and intended only for use by the kernel code
itself. Was line 289 the line you intended to highlight?
The function cannot be found, and throws a compilation error, in my
opinion there can be 2 solutions to this:
Add semphr.h to the queue.c includes
Change the functioncall in queue.c to xQueueSemaphoreTake
It seems I have found the problem. My code says xSemaphoreTake. So I probably have made an error while updating FreeRTOS. The latest code indeed says xQueueSemaphoreTake.