labapart / polymcu

An open framework for micro-controller software
http://labapart.com/products/polymcu
203 stars 41 forks source link

FreeRTOSConfig.h should be a separate header #2

Open jacquelinekay opened 8 years ago

jacquelinekay commented 8 years ago

First, thanks a lot for working on this project. It's so helpful to have a CMake-based buildsystem for the ARM/CMSIS/FreeRTOS! I haven't worked much with other stacks but it's cool to know that I could use this if I wanted to.

The FreeRTOS application doesn't compile for the Arm Cortex M7 target out of the box because configMAX_SYSCALL_INTERRUPT_PRIORITY doesn't get set. I noticed that this gets set in board.h for the ARMCM4 target but not the M7. The way this is done in the ST Cube framework is by the application providing a separate FreeRTOSConfig.h header. What do you think of this pattern? It seems cleaner to me. For now I just throw the definition of the missing settings into board.h to be consistent with the other target as a workaround.

oliviermartin commented 8 years ago

The reason I did not do it for the other ARM Cortex-M was I have not spent much time thinking about the correct definitions for the other ones. But I agree it is not elegant.

Another approach would be to add a new CMake variable like RTOS_MAX_SYSCALL_INTERRUPT_PRIORITY to the current list here: https://github.com/labapart/polymcu#rtos-variables

And add this definition to the existing RTOS/FreeRTOS/include/FreeRTOSConfig.h.in like that:

/* The highest interrupt priority that can be used by any interrupt service
routine that makes calls to interrupt safe FreeRTOS API functions.  DO NOT CALL
INTERRUPT SAFE FREERTOS API FUNCTIONS FROM ANY INTERRUPT THAT HAS A HIGHER
PRIORITY THAN THIS! (higher priorities are lower numeric values. */
#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY    5

/* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!!
See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */
#cmakedefine RTOS_MAX_SYSCALL_INTERRUPT_PRIORITY
#ifdef RTOS_MAX_SYSCALL_INTERRUPT_PRIORITY
  #define configMAX_SYSCALL_INTERRUPT_PRIORITY @RTOS_MAX_SYSCALL_INTERRUPT_PRIORITY@
#else
  #define configMAX_SYSCALL_INTERRUPT_PRIORITY ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - __NVIC_PRIO_BITS) )
#endif

What do you think?

jacquelinekay commented 8 years ago

That seems like a good solution to me.