diff --git a/include/nuttx/board.h b/include/nuttx/board.h index d89209de39..8f42a973a9 100644 --- a/include/nuttx/board.h +++ b/include/nuttx/board.h @@ -1,7 +1,7 @@ /**************************************************************************** * include/nuttx/board.h * - * Copyright (C) 2015-2018 Gregory Nutt. All rights reserved. + * Copyright (C) 2015-2019 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -257,6 +257,28 @@ int board_reset(int status); int board_uniqueid(FAR uint8_t *uniqueid); #endif +/**************************************************************************** + * Name: board_timerhook + * + * Description: + * If the system is not configured for Tickless operation, then a system + * timer interrupt will be used. If CONFIG_SYSTEMTICK_HOOK is selected + * then the OS will call out to this user-provided function on every + * timer interrupt. This permits custom actions that may be performed on + * each by boad-specific, OS internal logic. + * + * Input Parameters: + * None + * + * Returned Value: + * None. + * + ****************************************************************************/ + +#ifdef CONFIG_SYSTEMTICK_HOOK +void board_timerhook(void); +#endif + /**************************************************************************** * Name: board__initialize * @@ -640,7 +662,7 @@ void board_crashdump(uintptr_t currentsp, FAR void *tcb, #endif /**************************************************************************** - * Name: board_initrngseed + * Name: board_init_rngseed * * Description: * If CONFIG_BOARD_INITRNGSEED is selected then board_init_rngseed is diff --git a/sched/Kconfig b/sched/Kconfig index ef4ea6d99d..0795a899e2 100644 --- a/sched/Kconfig +++ b/sched/Kconfig @@ -137,6 +137,18 @@ config SYSTEMTICK_EXTCLK to move the scheduling off the processor clock to allow entering low power states that would disable that clock. +config SYSTEMTICK_HOOK + bool "System timer hook" + default n + ---help--- + Enable a call to a user-provided, board-level function on each timer + tick. This permits custom actions that may be performed on each + timer tick. The form of the user-provided function is: + + void board_timerhook(void); + + (prototyped in include/nuttx/board.h). + endif # !SCHED_TICKLESS config SYSTEM_TIME64 diff --git a/sched/sched/sched_processtimer.c b/sched/sched/sched_processtimer.c index fc71746c73..21547fa735 100644 --- a/sched/sched/sched_processtimer.c +++ b/sched/sched/sched_processtimer.c @@ -1,7 +1,7 @@ /**************************************************************************** * sched/sched/sched_processtimer.c * - * Copyright (C) 2007, 2009, 2014-2018 Gregory Nutt. All rights reserved. + * Copyright (C) 2007, 2009, 2014-2019 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -222,4 +222,12 @@ void sched_process_timer(void) /* Process watchdogs */ wd_timer(); + +#ifdef CONFIG_SYSTEMTICK_HOOK + /* Call out to a user-provided function in order to perform board-specific, + * custom timer operations. + */ + + board_timerhook(); +#endif }