diff options
Diffstat (limited to 'os/hal/include/usbh')
-rw-r--r-- | os/hal/include/usbh/debug.h | 49 | ||||
-rw-r--r-- | os/hal/include/usbh/debug_helpers.h | 163 | ||||
-rw-r--r-- | os/hal/include/usbh/dev/aoa.h | 1 | ||||
-rw-r--r-- | os/hal/include/usbh/dev/ftdi.h | 2 | ||||
-rw-r--r-- | os/hal/include/usbh/dev/msd.h | 3 | ||||
-rw-r--r-- | os/hal/include/usbh/dev/uvc.h | 4 |
6 files changed, 211 insertions, 11 deletions
diff --git a/os/hal/include/usbh/debug.h b/os/hal/include/usbh/debug.h index 41319b9..f90a11a 100644 --- a/os/hal/include/usbh/debug.h +++ b/os/hal/include/usbh/debug.h @@ -24,18 +24,53 @@ #if HAL_USE_USBH
#if USBH_DEBUG_ENABLE
+#if USBH_DEBUG_MULTI_HOST
+ /* output callback */
+ void USBH_DEBUG_OUTPUT_CALLBACK(USBHDriver *host, const uint8_t *buff, size_t len);
+
+ /* printing functions */
+ void usbDbgPrintf(USBHDriver *host, const char *fmt, ...);
+ void usbDbgPuts(USBHDriver *host, const char *s);
+ void usbDbgInit(USBHDriver *host);
+#else
+ /* output callback */
+ void USBH_DEBUG_OUTPUT_CALLBACK(const uint8_t *buff, size_t len);
+
+ /* printing functions */
void usbDbgPrintf(const char *fmt, ...);
void usbDbgPuts(const char *s);
- void usbDbgInit(USBHDriver *host);
+ void usbDbgInit(void);
+#endif
+
void usbDbgReset(void);
- void usbDbgSystemHalted(void);
#else
-#define usbDbgPrintf(fmt, ...) do {} while(0)
-#define usbDbgPuts(s) do {} while(0)
-#define usbDbgInit(host) do {} while(0)
-#define usbDbgReset() do {} while(0)
-#define usbDbgSystemHalted() do {} while(0)
+
+#if USBH_DEBUG_MULTI_HOST
+# define usbDbgPrintf(host, fmt, ...) do {} while(0)
+# define usbDbgPuts(host, s) do {} while(0)
+# define usbDbgInit(host) do {} while(0)
+#else
+# define usbDbgPrintf(fmt, ...) do {} while(0)
+# define usbDbgPuts(s) do {} while(0)
+# define usbDbgInit() do {} while(0)
+#endif
+# define usbDbgReset() do {} while(0)
+#endif
+
+#if USBH_DEBUG_MULTI_HOST
+#define _usbh_dbg(host, s) usbDbgPuts(host, s)
+#define _usbh_dbgf(host, f, ...) usbDbgPrintf(host, f, ##__VA_ARGS__)
+#define _usbh_ldbg(host, lvl, n, s) do {if (lvl >= n) usbDbgPuts(host, s); } while(0)
+#define _usbh_ldbgf(host, lvl, n, f, ...) do {if (lvl >= n) usbDbgPrintf(host, f, ##__VA_ARGS__); } while(0)
+#else
+
+#define _usbh_dbg(host, s) usbDbgPuts(s)
+#define _usbh_dbgf(host, f, ...) usbDbgPrintf(f, ##__VA_ARGS__)
+#define _usbh_ldbg(host, lvl, n, s) do {if (lvl >= n) usbDbgPuts(s); } while(0)
+#define _usbh_ldbgf(host, lvl, n, f, ...) do {if (lvl >= n) usbDbgPrintf(f, ##__VA_ARGS__); } while(0)
+
#endif
+ #endif
diff --git a/os/hal/include/usbh/debug_helpers.h b/os/hal/include/usbh/debug_helpers.h new file mode 100644 index 0000000..b09bd0a --- /dev/null +++ b/os/hal/include/usbh/debug_helpers.h @@ -0,0 +1,163 @@ +#ifndef USBH_INTERNAL_H_
+#error "Internal use only"
+#endif
+
+#ifndef _USBH_DEBUG_HELPER_ENABLE_TRACE
+#error "_USBH_DEBUG_HELPER_ENABLE_TRACE must be set"
+#endif
+#ifndef _USBH_DEBUG_HELPER_ENABLE_INFO
+#error "_USBH_DEBUG_HELPER_ENABLE_INFO must be set"
+#endif
+#ifndef _USBH_DEBUG_HELPER_ENABLE_WARNINGS
+#error "_USBH_DEBUG_HELPER_ENABLE_WARNINGS must be set"
+#endif
+#ifndef _USBH_DEBUG_HELPER_ENABLE_ERRORS
+#error "_USBH_DEBUG_HELPER_ENABLE_ERRORS must be set"
+#endif
+
+#define _usbh_dbg_host(s) _usbh_dbg(host, s)
+#define _usbh_dbg_port(s) _usbh_dbg(port->device.host, s)
+#define _usbh_dbg_dev(s) _usbh_dbg(dev->host, s)
+#define _usbh_dbg_ep(lvl, s) _usbh_ldbg(ep->device->host, ep->trace_level, lvl, s)
+#define _usbh_dbg_urb(lvl, s) _usbh_ldbg(urb->ep->device->host, urb->ep->trace_level, lvl, s)
+
+#define _usbh_dbgf_host(f, ...) _usbh_dbgf(host, f, ##__VA_ARGS__)
+#define _usbh_dbgf_port(f, ...) _usbh_dbgf(port->device.host, f, ##__VA_ARGS__)
+#define _usbh_dbgf_dev(f, ...) _usbh_dbgf(dev->host, f, ##__VA_ARGS__)
+#define _usbh_dbgf_ep(f, lvl, ...) _usbh_ldbgf(ep->device->host, ep->trace_level, lvl, "\t%s: " f, ep->name, ##__VA_ARGS__)
+#define _usbh_dbgf_urb(f, lvl, ...) _usbh_ldbgf(urb->ep->device->host, urb->ep->trace_level, lvl, "\t%s: " f, urb->ep->name, ##__VA_ARGS__)
+
+#if defined(_USBH_DEBUG_HELPER_CLASS_DRIVER)
+#define _usbh_dbg_classdrv(drv, s) _usbh_dbg(drv->dev->host, s)
+#define _usbh_dbgf_classdrv(drv, f, ...) _usbh_dbgf(drv->dev->host, f, ##__VA_ARGS__)
+#endif
+
+#define _usbh_dbg_dummy do {} while(0)
+
+#if _USBH_DEBUG_HELPER_ENABLE_TRACE
+#define udbg(s) _usbh_dbg_host(s)
+#define uportdbg(s) _usbh_dbg_port(s)
+#define udevdbg(s) _usbh_dbg_dev(s)
+#define uepdbg(s) _usbh_dbg_ep(4, s)
+#define uurbdbg(s) _usbh_dbg_urb(4, s)
+#define udbgf(f, ...) _usbh_dbgf_host(f, ##__VA_ARGS__)
+#define uportdbgf(f, ...) _usbh_dbgf_port(f, ##__VA_ARGS__)
+#define udevdbgf(f, ...) _usbh_dbgf_dev(f, ##__VA_ARGS__)
+#define uepdbgf(f, ...) _usbh_dbgf_ep(f, 4, ##__VA_ARGS__)
+#define uurbdbgf(f, ...) _usbh_dbgf_urb(f, 4, ##__VA_ARGS__)
+#else
+#define udbg(s) _usbh_dbg_dummy
+#define uportdbg(s) _usbh_dbg_dummy
+#define udevdbg(s) _usbh_dbg_dummy
+#define uurbdbg(s) _usbh_dbg_dummy
+#define uepdbg(s) _usbh_dbg_dummy
+#define udbgf(f, ...) _usbh_dbg_dummy
+#define uportdbgf(f, ...) _usbh_dbg_dummy
+#define udevdbgf(f, ...) _usbh_dbg_dummy
+#define uepdbgf(f, ...) _usbh_dbg_dummy
+#define uurbdbgf(f, ...) _usbh_dbg_dummy
+#endif
+
+#if _USBH_DEBUG_HELPER_ENABLE_INFO
+#define uinfo(s) _usbh_dbg_host(s)
+#define uportinfo(s) _usbh_dbg_port(s)
+#define udevinfo(s) _usbh_dbg_dev(s)
+#define uepinfo(s) _usbh_dbg_ep(3, s)
+#define uurbinfo(s) _usbh_dbg_urb(3, s)
+#define uinfof(f, ...) _usbh_dbgf_host(f, ##__VA_ARGS__)
+#define uportinfof(f, ...) _usbh_dbgf_port(f, ##__VA_ARGS__)
+#define udevinfof(f, ...) _usbh_dbgf_dev(f, ##__VA_ARGS__)
+#define uepinfof(f, ...) _usbh_dbgf_ep(f, 3, ##__VA_ARGS__)
+#define uurbinfof(f, ...) _usbh_dbgf_urb(f, 3, ##__VA_ARGS__)
+#else
+#define uinfo(s) _usbh_dbg_dummy
+#define udevinfo(s) _usbh_dbg_dummy
+#define uportinfo(s) _usbh_dbg_dummy
+#define uepinfo(s) _usbh_dbg_dummy
+#define uurbinfo(s) _usbh_dbg_dummy
+#define uinfof(f, ...) _usbh_dbg_dummy
+#define uportinfof(f, ...) _usbh_dbg_dummy
+#define udevinfof(f, ...) _usbh_dbg_dummy
+#define uepinfof(f, ...) _usbh_dbg_dummy
+#define uurbinfof(f, ...) _usbh_dbg_dummy
+#endif
+
+#if _USBH_DEBUG_HELPER_ENABLE_WARNINGS
+#define uwarn(s) _usbh_dbg_host(s)
+#define uportwarn(s) _usbh_dbg_port(s)
+#define udevwarn(s) _usbh_dbg_dev(s)
+#define uepwarn(s) _usbh_dbg_ep(3, s)
+#define uurbwarn(s) _usbh_dbg_urb(3, s)
+#define uwarnf(f, ...) _usbh_dbgf_host(f, ##__VA_ARGS__)
+#define uportwarnf(f, ...) _usbh_dbgf_port(f, ##__VA_ARGS__)
+#define udevwarnf(f, ...) _usbh_dbgf_dev(f, ##__VA_ARGS__)
+#define uepwarnf(f, ...) _usbh_dbgf_ep(f, 3, ##__VA_ARGS__)
+#define uurbwarnf(f, ...) _usbh_dbgf_urb(f, 3, ##__VA_ARGS__)
+#else
+#define uwarn(s) _usbh_dbg_dummy
+#define udevwarn(s) _usbh_dbg_dummy
+#define uportwarn(s) _usbh_dbg_dummy
+#define uepwarn(s) _usbh_dbg_dummy
+#define uurbwarn(s) _usbh_dbg_dummy
+#define uwarnf(f, ...) _usbh_dbg_dummy
+#define uportwarnf(f, ...) _usbh_dbg_dummy
+#define udevwarnf(f, ...) _usbh_dbg_dummy
+#define uepwarnf(f, ...) _usbh_dbg_dummy
+#define uurbwarnf(f, ...) _usbh_dbg_dummy
+#endif
+
+
+#if _USBH_DEBUG_HELPER_ENABLE_ERRORS
+#define uerr(s) _usbh_dbg_host(s)
+#define uporterr(s) _usbh_dbg_port(s)
+#define udeverr(s) _usbh_dbg_dev(s)
+#define ueperr(s) _usbh_dbg_ep(3, s)
+#define uurberr(s) _usbh_dbg_urb(3, s)
+#define uerrf(f, ...) _usbh_dbgf_host(f, ##__VA_ARGS__)
+#define uporterrf(f, ...) _usbh_dbgf_port(f, ##__VA_ARGS__)
+#define udeverrf(f, ...) _usbh_dbgf_dev(f, ##__VA_ARGS__)
+#define ueperrf(f, ...) _usbh_dbgf_ep(f, 3, ##__VA_ARGS__)
+#define uurberrf(f, ...) _usbh_dbgf_urb(f, 3, ##__VA_ARGS__)
+#else
+#define uerr(s) _usbh_dbg_dummy
+#define udeverr(s) _usbh_dbg_dummy
+#define uporterr(s) _usbh_dbg_dummy
+#define ueperr(s) _usbh_dbg_dummy
+#define uurberr(s) _usbh_dbg_dummy
+#define uerrf(f, ...) _usbh_dbg_dummy
+#define uporterrf(f, ...) _usbh_dbg_dummy
+#define udeverrf(f, ...) _usbh_dbg_dummy
+#define ueperrf(f, ...) _usbh_dbg_dummy
+#define uurberrf(f, ...) _usbh_dbg_dummy
+#endif
+
+#if defined(_USBH_DEBUG_HELPER_CLASS_DRIVER)
+#if _USBH_DEBUG_HELPER_ENABLE_TRACE
+#define uclassdrvdbg(s) _usbh_dbg_classdrv(_USBH_DEBUG_HELPER_CLASS_DRIVER, s)
+#define uclassdrvdbgf(f, ...) _usbh_dbgf_classdrv(_USBH_DEBUG_HELPER_CLASS_DRIVER, f, ##__VA_ARGS__)
+#else
+#define uclassdrvdbg(s) _usbh_dbg_dummy
+#define uclassdrvdbgf(f, ...) _usbh_dbg_dummy
+#endif
+#if _USBH_DEBUG_HELPER_ENABLE_INFO
+#define uclassdrvinfo(s) _usbh_dbg_classdrv(_USBH_DEBUG_HELPER_CLASS_DRIVER, s)
+#define uclassdrvinfof(f, ...) _usbh_dbgf_classdrv(_USBH_DEBUG_HELPER_CLASS_DRIVER, f, ##__VA_ARGS__)
+#else
+#define uclassdrvinfo(s) _usbh_dbg_dummy
+#define uclassdrvinfof(f, ...) _usbh_dbg_dummy
+#endif
+#if _USBH_DEBUG_HELPER_ENABLE_WARNINGS
+#define uclassdrvwarn(s) _usbh_dbg_classdrv(_USBH_DEBUG_HELPER_CLASS_DRIVER, s)
+#define uclassdrvwarnf(f, ...) _usbh_dbgf_classdrv(_USBH_DEBUG_HELPER_CLASS_DRIVER, f, ##__VA_ARGS__)
+#else
+#define uclassdrvwarn(s) _usbh_dbg_dummy
+#define uclassdrvwarnf(f, ...) _usbh_dbg_dummy
+#endif
+#if _USBH_DEBUG_HELPER_ENABLE_ERRORS
+#define uclassdrverr(s) _usbh_dbg_classdrv(_USBH_DEBUG_HELPER_CLASS_DRIVER, s)
+#define uclassdrverrf(f, ...) _usbh_dbgf_classdrv(_USBH_DEBUG_HELPER_CLASS_DRIVER, f, ##__VA_ARGS__)
+#else
+#define uclassdrverr(s) _usbh_dbg_dummy
+#define uclassdrverrf(f, ...) _usbh_dbg_dummy
+#endif
+#endif
diff --git a/os/hal/include/usbh/dev/aoa.h b/os/hal/include/usbh/dev/aoa.h index 8205dd5..1f36370 100644 --- a/os/hal/include/usbh/dev/aoa.h +++ b/os/hal/include/usbh/dev/aoa.h @@ -130,6 +130,7 @@ typedef bool (*usbhaoa_filter_callback_t)(usbh_device_t *dev, const uint8_t *des #define usbhaoaGetState(aoap) ((aoap)->state) #define usbhaoaGetChannelState(aoap) ((aoap)->channel.state) +#define usbhaoaGetHost(aoap) ((aoap)->dev->host) /*===========================================================================*/ /* External declarations. */ diff --git a/os/hal/include/usbh/dev/ftdi.h b/os/hal/include/usbh/dev/ftdi.h index 84ea4bc..fdd767d 100644 --- a/os/hal/include/usbh/dev/ftdi.h +++ b/os/hal/include/usbh/dev/ftdi.h @@ -127,7 +127,7 @@ struct USBHFTDIDriver { /* Driver macros. */
/*===========================================================================*/
#define usbhftdipGetState(ftdipp) ((ftdipp)->state)
-
+#define usbhftdipGetHost(ftdipp) ((ftdipp)->ftdip->dev->host)
/*===========================================================================*/
/* External declarations. */
diff --git a/os/hal/include/usbh/dev/msd.h b/os/hal/include/usbh/dev/msd.h index b245bfc..113f523 100644 --- a/os/hal/include/usbh/dev/msd.h +++ b/os/hal/include/usbh/dev/msd.h @@ -72,7 +72,6 @@ struct USBHMassStorageLUNDriver { /* Driver macros. */
/*===========================================================================*/
-
/*===========================================================================*/
/* External declarations. */
/*===========================================================================*/
@@ -95,6 +94,8 @@ extern "C" { bool usbhmsdLUNGetInfo(USBHMassStorageLUNDriver *lunp, BlockDeviceInfo *bdip);
bool usbhmsdLUNIsInserted(USBHMassStorageLUNDriver *lunp);
bool usbhmsdLUNIsProtected(USBHMassStorageLUNDriver *lunp);
+
+ USBHDriver *usbhmsdLUNGetHost(const USBHMassStorageLUNDriver *lunp);
#ifdef __cplusplus
}
#endif
diff --git a/os/hal/include/usbh/dev/uvc.h b/os/hal/include/usbh/dev/uvc.h index 713d16c..7116c91 100644 --- a/os/hal/include/usbh/dev/uvc.h +++ b/os/hal/include/usbh/dev/uvc.h @@ -408,9 +408,9 @@ extern "C" { const uint8_t *framedesc, uint32_t dwFrameInterval); #if USBH_DEBUG_ENABLE && USBHUVC_DEBUG_ENABLE_INFO - void usbhuvcPrintProbeCommit(const usbh_uvc_ctrl_vs_probecommit_data_t *pc); + void usbhuvcPrintProbeCommit(USBHUVCDriver *uvcdp, const usbh_uvc_ctrl_vs_probecommit_data_t *pc); #else -# define usbhuvcPrintProbeCommit(pc) do {} while(0) +# define usbhuvcPrintProbeCommit(uvcdp, pc) do {} while(0) #endif bool usbhuvcProbe(USBHUVCDriver *uvcdp); bool usbhuvcCommit(USBHUVCDriver *uvcdp); |