more error string clean up

This commit is contained in:
hathach 2018-03-28 13:41:00 +07:00
parent 604275341e
commit 111065c042
5 changed files with 17 additions and 52 deletions

View File

@ -97,11 +97,11 @@ extern "C"
//--------------------------------------------------------------------+
#define ASSERT_STATUS_MESSAGE(sts, message) \
ASSERT_DEFINE(tusb_error_t status = (tusb_error_t)(sts),\
TUSB_ERROR_NONE == status, status, "%s: %s", TUSB_ErrorStr[status], message)
TUSB_ERROR_NONE == status, status, "%s: %s", tusb_strerr[status], message)
#define ASSERT_STATUS(sts) \
ASSERT_DEFINE(tusb_error_t status = (tusb_error_t)(sts),\
TUSB_ERROR_NONE == status, status, "%s", TUSB_ErrorStr[status])
TUSB_ERROR_NONE == status, status, "%s", tusb_strerr[status])
//--------------------------------------------------------------------+
// Logical Assert

View File

@ -1,48 +0,0 @@
/**************************************************************************/
/*!
@file tusb_error.c
@author hathach (tinyusb.org)
@section LICENSE
Software License Agreement (BSD License)
Copyright (c) 2013, hathach (tinyusb.org)
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holders nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This file is part of the tinyusb stack.
*/
/**************************************************************************/
#include "tusb_error.h"
#if TUSB_CFG_DEBUG
char const* const TUSB_ErrorStr[TUSB_ERROR_COUNT] =
{
ERROR_TABLE(ERROR_STRING)
};
#endif

View File

@ -102,7 +102,7 @@ typedef enum
#if TUSB_CFG_DEBUG
/// Enum to String for debugging purposes. Only available if \ref TUSB_CFG_DEBUG > 0
extern char const* const TUSB_ErrorStr[TUSB_ERROR_COUNT];
extern char const* const tusb_strerr[TUSB_ERROR_COUNT];
#endif
#ifdef __cplusplus

View File

@ -61,7 +61,7 @@
//--------------------------------------------------------------------+
#if TUSB_CFG_DEBUG >= 1
// #define _VERIFY_MESS(format, ...) cprintf("[%08ld] %s: %d: verify failed\n", get_millis(), __func__, __LINE__)
#define _VERIFY_MESS(_status) printf("%s: %d: verify failed, error = %s\n", __PRETTY_FUNCTION__, __LINE__, TUSB_ErrorStr[_status]);
#define _VERIFY_MESS(_status) printf("%s: %d: verify failed, error = %s\n", __PRETTY_FUNCTION__, __LINE__, tusb_strerr[_status]);
#define _ASSERT_MESS() printf("%s: %d: assert failed\n", __PRETTY_FUNCTION__, __LINE__);
#else
#define _VERIFY_MESS(_status)

View File

@ -68,3 +68,16 @@ void tusb_task(void)
#endif
}
#endif
/*------------------------------------------------------------------*/
/* Debug
*------------------------------------------------------------------*/
#if TUSB_CFG_DEBUG
char const* const tusb_strerr[TUSB_ERROR_COUNT] =
{
ERROR_TABLE(ERROR_STRING)
};
#endif