stm32l151c8, Chibios v 17.6.0
Here is the code I use now (it is definitely something wrong in boundaries). What is wrong?
Code: Select all
uint32_t GetThdFreeStack(void *wsp, uint32_t size) {
uint32_t n = 0;
#if CH_DBG_FILL_THREADS
uint8_t *startp = (uint8_t *)wsp + sizeof(thread_t);
uint8_t *endp = (uint8_t *)wsp + size;
while (startp < endp)
if(*startp++ == CH_DBG_STACK_FILL_VALUE) ++n;
#endif
return n;
}
void PrintThdFreeStack(void *wsp, uint32_t size) {
Printf("Free stack memory: %u of %u bytes\r",
GetThdFreeStack(wsp, size) - sizeof(thread_t),
size - sizeof(thread_t));
}
...
static THD_WORKING_AREA(waEffectsThread, 128);
...
PrintThdFreeStack(waEffectsThread, sizeof(waEffectsThread));