Skip to content

Commit 9c5da7c

Browse files
committed
Add __attribute (( weak )) permitting declaration of hooks.
Adding the weak attribute to the in-built hooks allows them to be redefined by the user, should that be desirable.
1 parent f17a1d0 commit 9c5da7c

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/variantHooks.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ void initVariant(void)
105105
* NOTE: vApplicationIdleHook() MUST NOT, UNDER ANY CIRCUMSTANCES, CALL A FUNCTION THAT MIGHT BLOCK.
106106
*
107107
*/
108+
void vApplicationIdleHook( void ) __attribute__((weak));
109+
108110
void vApplicationIdleHook( void )
109111
{
110112
loop(); // the normal Arduino loop() function is run here.
@@ -131,6 +133,8 @@ void vApplicationIdleHook( void )
131133
This routine will never return.
132134
This routine is referenced in the task.c file of FreeRTOS as an extern.
133135
\*---------------------------------------------------------------------------*/
136+
void vApplicationMallocFailedHook( void ) __attribute__((weak));
137+
134138
void vApplicationMallocFailedHook( void )
135139
{
136140
#if defined(__AVR_ATmega640__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1281__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__) // Arduino Mega with 2560
@@ -192,7 +196,9 @@ void vApplicationMallocFailedHook( void )
192196
This routine will never return.
193197
This routine is referenced in the task.c file of FreeRTOS as an extern.
194198
\*---------------------------------------------------------------------------*/
195-
void vApplicationStackOverflowHook( TaskHandle_t xTask __attribute__((unused)), portCHAR *pcTaskName __attribute__((unused)) )
199+
void vApplicationStackOverflowHook( TaskHandle_t xTask __attribute__((unused)), portCHAR *pcTaskName __attribute__((unused)) ) __attribute__((weak));
200+
201+
void vApplicationStackOverflowHook( TaskHandle_t xTask, portCHAR *pcTaskName )
196202
{
197203
#if defined(__AVR_ATmega640__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1281__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__) // Arduino Mega with 2560
198204
DDRB |= _BV(DDB7);

0 commit comments

Comments
 (0)