mirror of
https://github.com/hathach/tinyusb.git
synced 2025-03-29 19:20:22 +00:00
rename ASSERT_STATUS to ASSERT_ERR, merge assertion.h to verify.h
This commit is contained in:
parent
0a162a7d28
commit
d88ae5cc16
@ -73,7 +73,7 @@ static tusb_error_t cush_validate_paras(uint8_t dev_addr, uint16_t vendor_id, ui
|
||||
//--------------------------------------------------------------------+
|
||||
tusb_error_t tusbh_custom_read(uint8_t dev_addr, uint16_t vendor_id, uint16_t product_id, void * p_buffer, uint16_t length)
|
||||
{
|
||||
ASSERT_STATUS( cush_validate_paras(dev_addr, vendor_id, product_id, p_buffer, length) );
|
||||
ASSERT_ERR( cush_validate_paras(dev_addr, vendor_id, product_id, p_buffer, length) );
|
||||
|
||||
if ( !hcd_pipe_is_idle(custom_interface[dev_addr-1].pipe_in) )
|
||||
{
|
||||
@ -87,7 +87,7 @@ tusb_error_t tusbh_custom_read(uint8_t dev_addr, uint16_t vendor_id, uint16_t pr
|
||||
|
||||
tusb_error_t tusbh_custom_write(uint8_t dev_addr, uint16_t vendor_id, uint16_t product_id, void const * p_data, uint16_t length)
|
||||
{
|
||||
ASSERT_STATUS( cush_validate_paras(dev_addr, vendor_id, product_id, p_data, length) );
|
||||
ASSERT_ERR( cush_validate_paras(dev_addr, vendor_id, product_id, p_data, length) );
|
||||
|
||||
if ( !hcd_pipe_is_idle(custom_interface[dev_addr-1].pipe_out) )
|
||||
{
|
||||
|
@ -80,7 +80,7 @@ tusb_error_t hidh_interface_get_report(uint8_t dev_addr, void * report, hidh_int
|
||||
VERIFY (report, TUSB_ERROR_INVALID_PARA);
|
||||
TU_ASSSERT (!hcd_pipe_is_busy(p_hid->pipe_hdl), TUSB_ERROR_INTERFACE_IS_BUSY);
|
||||
|
||||
ASSERT_STATUS( hcd_pipe_xfer(p_hid->pipe_hdl, report, p_hid->report_size, true) ) ;
|
||||
ASSERT_ERR( hcd_pipe_xfer(p_hid->pipe_hdl, report, p_hid->report_size, true) ) ;
|
||||
|
||||
return TUSB_ERROR_NONE;
|
||||
}
|
||||
|
@ -116,16 +116,16 @@ static tusb_error_t msch_command_xfer(msch_interface_t * p_msch, void* p_buffer)
|
||||
{ // there is data phase
|
||||
if (p_msch->cbw.dir & TUSB_DIR_IN_MASK)
|
||||
{
|
||||
ASSERT_STATUS( hcd_pipe_xfer(p_msch->bulk_out, (uint8_t*) &p_msch->cbw, sizeof(msc_cbw_t), false) );
|
||||
ASSERT_STATUS( hcd_pipe_queue_xfer(p_msch->bulk_in , p_buffer, p_msch->cbw.xfer_bytes) );
|
||||
ASSERT_ERR( hcd_pipe_xfer(p_msch->bulk_out, (uint8_t*) &p_msch->cbw, sizeof(msc_cbw_t), false) );
|
||||
ASSERT_ERR( hcd_pipe_queue_xfer(p_msch->bulk_in , p_buffer, p_msch->cbw.xfer_bytes) );
|
||||
}else
|
||||
{
|
||||
ASSERT_STATUS( hcd_pipe_queue_xfer(p_msch->bulk_out, (uint8_t*) &p_msch->cbw, sizeof(msc_cbw_t)) );
|
||||
ASSERT_STATUS( hcd_pipe_xfer(p_msch->bulk_out , p_buffer, p_msch->cbw.xfer_bytes, false) );
|
||||
ASSERT_ERR( hcd_pipe_queue_xfer(p_msch->bulk_out, (uint8_t*) &p_msch->cbw, sizeof(msc_cbw_t)) );
|
||||
ASSERT_ERR( hcd_pipe_xfer(p_msch->bulk_out , p_buffer, p_msch->cbw.xfer_bytes, false) );
|
||||
}
|
||||
}
|
||||
|
||||
ASSERT_STATUS( hcd_pipe_xfer(p_msch->bulk_in , (uint8_t*) &p_msch->csw, sizeof(msc_csw_t), true) );
|
||||
ASSERT_ERR( hcd_pipe_xfer(p_msch->bulk_in , (uint8_t*) &p_msch->csw, sizeof(msc_csw_t), true) );
|
||||
|
||||
return TUSB_ERROR_NONE;
|
||||
}
|
||||
@ -149,7 +149,7 @@ tusb_error_t tusbh_msc_inquiry(uint8_t dev_addr, uint8_t lun, uint8_t *p_data)
|
||||
|
||||
memcpy(p_msch->cbw.command, &cmd_inquiry, p_msch->cbw.cmd_len);
|
||||
|
||||
ASSERT_STATUS ( msch_command_xfer(p_msch, p_data) );
|
||||
ASSERT_ERR ( msch_command_xfer(p_msch, p_data) );
|
||||
|
||||
return TUSB_ERROR_NONE;
|
||||
}
|
||||
@ -174,7 +174,7 @@ tusb_error_t tusbh_msc_read_capacity10(uint8_t dev_addr, uint8_t lun, uint8_t *p
|
||||
|
||||
memcpy(p_msch->cbw.command, &cmd_read_capacity10, p_msch->cbw.cmd_len);
|
||||
|
||||
ASSERT_STATUS ( msch_command_xfer(p_msch, p_data) );
|
||||
ASSERT_ERR ( msch_command_xfer(p_msch, p_data) );
|
||||
|
||||
return TUSB_ERROR_NONE;
|
||||
}
|
||||
@ -199,7 +199,7 @@ tusb_error_t tuh_msc_request_sense(uint8_t dev_addr, uint8_t lun, uint8_t *p_dat
|
||||
|
||||
memcpy(p_msch->cbw.command, &cmd_request_sense, p_msch->cbw.cmd_len);
|
||||
|
||||
ASSERT_STATUS ( msch_command_xfer(p_msch, p_data) );
|
||||
ASSERT_ERR ( msch_command_xfer(p_msch, p_data) );
|
||||
|
||||
return TUSB_ERROR_NONE;
|
||||
}
|
||||
@ -225,8 +225,8 @@ tusb_error_t tuh_msc_test_unit_ready(uint8_t dev_addr, uint8_t lun, msc_csw_t *
|
||||
memcpy(p_msch->cbw.command, &cmd_test_unit_ready, p_msch->cbw.cmd_len);
|
||||
|
||||
// TODO MSCH refractor test uinit ready
|
||||
ASSERT_STATUS( hcd_pipe_xfer(p_msch->bulk_out, (uint8_t*) &p_msch->cbw, sizeof(msc_cbw_t), false) );
|
||||
ASSERT_STATUS( hcd_pipe_xfer(p_msch->bulk_in , (uint8_t*) p_csw, sizeof(msc_csw_t), true) );
|
||||
ASSERT_ERR( hcd_pipe_xfer(p_msch->bulk_out, (uint8_t*) &p_msch->cbw, sizeof(msc_cbw_t), false) );
|
||||
ASSERT_ERR( hcd_pipe_xfer(p_msch->bulk_in , (uint8_t*) p_csw, sizeof(msc_csw_t), true) );
|
||||
|
||||
return TUSB_ERROR_NONE;
|
||||
}
|
||||
@ -252,7 +252,7 @@ tusb_error_t tuh_msc_read10(uint8_t dev_addr, uint8_t lun, void * p_buffer, uin
|
||||
|
||||
memcpy(p_msch->cbw.command, &cmd_read10, p_msch->cbw.cmd_len);
|
||||
|
||||
ASSERT_STATUS ( msch_command_xfer(p_msch, p_buffer));
|
||||
ASSERT_ERR ( msch_command_xfer(p_msch, p_buffer));
|
||||
|
||||
return TUSB_ERROR_NONE;
|
||||
}
|
||||
@ -278,7 +278,7 @@ tusb_error_t tuh_msc_write10(uint8_t dev_addr, uint8_t lun, void const * p_buffe
|
||||
|
||||
memcpy(p_msch->cbw.command, &cmd_write10, p_msch->cbw.cmd_len);
|
||||
|
||||
ASSERT_STATUS ( msch_command_xfer(p_msch, (void*) p_buffer));
|
||||
ASSERT_ERR ( msch_command_xfer(p_msch, (void*) p_buffer));
|
||||
|
||||
return TUSB_ERROR_NONE;
|
||||
}
|
||||
|
@ -1,94 +0,0 @@
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@file assertion.h
|
||||
@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.
|
||||
*/
|
||||
/**************************************************************************/
|
||||
|
||||
/** \ingroup Group_Common
|
||||
* \defgroup group_assertion Assertion
|
||||
* @{ */
|
||||
|
||||
|
||||
#ifndef _TUSB_ASSERTION_H_
|
||||
#define _TUSB_ASSERTION_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "tusb_option.h"
|
||||
#include "tusb_compiler.h"
|
||||
|
||||
#define VOID_RETURN
|
||||
|
||||
//#if ( defined CFG_PRINTF_UART || defined CFG_PRINTF_USBCDC || defined CFG_PRINTF_DEBUG )
|
||||
#if TUSB_CFG_DEBUG
|
||||
#define _PRINTF(...) printf(__VA_ARGS__)
|
||||
#else
|
||||
#define _PRINTF(...)
|
||||
#endif
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Assert Helper
|
||||
//--------------------------------------------------------------------+
|
||||
#define _ASSERT_MESSAGE(format, ...) _PRINTF("Assert at %s: %s: %d: " format "\n", __BASE_FILE__, __func__ , __LINE__, __VA_ARGS__)
|
||||
|
||||
#define ASSERT_DEFINE(setup_statement, condition, error, format, ...) \
|
||||
do{\
|
||||
setup_statement;\
|
||||
if (!(condition)) {\
|
||||
verify_breakpoint();\
|
||||
_ASSERT_MESSAGE(format, __VA_ARGS__);\
|
||||
return error; /* Throw X for Test */\
|
||||
}\
|
||||
}while(0)
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// tusb_error_t Status Assert TODO use ASSERT_DEFINE
|
||||
//--------------------------------------------------------------------+
|
||||
#define ASSERT_STATUS(sts) \
|
||||
ASSERT_DEFINE(tusb_error_t status = (tusb_error_t)(sts),\
|
||||
TUSB_ERROR_NONE == status, status, "%s", tusb_strerr[status])
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _TUSB_ASSERTION_H_ */
|
||||
|
||||
/** @} */
|
@ -63,7 +63,6 @@
|
||||
|
||||
//------------- General Header -------------//
|
||||
#include "tusb_compiler.h"
|
||||
#include "assertion.h"
|
||||
#include "verify.h"
|
||||
#include "binary.h"
|
||||
#include "tusb_error.h"
|
||||
|
@ -134,11 +134,11 @@ tusb_error_t hcd_init(void)
|
||||
memclr_(&ehci_data, sizeof(ehci_data_t));
|
||||
|
||||
#if (TUSB_CFG_CONTROLLER_0_MODE & TUSB_MODE_HOST)
|
||||
ASSERT_STATUS (hcd_controller_init(0));
|
||||
ASSERT_ERR (hcd_controller_init(0));
|
||||
#endif
|
||||
|
||||
#if (TUSB_CFG_CONTROLLER_1_MODE & TUSB_MODE_HOST)
|
||||
ASSERT_STATUS (hcd_controller_init(1));
|
||||
ASSERT_ERR (hcd_controller_init(1));
|
||||
#endif
|
||||
|
||||
return TUSB_ERROR_NONE;
|
||||
@ -347,7 +347,7 @@ tusb_error_t hcd_pipe_control_close(uint8_t dev_addr)
|
||||
|
||||
if (dev_addr != 0)
|
||||
{
|
||||
ASSERT_STATUS( list_remove_qhd( (ehci_link_t*) get_async_head( usbh_devices[dev_addr].core_id ),
|
||||
ASSERT_ERR( list_remove_qhd( (ehci_link_t*) get_async_head( usbh_devices[dev_addr].core_id ),
|
||||
(ehci_link_t*) p_qhd) );
|
||||
}
|
||||
|
||||
@ -416,7 +416,7 @@ tusb_error_t hcd_pipe_queue_xfer(pipe_handle_t pipe_hdl, uint8_t buffer[], uint
|
||||
|
||||
tusb_error_t hcd_pipe_xfer(pipe_handle_t pipe_hdl, uint8_t buffer[], uint16_t total_bytes, bool int_on_complete)
|
||||
{
|
||||
ASSERT_STATUS ( hcd_pipe_queue_xfer(pipe_hdl, buffer, total_bytes) );
|
||||
ASSERT_ERR ( hcd_pipe_queue_xfer(pipe_hdl, buffer, total_bytes) );
|
||||
|
||||
ehci_qhd_t *p_qhd = qhd_get_from_pipe_handle(pipe_hdl);
|
||||
|
||||
@ -445,14 +445,14 @@ tusb_error_t hcd_pipe_close(pipe_handle_t pipe_hdl)
|
||||
|
||||
if ( pipe_hdl.xfer_type == TUSB_XFER_BULK )
|
||||
{
|
||||
ASSERT_STATUS( list_remove_qhd(
|
||||
ASSERT_ERR( list_remove_qhd(
|
||||
(ehci_link_t*) get_async_head( usbh_devices[pipe_hdl.dev_addr].core_id ),
|
||||
(ehci_link_t*) p_qhd) );
|
||||
}
|
||||
#if EHCI_PERIODIC_LIST // TODO refractor/group this together
|
||||
else
|
||||
{
|
||||
ASSERT_STATUS( list_remove_qhd(
|
||||
ASSERT_ERR( list_remove_qhd(
|
||||
get_period_head( usbh_devices[pipe_hdl.dev_addr].core_id, p_qhd->interval_ms ),
|
||||
(ehci_link_t*) p_qhd) );
|
||||
}
|
||||
|
@ -484,7 +484,7 @@ static tusb_error_t pipe_queue_xfer(pipe_handle_t pipe_hdl, uint8_t buffer[], u
|
||||
td_insert_to_ed(p_ed, p_gtd);
|
||||
}else
|
||||
{
|
||||
ASSERT_STATUS(TUSB_ERROR_NOT_SUPPORTED_YET);
|
||||
ASSERT_ERR(TUSB_ERROR_NOT_SUPPORTED_YET);
|
||||
}
|
||||
|
||||
return TUSB_ERROR_NONE;
|
||||
@ -497,7 +497,7 @@ tusb_error_t hcd_pipe_queue_xfer(pipe_handle_t pipe_hdl, uint8_t buffer[], uint
|
||||
|
||||
tusb_error_t hcd_pipe_xfer(pipe_handle_t pipe_hdl, uint8_t buffer[], uint16_t total_bytes, bool int_on_complete)
|
||||
{
|
||||
ASSERT_STATUS( pipe_queue_xfer(pipe_hdl, buffer, total_bytes, true) );
|
||||
ASSERT_ERR( pipe_queue_xfer(pipe_hdl, buffer, total_bytes, true) );
|
||||
|
||||
tusb_xfer_type_t xfer_type = ed_get_xfer_type( ed_from_pipe_handle(pipe_hdl) );
|
||||
|
||||
|
@ -144,7 +144,7 @@ tusb_error_t usbh_init(void)
|
||||
{
|
||||
memclr_(usbh_devices, sizeof(usbh_device_info_t)*(TUSB_CFG_HOST_DEVICE_MAX+1));
|
||||
|
||||
ASSERT_STATUS( hcd_init() );
|
||||
ASSERT_ERR( hcd_init() );
|
||||
|
||||
//------------- Enumeration & Reporter Task init -------------//
|
||||
enum_queue_hdl = osal_queue_create( ENUM_QUEUE_DEPTH, sizeof(uint32_t) );
|
||||
@ -223,7 +223,7 @@ tusb_error_t usbh_pipe_control_open(uint8_t dev_addr, uint8_t max_packet_size)
|
||||
osal_semaphore_reset( usbh_devices[dev_addr].control.sem_hdl );
|
||||
osal_mutex_reset( usbh_devices[dev_addr].control.mutex_hdl );
|
||||
|
||||
ASSERT_STATUS( hcd_pipe_control_open(dev_addr, max_packet_size) );
|
||||
ASSERT_ERR( hcd_pipe_control_open(dev_addr, max_packet_size) );
|
||||
|
||||
return TUSB_ERROR_NONE;
|
||||
}
|
||||
@ -231,7 +231,7 @@ tusb_error_t usbh_pipe_control_open(uint8_t dev_addr, uint8_t max_packet_size)
|
||||
static inline tusb_error_t usbh_pipe_control_close(uint8_t dev_addr) ATTR_ALWAYS_INLINE;
|
||||
static inline tusb_error_t usbh_pipe_control_close(uint8_t dev_addr)
|
||||
{
|
||||
ASSERT_STATUS( hcd_pipe_control_close(dev_addr) );
|
||||
ASSERT_ERR( hcd_pipe_control_close(dev_addr) );
|
||||
|
||||
return TUSB_ERROR_NONE;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user