From 0868a3a8aec1d3434ed3be58af77a8e588e40b67 Mon Sep 17 00:00:00 2001 From: goldsimon Date: Mon, 15 Jan 2018 14:00:49 +0100 Subject: [PATCH] freertos port: make sys_now() overriable for platforms that have a hardware timer, this can be more accurate than using freertos ticks --- ports/freertos/sys_arch.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ports/freertos/sys_arch.c b/ports/freertos/sys_arch.c index 998a321..e6cdee7 100644 --- a/ports/freertos/sys_arch.c +++ b/ports/freertos/sys_arch.c @@ -74,6 +74,13 @@ #define LWIP_FREERTOS_CHECK_CORE_LOCKING 0 #endif +/** Set this to 0 to implement sys_now() yourself, e.g. using a hw timer. + * Default is 1, where FreeRTOS ticks are used to calculate back to ms. + */ +#ifndef LWIP_FREERTOS_SYS_NOW_FROM_FREERTOS +#define LWIP_FREERTOS_SYS_NOW_FROM_FREERTOS 1 +#endif + #if !configSUPPORT_DYNAMIC_ALLOCATION # error "lwIP FreeRTOS port requires configSUPPORT_DYNAMIC_ALLOCATION" #endif @@ -112,11 +119,13 @@ sys_init(void) #error This port requires 32 bit ticks or timer overflow will fail #endif +#if LWIP_FREERTOS_SYS_NOW_FROM_FREERTOS u32_t sys_now(void) { return xTaskGetTickCount() * portTICK_PERIOD_MS; } +#endif u32_t sys_jiffies(void)