- add ASSERT_
- rename edpt_equal
-
This commit is contained in:
hathach
2018-03-08 11:42:28 +07:00
parent d28e7e3966
commit 817f23e5e0
7 changed files with 36 additions and 5 deletions

View File

@@ -67,6 +67,7 @@
#include "verify.h"
#include "binary.h"
#include "tusb_errors.h"
#include "fifo.h"
//------------- TUSB Header -------------//
#include "tusb_types.h"

View File

@@ -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.

View File

@@ -106,6 +106,7 @@ typedef struct
}
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);
uint16_t fifo_write_n (fifo_t* f, void const * p_data, uint16_t count);

View File

@@ -62,8 +62,10 @@
#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 _ASSERT_MESS() printf("%s: %d: assert failed\n", __PRETTY_FUNCTION__, __LINE__);
#else
#define VERIFY_MESS(_status)
#define _ASSERT_MESS()
#endif
/**
@@ -143,6 +145,18 @@
#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
}
#endif