Skip to content

Commit 4f2c388

Browse files
committed
Review size definition
Fix issue raised in issue comment: #39 (comment) when configMEMMANG_HEAP_NB is equal to 1, 2 or 4 Signed-off-by: Frederic Pillon <[email protected]>
1 parent 23ba1f9 commit 4f2c388

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

src/FreeRTOSConfig_Default.h

+14-6
Original file line numberDiff line numberDiff line change
@@ -79,26 +79,34 @@
7979
* which is not suitable for the new CMSIS-RTOS v2 priority range
8080
*/
8181
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 0
82-
82+
/* Require to be a value as used in cmsis_os2.c as array size */
83+
#ifndef configMINIMAL_STACK_SIZE
8384
#define configMINIMAL_STACK_SIZE ((uint16_t)128)
85+
#endif
86+
#ifndef configTOTAL_HEAP_SIZE
8487
#define configTOTAL_HEAP_SIZE ((size_t)(15 * 1024))
85-
#define configISR_STACK_SIZE_WORDS (0x100)
88+
#endif
8689
#else
90+
#define configMAX_PRIORITIES (7)
91+
#endif /* configUSE_CMSIS_RTOS_V2 */
92+
8793
extern char _end; /* Defined in the linker script */
8894
extern char _estack; /* Defined in the linker script */
8995
extern char _Min_Stack_Size; /* Defined in the linker script */
90-
91-
#define configMAX_PRIORITIES (7)
92-
9396
/*
9497
* _Min_Stack_Size is often set to 0x400 in the linker script
9598
* Use it divided by 8 to set minmimal stack size of a task to 128 by default.
9699
* End user will have to properly configure those value depending to their needs.
97100
*/
101+
#ifndef configMINIMAL_STACK_SIZE
98102
#define configMINIMAL_STACK_SIZE ((uint16_t)((uint32_t)&_Min_Stack_Size/8))
103+
#endif
104+
#ifndef configTOTAL_HEAP_SIZE
99105
#define configTOTAL_HEAP_SIZE ((size_t)(&_estack - _Min_Stack_Size - &_end))
106+
#endif
107+
#ifndef configISR_STACK_SIZE_WORDS
100108
#define configISR_STACK_SIZE_WORDS ((uint32_t)&_Min_Stack_Size/4)
101-
#endif /* configUSE_CMSIS_RTOS_V2 */
109+
#endif
102110

103111
#define configUSE_PREEMPTION 1
104112
#define configUSE_IDLE_HOOK 1

src/heap.c

+6
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@
1515
#define configMEMMANG_HEAP_NB -1
1616
#endif
1717

18+
#if configMEMMANG_HEAP_NB != -1
19+
/* Need to be redefined as a value as it used in some heap_*.c as array size */
20+
#undef configTOTAL_HEAP_SIZE
21+
#define configTOTAL_HEAP_SIZE ((size_t)(15 * 1024))
22+
#endif
23+
1824
#if (configMEMMANG_HEAP_NB == -1)
1925
#include "../portable/MemMang/heap_useNewlib_ST.c"
2026
#elif (configMEMMANG_HEAP_NB == 1)

0 commit comments

Comments
 (0)