...
Within the core, several macros are created to set debug messages. These macros are defined in usbd_core.h
and make use of the core functions USBD_Dbg()
and USBD_DbgArg()
that will set up a debug event structure and put the event into the debug event pool. These macros are defined in Listing - Core Level Debug Macros.
Anchor |
---|
| Listing - Core Level Debug Macros |
---|
| Listing - Core Level Debug Macros |
---|
|
Code Block |
---|
language | cpp |
---|
title | Listing - Core Level Debug Macros |
---|
linenumbers | true |
---|
|
#define USBD_DBG_GENERIC(msg, ep_addr, if_nbr) USBD_Dbg((msg), \
(ep_addr), \
(if_nbr), \
USBD_ERR_NONE)
#define USBD_DBG_GENERIC_ERR(msg, ep_addr, if_nbr, err) USBD_Dbg((msg), \
(ep_addr), \
(if_nbr), \
(err))
#define USBD_DBG_GENERIC_ARG(msg, ep_addr, if_nbr, arg) USBD_DbgArg((msg), \
(ep_addr), \
(if_nbr), \
(CPU_INT32U)(arg),\
(USBD_ERR_NONE))
#define USBD_DBG_GENERIC_ARG_ERR(msg, ep_addr, if_nbr, arg, err) USBD_DbgArg((msg), \
(ep_addr), \
(if_nbr), \
(CPU_INT32U)(arg),\
(err)) |
There are subtle yet important differences between each debug macro. The first debug macro is the most simple, specifying just the debug message, endpoint address and interface number as parameters. The second and third macros differ in the last parameter where one specifies the error and the other specifies an argument of choice. The last macro lets the caller specify all details including both error and argument.
Furthermore, core level debug macros can be further mapped to other macros to simplify the repetition of endpoint address and interface number parameters. Listing - Mapped Core Tracing Macros shows an example of a bus specific debug macro and a standard debug macro found in usbd_core.c
.
Anchor |
---|
| Listing - Mapped Core Tracing Macros |
---|
| Listing - Mapped Core Tracing Macros |
---|
|
Code Block |
---|
language | cpp |
---|
title | Listing - Mapped Core Tracing Macros |
---|
linenumbers | true |
---|
|
#define USBD_DBG_CORE_BUS(msg) USBD_DBG_GENERIC((msg), \
USBD_EP_ADDR_NONE, \
USBD_IF_NBR_NONE)
#define USBD_DBG_CORE_STD(msg) USBD_DBG_GENERIC((msg), \
0u,
USBD_IF_NBR_NONE) |