Page 1 of 1

Use of SYSTEM_HALT_HOOK with HAL

Posted: Wed Jun 26, 2013 2:58 pm
by trepidacious
I was just looking at SYSTEM_HALT_HOOK, and I can't find any examples of using it. My use case is just to change the mode of a few pins on port_halt, to put a board into a safe state when it halts. It seems like this would be a reasonable use of the hook?

However I can't work out how to use HAL functions from the hook, e.g. palSetPadMode. Is this possible?

I'm running on an STM32F4, custom board, if that makes any difference, thanks.

Re: Use of SYSTEM_HALT_HOOK with HAL

Posted: Wed Jun 26, 2013 3:23 pm
by Giovanni
Hi,

The issue is that hal.h is not necessarily included where the macro is placed. The workaround is to just call a function from the hook placed in another module:

extern void myfunc(void);
myfunc();

The module containing myfunc() can include hal.h and use pal functions/macros.

Note that from that hook you should make no assumptions regarding the system state (interrupts enabled or disabled, thread context or ISR context etc).

Giovanni