From e9ca7b4d0d460def70b2838b3b56ac7241f25e1d Mon Sep 17 00:00:00 2001 From: Rahix <rahix@rahix.de> Date: Thu, 11 Jul 2019 21:58:00 +0200 Subject: [PATCH] feat(epicardium): Enable FreeRTOS timers Signed-off-by: Rahix <rahix@rahix.de> --- epicardium/FreeRTOSConfig.h | 5 +++++ epicardium/support.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/epicardium/FreeRTOSConfig.h b/epicardium/FreeRTOSConfig.h index 51d3fd3b..eb82e801 100644 --- a/epicardium/FreeRTOSConfig.h +++ b/epicardium/FreeRTOSConfig.h @@ -43,6 +43,11 @@ #define configUSE_CO_ROUTINES 0 #define configUSE_16_BIT_TICKS 0 #define configUSE_MUTEXES 1 +#define configUSE_TIMERS 1 + +#define configTIMER_TASK_PRIORITY (configMAX_PRIORITIES - 1) +#define configTIMER_QUEUE_LENGTH 10 +#define configTIMER_TASK_STACK_DEPTH (configMINIMAL_STACK_SIZE * 2) #define INCLUDE_vTaskSuspend 1 #define INCLUDE_vTaskDelay 1 diff --git a/epicardium/support.c b/epicardium/support.c index 7d6fb238..534506ba 100644 --- a/epicardium/support.c +++ b/epicardium/support.c @@ -80,3 +80,35 @@ void vApplicationGetIdleTaskMemory( */ *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE; } + +void vApplicationGetTimerTaskMemory( + StaticTask_t **ppxTimerTaskTCBBuffer, + StackType_t **ppxTimerTaskStackBuffer, + uint32_t *pulTimerTaskStackSize +) { + /* + * If the buffers to be provided to the Timer task are declared inside + * this function then they must be declared static - otherwise they will + * be allocated on the stack and so not exists after this function + * exits. + */ + static StaticTask_t xTimerTaskTCB; + static StackType_t uxTimerTaskStack[configTIMER_TASK_STACK_DEPTH]; + + /* + * Pass out a pointer to the StaticTask_t structure in which the Timer + * task's state will be stored. + */ + *ppxTimerTaskTCBBuffer = &xTimerTaskTCB; + + /* Pass out the array that will be used as the Timer task's stack. */ + *ppxTimerTaskStackBuffer = uxTimerTaskStack; + + /* + * Pass out the size of the array pointed to by + * *ppxTimerTaskStackBuffer. Note that, as the array is necessarily of + * type StackType_t, configMINIMAL_STACK_SIZE is specified in words, not + * bytes. + */ + *pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH; +} -- GitLab