start to support
- usbd host - osal some global define #define TUSB_CFG_HOST_CONTROLLER_NUM #define TUSB_CFG_HOST_DEVICE_MAX #define TUSB_CFG_CONFIGURATION_MAX rename & refractor HID type structure & enum use CException to test asssertion library add test for hid_host_keyboard with usbd configure get & osal queue get stubs update test for assertion library refractor ASSERT_STATUS in assertion library update tusb_error_t values rename usb basic type & enum in tusb_types.h and std_descriptors.h
This commit is contained in:
@@ -71,28 +71,32 @@ extern "C"
|
||||
#define ASSERT_FILENAME __BASE_FILE__
|
||||
#define ASSERT_FUNCTION __PRETTY_FUNCTION__
|
||||
#define ASSERT_STATEMENT _PRINTF("assert at %s: %s :%d :\n", ASSERT_FILENAME, ASSERT_FUNCTION, __LINE__)
|
||||
|
||||
#ifndef _TEST_ASSERT_
|
||||
#define ASSERT_ERROR_HANDLE(x) return (x)
|
||||
#else
|
||||
#define ASSERT_ERROR_HANDLE(x) Throw(x)
|
||||
#endif
|
||||
|
||||
#define ASSERT_DEFINE(setup_statement, condition, error, format, ...) \
|
||||
do{\
|
||||
setup_statement;\
|
||||
if (!(condition)) {\
|
||||
_PRINTF("Assert at %s: %s:%d: " format "\n", ASSERT_FILENAME, ASSERT_FUNCTION, __LINE__, __VA_ARGS__);\
|
||||
return error;\
|
||||
ASSERT_ERROR_HANDLE(error);\
|
||||
}\
|
||||
}while(0)
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// tusb_error_t Status Assert
|
||||
// tusb_error_t Status Assert TODO use ASSERT_DEFINE
|
||||
//--------------------------------------------------------------------+
|
||||
#define ASSERT_STATUS_MESSAGE(sts, message) \
|
||||
do{\
|
||||
tusb_error_t status = (tusb_error_t)(sts);\
|
||||
if (TUSB_ERROR_NONE != status) {\
|
||||
_PRINTF("Assert at %s line %d: %s %s\n", ASSERT_FILENAME, ASSERT_FUNCTION, __LINE__, TUSB_ErrorStr[status], message); \
|
||||
return status;\
|
||||
}\
|
||||
}while(0)
|
||||
ASSERT_DEFINE(tusb_error_t status = (tusb_error_t)(sts),\
|
||||
TUSB_ERROR_NONE == status, status, "%s: %s", TUSB_ErrorStr[status], message)
|
||||
|
||||
#define ASSERT_STATUS(sts) ASSERT_STATUS_MESSAGE(sts, NULL)
|
||||
#define ASSERT_STATUS(sts) \
|
||||
ASSERT_DEFINE(tusb_error_t status = (tusb_error_t)(sts),\
|
||||
TUSB_ERROR_NONE == status, status, "%s", TUSB_ErrorStr[status])
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Logical Assert
|
||||
@@ -102,7 +106,14 @@ extern "C"
|
||||
#define ASSERT_FALSE(condition , error) ASSERT_DEFINE( ,!(condition), error, "%s", "evaluated to true")
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Integer Assert
|
||||
// Pointer Assert
|
||||
//--------------------------------------------------------------------+
|
||||
#define ASSERT_PTR(...) ASSERT_PTR_NOT_NULL(__VA_ARGS__)
|
||||
#define ASSERT_PTR_NOT_NULL(pointer, error) ASSERT_DEFINE( , NULL != (pointer), error, "%s", "pointer is NULL")
|
||||
#define ASSERT_PTR_NULL(pointer, error) ASSERT_DEFINE( , NULL == (pointer), error, "%s", "pointer is not NULL")
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Integral Assert
|
||||
//--------------------------------------------------------------------+
|
||||
#define ASSERT_XXX_EQUAL(type_format, expected, actual, error) \
|
||||
ASSERT_DEFINE(\
|
||||
@@ -118,6 +129,9 @@ extern "C"
|
||||
error,\
|
||||
"expected within " type_format " - " type_format ", actual " type_format, low, up, act)
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Integer Assert
|
||||
//--------------------------------------------------------------------+
|
||||
#define ASSERT_INT(...) ASSERT_INT_EQUAL(__VA_ARGS__)
|
||||
#define ASSERT_INT_EQUAL(...) ASSERT_XXX_EQUAL("%d", __VA_ARGS__)
|
||||
#define ASSERT_INT_WITHIN(...) ASSERT_XXX_WITHIN("%d", __VA_ARGS__)
|
||||
@@ -130,11 +144,12 @@ extern "C"
|
||||
#define ASSERT_HEX_WITHIN(...) ASSERT_XXX_WITHIN("0x%x", __VA_ARGS__)
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Pointer Assert
|
||||
// TODO Bin Assert
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// TODO Bit Assert
|
||||
//--------------------------------------------------------------------+
|
||||
#define ASSSERT_PTR(...) ASSERT_PTR_NOT_NULL(__VA_ARGS__)
|
||||
#define ASSERT_PTR_NOT_NULL(pointer, error) ASSERT_DEFINE( , NULL != (pointer), error, "%s", "pointer is NULL")
|
||||
#define ASSSERT_PTR_NULL(pointer, error) ASSERT_DEFINE( , NULL == (pointer), error, "%s", "pointer is NULL")
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -74,15 +74,22 @@
|
||||
#include "osal/osal.h"
|
||||
|
||||
|
||||
/// form an uint32_t from 4 x uint8_t
|
||||
static inline uint32_t u32_from_u8(uint8_t b1, uint8_t b2, uint8_t b3, uint8_t b4) ATTR_ALWAYS_INLINE ATTR_CONST;
|
||||
static inline uint32_t u32_from_u8(uint8_t b1, uint8_t b2, uint8_t b3, uint8_t b4)
|
||||
{
|
||||
return (b1 << 24) + (b2 << 16) + (b3 << 8) + b4;
|
||||
}
|
||||
|
||||
/// min value
|
||||
static inline uint32_t min_of(uint32_t x, uint32_t y) ATTR_ALWAYS_INLINE;
|
||||
static inline uint32_t min_of(uint32_t x, uint32_t y) ATTR_ALWAYS_INLINE ATTR_CONST;
|
||||
static inline uint32_t min_of(uint32_t x, uint32_t y)
|
||||
{
|
||||
return (x < y) ? x : y;
|
||||
}
|
||||
|
||||
/// max value
|
||||
static inline uint32_t max_of(uint32_t x, uint32_t y) ATTR_ALWAYS_INLINE;
|
||||
static inline uint32_t max_of(uint32_t x, uint32_t y) ATTR_ALWAYS_INLINE ATTR_CONST;
|
||||
static inline uint32_t max_of(uint32_t x, uint32_t y)
|
||||
{
|
||||
return (x > y) ? x : y;
|
||||
|
||||
@@ -60,7 +60,10 @@
|
||||
|
||||
#define ERROR_TABLE(ENTRY) \
|
||||
ENTRY(TUSB_ERROR_NONE)\
|
||||
ENTRY(tERROR_FAILED)\
|
||||
ENTRY(TUSB_ERROR_INVALID_PARA)\
|
||||
ENTRY(TUSB_ERROR_CLASS_DEVICE_DONT_SUPPORT)\
|
||||
ENTRY(TUSB_ERROR_OSAL_TIMEOUT)\
|
||||
ENTRY(TUSB_ERROR_FAILED)\
|
||||
|
||||
|
||||
/** \enum tusb_error_t
|
||||
@@ -68,7 +71,7 @@
|
||||
*/
|
||||
typedef enum {
|
||||
ERROR_TABLE(ERROR_ENUM)
|
||||
ERROR_COUNT
|
||||
TUSB_ERROR_COUNT
|
||||
}tusb_error_t;
|
||||
|
||||
#if TUSB_CFG_DEBUG == 3
|
||||
|
||||
Reference in New Issue
Block a user