From d8580d39b9600a2bf7df56a190bcf8a0ca80516e Mon Sep 17 00:00:00 2001 From: David Sidrane Date: Mon, 12 Dec 2016 14:57:50 -1000 Subject: [PATCH] Honor Micro hal and new Nuttx Loging API --- src/drivers/stm32/drv_hrt.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/src/drivers/stm32/drv_hrt.c b/src/drivers/stm32/drv_hrt.c index f3ec622a3d..6a5393e511 100644 --- a/src/drivers/stm32/drv_hrt.c +++ b/src/drivers/stm32/drv_hrt.c @@ -62,14 +62,16 @@ #include #include -#include "chip.h" -#include "up_internal.h" -#include "up_arch.h" -#include "stm32.h" #include "stm32_gpio.h" #include "stm32_tim.h" +#ifdef CONFIG_DEBUG_HRT +# define hrtinfo _info +#else +# define hrtinfo(x...) +#endif + #ifdef HRT_TIMER /* HRT configuration */ @@ -865,7 +867,7 @@ hrt_call_enter(struct hrt_call *entry) if ((call == NULL) || (entry->deadline < call->deadline)) { sq_addfirst(&entry->link, &callout_queue); - //lldbg("call enter at head, reschedule\n"); + hrtinfo("call enter at head, reschedule\n"); /* we changed the next deadline, reschedule the timer event */ hrt_call_reschedule(); @@ -874,14 +876,14 @@ hrt_call_enter(struct hrt_call *entry) next = (struct hrt_call *)sq_next(&call->link); if ((next == NULL) || (entry->deadline < next->deadline)) { - //lldbg("call enter after head\n"); + hrtinfo("call enter after head\n"); sq_addafter(&call->link, &entry->link, &callout_queue); break; } } while ((call = next) != NULL); } - //lldbg("scheduled\n"); + hrtinfo("scheduled\n"); } static void @@ -905,7 +907,7 @@ hrt_call_invoke(void) } sq_rem(&call->link, &callout_queue); - //lldbg("call pop\n"); + hrtinfo("call pop\n"); /* save the intended deadline for periodic calls */ deadline = call->deadline; @@ -915,7 +917,7 @@ hrt_call_invoke(void) /* invoke the callout (if there is one) */ if (call->callout) { - //lldbg("call %p: %p(%p)\n", call, call->callout, call->arg); + hrtinfo("call %p: %p(%p)\n", call, call->callout, call->arg); call->callout(call->arg); } @@ -958,19 +960,20 @@ hrt_call_reschedule() * hrt_absolute_time runs at least once per timer period. */ if (next != NULL) { - //lldbg("entry in queue\n"); + hrtinfo("entry in queue\n"); + if (next->deadline <= (now + HRT_INTERVAL_MIN)) { - //lldbg("pre-expired\n"); + hrtinfo("pre-expired\n"); /* set a minimal deadline so that we call ASAP */ deadline = now + HRT_INTERVAL_MIN; } else if (next->deadline < deadline) { - //lldbg("due soon\n"); + hrtinfo("due soon\n"); deadline = next->deadline; } } - //lldbg("schedule for %u at %u\n", (unsigned)(deadline & 0xffffffff), (unsigned)(now & 0xffffffff)); + hrtinfo("schedule for %u at %u\n", (unsigned)(deadline & 0xffffffff), (unsigned)(now & 0xffffffff)); /* set the new compare value and remember it for latency tracking */ rCCR_HRT = latency_baseline = deadline & 0xffff;