HAL_ChibiOS: added a debug function for showing stack free

this can be enabled when needed to investigate stack space remaining
This commit is contained in:
Andrew Tridgell 2018-05-30 20:15:43 +10:00
parent 010cd71ab6
commit bb2e7a189f
2 changed files with 24 additions and 0 deletions

View File

@ -58,3 +58,22 @@ void dma_flush(const void *buf, uint32_t size)
}
#endif
}
#if CH_DBG_ENABLE_STACK_CHECK == TRUE
void show_stack_usage(void)
{
thread_t *tp;
tp = chRegFirstThread();
do {
uint32_t stklimit = (uint32_t)tp->wabase;
uint8_t *p = (uint8_t *)tp->wabase;
while (*p == CH_DBG_STACK_FILL_VALUE) {
p++;
}
uint32_t stack_left = ((uint32_t)p) - stklimit;
printf("%s %u\n", tp->name, stack_left);
tp = chRegNextThread(tp);
} while (tp != NULL);
}
#endif

View File

@ -32,6 +32,11 @@ void dma_invalidate(void *buf, uint32_t size);
*/
void dma_flush(const void *buf, uint32_t size);
#if CH_DBG_ENABLE_STACK_CHECK == TRUE
// print stack usage
void show_stack_usage(void);
#endif
#ifdef __cplusplus
}
#endif