mirror of
https://github.com/hathach/tinyusb.git
synced 2025-02-21 03:40:52 +00:00
add option to silent a driver log
This commit is contained in:
parent
ecb100a62f
commit
137dff620b
@ -37,6 +37,10 @@
|
|||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// MACRO CONSTANT TYPEDEF
|
// MACRO CONSTANT TYPEDEF
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
|
|
||||||
|
// Can be selectively disabled to reduce logging when troubleshooting other driver
|
||||||
|
#define MSC_DEBUG 2
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
MSC_STAGE_CMD = 0,
|
MSC_STAGE_CMD = 0,
|
||||||
@ -99,7 +103,7 @@ static inline uint16_t rdwr10_get_blockcount(uint8_t const command[])
|
|||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
#if CFG_TUSB_DEBUG >= 2
|
#if CFG_TUSB_DEBUG >= 2
|
||||||
|
|
||||||
static tu_lookup_entry_t const _msc_scsi_cmd_lookup[] =
|
TU_ATTR_UNUSED static tu_lookup_entry_t const _msc_scsi_cmd_lookup[] =
|
||||||
{
|
{
|
||||||
{ .key = SCSI_CMD_TEST_UNIT_READY , .data = "Test Unit Ready" },
|
{ .key = SCSI_CMD_TEST_UNIT_READY , .data = "Test Unit Ready" },
|
||||||
{ .key = SCSI_CMD_INQUIRY , .data = "Inquiry" },
|
{ .key = SCSI_CMD_INQUIRY , .data = "Inquiry" },
|
||||||
@ -114,7 +118,7 @@ static tu_lookup_entry_t const _msc_scsi_cmd_lookup[] =
|
|||||||
{ .key = SCSI_CMD_WRITE_10 , .data = "Write10" }
|
{ .key = SCSI_CMD_WRITE_10 , .data = "Write10" }
|
||||||
};
|
};
|
||||||
|
|
||||||
static tu_lookup_table_t const _msc_scsi_cmd_table =
|
TU_ATTR_UNUSED static tu_lookup_table_t const _msc_scsi_cmd_table =
|
||||||
{
|
{
|
||||||
.count = TU_ARRAY_SIZE(_msc_scsi_cmd_lookup),
|
.count = TU_ARRAY_SIZE(_msc_scsi_cmd_lookup),
|
||||||
.items = _msc_scsi_cmd_lookup
|
.items = _msc_scsi_cmd_lookup
|
||||||
@ -232,8 +236,8 @@ bool mscd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t event, uint32_t
|
|||||||
TU_ASSERT( event == XFER_RESULT_SUCCESS &&
|
TU_ASSERT( event == XFER_RESULT_SUCCESS &&
|
||||||
xferred_bytes == sizeof(msc_cbw_t) && p_cbw->signature == MSC_CBW_SIGNATURE );
|
xferred_bytes == sizeof(msc_cbw_t) && p_cbw->signature == MSC_CBW_SIGNATURE );
|
||||||
|
|
||||||
TU_LOG2(" SCSI Command: %s\r\n", tu_lookup_find(&_msc_scsi_cmd_table, p_cbw->command[0]));
|
TU_LOG(MSC_DEBUG, " SCSI Command: %s\r\n", tu_lookup_find(&_msc_scsi_cmd_table, p_cbw->command[0]));
|
||||||
// TU_LOG2_MEM(p_cbw, xferred_bytes, 2);
|
// TU_LOG_MEM(MSC_DEBUG, p_cbw, xferred_bytes, 2);
|
||||||
|
|
||||||
p_csw->signature = MSC_CSW_SIGNATURE;
|
p_csw->signature = MSC_CSW_SIGNATURE;
|
||||||
p_csw->tag = p_cbw->tag;
|
p_csw->tag = p_cbw->tag;
|
||||||
@ -305,8 +309,8 @@ bool mscd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t event, uint32_t
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case MSC_STAGE_DATA:
|
case MSC_STAGE_DATA:
|
||||||
TU_LOG2(" SCSI Data\r\n");
|
TU_LOG(MSC_DEBUG, " SCSI Data\r\n");
|
||||||
//TU_LOG2_MEM(_mscd_buf, xferred_bytes, 2);
|
//TU_LOG_MEM(MSC_DEBUG, _mscd_buf, xferred_bytes, 2);
|
||||||
|
|
||||||
// OUT transfer, invoke callback if needed
|
// OUT transfer, invoke callback if needed
|
||||||
if ( !tu_bit_test(p_cbw->dir, 7) )
|
if ( !tu_bit_test(p_cbw->dir, 7) )
|
||||||
@ -402,8 +406,8 @@ bool mscd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t event, uint32_t
|
|||||||
// Wait for the Status phase to complete
|
// Wait for the Status phase to complete
|
||||||
if( (ep_addr == p_msc->ep_in) && (xferred_bytes == sizeof(msc_csw_t)) )
|
if( (ep_addr == p_msc->ep_in) && (xferred_bytes == sizeof(msc_csw_t)) )
|
||||||
{
|
{
|
||||||
TU_LOG2(" SCSI Status: %u\r\n", p_csw->status);
|
TU_LOG(MSC_DEBUG, " SCSI Status: %u\r\n", p_csw->status);
|
||||||
// TU_LOG2_MEM(p_csw, xferred_bytes, 2);
|
// TU_LOG_MEM(MSC_DEBUG, p_csw, xferred_bytes, 2);
|
||||||
|
|
||||||
// Invoke complete callback if defined
|
// Invoke complete callback if defined
|
||||||
// Note: There is racing issue with samd51 + qspi flash testing with arduino
|
// Note: There is racing issue with samd51 + qspi flash testing with arduino
|
||||||
|
@ -305,11 +305,11 @@ void tu_print_var(uint8_t const* buf, uint32_t bufsize)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Log with Level
|
// Log with Level
|
||||||
#define TU_LOG(n, ...) TU_LOG##n(__VA_ARGS__)
|
#define TU_LOG(n, ...) TU_XSTRCAT(TU_LOG, n)(__VA_ARGS__)
|
||||||
#define TU_LOG_MEM(n, ...) TU_LOG##n##_MEM(__VA_ARGS__)
|
#define TU_LOG_MEM(n, ...) TU_XSTRCAT3(TU_LOG, n, _MEM)(__VA_ARGS__)
|
||||||
#define TU_LOG_VAR(n, ...) TU_LOG##n##_VAR(__VA_ARGS__)
|
#define TU_LOG_VAR(n, ...) TU_XSTRCAT3(TU_LOG, n, _VAR)(__VA_ARGS__)
|
||||||
#define TU_LOG_INT(n, ...) TU_LOG##n##_INT(__VA_ARGS__)
|
#define TU_LOG_INT(n, ...) TU_XSTRCAT3(TU_LOG, n, _INT)(__VA_ARGS__)
|
||||||
#define TU_LOG_HEX(n, ...) TU_LOG##n##_HEX(__VA_ARGS__)
|
#define TU_LOG_HEX(n, ...) TU_XSTRCAT3(TU_LOG, n, _HEX)(__VA_ARGS__)
|
||||||
#define TU_LOG_LOCATION() tu_printf("%s: %d:\r\n", __PRETTY_FUNCTION__, __LINE__)
|
#define TU_LOG_LOCATION() tu_printf("%s: %d:\r\n", __PRETTY_FUNCTION__, __LINE__)
|
||||||
#define TU_LOG_FAILED() tu_printf("%s: %d: Failed\r\n", __PRETTY_FUNCTION__, __LINE__)
|
#define TU_LOG_FAILED() tu_printf("%s: %d: Failed\r\n", __PRETTY_FUNCTION__, __LINE__)
|
||||||
|
|
||||||
@ -373,6 +373,14 @@ static inline const char* tu_lookup_find(tu_lookup_table_t const* p_table, uint3
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// TODO replace all TU_LOGn with TU_LOG(n)
|
// TODO replace all TU_LOGn with TU_LOG(n)
|
||||||
|
|
||||||
|
#define TU_LOG0(...)
|
||||||
|
#define TU_LOG0_MEM(...)
|
||||||
|
#define TU_LOG0_VAR(...)
|
||||||
|
#define TU_LOG0_INT(...)
|
||||||
|
#define TU_LOG0_HEX(...)
|
||||||
|
|
||||||
|
|
||||||
#ifndef TU_LOG1
|
#ifndef TU_LOG1
|
||||||
#define TU_LOG1(...)
|
#define TU_LOG1(...)
|
||||||
#define TU_LOG1_MEM(...)
|
#define TU_LOG1_MEM(...)
|
||||||
|
@ -32,10 +32,14 @@
|
|||||||
#ifndef _TUSB_COMPILER_H_
|
#ifndef _TUSB_COMPILER_H_
|
||||||
#define _TUSB_COMPILER_H_
|
#define _TUSB_COMPILER_H_
|
||||||
|
|
||||||
#define TU_STRING(x) #x ///< stringify without expand
|
#define TU_STRING(x) #x ///< stringify without expand
|
||||||
#define TU_XSTRING(x) TU_STRING(x) ///< expand then stringify
|
#define TU_XSTRING(x) TU_STRING(x) ///< expand then stringify
|
||||||
#define TU_STRCAT(a, b) a##b ///< concat without expand
|
|
||||||
#define TU_XSTRCAT(a, b) TU_STRCAT(a, b) ///< expand then concat
|
#define TU_STRCAT(a, b) a##b ///< concat without expand
|
||||||
|
#define TU_STRCAT3(a, b, c) a##b##c ///< concat without expand
|
||||||
|
|
||||||
|
#define TU_XSTRCAT(a, b) TU_STRCAT(a, b) ///< expand then concat
|
||||||
|
#define TU_XSTRCAT3(a, b, c) TU_STRCAT3(a, b, c) ///< expand then concat 3 tokens
|
||||||
|
|
||||||
#if defined __COUNTER__ && __COUNTER__ != __COUNTER__
|
#if defined __COUNTER__ && __COUNTER__ != __COUNTER__
|
||||||
#define _TU_COUNTER_ __COUNTER__
|
#define _TU_COUNTER_ __COUNTER__
|
||||||
|
@ -120,9 +120,9 @@ bool tu_fifo_peek (tu_fifo_t* f, void * p_buffer);
|
|||||||
uint16_t tu_fifo_peek_n (tu_fifo_t* f, void * p_buffer, uint16_t n);
|
uint16_t tu_fifo_peek_n (tu_fifo_t* f, void * p_buffer, uint16_t n);
|
||||||
|
|
||||||
uint16_t tu_fifo_count (tu_fifo_t* f);
|
uint16_t tu_fifo_count (tu_fifo_t* f);
|
||||||
|
uint16_t tu_fifo_remaining (tu_fifo_t* f);
|
||||||
bool tu_fifo_empty (tu_fifo_t* f);
|
bool tu_fifo_empty (tu_fifo_t* f);
|
||||||
bool tu_fifo_full (tu_fifo_t* f);
|
bool tu_fifo_full (tu_fifo_t* f);
|
||||||
uint16_t tu_fifo_remaining (tu_fifo_t* f);
|
|
||||||
bool tu_fifo_overflowed (tu_fifo_t* f);
|
bool tu_fifo_overflowed (tu_fifo_t* f);
|
||||||
void tu_fifo_correct_read_pointer (tu_fifo_t* f);
|
void tu_fifo_correct_read_pointer (tu_fifo_t* f);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user