Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d05df76

Browse filesBrowse files
committed
feat: provide default functions only if requested
configUSE_MALLOC_FAILED_HOOK and configCHECK_FOR_STACK_OVERFLOW allow to define specific function to call when a malloc failed or a stack overflow occured. Respectively, vApplicationIdleHook and vApplicationStackOverflowHook. Previous implementation provide them unconditionally preventing users to define their own implementation. Now extra config is required to have the default implementation: /* Set to 1 to use default blink hook if configUSE_MALLOC_FAILED_HOOK is 1 */ #ifndef configUSE_MALLOC_FAILED_HOOK_BLINK #define configUSE_MALLOC_FAILED_HOOK_BLINK 0 #endif /* Set to 1 to used default blink if configCHECK_FOR_STACK_OVERFLOW is 1 or 2 */ #ifndef configCHECK_FOR_STACK_OVERFLOW_BLINK #define configCHECK_FOR_STACK_OVERFLOW_BLINK 0 #endif Fixes #69. Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
1 parent f3abddc commit d05df76
Copy full SHA for d05df76

File tree

Expand file treeCollapse file tree

2 files changed

+20
-11
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+20
-11
lines changed

‎src/FreeRTOSConfig_Default.h

Copy file name to clipboardExpand all lines: src/FreeRTOSConfig_Default.h
+11-2Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,16 @@
4646
* -1 for heap_useNewlib_ST.c
4747
* Default -1 see heap.c
4848
*/
49-
/*#define configMEMMANG_HEAP_NB 3*/
49+
/* #define configMEMMANG_HEAP_NB 3 */
50+
51+
/* Set to 1 to use default blink hook if configUSE_MALLOC_FAILED_HOOK is 1 */
52+
#ifndef configUSE_MALLOC_FAILED_HOOK_BLINK
53+
#define configUSE_MALLOC_FAILED_HOOK_BLINK 0
54+
#endif
55+
/* Set to 1 to used default blink if configCHECK_FOR_STACK_OVERFLOW is 1 or 2 */
56+
#ifndef configCHECK_FOR_STACK_OVERFLOW_BLINK
57+
#define configCHECK_FOR_STACK_OVERFLOW_BLINK 0
58+
#endif
5059

5160
/* configUSE_CMSIS_RTOS_V2 has to be defined and set to 1 to use CMSIS-RTOSv2 */
5261
/*#define configUSE_CMSIS_RTOS_V2 1*/
@@ -218,7 +227,7 @@ header file. */
218227
/*
219228
* IMPORTANT:
220229
* SysTick_Handler() from stm32duino core is calling weak osSystickHandler().
221-
* Both CMSIS-RTOSv2 and CMSIS-RTOS override osSystickHandler()
230+
* Both CMSIS-RTOSv2 and CMSIS-RTOS override osSystickHandler()
222231
* which is calling xPortSysTickHandler(), defined in respective CortexM-x port
223232
*/
224233
/* #define xPortSysTickHandler SysTick_Handler */

‎src/STM32FreeRTOS.c

Copy file name to clipboardExpand all lines: src/STM32FreeRTOS.c
+9-9Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,12 @@ void assertBlink() {
5050
errorBlink(1);
5151
}
5252
//------------------------------------------------------------------------------
53-
#if ( configUSE_MALLOC_FAILED_HOOK == 1 )
53+
#if ( ( configUSE_MALLOC_FAILED_HOOK == 1 ) && ( configUSE_MALLOC_FAILED_HOOK_BLINK == 1 ) )
5454
/** vApplicationMallocFailedHook()
55-
Blink two short pulses if malloc fails.
56-
57-
will only be called if
58-
configUSE_MALLOC_FAILED_HOOK is set to 1 in FreeRTOSConfig.h. It is a hook
59-
function that will get called if a call to pvPortMalloc() fails.
55+
Blink two short pulses if malloc fails. Itwill only be called if
56+
configUSE_MALLOC_FAILED_HOOK is set to 1 and
57+
configUSE_MALLOC_FAILED_HOOK_BLINK defined in FreeRTOSConfig.h.
58+
It is a hook function that will get called if a call to pvPortMalloc() fails.
6059
pvPortMalloc() is called internally by the kernel whenever a task, queue,
6160
timer or semaphore is created. It is also called by various parts of the
6261
demo application. If heap_1.c or heap_2.c are used, then the size of the
@@ -87,11 +86,12 @@ void __attribute__((weak)) vApplicationIdleHook( void ) {
8786
#endif /* configUSE_IDLE_HOOK == 1 */
8887

8988
/*-----------------------------------------------------------*/
90-
#if ( configCHECK_FOR_STACK_OVERFLOW >= 1 )
89+
#if ( ( configCHECK_FOR_STACK_OVERFLOW >= 1 ) && ( configCHECK_FOR_STACK_OVERFLOW_BLINK == 1 ) )
9190
/** Blink three short pulses if stack overflow is detected.
9291
Run time stack overflow checking is performed if
93-
configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook
94-
function is called if a stack overflow is detected.
92+
configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2 and
93+
configCHECK_FOR_STACK_OVERFLOW_BLINK is defined.
94+
This hook function is called if a stack overflow is detected.
9595
\param[in] pxTask Task handle
9696
\param[in] pcTaskName Task name
9797
*/

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.