diff options
author | Diego Ismirlian <dismirlian (at) google's mail.com> | 2017-12-04 13:11:16 -0300 |
---|---|---|
committer | Diego Ismirlian <dismirlian (at) google's mail.com> | 2017-12-04 13:11:16 -0300 |
commit | 03615f40dc3d1cbb5354035c326963b49759f440 (patch) | |
tree | 38365f8ddf10be42264e7b9867963096fca1ccb2 /os/hal/src | |
parent | dbaa1b87001d7c0c1e7970b66304011e7538c457 (diff) | |
download | ChibiOS-Contrib-03615f40dc3d1cbb5354035c326963b49759f440.tar.gz ChibiOS-Contrib-03615f40dc3d1cbb5354035c326963b49759f440.tar.bz2 ChibiOS-Contrib-03615f40dc3d1cbb5354035c326963b49759f440.zip |
USBH: debug improvements
Diffstat (limited to 'os/hal/src')
-rw-r--r-- | os/hal/src/usbh/hal_usbh_debug.c | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/os/hal/src/usbh/hal_usbh_debug.c b/os/hal/src/usbh/hal_usbh_debug.c index d32f1c6..85c6640 100644 --- a/os/hal/src/usbh/hal_usbh_debug.c +++ b/os/hal/src/usbh/hal_usbh_debug.c @@ -22,7 +22,13 @@ #include "ch.h" #include "usbh/debug.h" #include <stdarg.h> +#if 0 +#include "debug.h" +#else #include "chprintf.h" +#define dbg_lock() +#define dbg_unlock() +#endif #define MAX_FILLER 11 #define FLOAT_PRECISION 9 @@ -393,6 +399,9 @@ void usbDbgPrintf(const char *fmt, ...) chThdDequeueNextI(&USBH_DEBUG_USBHD.iq.q_waiting, Q_OK); } chSysRestoreStatusX(sts); + if (!port_is_isr_context() && chSchIsPreemptionRequired()) { + chSchRescheduleS(); + } va_end(ap); } @@ -422,6 +431,9 @@ void usbDbgPuts(const char *s) chThdDequeueNextI(&USBH_DEBUG_USBHD.iq.q_waiting, Q_OK); } chSysRestoreStatusX(sts); + if (!port_is_isr_context() && chSchIsPreemptionRequired()) { + chSchRescheduleS(); + } } void usbDbgReset(void) { @@ -435,6 +447,9 @@ void usbDbgReset(void) { USBH_DEBUG_SD.oqueue.q_counter--; } chSysRestoreStatusX(sts); + if (!port_is_isr_context() && chSchIsPreemptionRequired()) { + chSchRescheduleS(); + } } static int _get(void) { @@ -527,6 +542,7 @@ static void usb_debug_thread(void *arg) { uint32_t f = hfnum & 0xffff; uint32_t p = 1000 - ((hfnum >> 16) / (hfir / 1000)); + dbg_lock(); chprintf((BaseSequentialStream *)&USBH_DEBUG_SD, "%05d.%03d ", f, p); state = 4; } else if (state == 3) { @@ -543,6 +559,7 @@ static void usb_debug_thread(void *arg) { c = iqGet(&host->iq); if (c < 0) goto reset; t |= c << 24; + dbg_lock(); chprintf((BaseSequentialStream *)&USBH_DEBUG_SD, "+%08d ", t); state = 4; } else { @@ -550,8 +567,7 @@ static void usb_debug_thread(void *arg) { if (!c) { sdPut(&USBH_DEBUG_SD, '\r'); sdPut(&USBH_DEBUG_SD, '\n'); - state = 0; - break; + goto reset; } sdPut(&USBH_DEBUG_SD, (uint8_t)c); c = iqGet(&host->iq); if (c < 0) goto reset; @@ -560,6 +576,9 @@ static void usb_debug_thread(void *arg) { continue; reset: + if (state == 4) { + dbg_unlock(); + } state = 0; } } |