mirror of
https://github.com/hathach/tinyusb.git
synced 2025-01-17 05:32:55 +08:00
Merge pull request #2200 from hathach/selective-log
default class driver log level to CFG_TUH/TUD_LOG_LEVEL
This commit is contained in:
commit
5cf94234d2
@ -2,8 +2,8 @@
|
||||
[codespell]
|
||||
# In the event of a false positive, add the problematic word, in all lowercase, to 'ignore-words.txt' (one word per line).
|
||||
# Or copy & paste the whole problematic line to 'exclude-file.txt'
|
||||
ignore-words = .codespell/ignore-words.txt
|
||||
exclude-file = .codespell/exclude-file.txt
|
||||
ignore-words = tools/codespell/ignore-words.txt
|
||||
exclude-file = tools/codespell/exclude-file.txt
|
||||
check-filenames =
|
||||
check-hidden =
|
||||
count =
|
||||
|
@ -33,6 +33,13 @@
|
||||
|
||||
#include "cdc_device.h"
|
||||
|
||||
// Level where CFG_TUSB_DEBUG must be at least for this driver is logged
|
||||
#ifndef CFG_TUD_CDC_LOG_LEVEL
|
||||
#define CFG_TUD_CDC_LOG_LEVEL CFG_TUD_LOG_LEVEL
|
||||
#endif
|
||||
|
||||
#define TU_LOG_DRV(...) TU_LOG(CFG_TUD_CDC_LOG_LEVEL, __VA_ARGS__)
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// MACRO CONSTANT TYPEDEF
|
||||
//--------------------------------------------------------------------+
|
||||
@ -353,7 +360,7 @@ bool cdcd_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_request_t
|
||||
case CDC_REQUEST_SET_LINE_CODING:
|
||||
if (stage == CONTROL_STAGE_SETUP)
|
||||
{
|
||||
TU_LOG2(" Set Line Coding\r\n");
|
||||
TU_LOG_DRV(" Set Line Coding\r\n");
|
||||
tud_control_xfer(rhport, request, &p_cdc->line_coding, sizeof(cdc_line_coding_t));
|
||||
}
|
||||
else if ( stage == CONTROL_STAGE_ACK)
|
||||
@ -365,7 +372,7 @@ bool cdcd_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_request_t
|
||||
case CDC_REQUEST_GET_LINE_CODING:
|
||||
if (stage == CONTROL_STAGE_SETUP)
|
||||
{
|
||||
TU_LOG2(" Get Line Coding\r\n");
|
||||
TU_LOG_DRV(" Get Line Coding\r\n");
|
||||
tud_control_xfer(rhport, request, &p_cdc->line_coding, sizeof(cdc_line_coding_t));
|
||||
}
|
||||
break;
|
||||
@ -390,7 +397,7 @@ bool cdcd_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_request_t
|
||||
// Disable fifo overwriting if DTR bit is set
|
||||
tu_fifo_set_overwritable(&p_cdc->tx_ff, !dtr);
|
||||
|
||||
TU_LOG2(" Set Control Line State: DTR = %d, RTS = %d\r\n", dtr, rts);
|
||||
TU_LOG_DRV(" Set Control Line State: DTR = %d, RTS = %d\r\n", dtr, rts);
|
||||
|
||||
// Invoke callback
|
||||
if ( tud_cdc_line_state_cb ) tud_cdc_line_state_cb(itf, dtr, rts);
|
||||
@ -403,7 +410,7 @@ bool cdcd_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_request_t
|
||||
}
|
||||
else if (stage == CONTROL_STAGE_ACK)
|
||||
{
|
||||
TU_LOG2(" Send Break\r\n");
|
||||
TU_LOG_DRV(" Send Break\r\n");
|
||||
if ( tud_cdc_send_break_cb ) tud_cdc_send_break_cb(itf, request->wValue);
|
||||
}
|
||||
break;
|
||||
|
@ -33,9 +33,12 @@
|
||||
|
||||
#include "cdc_host.h"
|
||||
|
||||
// Debug level, TUSB_CFG_DEBUG must be at least this level for debug message
|
||||
#define CDCH_DEBUG 2
|
||||
#define TU_LOG_DRV(...) TU_LOG(CDCH_DEBUG, __VA_ARGS__)
|
||||
// Level where CFG_TUSB_DEBUG must be at least for this driver is logged
|
||||
#ifndef CFG_TUH_CDC_LOG_LEVEL
|
||||
#define CFG_TUH_CDC_LOG_LEVEL CFG_TUH_LOG_LEVEL
|
||||
#endif
|
||||
|
||||
#define TU_LOG_DRV(...) TU_LOG(CFG_TUH_CDC_LOG_LEVEL, __VA_ARGS__)
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Host CDC Interface
|
||||
|
@ -37,6 +37,13 @@
|
||||
// MACRO CONSTANT TYPEDEF
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
// Level where CFG_TUSB_DEBUG must be at least for this driver is logged
|
||||
#ifndef CFG_TUD_DFU_LOG_LEVEL
|
||||
#define CFG_TUD_DFU_LOG_LEVEL CFG_TUD_LOG_LEVEL
|
||||
#endif
|
||||
|
||||
#define TU_LOG_DRV(...) TU_LOG(CFG_TUD_DFU_LOG_LEVEL, __VA_ARGS__)
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// INTERNAL OBJECT & FUNCTION DECLARATION
|
||||
//--------------------------------------------------------------------+
|
||||
@ -205,7 +212,7 @@ bool dfu_moded_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_reque
|
||||
{
|
||||
TU_VERIFY(request->bmRequestType_bit.recipient == TUSB_REQ_RCPT_INTERFACE);
|
||||
|
||||
TU_LOG2(" DFU State : %s, Status: %s\r\n", tu_lookup_find(&_dfu_state_table, _dfu_ctx.state), tu_lookup_find(&_dfu_status_table, _dfu_ctx.status));
|
||||
TU_LOG_DRV(" DFU State : %s, Status: %s\r\n", tu_lookup_find(&_dfu_state_table, _dfu_ctx.state), tu_lookup_find(&_dfu_status_table, _dfu_ctx.status));
|
||||
|
||||
if ( request->bmRequestType_bit.type == TUSB_REQ_TYPE_STANDARD )
|
||||
{
|
||||
@ -235,7 +242,7 @@ bool dfu_moded_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_reque
|
||||
}
|
||||
else if ( request->bmRequestType_bit.type == TUSB_REQ_TYPE_CLASS )
|
||||
{
|
||||
TU_LOG2(" DFU Request: %s\r\n", tu_lookup_find(&_dfu_request_table, request->bRequest));
|
||||
TU_LOG_DRV(" DFU Request: %s\r\n", tu_lookup_find(&_dfu_request_table, request->bRequest));
|
||||
|
||||
// Class request
|
||||
switch ( request->bRequest )
|
||||
|
@ -37,6 +37,13 @@
|
||||
// MACRO CONSTANT TYPEDEF
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
// Level where CFG_TUSB_DEBUG must be at least for this driver is logged
|
||||
#ifndef CFG_TUD_DFU_RUNTIME_LOG_LEVEL
|
||||
#define CFG_TUD_DFU_RUNTIME_LOG_LEVEL CFG_TUD_LOG_LEVEL
|
||||
#endif
|
||||
|
||||
#define TU_LOG_DRV(...) TU_LOG(CFG_TUD_DFU_RUNTIME_LOG_LEVEL, __VA_ARGS__)
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// INTERNAL OBJECT & FUNCTION DECLARATION
|
||||
//--------------------------------------------------------------------+
|
||||
@ -99,7 +106,7 @@ bool dfu_rtd_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_request
|
||||
{
|
||||
case DFU_REQUEST_DETACH:
|
||||
{
|
||||
TU_LOG2(" DFU RT Request: DETACH\r\n");
|
||||
TU_LOG_DRV(" DFU RT Request: DETACH\r\n");
|
||||
tud_control_status(rhport, request);
|
||||
tud_dfu_runtime_reboot_to_dfu_cb();
|
||||
}
|
||||
@ -107,7 +114,7 @@ bool dfu_rtd_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_request
|
||||
|
||||
case DFU_REQUEST_GETSTATUS:
|
||||
{
|
||||
TU_LOG2(" DFU RT Request: GETSTATUS\r\n");
|
||||
TU_LOG_DRV(" DFU RT Request: GETSTATUS\r\n");
|
||||
dfu_status_response_t resp;
|
||||
// Status = OK, Poll timeout is ignored during RT, State = APP_IDLE, IString = 0
|
||||
TU_VERIFY(tu_memset_s(&resp, sizeof(resp), 0x00, sizeof(resp))==0);
|
||||
@ -117,7 +124,7 @@ bool dfu_rtd_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_request
|
||||
|
||||
default:
|
||||
{
|
||||
TU_LOG2(" DFU RT Unexpected Request: %d\r\n", request->bRequest);
|
||||
TU_LOG_DRV(" DFU RT Unexpected Request: %d\r\n", request->bRequest);
|
||||
return false; // stall unsupported request
|
||||
}
|
||||
}
|
||||
|
@ -33,10 +33,12 @@
|
||||
|
||||
#include "hid_host.h"
|
||||
|
||||
// Debug level, TUSB_CFG_DEBUG must be at least this level for debug message
|
||||
#define HIDH_DEBUG 2
|
||||
#define TU_LOG_DRV(...) TU_LOG(HIDH_DEBUG, __VA_ARGS__)
|
||||
// Level where CFG_TUSB_DEBUG must be at least for this driver is logged
|
||||
#ifndef CFG_TUH_HID_LOG_LEVEL
|
||||
#define CFG_TUH_HID_LOG_LEVEL CFG_TUH_LOG_LEVEL
|
||||
#endif
|
||||
|
||||
#define TU_LOG_DRV(...) TU_LOG(CFG_TUH_HID_LOG_LEVEL, __VA_ARGS__)
|
||||
//--------------------------------------------------------------------+
|
||||
// MACRO CONSTANT TYPEDEF
|
||||
//--------------------------------------------------------------------+
|
||||
|
@ -36,7 +36,7 @@
|
||||
|
||||
// Level where CFG_TUSB_DEBUG must be at least for this driver is logged
|
||||
#ifndef CFG_TUD_MSC_LOG_LEVEL
|
||||
#define CFG_TUD_MSC_LOG_LEVEL 2
|
||||
#define CFG_TUD_MSC_LOG_LEVEL CFG_TUD_LOG_LEVEL
|
||||
#endif
|
||||
|
||||
#define TU_LOG_DRV(...) TU_LOG(CFG_TUD_MSC_LOG_LEVEL, __VA_ARGS__)
|
||||
|
@ -33,9 +33,12 @@
|
||||
|
||||
#include "msc_host.h"
|
||||
|
||||
// Debug level, TUSB_CFG_DEBUG must be at least this level for debug message
|
||||
#define MSCH_DEBUG 2
|
||||
#define TU_LOG_MSCH(...) TU_LOG(MSCH_DEBUG, __VA_ARGS__)
|
||||
// Level where CFG_TUSB_DEBUG must be at least for this driver is logged
|
||||
#ifndef CFG_TUH_MSC_LOG_LEVEL
|
||||
#define CFG_TUH_MSC_LOG_LEVEL CFG_TUH_LOG_LEVEL
|
||||
#endif
|
||||
|
||||
#define TU_LOG_DRV(...) TU_LOG(CFG_TUH_MSC_LOG_LEVEL, __VA_ARGS__)
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// MACRO CONSTANT TYPEDEF
|
||||
@ -308,7 +311,7 @@ void msch_close(uint8_t dev_addr)
|
||||
msch_interface_t* p_msc = get_itf(dev_addr);
|
||||
TU_VERIFY(p_msc->configured, );
|
||||
|
||||
TU_LOG_MSCH(" MSCh close addr = %d\r\n", dev_addr);
|
||||
TU_LOG_DRV(" MSCh close addr = %d\r\n", dev_addr);
|
||||
|
||||
// invoke Application Callback
|
||||
if (p_msc->mounted) {
|
||||
@ -426,7 +429,7 @@ bool msch_set_config(uint8_t dev_addr, uint8_t itf_num)
|
||||
p_msc->configured = true;
|
||||
|
||||
//------------- Get Max Lun -------------//
|
||||
TU_LOG_MSCH("MSC Get Max Lun\r\n");
|
||||
TU_LOG_DRV("MSC Get Max Lun\r\n");
|
||||
tusb_control_request_t const request =
|
||||
{
|
||||
.bmRequestType_bit =
|
||||
@ -465,7 +468,7 @@ static void config_get_maxlun_complete (tuh_xfer_t* xfer)
|
||||
p_msc->max_lun++; // MAX LUN is minus 1 by specs
|
||||
|
||||
// TODO multiple LUN support
|
||||
TU_LOG_MSCH("SCSI Test Unit Ready\r\n");
|
||||
TU_LOG_DRV("SCSI Test Unit Ready\r\n");
|
||||
uint8_t const lun = 0;
|
||||
tuh_msc_test_unit_ready(daddr, lun, config_test_unit_ready_complete, 0);
|
||||
}
|
||||
@ -478,14 +481,14 @@ static bool config_test_unit_ready_complete(uint8_t dev_addr, tuh_msc_complete_d
|
||||
if (csw->status == 0)
|
||||
{
|
||||
// Unit is ready, read its capacity
|
||||
TU_LOG_MSCH("SCSI Read Capacity\r\n");
|
||||
TU_LOG_DRV("SCSI Read Capacity\r\n");
|
||||
tuh_msc_read_capacity(dev_addr, cbw->lun, (scsi_read_capacity10_resp_t*) ((void*) _msch_buffer), config_read_capacity_complete, 0);
|
||||
}else
|
||||
{
|
||||
// Note: During enumeration, some device fails Test Unit Ready and require a few retries
|
||||
// with Request Sense to start working !!
|
||||
// TODO limit number of retries
|
||||
TU_LOG_MSCH("SCSI Request Sense\r\n");
|
||||
TU_LOG_DRV("SCSI Request Sense\r\n");
|
||||
TU_ASSERT(tuh_msc_request_sense(dev_addr, cbw->lun, _msch_buffer, config_request_sense_complete, 0));
|
||||
}
|
||||
|
||||
|
@ -34,6 +34,13 @@
|
||||
#include "device/usbd_pvt.h"
|
||||
#include "net_device.h"
|
||||
|
||||
// Level where CFG_TUSB_DEBUG must be at least for this driver is logged
|
||||
#ifndef CFG_TUD_NCM_LOG_LEVEL
|
||||
#define CFG_TUD_NCM_LOG_LEVEL CFG_TUD_LOG_LEVEL
|
||||
#endif
|
||||
|
||||
#define TU_LOG_DRV(...) TU_LOG(CFG_TUD_NCM_LOG_LEVEL, __VA_ARGS__)
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// MACRO CONSTANT TYPEDEF
|
||||
//--------------------------------------------------------------------+
|
||||
@ -473,13 +480,13 @@ bool tud_network_can_xmit(uint16_t size)
|
||||
TU_VERIFY(ncm_interface.itf_data_alt == 1);
|
||||
|
||||
if (ncm_interface.datagram_count >= ncm_interface.max_datagrams_per_ntb) {
|
||||
TU_LOG2("NTB full [by count]\r\n");
|
||||
TU_LOG_DRV("NTB full [by count]\r\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t next_datagram_offset = ncm_interface.next_datagram_offset;
|
||||
if (next_datagram_offset + size > ncm_interface.ntb_in_size) {
|
||||
TU_LOG2("ntb full [by size]\r\n");
|
||||
TU_LOG_DRV("ntb full [by size]\r\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -34,6 +34,13 @@
|
||||
|
||||
#include "video_device.h"
|
||||
|
||||
// Level where CFG_TUSB_DEBUG must be at least for this driver is logged
|
||||
#ifndef CFG_TUD_VIDEO_LOG_LEVEL
|
||||
#define CFG_TUD_VIDEO_LOG_LEVEL CFG_TUD_LOG_LEVEL
|
||||
#endif
|
||||
|
||||
#define TU_LOG_DRV(...) TU_LOG(CFG_TUD_VIDEO_LOG_LEVEL, __VA_ARGS__)
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// MACRO CONSTANT TYPEDEF
|
||||
//--------------------------------------------------------------------+
|
||||
@ -609,17 +616,17 @@ static bool _close_vc_itf(uint8_t rhport, videod_interface_t *self)
|
||||
* @param[in] altnum The target alternate setting number. */
|
||||
static bool _open_vc_itf(uint8_t rhport, videod_interface_t *self, uint_fast8_t altnum)
|
||||
{
|
||||
TU_LOG2(" open VC %d\n", altnum);
|
||||
TU_LOG_DRV(" open VC %d\n", altnum);
|
||||
uint8_t const *beg = self->beg;
|
||||
uint8_t const *end = beg + self->len;
|
||||
|
||||
/* The first descriptor is a video control interface descriptor. */
|
||||
uint8_t const *cur = _find_desc_itf(beg, end, _desc_itfnum(beg), altnum);
|
||||
TU_LOG2(" cur %d\n", cur - beg);
|
||||
TU_LOG_DRV(" cur %d\n", cur - beg);
|
||||
TU_VERIFY(cur < end);
|
||||
|
||||
tusb_desc_vc_itf_t const *vc = (tusb_desc_vc_itf_t const *)cur;
|
||||
TU_LOG2(" bInCollection %d\n", vc->ctl.bInCollection);
|
||||
TU_LOG_DRV(" bInCollection %d\n", vc->ctl.bInCollection);
|
||||
/* Support for up to 2 streaming interfaces only. */
|
||||
TU_ASSERT(vc->ctl.bInCollection <= CFG_TUD_VIDEO_STREAMING);
|
||||
|
||||
@ -628,7 +635,7 @@ static bool _open_vc_itf(uint8_t rhport, videod_interface_t *self, uint_fast8_t
|
||||
|
||||
/* Advance to the next descriptor after the class-specific VC interface header descriptor. */
|
||||
cur += vc->std.bLength + vc->ctl.bLength;
|
||||
TU_LOG2(" bNumEndpoints %d\n", vc->std.bNumEndpoints);
|
||||
TU_LOG_DRV(" bNumEndpoints %d\n", vc->std.bNumEndpoints);
|
||||
/* Open the notification endpoint if it exist. */
|
||||
if (vc->std.bNumEndpoints) {
|
||||
/* Support for 1 endpoint only. */
|
||||
@ -662,7 +669,7 @@ static bool _init_vs_configuration(videod_streaming_interface_t *stm)
|
||||
static bool _open_vs_itf(uint8_t rhport, videod_streaming_interface_t *stm, uint_fast8_t altnum)
|
||||
{
|
||||
uint_fast8_t i;
|
||||
TU_LOG2(" reopen VS %d\n", altnum);
|
||||
TU_LOG_DRV(" reopen VS %d\n", altnum);
|
||||
uint8_t const *desc = _videod_itf[stm->index_vc].beg;
|
||||
|
||||
/* Close endpoints of previous settings. */
|
||||
@ -672,7 +679,7 @@ static bool _open_vs_itf(uint8_t rhport, videod_streaming_interface_t *stm, uint
|
||||
uint8_t ep_adr = _desc_ep_addr(desc + ofs_ep);
|
||||
usbd_edpt_close(rhport, ep_adr);
|
||||
stm->desc.ep[i] = 0;
|
||||
TU_LOG2(" close EP%02x\n", ep_adr);
|
||||
TU_LOG_DRV(" close EP%02x\n", ep_adr);
|
||||
}
|
||||
|
||||
/* clear transfer management information */
|
||||
@ -709,12 +716,12 @@ static bool _open_vs_itf(uint8_t rhport, videod_streaming_interface_t *stm, uint
|
||||
}
|
||||
TU_ASSERT(usbd_edpt_open(rhport, ep));
|
||||
stm->desc.ep[i] = (uint16_t) (cur - desc);
|
||||
TU_LOG2(" open EP%02x\n", _desc_ep_addr(cur));
|
||||
TU_LOG_DRV(" open EP%02x\n", _desc_ep_addr(cur));
|
||||
}
|
||||
if (altnum) {
|
||||
stm->state = VS_STATE_STREAMING;
|
||||
}
|
||||
TU_LOG2(" done\n");
|
||||
TU_LOG_DRV(" done\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -45,13 +45,6 @@
|
||||
#define CFG_TUH_INTERFACE_MAX 8
|
||||
#endif
|
||||
|
||||
// Level where CFG_TUSB_DEBUG must be at least for USBH is logged
|
||||
#ifndef CFG_TUH_LOG_LEVEL
|
||||
#define CFG_TUH_LOG_LEVEL 2
|
||||
#endif
|
||||
|
||||
#define TU_LOG_USBH(...) TU_LOG(CFG_TUH_LOG_LEVEL, __VA_ARGS__)
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// USBH-HCD common data structure
|
||||
//--------------------------------------------------------------------+
|
||||
|
@ -35,6 +35,13 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Level where CFG_TUSB_DEBUG must be at least for USBH is logged
|
||||
#ifndef CFG_TUH_LOG_LEVEL
|
||||
#define CFG_TUH_LOG_LEVEL 2
|
||||
#endif
|
||||
|
||||
#define TU_LOG_USBH(...) TU_LOG(CFG_TUH_LOG_LEVEL, __VA_ARGS__)
|
||||
|
||||
enum {
|
||||
USBH_EPSIZE_BULK_MAX = (TUH_OPT_HIGH_SPEED ? TUSB_EPSIZE_BULK_HS : TUSB_EPSIZE_BULK_FS)
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user