add ASSERT_BIN8 and its test code

add some common api for task in osal.h for mocking
This commit is contained in:
hathach
2013-01-31 11:05:33 +07:00
parent 658b2b970c
commit eca87e5ee5
4 changed files with 46 additions and 11 deletions
+18
View File
@@ -146,6 +146,24 @@ extern "C"
//--------------------------------------------------------------------+
// TODO Bin Assert
//--------------------------------------------------------------------+
#define BIN8_PRINTF_PATTERN "%d%d%d%d%d%d%d%d"
#define BIN8_PRINTF_CONVERT(byte) \
((byte) & 0x80 ? 1 : 0), \
((byte) & 0x40 ? 1 : 0), \
((byte) & 0x20 ? 1 : 0), \
((byte) & 0x10 ? 1 : 0), \
((byte) & 0x08 ? 1 : 0), \
((byte) & 0x04 ? 1 : 0), \
((byte) & 0x02 ? 1 : 0), \
((byte) & 0x01 ? 1 : 0)
#define ASSERT_BIN8(...) ASSERT_BIN8_EQUAL(__VA_ARGS__)
#define ASSERT_BIN8_EQUAL(expected, actual, error)\
ASSERT_DEFINE(\
uint8_t exp = (expected); uint8_t act = (actual),\
exp==act,\
error,\
"expected " BIN8_PRINTF_PATTERN ", actual " BIN8_PRINTF_PATTERN, BIN8_PRINTF_CONVERT(exp), BIN8_PRINTF_CONVERT(act) )
//--------------------------------------------------------------------+
// TODO Bit Assert
+8
View File
@@ -76,6 +76,14 @@
typedef uint32_t osal_timeout_t;
//------------- Task -------------//
#define OSAL_TASK_LOOP
#define OSAL_TASK_LOOP_BEGIN
#define OSAL_TASK_LOOP_END
typedef uint32_t osal_task_t;
tusb_error_t osal_task_create(osal_task_t *task);
//------------- Semaphore -------------//
typedef uint32_t osal_semaphore_t;
typedef void* osal_semaphore_handle_t;
+2
View File
@@ -57,6 +57,8 @@
#include "common/common.h"
//typedef void (*pfTask)( void * );
enum
{
OSAL_TIMEOUT_NOTIMEOUT = 0, // for use within ISR, return immediately