diff options
| author | hathach <[email protected]> | 2013-01-11 20:49:46 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2013-01-11 20:49:46 +0700 |
| commit | e935f29541d1c65a0bd7f480f0ccf0137450f091 (patch) | |
| tree | cbd64175b9e9179345569acf7a867b2a036bcb85 /tinyusb/common | |
| parent | d76df5400379495d0eb6c6a8301a84042681ea12 (diff) | |
tested keyboard device with lpcXpresso1347 board
Diffstat (limited to 'tinyusb/common')
| -rw-r--r-- | tinyusb/common/common.h | 62 |
1 files changed, 2 insertions, 60 deletions
diff --git a/tinyusb/common/common.h b/tinyusb/common/common.h index abd0743d0..921de01bc 100644 --- a/tinyusb/common/common.h +++ b/tinyusb/common/common.h @@ -64,6 +64,8 @@ #include "compiler/compiler.h" #include "tusb_option.h" #include "errors.h" +#include "assertion.h" +#include "binary.h" #include "mcu/mcu.h" #include "hal/hal.h" @@ -76,66 +78,6 @@ /// max value #define MAX_(x, y) (((x) > (y)) ? (x) : (y)) -/// n-th Bit -#define BIT_(n) (1 << (n)) - -/// set n-th bit of x to 1 -#define BIT_SET_(x, n) ( (x) | BIT_(n) ) - -/// clear n-th bit of x -#define BIT_CLR_(x, n) ( (x) & (~BIT_(n)) ) - -/// add hex represenation -#define HEX_(n) 0x##n##LU - -// internal macro of B8, B16, B32 -#define _B8__(x) ((x&0x0000000FLU)?1:0) \ - +((x&0x000000F0LU)?2:0) \ - +((x&0x00000F00LU)?4:0) \ - +((x&0x0000F000LU)?8:0) \ - +((x&0x000F0000LU)?16:0) \ - +((x&0x00F00000LU)?32:0) \ - +((x&0x0F000000LU)?64:0) \ - +((x&0xF0000000LU)?128:0) - -#define B8_(d) ((unsigned char)_B8__(HEX_(d))) -#define B16_(dmsb,dlsb) (((unsigned short)B8(dmsb)<<8) + B8(dlsb)) -#define B32_(dmsb,db2,db3,dlsb) \ - (((unsigned long)B8(dmsb)<<24) \ - + ((unsigned long)B8(db2)<<16) \ - + ((unsigned long)B8(db3)<<8) \ - + B8(dlsb)) - - - -//#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 - -#define ASSERT_MESSAGE(condition, value, message) \ - do{\ - if (!(condition)) {\ - PRINTF("Assert at %s %s line %d: %s\n", __BASE_FILE__, __PRETTY_FUNCTION__, __LINE__, message); \ - return (value);\ - }\ - }while(0) - -#define ASSERT(condition, value) ASSERT_MESSAGE(condition, value, NULL) - -#define ASSERT_ERROR_MESSAGE(sts, message) \ - do{\ - TUSB_Error_t status = (TUSB_Error_t)(sts);\ - if (tERROR_NONE != status) {\ - PRINTF("Assert at %s line %d: %s %s\n", __BASE_FILE__, __PRETTY_FUNCTION__, __LINE__, TUSB_ErrorStr[status], message); \ - return status;\ - }\ - }while(0) - -#define ASSERT_ERROR(sts) ASSERT_ERROR_MESSAGE(sts, NULL) - #ifdef __cplusplus } #endif |
