rename VERIFY to TU_VERIFY to avoid conflict with application

This commit is contained in:
hathach 2018-08-13 18:10:23 +07:00
parent b07124c623
commit e07b1acbed
29 changed files with 119 additions and 119 deletions

View File

@ -115,7 +115,7 @@ void cdc_serial_host_app_init(void)
sem_hdl = osal_semaphore_create(1, 0);
TU_ASSERT( sem_hdl, VOID_RETURN);
VERIFY( osal_task_create(cdc_serial_host_app_task, "cdc", 128, NULL, CDC_SERIAL_APP_TASK_PRIO), );
TU_VERIFY( osal_task_create(cdc_serial_host_app_task, "cdc", 128, NULL, CDC_SERIAL_APP_TASK_PRIO), );
}
//------------- main task -------------//

View File

@ -105,7 +105,7 @@ void keyboard_host_app_init(void)
queue_kbd_hdl = osal_queue_create( QUEUE_KEYBOARD_REPORT_DEPTH, sizeof(hid_keyboard_report_t) );
TU_ASSERT( queue_kbd_hdl, VOID_RETURN );
VERIFY( osal_task_create(keyboard_host_app_task, "kbd", 128, NULL, KEYBOARD_APP_TASK_PRIO), );
TU_VERIFY( osal_task_create(keyboard_host_app_task, "kbd", 128, NULL, KEYBOARD_APP_TASK_PRIO), );
}
//------------- main task -------------//

View File

@ -106,7 +106,7 @@ void mouse_host_app_init(void)
queue_mouse_hdl = osal_queue_create( QUEUE_MOUSE_REPORT_DEPTH, sizeof(hid_mouse_report_t) );
TU_ASSERT( queue_mouse_hdl, VOID_RETURN);
VERIFY( osal_task_create(mouse_host_app_task, "mouse", 128, NULL, MOUSE_APP_TASK_PRIO), );
TU_VERIFY( osal_task_create(mouse_host_app_task, "mouse", 128, NULL, MOUSE_APP_TASK_PRIO), );
}
//------------- main task -------------//

View File

@ -300,7 +300,7 @@ typedef struct ATTR_PACKED
uint8_t : 0;
}cdc_acm_capability_t;
VERIFY_STATIC(sizeof(cdc_acm_capability_t) == 1, "mostly problem with compiler");
TU_VERIFY_STATIC(sizeof(cdc_acm_capability_t) == 1, "mostly problem with compiler");
/// \brief Abstract Control Management Functional Descriptor
/// \details This functional descriptor describes the commands supported by by the Communications Class interface with SubClass code of \ref CDC_COMM_SUBCLASS_ABSTRACT_CONTROL_MODEL
@ -390,7 +390,7 @@ typedef struct ATTR_PACKED
uint8_t data_bits; ///< can be 5, 6, 7, 8 or 16
} cdc_line_coding_t;
VERIFY_STATIC(sizeof(cdc_line_coding_t) == 7, "size is not correct");
TU_VERIFY_STATIC(sizeof(cdc_line_coding_t) == 7, "size is not correct");
typedef struct ATTR_PACKED
{
@ -399,7 +399,7 @@ typedef struct ATTR_PACKED
uint16_t : 14;
} cdc_line_control_state_t;
VERIFY_STATIC(sizeof(cdc_line_control_state_t) == 2, "size is not correct");
TU_VERIFY_STATIC(sizeof(cdc_line_control_state_t) == 2, "size is not correct");
/** @} */

View File

