mirror of
https://github.com/hathach/tinyusb.git
synced 2025-02-18 21:41:12 +00:00
enhance
- add ASSERT_ - rename edpt_equal -
This commit is contained in:
parent
d28e7e3966
commit
817f23e5e0
@ -308,7 +308,7 @@ tusb_error_t hidd_xfer_cb(endpoint_handle_t edpt_hdl, tusb_event_t event, uint32
|
|||||||
for(uint8_t i=0; i<HIDD_NUMBER_OF_SUBCLASS; i++)
|
for(uint8_t i=0; i<HIDD_NUMBER_OF_SUBCLASS; i++)
|
||||||
{
|
{
|
||||||
hidd_interface_t * const p_interface = hidd_class_driver[i].p_interface;
|
hidd_interface_t * const p_interface = hidd_class_driver[i].p_interface;
|
||||||
if ( (p_interface != NULL) && endpointhandle_is_equal(edpt_hdl, p_interface->ept_handle) )
|
if ( (p_interface != NULL) && edpt_equal(edpt_hdl, p_interface->ept_handle) )
|
||||||
{
|
{
|
||||||
hidd_class_driver[i].xfer_cb(edpt_hdl.coreid, event, xferred_bytes);
|
hidd_class_driver[i].xfer_cb(edpt_hdl.coreid, event, xferred_bytes);
|
||||||
}
|
}
|
||||||
|
@ -150,14 +150,14 @@ tusb_error_t mscd_xfer_cb(endpoint_handle_t edpt_hdl, tusb_event_t event, uint32
|
|||||||
msc_cmd_block_wrapper_t * const p_cbw = &p_msc->cbw;
|
msc_cmd_block_wrapper_t * const p_cbw = &p_msc->cbw;
|
||||||
msc_cmd_status_wrapper_t * const p_csw = &p_msc->csw;
|
msc_cmd_status_wrapper_t * const p_csw = &p_msc->csw;
|
||||||
|
|
||||||
VERIFY(endpointhandle_is_equal(edpt_hdl, p_msc->edpt_out) || endpointhandle_is_equal(edpt_hdl, p_msc->edpt_in), TUSB_ERROR_INVALID_PARA);
|
VERIFY(edpt_equal(edpt_hdl, p_msc->edpt_out) || edpt_equal(edpt_hdl, p_msc->edpt_in), TUSB_ERROR_INVALID_PARA);
|
||||||
|
|
||||||
//------------- new CBW received -------------//
|
//------------- new CBW received -------------//
|
||||||
if ( !is_waiting_read10_write10 )
|
if ( !is_waiting_read10_write10 )
|
||||||
{
|
{
|
||||||
// if ( endpointhandle_is_equal(p_msc->edpt_in, edpt_hdl) ) return TUSB_ERROR_NONE; // bulk in interrupt for dcd to clean up
|
// if ( edpt_equal(p_msc->edpt_in, edpt_hdl) ) return TUSB_ERROR_NONE; // bulk in interrupt for dcd to clean up
|
||||||
|
|
||||||
ASSERT( endpointhandle_is_equal(p_msc->edpt_out, edpt_hdl) &&
|
ASSERT( edpt_equal(p_msc->edpt_out, edpt_hdl) &&
|
||||||
xferred_bytes == sizeof(msc_cmd_block_wrapper_t) &&
|
xferred_bytes == sizeof(msc_cmd_block_wrapper_t) &&
|
||||||
event == TUSB_EVENT_XFER_COMPLETE &&
|
event == TUSB_EVENT_XFER_COMPLETE &&
|
||||||
p_cbw->signature == MSC_CBW_SIGNATURE, TUSB_ERROR_INVALID_PARA );
|
p_cbw->signature == MSC_CBW_SIGNATURE, TUSB_ERROR_INVALID_PARA );
|
||||||
|
@ -67,6 +67,7 @@
|
|||||||
#include "verify.h"
|
#include "verify.h"
|
||||||
#include "binary.h"
|
#include "binary.h"
|
||||||
#include "tusb_errors.h"
|
#include "tusb_errors.h"
|
||||||
|
#include "fifo.h"
|
||||||
|
|
||||||
//------------- TUSB Header -------------//
|
//------------- TUSB Header -------------//
|
||||||
#include "tusb_types.h"
|
#include "tusb_types.h"
|
||||||
|
@ -64,6 +64,21 @@ static inline bool fifo_initalized(fifo_t* f)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void fifo_config(fifo_t *f, void* buffer, uint16_t depth, uint16_t item_size, bool overwritable)
|
||||||
|
{
|
||||||
|
mutex_lock_if_needed(f);
|
||||||
|
|
||||||
|
f->buffer = (uint8_t*) buffer;
|
||||||
|
f->depth = depth;
|
||||||
|
f->item_size = item_size;
|
||||||
|
f->overwritable = overwritable;
|
||||||
|
|
||||||
|
f->rd_idx = f->wr_idx = f->count = 0;
|
||||||
|
|
||||||
|
mutex_unlock_if_needed(f);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
/*!
|
/*!
|
||||||
@brief Read one byte out of the RX buffer.
|
@brief Read one byte out of the RX buffer.
|
||||||
|
@ -106,6 +106,7 @@ typedef struct
|
|||||||
}
|
}
|
||||||
|
|
||||||
void fifo_clear(fifo_t *f);
|
void fifo_clear(fifo_t *f);
|
||||||
|
void fifo_config(fifo_t *f, void* buffer, uint16_t depth, uint16_t item_size, bool overwritable);
|
||||||
|
|
||||||
bool fifo_write (fifo_t* f, void const * p_data);
|
bool fifo_write (fifo_t* f, void const * p_data);
|
||||||
uint16_t fifo_write_n (fifo_t* f, void const * p_data, uint16_t count);
|
uint16_t fifo_write_n (fifo_t* f, void const * p_data, uint16_t count);
|
||||||
|
@ -62,8 +62,10 @@
|
|||||||
#if TUSB_CFG_DEBUG >= 1
|
#if TUSB_CFG_DEBUG >= 1
|
||||||
// #define VERIFY_MESS(format, ...) cprintf("[%08ld] %s: %d: verify failed\n", get_millis(), __func__, __LINE__)
|
// #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_ErrorStr[_status]);
|
||||||
|
#define _ASSERT_MESS() printf("%s: %d: assert failed\n", __PRETTY_FUNCTION__, __LINE__);
|
||||||
#else
|
#else
|
||||||
#define VERIFY_MESS(_status)
|
#define VERIFY_MESS(_status)
|
||||||
|
#define _ASSERT_MESS()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -143,6 +145,18 @@
|
|||||||
|
|
||||||
#define VERIFY_HDLR(...) GET_4TH_ARG(__VA_ARGS__, VERIFY_HDLR_3ARGS, VERIFY_HDLR_2ARGS)(__VA_ARGS__)
|
#define VERIFY_HDLR(...) GET_4TH_ARG(__VA_ARGS__, VERIFY_HDLR_3ARGS, VERIFY_HDLR_2ARGS)(__VA_ARGS__)
|
||||||
|
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------*/
|
||||||
|
/* ASSERT
|
||||||
|
* basically VERIFY with hal_debugger_breakpoint as handler
|
||||||
|
* - 1 arg : return false if failed
|
||||||
|
* - 2 arg : return error if failed
|
||||||
|
*------------------------------------------------------------------*/
|
||||||
|
#define ASSERT_1ARGS(cond) do { if (!(cond)) { hal_debugger_breakpoint(); _ASSERT_MESS() return false; } } while(0)
|
||||||
|
#define ASSERT_2ARGS(cond, _error) do { if (!(cond)) { hal_debugger_breakpoint(); _ASSERT_MESS() return _error;} } while(0)
|
||||||
|
|
||||||
|
#define ASSERT_(...) GET_3RD_ARG(__VA_ARGS__, ASSERT_2ARGS, ASSERT_1ARGS)(__VA_ARGS__)
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -63,7 +63,7 @@ typedef struct {
|
|||||||
uint8_t index; // must be zero to indicate control
|
uint8_t index; // must be zero to indicate control
|
||||||
} endpoint_handle_t;
|
} endpoint_handle_t;
|
||||||
|
|
||||||
static inline bool endpointhandle_is_equal(endpoint_handle_t x, endpoint_handle_t y)
|
static inline bool edpt_equal(endpoint_handle_t x, endpoint_handle_t y)
|
||||||
{
|
{
|
||||||
return (x.coreid == y.coreid) && (x.index == y.index);
|
return (x.coreid == y.coreid) && (x.index == y.index);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user