@ -157,11 +157,11 @@ uint32_t tud_cdc_n_write(uint8_t itf, void const* buffer, uint32_t bufsize)
bool tud_cdc_n_write_flush (uint8_t itf)
{
cdcd_interface_t* p_cdc = &_cdcd_itf[itf];
VERIFY( !dcd_edpt_busy(TUD_OPT_RHPORT, p_cdc->ep_in) ); // skip if previous transfer not complete
TU_VERIFY( !dcd_edpt_busy(TUD_OPT_RHPORT, p_cdc->ep_in) ); // skip if previous transfer not complete
uint16_t count = tu_fifo_read_n(&_cdcd_itf[itf].tx_ff, p_cdc->epout_buf, CFG_TUD_CDC_EPSIZE);
VERIFY( tud_cdc_n_connected(itf) ); // fifo is empty if not connected
TU_VERIFY( tud_cdc_n_connected(itf) ); // fifo is empty if not connected
if ( count ) TU_ASSERT( dcd_edpt_xfer(TUD_OPT_RHPORT, p_cdc->ep_in, p_cdc->epout_buf, count) );

View File

@ -142,7 +142,7 @@ typedef struct {
uint8_t oid_buffer[] ; ///< Flexible array contains the input data supplied by the host, required for the OID query request processing by the device, as per the host NDIS specification.
} rndis_msg_query_t, rndis_msg_set_t;
VERIFY_STATIC(sizeof(rndis_msg_query_t) == 28, "Make sure flexible array member does not affect layout");
TU_VERIFY_STATIC(sizeof(rndis_msg_query_t) == 28, "Make sure flexible array member does not affect layout");
/// \brief Query Complete Message
/// \details This message MUST be sent by the device in response to a query OID message.
@ -156,7 +156,7 @@ typedef struct {
uint8_t oid_buffer[] ; ///< Flexible array member contains the response data to the OID query request as specified by the host.
} rndis_msg_query_cmplt_t;
VERIFY_STATIC(sizeof(rndis_msg_query_cmplt_t) == 24, "Make sure flexible array member does not affect layout");
TU_VERIFY_STATIC(sizeof(rndis_msg_query_cmplt_t) == 24, "Make sure flexible array member does not affect layout");
//------------- Reset -------------//
/// \brief Reset Message

View File

@ -75,7 +75,7 @@ static tusb_error_t send_message_get_response_subtask( uint8_t dev_addr, cdch_da
tusb_error_t tusbh_cdc_rndis_get_mac_addr(uint8_t dev_addr, uint8_t mac_address[6])
{
TU_ASSERT( tusbh_cdc_rndis_is_mounted(dev_addr), TUSB_ERROR_CDCH_DEVICE_NOT_MOUNTED);
VERIFY( mac_address, TUSB_ERROR_INVALID_PARA);
TU_VERIFY( mac_address, TUSB_ERROR_INVALID_PARA);
memcpy(mac_address, rndish_data[dev_addr-1].mac_address, 6);

View File

@ -125,7 +125,7 @@ bool tud_hid_generic_ready(void)
bool tud_hid_generic_report(uint8_t report_id, void const* report, uint8_t len)
{
VERIFY( tud_hid_generic_ready() && (len < REPORT_BUFSIZE) );
TU_VERIFY( tud_hid_generic_ready() && (len < REPORT_BUFSIZE) );
hidd_interface_t * p_hid = &_hidd_itf[ITF_IDX_GENERIC];
@ -159,7 +159,7 @@ bool tud_hid_keyboard_is_boot_protocol(void)
static bool hidd_kbd_report(hid_keyboard_report_t const *p_report)
{
VERIFY( tud_hid_keyboard_ready() );
TU_VERIFY( tud_hid_keyboard_ready() );
hidd_interface_t * p_hid = _kbd_rpt.itf;
@ -253,7 +253,7 @@ bool tud_hid_mouse_is_boot_protocol(void)
static bool hidd_mouse_report(hid_mouse_report_t const *p_report)
{
VERIFY( tud_hid_mouse_ready() );
TU_VERIFY( tud_hid_mouse_ready() );
hidd_interface_t * p_hid = _mse_rpt.itf;
memcpy(p_hid->report_buf, p_report, sizeof(hid_mouse_report_t));
@ -277,7 +277,7 @@ bool tud_hid_mouse_data(uint8_t buttons, int8_t x, int8_t y, int8_t scroll, int8
bool tud_hid_mouse_move(int8_t x, int8_t y)
{
VERIFY( tud_hid_mouse_ready() );
TU_VERIFY( tud_hid_mouse_ready() );
hidd_interface_t * p_hid = _mse_rpt.itf;
uint8_t prev_buttons = p_hid->report_buf[0];
@ -287,7 +287,7 @@ bool tud_hid_mouse_move(int8_t x, int8_t y)
bool tud_hid_mouse_scroll(int8_t vertical, int8_t horizontal)
{
VERIFY( tud_hid_mouse_ready() );
TU_VERIFY( tud_hid_mouse_ready() );
hidd_interface_t * p_hid = _mse_rpt.itf;
uint8_t prev_buttons = p_hid->report_buf[0];
@ -390,7 +390,7 @@ tusb_error_t hidd_open(uint8_t rhport, tusb_desc_interface_t const * desc_itf, u
TU_ASSERT(p_hid, ERR_TUD_INVALID_DESCRIPTOR);
}
VERIFY(p_hid->desc_report, ERR_TUD_INVALID_DESCRIPTOR);
TU_VERIFY(p_hid->desc_report, ERR_TUD_INVALID_DESCRIPTOR);
TU_ASSERT( dcd_edpt_open(rhport, desc_edpt), ERR_TUD_EDPT_OPEN_FAILED );
p_hid->itf_num = desc_itf->bInterfaceNumber;

View File

@ -77,7 +77,7 @@ tusb_error_t hidh_interface_get_report(uint8_t dev_addr, void * report, hidh_int
//------------- parameters validation -------------//
// TODO change to use is configured function
TU_ASSERT (TUSB_DEVICE_STATE_CONFIGURED == tuh_device_get_state(dev_addr), TUSB_ERROR_DEVICE_NOT_READY);
VERIFY (report, TUSB_ERROR_INVALID_PARA);
TU_VERIFY (report, TUSB_ERROR_INVALID_PARA);
TU_ASSSERT (!hcd_pipe_is_busy(p_hid->pipe_hdl), TUSB_ERROR_INTERFACE_IS_BUSY);
TU_ASSERT_ERR( hcd_pipe_xfer(p_hid->pipe_hdl, report, p_hid->report_size, true) ) ;

View File

@ -109,7 +109,7 @@ typedef struct ATTR_PACKED
uint8_t command[16] ; ///< The command block to be executed by the device. The device shall interpret the first cmd_len bytes in this field as a command block
}msc_cbw_t;
VERIFY_STATIC(sizeof(msc_cbw_t) == 31, "size is not correct");
TU_VERIFY_STATIC(sizeof(msc_cbw_t) == 31, "size is not correct");
/// Command Status Wrapper
typedef struct ATTR_PACKED
@ -120,7 +120,7 @@ typedef struct ATTR_PACKED
uint8_t status ; ///< indicates the success or failure of the command. Values from \ref msc_csw_status_t
}msc_csw_t;
VERIFY_STATIC(sizeof(msc_csw_t) == 13, "size is not correct");
TU_VERIFY_STATIC(sizeof(msc_csw_t) == 13, "size is not correct");
//--------------------------------------------------------------------+
// SCSI Constant
@ -173,7 +173,7 @@ typedef struct ATTR_PACKED
uint8_t control ;
} scsi_test_unit_ready_t;
VERIFY_STATIC(sizeof(scsi_test_unit_ready_t) == 6, "size is not correct");
TU_VERIFY_STATIC(sizeof(scsi_test_unit_ready_t) == 6, "size is not correct");
/// SCSI Inquiry Command
typedef struct ATTR_PACKED
@ -186,7 +186,7 @@ typedef struct ATTR_PACKED
uint8_t control ;
} scsi_inquiry_t, scsi_request_sense_t;
VERIFY_STATIC(sizeof(scsi_inquiry_t) == 6, "size is not correct");
TU_VERIFY_STATIC(sizeof(scsi_inquiry_t) == 6, "size is not correct");
/// SCSI Inquiry Response Data
typedef struct ATTR_PACKED
@ -232,7 +232,7 @@ typedef struct ATTR_PACKED
uint8_t product_rev[4]; ///< 4 bytes of ASCII data defined by the vendor.
} scsi_inquiry_resp_t;
VERIFY_STATIC(sizeof(scsi_inquiry_resp_t) == 36, "size is not correct");
TU_VERIFY_STATIC(sizeof(scsi_inquiry_resp_t) == 36, "size is not correct");
typedef struct ATTR_PACKED
@ -259,7 +259,7 @@ typedef struct ATTR_PACKED
} scsi_sense_fixed_resp_t;
VERIFY_STATIC(sizeof(scsi_sense_fixed_resp_t) == 18, "size is not correct");
TU_VERIFY_STATIC(sizeof(scsi_sense_fixed_resp_t) == 18, "size is not correct");
typedef struct ATTR_PACKED
{
@ -277,7 +277,7 @@ typedef struct ATTR_PACKED
uint8_t control;
} scsi_mode_sense6_t;
VERIFY_STATIC( sizeof(scsi_mode_sense6_t) == 6, "size is not correct");
TU_VERIFY_STATIC( sizeof(scsi_mode_sense6_t) == 6, "size is not correct");
typedef struct ATTR_PACKED
{
@ -287,7 +287,7 @@ typedef struct ATTR_PACKED
uint8_t block_descriptor_len;
} scsi_mode_sense6_resp_t;
VERIFY_STATIC( sizeof(scsi_mode_sense6_resp_t) == 4, "size is not correct");
TU_VERIFY_STATIC( sizeof(scsi_mode_sense6_resp_t) == 4, "size is not correct");
typedef struct ATTR_PACKED
{
@ -297,7 +297,7 @@ typedef struct ATTR_PACKED
uint8_t control;
} scsi_prevent_allow_medium_removal_t;
VERIFY_STATIC( sizeof(scsi_prevent_allow_medium_removal_t) == 6, "size is not correct");
TU_VERIFY_STATIC( sizeof(scsi_prevent_allow_medium_removal_t) == 6, "size is not correct");
typedef struct ATTR_PACKED
{
@ -320,7 +320,7 @@ typedef struct ATTR_PACKED
uint8_t control;
} scsi_start_stop_unit_t;
VERIFY_STATIC( sizeof(scsi_start_stop_unit_t) == 6, "size is not correct");
TU_VERIFY_STATIC( sizeof(scsi_start_stop_unit_t) == 6, "size is not correct");
//--------------------------------------------------------------------+
// SCSI MMC
@ -334,7 +334,7 @@ typedef struct ATTR_PACKED
uint8_t control;
} scsi_read_format_capacity_t;
VERIFY_STATIC( sizeof(scsi_read_format_capacity_t) == 10, "size is not correct");
TU_VERIFY_STATIC( sizeof(scsi_read_format_capacity_t) == 10, "size is not correct");
typedef struct ATTR_PACKED{
uint8_t reserved[3];
@ -348,7 +348,7 @@ typedef struct ATTR_PACKED{
} scsi_read_format_capacity_data_t;
VERIFY_STATIC( sizeof(scsi_read_format_capacity_data_t) == 12, "size is not correct");
TU_VERIFY_STATIC( sizeof(scsi_read_format_capacity_data_t) == 12, "size is not correct");
//--------------------------------------------------------------------+
// SCSI Block Command (SBC-3)
@ -366,7 +366,7 @@ typedef struct ATTR_PACKED
uint8_t control ;
} scsi_read_capacity10_t;
VERIFY_STATIC(sizeof(scsi_read_capacity10_t) == 10, "size is not correct");
TU_VERIFY_STATIC(sizeof(scsi_read_capacity10_t) == 10, "size is not correct");
/// SCSI Read Capacity 10 Response Data
typedef struct {
@ -374,7 +374,7 @@ typedef struct {
uint32_t block_size ; ///< Block size in bytes
} scsi_read_capacity10_resp_t;
VERIFY_STATIC(sizeof(scsi_read_capacity10_resp_t) == 8, "size is not correct");
TU_VERIFY_STATIC(sizeof(scsi_read_capacity10_resp_t) == 8, "size is not correct");
/// SCSI Read 10 Command
typedef struct ATTR_PACKED
@ -387,8 +387,8 @@ typedef struct ATTR_PACKED
uint8_t control ;
} scsi_read10_t, scsi_write10_t;
VERIFY_STATIC(sizeof(scsi_read10_t) == 10, "size is not correct");
VERIFY_STATIC(sizeof(scsi_write10_t) == 10, "size is not correct");
TU_VERIFY_STATIC(sizeof(scsi_read10_t) == 10, "size is not correct");
TU_VERIFY_STATIC(sizeof(scsi_write10_t) == 10, "size is not correct");
#ifdef __cplusplus
}

View File

@ -152,7 +152,7 @@ void mscd_reset(uint8_t rhport)
tusb_error_t mscd_open(uint8_t rhport, tusb_desc_interface_t const * p_desc_itf, uint16_t *p_len)
{
// only support SCSI's BOT protocol
VERIFY( ( MSC_SUBCLASS_SCSI == p_desc_itf->bInterfaceSubClass &&
TU_VERIFY( ( MSC_SUBCLASS_SCSI == p_desc_itf->bInterfaceSubClass &&
MSC_PROTOCOL_BOT == p_desc_itf->bInterfaceProtocol ), TUSB_ERROR_MSC_UNSUPPORTED_PROTOCOL );
mscd_interface_t * p_msc = &_mscd_itf;

View File

@ -47,7 +47,7 @@
//--------------------------------------------------------------------+
// Class Driver Configuration
//--------------------------------------------------------------------+
VERIFY_STATIC(CFG_TUD_MSC_BUFSIZE < UINT16_MAX, "Size is not correct");
TU_VERIFY_STATIC(CFG_TUD_MSC_BUFSIZE < UINT16_MAX, "Size is not correct");
#ifndef CFG_TUD_MSC_MAXLUN
#define CFG_TUD_MSC_MAXLUN 1

View File

@ -56,12 +56,12 @@
#endif
//--------------------------------------------------------------------+
// Compile-time Assert (use VERIFY_STATIC to avoid name conflict)
// Compile-time Assert (use TU_VERIFY_STATIC to avoid name conflict)
//--------------------------------------------------------------------+
#if defined(__ICCARM__) || (__STDC_VERSION__ >= 201112L )
#define VERIFY_STATIC static_assert
#define TU_VERIFY_STATIC static_assert
#else
#define VERIFY_STATIC(const_expr, _mess) enum { XSTRING_CONCAT_(_verify_static_, _TU_COUNTER_) = 1/(!!(const_expr)) }
#define TU_VERIFY_STATIC(const_expr, _mess) enum { XSTRING_CONCAT_(_verify_static_, _TU_COUNTER_) = 1/(!!(const_expr)) }
#endif
// allow debugger to watch any module-wide variables anywhere

View File

@ -369,7 +369,7 @@ typedef struct ATTR_PACKED{
uint16_t wLength;
} tusb_control_request_t;
VERIFY_STATIC( sizeof(tusb_control_request_t) == 8, "mostly compiler option issue");
TU_VERIFY_STATIC( sizeof(tusb_control_request_t) == 8, "mostly compiler option issue");
// TODO move to somewhere suitable
static inline uint8_t bm_request_type(uint8_t direction, uint8_t type, uint8_t recipient)

View File

@ -50,8 +50,8 @@
*
* e.g
*
* - VERIFY( cond ) will return false if cond is false
* - VERIFY( cond, err) will return err instead if cond is false
* - TU_VERIFY( cond ) will return false if cond is false
* - TU_VERIFY( cond, err) will return err instead if cond is false
*------------------------------------------------------------------*/
#ifdef __cplusplus
@ -60,7 +60,7 @@
//--------------------------------------------------------------------+
// VERIFY Helper
// TU_VERIFY Helper
//--------------------------------------------------------------------+
#if CFG_TUSB_DEBUG >= 1
#include <stdio.h>
@ -88,21 +88,21 @@
/* Macro Generator
*------------------------------------------------------------------*/
// Helper to implement optional parameter for VERIFY Macro family
// Helper to implement optional parameter for TU_VERIFY Macro family
#define GET_3RD_ARG(arg1, arg2, arg3, ...) arg3
#define GET_4TH_ARG(arg1, arg2, arg3, arg4, ...) arg4
/*------------- Generator for VERIFY and VERIFY_HDLR -------------*/
#define VERIFY_DEFINE(_cond, _handler, _ret) do { if ( !(_cond) ) { _handler; return _ret; } } while(0)
/*------------- Generator for TU_VERIFY and TU_VERIFY_HDLR -------------*/
#define TU_VERIFY_DEFINE(_cond, _handler, _ret) do { if ( !(_cond) ) { _handler; return _ret; } } while(0)
/*------------- Generator for VERIFY_ERR and VERIFY_ERR_HDLR -------------*/
#define VERIFY_ERR_DEF2(_error, _handler) \
/*------------- Generator for TU_VERIFY_ERR and TU_VERIFY_ERR_HDLR -------------*/
#define TU_VERIFY_ERR_DEF2(_error, _handler) \
do { \
uint32_t _err = (uint32_t)(_error); \
if ( 0 != _err ) { _MESS_ERR(_err); _handler; return _err; }\
} while(0)
#define VERIFY_ERR_DEF3(_error, _handler, _ret) \
#define TU_VERIFY_ERR_DEF3(_error, _handler, _ret) \
do { \
uint32_t _err = (uint32_t)(_error); \
if ( 0 != _err ) { _MESS_ERR(_err); _handler; return _ret; }\
@ -112,66 +112,66 @@
/*------------------------------------------------------------------*/
/* VERIFY
* - VERIFY_1ARGS : return false if failed
* - VERIFY_2ARGS : return provided value if failed
/* TU_VERIFY
* - TU_VERIFY_1ARGS : return false if failed
* - TU_VERIFY_2ARGS : return provided value if failed
*------------------------------------------------------------------*/
#define VERIFY_1ARGS(_cond) VERIFY_DEFINE(_cond, , false)
#define VERIFY_2ARGS(_cond, _ret) VERIFY_DEFINE(_cond, , _ret)
#define TU_VERIFY_1ARGS(_cond) TU_VERIFY_DEFINE(_cond, , false)
#define TU_VERIFY_2ARGS(_cond, _ret) TU_VERIFY_DEFINE(_cond, , _ret)
#define VERIFY(...) GET_3RD_ARG(__VA_ARGS__, VERIFY_2ARGS, VERIFY_1ARGS)(__VA_ARGS__)
#define TU_VERIFY(...) GET_3RD_ARG(__VA_ARGS__, TU_VERIFY_2ARGS, TU_VERIFY_1ARGS)(__VA_ARGS__)
/*------------------------------------------------------------------*/
/* VERIFY WITH HANDLER
* - VERIFY_HDLR_2ARGS : execute handler, return false if failed
* - VERIFY_HDLR_3ARGS : execute handler, return provided error if failed
/* TU_VERIFY WITH HANDLER
* - TU_VERIFY_HDLR_2ARGS : execute handler, return false if failed
* - TU_VERIFY_HDLR_3ARGS : execute handler, return provided error if failed
*------------------------------------------------------------------*/
#define VERIFY_HDLR_2ARGS(_cond, _handler) VERIFY_DEFINE(_cond, _handler, false)
#define VERIFY_HDLR_3ARGS(_cond, _handler, _ret) VERIFY_DEFINE(_cond, _handler, _ret)
#define TU_VERIFY_HDLR_2ARGS(_cond, _handler) TU_VERIFY_DEFINE(_cond, _handler, false)
#define TU_VERIFY_HDLR_3ARGS(_cond, _handler, _ret) TU_VERIFY_DEFINE(_cond, _handler, _ret)
#define VERIFY_HDLR(...) GET_4TH_ARG(__VA_ARGS__, VERIFY_HDLR_3ARGS, VERIFY_HDLR_2ARGS)(__VA_ARGS__)
#define TU_VERIFY_HDLR(...) GET_4TH_ARG(__VA_ARGS__, TU_VERIFY_HDLR_3ARGS, TU_VERIFY_HDLR_2ARGS)(__VA_ARGS__)
/*------------------------------------------------------------------*/
/* VERIFY STATUS
* - VERIFY_ERR_1ARGS : return status of condition if failed
* - VERIFY_ERR_2ARGS : return provided status code if failed
/* TU_VERIFY STATUS
* - TU_VERIFY_ERR_1ARGS : return status of condition if failed
* - TU_VERIFY_ERR_2ARGS : return provided status code if failed
*------------------------------------------------------------------*/
#define VERIFY_ERR_1ARGS(_error) VERIFY_ERR_DEF2(_error, )
#define VERIFY_ERR_2ARGS(_error, _ret) VERIFY_ERR_DEF3(_error, ,_ret)
#define TU_VERIFY_ERR_1ARGS(_error) TU_VERIFY_ERR_DEF2(_error, )
#define TU_VERIFY_ERR_2ARGS(_error, _ret) TU_VERIFY_ERR_DEF3(_error, ,_ret)
#define VERIFY_ERR(...) GET_3RD_ARG(__VA_ARGS__, VERIFY_ERR_2ARGS, VERIFY_ERR_1ARGS)(__VA_ARGS__)
#define TU_VERIFY_ERR(...) GET_3RD_ARG(__VA_ARGS__, TU_VERIFY_ERR_2ARGS, TU_VERIFY_ERR_1ARGS)(__VA_ARGS__)
/*------------------------------------------------------------------*/
/* VERIFY STATUS WITH HANDLER
* - VERIFY_ERR_HDLR_2ARGS : execute handler, return status if failed
* - VERIFY_ERR_HDLR_3ARGS : execute handler, return provided error if failed
/* TU_VERIFY STATUS WITH HANDLER
* - TU_VERIFY_ERR_HDLR_2ARGS : execute handler, return status if failed
* - TU_VERIFY_ERR_HDLR_3ARGS : execute handler, return provided error if failed
*------------------------------------------------------------------*/
#define VERIFY_ERR_HDLR_2ARGS(_error, _handler) VERIFY_ERR_DEF2(_error, _handler)
#define VERIFY_ERR_HDLR_3ARGS(_error, _handler, _ret) VERIFY_ERR_DEF3(_error, _handler, _ret)
#define TU_VERIFY_ERR_HDLR_2ARGS(_error, _handler) TU_VERIFY_ERR_DEF2(_error, _handler)
#define TU_VERIFY_ERR_HDLR_3ARGS(_error, _handler, _ret) TU_VERIFY_ERR_DEF3(_error, _handler, _ret)
#define VERIFY_ERR_HDLR(...) GET_4TH_ARG(__VA_ARGS__, VERIFY_ERR_HDLR_3ARGS, VERIFY_ERR_HDLR_2ARGS)(__VA_ARGS__)
#define TU_VERIFY_ERR_HDLR(...) GET_4TH_ARG(__VA_ARGS__, TU_VERIFY_ERR_HDLR_3ARGS, TU_VERIFY_ERR_HDLR_2ARGS)(__VA_ARGS__)
/*------------------------------------------------------------------*/
/* ASSERT
* basically VERIFY with verify_breakpoint() as handler
* basically TU_VERIFY with verify_breakpoint() as handler
* - 1 arg : return false if failed
* - 2 arg : return error if failed
*------------------------------------------------------------------*/
#define ASSERT_1ARGS(_cond) VERIFY_DEFINE(_cond, _MESS_FAILED(); verify_breakpoint(), false)
#define ASSERT_2ARGS(_cond, _ret) VERIFY_DEFINE(_cond, _MESS_FAILED(); verify_breakpoint(), _ret)
#define ASSERT_1ARGS(_cond) TU_VERIFY_DEFINE(_cond, _MESS_FAILED(); verify_breakpoint(), false)
#define ASSERT_2ARGS(_cond, _ret) TU_VERIFY_DEFINE(_cond, _MESS_FAILED(); verify_breakpoint(), _ret)
#define TU_ASSERT(...) GET_3RD_ARG(__VA_ARGS__, ASSERT_2ARGS, ASSERT_1ARGS)(__VA_ARGS__)
/*------------------------------------------------------------------*/
/* ASSERT Error
* basically VERIFY Error with verify_breakpoint() as handler
* basically TU_VERIFY Error with verify_breakpoint() as handler
*------------------------------------------------------------------*/
#define ASERT_ERR_1ARGS(_error) VERIFY_ERR_DEF2(_error, verify_breakpoint())
#define ASERT_ERR_2ARGS(_error, _ret) VERIFY_ERR_DEF3(_error, verify_breakpoint(), _ret)
#define ASERT_ERR_1ARGS(_error) TU_VERIFY_ERR_DEF2(_error, verify_breakpoint())
#define ASERT_ERR_2ARGS(_error, _ret) TU_VERIFY_ERR_DEF3(_error, verify_breakpoint(), _ret)
#define TU_ASSERT_ERR(...) GET_3RD_ARG(__VA_ARGS__, ASERT_ERR_2ARGS, ASERT_ERR_1ARGS)(__VA_ARGS__)

View File

@ -189,7 +189,7 @@ typedef struct ATTR_ALIGNED(4)
};
} usbd_task_event_t;
VERIFY_STATIC(sizeof(usbd_task_event_t) <= 12, "size is not correct");
TU_VERIFY_STATIC(sizeof(usbd_task_event_t) <= 12, "size is not correct");
OSAL_TASK_DEF(_usbd_task_def, "usbd", usbd_task, CFG_TUD_TASK_PRIO, CFG_TUD_TASK_STACK_SZ);
@ -234,10 +234,10 @@ tusb_error_t usbd_init (void)
//------------- Task init -------------//
_usbd_q = osal_queue_create(&_usbd_qdef);
VERIFY(_usbd_q, TUSB_ERROR_OSAL_QUEUE_FAILED);
TU_VERIFY(_usbd_q, TUSB_ERROR_OSAL_QUEUE_FAILED);
_usbd_ctrl_sem = osal_semaphore_create(&_usbd_sem_def);
VERIFY(_usbd_q, TUSB_ERROR_OSAL_SEMAPHORE_FAILED);
TU_VERIFY(_usbd_q, TUSB_ERROR_OSAL_SEMAPHORE_FAILED);
osal_task_create(&_usbd_task_def);
@ -507,7 +507,7 @@ static uint16_t get_descriptor(uint8_t rhport, tusb_control_request_t const * co
if ( desc_index < tud_desc_set.string_count )
{
desc_data = tud_desc_set.string_arr[desc_index];
VERIFY( desc_data != NULL, 0 );
TU_VERIFY( desc_data != NULL, 0 );
len = desc_data[0]; // first byte of descriptor is its size
}else

View File

@ -64,7 +64,7 @@ CFG_TUSB_ATTR_USBRAM STATIC_VAR ehci_data_t ehci_data;
CFG_TUSB_ATTR_USBRAM ATTR_ALIGNED(4096) STATIC_VAR ehci_link_t period_frame_list0[EHCI_FRAMELIST_SIZE];
#ifndef __ICCARM__ // IAR cannot able to determine the alignment with datalignment pragma
VERIFY_STATIC( ALIGN_OF(period_frame_list0) == 4096, "Period Framelist must be 4k alginment"); // validation
TU_VERIFY_STATIC( ALIGN_OF(period_frame_list0) == 4096, "Period Framelist must be 4k alginment"); // validation
#endif
#endif
@ -72,7 +72,7 @@ CFG_TUSB_ATTR_USBRAM STATIC_VAR ehci_data_t ehci_data;
CFG_TUSB_ATTR_USBRAM ATTR_ALIGNED(4096) STATIC_VAR ehci_link_t period_frame_list1[EHCI_FRAMELIST_SIZE];
#ifndef __ICCARM__ // IAR cannot able to determine the alignment with datalignment pragma
VERIFY_STATIC( ALIGN_OF(period_frame_list1) == 4096, "Period Framelist must be 4k alginment"); // validation
TU_VERIFY_STATIC( ALIGN_OF(period_frame_list1) == 4096, "Period Framelist must be 4k alginment"); // validation
#endif
#endif
#endif

View File

@ -81,7 +81,7 @@ enum {
};
//------------- Validation -------------//
VERIFY_STATIC(EHCI_CFG_FRAMELIST_SIZE_BITS <= 7, "incorrect value");
TU_VERIFY_STATIC(EHCI_CFG_FRAMELIST_SIZE_BITS <= 7, "incorrect value");
//--------------------------------------------------------------------+
// EHCI Data Structure
@ -150,7 +150,7 @@ typedef struct {
uint32_t buffer[5];
} ehci_qtd_t; // XXX qtd is used to declare overlay in ehci_qhd_t -> cannot be declared with ATTR_ALIGNED(32)
VERIFY_STATIC( sizeof(ehci_qtd_t) == 32, "size is not correct" );
TU_VERIFY_STATIC( sizeof(ehci_qtd_t) == 32, "size is not correct" );
/// Queue Head (section 3.6)
typedef struct ATTR_ALIGNED(32) {
@ -202,7 +202,7 @@ typedef struct ATTR_ALIGNED(32) {
ehci_qtd_t * volatile p_qtd_list_tail; // tail of the scheduled TD list
} ehci_qhd_t;
VERIFY_STATIC( sizeof(ehci_qhd_t) == 64, "size is not correct" );
TU_VERIFY_STATIC( sizeof(ehci_qhd_t) == 64, "size is not correct" );
/// Highspeed Isochronous Transfer Descriptor (section 3.3)
typedef struct ATTR_ALIGNED(32) {
@ -234,7 +234,7 @@ typedef struct ATTR_ALIGNED(32) {
// uint32_t reserved[6];
} ehci_itd_t;
VERIFY_STATIC( sizeof(ehci_itd_t) == 64, "size is not correct" );
TU_VERIFY_STATIC( sizeof(ehci_itd_t) == 64, "size is not correct" );
/// Split (Full-Speed) Isochronous Transfer Descriptor
typedef struct ATTR_ALIGNED(32) {
@ -298,7 +298,7 @@ typedef struct ATTR_ALIGNED(32) {
uint8_t reserved2[2];
} ehci_sitd_t;
VERIFY_STATIC( sizeof(ehci_sitd_t) == 32, "size is not correct" );
TU_VERIFY_STATIC( sizeof(ehci_sitd_t) == 32, "size is not correct" );
//--------------------------------------------------------------------+
// EHCI Operational Register

View File

@ -104,7 +104,7 @@ typedef struct ATTR_PACKED{
uint8_t PortPwrCtrlMask; // just for compatibility, should be 0xff
} descriptor_hub_desc_t;
VERIFY_STATIC( sizeof(descriptor_hub_desc_t) == 9, "size is not correct");
TU_VERIFY_STATIC( sizeof(descriptor_hub_desc_t) == 9, "size is not correct");
enum {
HUB_REQUEST_GET_STATUS = 0 ,
@ -157,7 +157,7 @@ typedef struct {
} status, status_change;
} hub_status_response_t;
VERIFY_STATIC( sizeof(hub_status_response_t) == 4, "size is not correct");
TU_VERIFY_STATIC( sizeof(hub_status_response_t) == 4, "size is not correct");
// data in response of HUB_REQUEST_GET_STATUS, wIndex = Port num
typedef struct {
@ -182,7 +182,7 @@ typedef struct {
} status_current, status_change;
} hub_port_status_response_t;
VERIFY_STATIC( sizeof(hub_port_status_response_t) == 4, "size is not correct");
TU_VERIFY_STATIC( sizeof(hub_port_status_response_t) == 4, "size is not correct");
tusb_error_t hub_port_reset_subtask(uint8_t hub_addr, uint8_t hub_port);
tusb_error_t hub_port_clear_feature_subtask(uint8_t hub_addr, uint8_t hub_port, uint8_t feature);

View File

@ -79,7 +79,7 @@ typedef struct {
uint8_t reserved[116+4]; // TODO try to make use of this area if possible, extra 4 byte to make the whole struct size = 256
}ohci_hcca_t; // ATTR_ALIGNED(256)
VERIFY_STATIC( sizeof(ohci_hcca_t) == 256, "size is not correct" );
TU_VERIFY_STATIC( sizeof(ohci_hcca_t) == 256, "size is not correct" );
typedef struct {
uint32_t reserved[2];
@ -112,7 +112,7 @@ typedef struct ATTR_ALIGNED(16) {
uint8_t* buffer_end;
} ohci_gtd_t;
VERIFY_STATIC( sizeof(ohci_gtd_t) == 16, "size is not correct" );
TU_VERIFY_STATIC( sizeof(ohci_gtd_t) == 16, "size is not correct" );
typedef struct ATTR_ALIGNED(16) {
//------------- Word 0 -------------//
@ -153,7 +153,7 @@ typedef struct ATTR_ALIGNED(16) {
uint32_t next_ed; // 4 lsb bits are free to use
} ohci_ed_t;
VERIFY_STATIC( sizeof(ohci_ed_t) == 16, "size is not correct" );
TU_VERIFY_STATIC( sizeof(ohci_ed_t) == 16, "size is not correct" );
typedef struct ATTR_ALIGNED(32) {
/*---------- Word 1 ----------*/
@ -178,7 +178,7 @@ typedef struct ATTR_ALIGNED(32) {
volatile uint16_t offset_packetstatus[8];
} ochi_itd_t;
VERIFY_STATIC( sizeof(ochi_itd_t) == 32, "size is not correct" );
TU_VERIFY_STATIC( sizeof(ochi_itd_t) == 32, "size is not correct" );
// structure with member alignment required from large to small
typedef struct ATTR_ALIGNED(256) {
@ -298,7 +298,7 @@ typedef volatile struct
};
}ohci_registers_t;
VERIFY_STATIC( sizeof(ohci_registers_t) == 0x5c, "size is not correct");
TU_VERIFY_STATIC( sizeof(ohci_registers_t) == 0x5c, "size is not correct");
#ifdef __cplusplus
}

View File

@ -81,11 +81,11 @@ typedef void (*osal_task_func_t)( void * );
#define STASK_INVOKE(_subtask, _status) (_status) = _subtask
//------------- Sub Task Assert -------------//
#define STASK_ASSERT_ERR(_err) VERIFY_ERR(_err)
#define STASK_ASSERT_ERR_HDLR(_err, _func) VERIFY_ERR_HDLR(_err, _func)
#define STASK_ASSERT_ERR(_err) TU_VERIFY_ERR(_err)
#define STASK_ASSERT_ERR_HDLR(_err, _func) TU_VERIFY_ERR_HDLR(_err, _func)
#define STASK_ASSERT(_cond) VERIFY(_cond, TUSB_ERROR_OSAL_TASK_FAILED)
#define STASK_ASSERT_HDLR(_cond, _func) VERIFY_HDLR(_cond, _func)
#define STASK_ASSERT(_cond) TU_VERIFY(_cond, TUSB_ERROR_OSAL_TASK_FAILED)
#define STASK_ASSERT_HDLR(_cond, _func) TU_VERIFY_HDLR(_cond, _func)
#endif
#ifdef __cplusplus

View File

@ -121,11 +121,11 @@ static inline osal_task_t osal_task_create(osal_task_def_t* taskdef)
//------------- Sub Task Assert -------------//
#define STASK_RETURN(error) do { TASK_RESTART; return error; } while(0)
#define STASK_ASSERT_ERR(_err) VERIFY_ERR_HDLR(_err, verify_breakpoint(); TASK_RESTART, TUSB_ERROR_FAILED)
#define STASK_ASSERT_ERR_HDLR(_err, _func) VERIFY_ERR_HDLR(_err, verify_breakpoint(); _func; TASK_RESTART, TUSB_ERROR_FAILED )
#define STASK_ASSERT_ERR(_err) TU_VERIFY_ERR_HDLR(_err, verify_breakpoint(); TASK_RESTART, TUSB_ERROR_FAILED)
#define STASK_ASSERT_ERR_HDLR(_err, _func) TU_VERIFY_ERR_HDLR(_err, verify_breakpoint(); _func; TASK_RESTART, TUSB_ERROR_FAILED )
#define STASK_ASSERT(_cond) VERIFY_HDLR(_cond, verify_breakpoint(); TASK_RESTART, TUSB_ERROR_FAILED)
#define STASK_ASSERT_HDLR(_cond, _func) VERIFY_HDLR(_cond, verify_breakpoint(); _func; TASK_RESTART, TUSB_ERROR_FAILED)
#define STASK_ASSERT(_cond) TU_VERIFY_HDLR(_cond, verify_breakpoint(); TASK_RESTART, TUSB_ERROR_FAILED)
#define STASK_ASSERT_HDLR(_cond, _func) TU_VERIFY_HDLR(_cond, verify_breakpoint(); _func; TASK_RESTART, TUSB_ERROR_FAILED)
//--------------------------------------------------------------------+
// QUEUE API

View File

@ -104,7 +104,7 @@ typedef struct ATTR_PACKED
volatile uint16_t active : 1 ; ///< The buffer is enabled. HW can use the buffer to store received OUT data or to transmit data on the IN endpoint. Software can only set this bit to 1. As long as this bit is set to one, software is not allowed to update any of the values in this 32-bit word. In case software wants to deactivate the buffer, it must write a one to the corresponding “skip” bit in the USB Endpoint skip register. Hardware can only write this bit to zero. It will do this when it receives a short packet or when the NBytes field transitions to zero or when software has written a one to the “skip” bit.
}dcd_11u_13u_qhd_t;
VERIFY_STATIC( sizeof(dcd_11u_13u_qhd_t) == 4, "size is not correct" );
TU_VERIFY_STATIC( sizeof(dcd_11u_13u_qhd_t) == 4, "size is not correct" );
// NOTE data will be transferred as soon as dcd get request by dcd_pipe(_queue)_xfer using double buffering.
// If there is another dcd_edpt_xfer request, the new request will be saved and executed when the first is done.

View File

@ -384,7 +384,7 @@ bool dcd_control_xfer(uint8_t rhport, tusb_dir_t dir, uint8_t * p_buffer, uint16
{
(void) rhport;
VERIFY( !(length != 0 && p_buffer == NULL) );
TU_VERIFY( !(length != 0 && p_buffer == NULL) );
// determine Endpoint where Data & Status phase occurred (IN or OUT)
uint8_t const ep_data = (dir == TUSB_DIR_IN) ? 1 : 0;
@ -399,13 +399,13 @@ bool dcd_control_xfer(uint8_t rhport, tusb_dir_t dir, uint8_t * p_buffer, uint16
dcd_data.control_dma.remaining_bytes = length;
// lpc17xx already received the first DATA OUT packet by now
VERIFY_ERR ( pipe_control_xfer(ep_data, p_buffer, length), false );
TU_VERIFY_ERR ( pipe_control_xfer(ep_data, p_buffer, length), false );
}
//------------- Status Phase (opposite direct to Data) -------------//
if (dir == TUSB_DIR_OUT)
{ // only write for CONTROL OUT, CONTROL IN data will be retrieved in hal_dcd_isr // TODO ????
VERIFY_ERR ( pipe_control_write(NULL, 0), false );
TU_VERIFY_ERR ( pipe_control_write(NULL, 0), false );
}
return true;

View File

@ -80,7 +80,7 @@ typedef struct ATTR_ALIGNED(4)
// uint32_t iso_packet_size_addr; // iso only, can be omitted for non-iso
}dcd_dma_descriptor_t;
VERIFY_STATIC( sizeof(dcd_dma_descriptor_t) == 16, "size is not correct"); // TODO not support ISO for now
TU_VERIFY_STATIC( sizeof(dcd_dma_descriptor_t) == 16, "size is not correct"); // TODO not support ISO for now
//--------------------------------------------------------------------+

View File

@ -244,7 +244,7 @@ bool dcd_control_xfer(uint8_t rhport, tusb_dir_t dir, uint8_t * p_buffer, uint16
// wait until ENDPTSETUPSTAT before priming data/status in response TODO add time out
while(lpc_usb->ENDPTSETUPSTAT & BIT_(0)) {}
VERIFY( !qhd->qtd_overlay.active );
TU_VERIFY( !qhd->qtd_overlay.active );
dcd_qtd_t* qtd = &p_dcd->qtd[0];
qtd_init(qtd, p_buffer, length);
@ -295,7 +295,7 @@ bool dcd_edpt_open(uint8_t rhport, tusb_desc_endpoint_t const * p_endpoint_desc)
{
// TODO USB1 only has 4 non-control enpoint (USB0 has 5)
// TODO not support ISO yet
VERIFY ( p_endpoint_desc->bmAttributes.xfer != TUSB_XFER_ISOCHRONOUS);
TU_VERIFY ( p_endpoint_desc->bmAttributes.xfer != TUSB_XFER_ISOCHRONOUS);
tusb_dir_t dir = (p_endpoint_desc->bEndpointAddress & TUSB_DIR_IN_MASK) ? TUSB_DIR_IN : TUSB_DIR_OUT;
@ -313,7 +313,7 @@ bool dcd_edpt_open(uint8_t rhport, tusb_desc_endpoint_t const * p_endpoint_desc)
volatile uint32_t * reg_control = get_reg_control_addr(rhport, ep_idx);
// endpoint must not be already enabled
VERIFY( !( (*reg_control) & (ENDPTCTRL_MASK_ENABLE << (dir ? 16 : 0)) ) );
TU_VERIFY( !( (*reg_control) & (ENDPTCTRL_MASK_ENABLE << (dir ? 16 : 0)) ) );
(*reg_control) |= ((p_endpoint_desc->bmAttributes.xfer << 2) | ENDPTCTRL_MASK_ENABLE | ENDPTCTRL_MASK_TOGGLE_RESET) << (dir ? 16 : 0);
@ -363,7 +363,7 @@ bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t
{
uint8_t ep_idx = edpt_addr2phy(ep_addr);
VERIFY ( pipe_add_xfer(rhport, ep_idx, buffer, total_bytes, true) );
TU_VERIFY ( pipe_add_xfer(rhport, ep_idx, buffer, total_bytes, true) );
dcd_qhd_t* p_qhd = &dcd_data_ptr[rhport]->qhd[ ep_idx ];
dcd_qtd_t* p_qtd = &dcd_data_ptr[rhport]->qtd[ p_qhd->list_qtd_idx[0] ];

View File

@ -122,7 +122,7 @@ typedef struct
uint8_t reserved;
} dcd_qtd_t;
VERIFY_STATIC( sizeof(dcd_qtd_t) == 32, "size is not correct");
TU_VERIFY_STATIC( sizeof(dcd_qtd_t) == 32, "size is not correct");
typedef struct
{
@ -153,7 +153,7 @@ typedef struct
uint8_t reserved[16-DCD_QTD_PER_QHD_MAX];
} dcd_qhd_t;
VERIFY_STATIC( sizeof(dcd_qhd_t) == 64, "size is not correct");
TU_VERIFY_STATIC( sizeof(dcd_qhd_t) == 64, "size is not correct");
#ifdef __cplusplus

View File

@ -86,7 +86,7 @@ bool tusb_hal_init(void)
//------------- USB0 -------------//
#if CFG_TUSB_RHPORT0_MODE
CGU_EnableEntity(CGU_CLKSRC_PLL0, DISABLE); /* Disable PLL first */
VERIFY( CGU_ERROR_SUCCESS == CGU_SetPLL0()); /* the usb core require output clock = 480MHz */
TU_VERIFY( CGU_ERROR_SUCCESS == CGU_SetPLL0()); /* the usb core require output clock = 480MHz */
CGU_EntityConnect(CGU_CLKSRC_XTAL_OSC, CGU_CLKSRC_PLL0);
CGU_EnableEntity(CGU_CLKSRC_PLL0, ENABLE); /* Enable PLL after all setting is done */

View File

@ -49,7 +49,7 @@ tusb_error_t tusb_init(void)
// skip if already initialized
if (_initialized) return TUSB_ERROR_NONE;
VERIFY( tusb_hal_init(), TUSB_ERROR_FAILED ) ; // hardware init
TU_VERIFY( tusb_hal_init(), TUSB_ERROR_FAILED ) ; // hardware init
#if MODE_HOST_SUPPORTED
TU_ASSERT_ERR( usbh_init() ); // host stack init