summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorhathach <[email protected]>2019-05-14 11:46:22 +0700
committerhathach <[email protected]>2019-05-14 11:46:22 +0700
commit6135019230dd5e6c1c8cb17c83d20fabb500228d (patch)
treea91e4a8bbd3e32d17b3c153afcf3d5df2176ace4 /src
parentfdc12db431c568ff4f3ff309f84f72c5d8475b2a (diff)
clean up
Diffstat (limited to 'src')
-rw-r--r--src/class/cdc/cdc_rndis_host.c2
-rw-r--r--src/class/hid/hid_host.c2
-rw-r--r--src/class/msc/msc_device.c3
-rw-r--r--src/common/tusb_common.h59
-rw-r--r--src/common/tusb_compiler.h8
-rw-r--r--src/common/tusb_verify.h2
-rw-r--r--src/host/hub.c4
-rw-r--r--src/tusb_option.h9
8 files changed, 39 insertions, 50 deletions
diff --git a/src/class/cdc/cdc_rndis_host.c b/src/class/cdc/cdc_rndis_host.c
index 587e9ddc8..e5ae34b52 100644
--- a/src/class/cdc/cdc_rndis_host.c
+++ b/src/class/cdc/cdc_rndis_host.c
@@ -43,7 +43,7 @@
CFG_TUSB_MEM_SECTION static uint8_t msg_notification[CFG_TUSB_HOST_DEVICE_MAX][8];
CFG_TUSB_MEM_SECTION ATTR_ALIGNED(4) static uint8_t msg_payload[RNDIS_MSG_PAYLOAD_MAX];
-STATIC_VAR rndish_data_t rndish_data[CFG_TUSB_HOST_DEVICE_MAX];
+static rndish_data_t rndish_data[CFG_TUSB_HOST_DEVICE_MAX];
// TODO Microsoft requires message length for any get command must be at least 4096 bytes
diff --git a/src/class/hid/hid_host.c b/src/class/hid/hid_host.c
index 5aabbc01f..0e6437a20 100644
--- a/src/class/hid/hid_host.c
+++ b/src/class/hid/hid_host.c
@@ -111,7 +111,7 @@ bool tuh_hid_keyboard_is_busy(uint8_t dev_addr)
//--------------------------------------------------------------------+
#if CFG_TUH_HID_MOUSE
-STATIC_VAR hidh_interface_info_t mouseh_data[CFG_TUSB_HOST_DEVICE_MAX]; // does not have addr0, index = dev_address-1
+static hidh_interface_info_t mouseh_data[CFG_TUSB_HOST_DEVICE_MAX]; // does not have addr0, index = dev_address-1
//------------- Public API -------------//
bool tuh_hid_mouse_is_mounted(uint8_t dev_addr)
diff --git a/src/class/msc/msc_device.c b/src/class/msc/msc_device.c
index c486d5e04..a07c926d7 100644
--- a/src/class/msc/msc_device.c
+++ b/src/class/msc/msc_device.c
@@ -80,7 +80,8 @@ static inline uint32_t rdwr10_get_lba(uint8_t const command[])
uint32_t lba;
memcpy(&lba, &p_rdwr10->lba, 4);
- return __be2n(lba);
+ // lba is in Big Endian format
+ return __be2n(lba);
}
static inline uint16_t rdwr10_get_blockcount(uint8_t const command[])
diff --git a/src/common/tusb_common.h b/src/common/tusb_common.h
index e687b8983..1f55a0fc0 100644
--- a/src/common/tusb_common.h
+++ b/src/common/tusb_common.h
@@ -67,34 +67,6 @@
#define ENDIAN_BE16(le16) ((uint16_t) ((U16_LOW_U8(le16) << 8) | U16_HIGH_U8(le16)) )
-//------------- Binary constant -------------//
-#if defined(__GNUC__) && !defined(__CC_ARM)
-
-#define TU_BIN8(x) ((uint8_t) (0b##x))
-#define TU_BIN16(b1, b2) ((uint16_t) (0b##b1##b2))
-#define TU_BIN32(b1, b2, b3, b4) ((uint32_t) (0b##b1##b2##b3##b4))
-
-#else
-
-// internal macro of B8, B16, B32
-#define _B8__(x) (((x&0x0000000FUL)?1:0) \
- +((x&0x000000F0UL)?2:0) \
- +((x&0x00000F00UL)?4:0) \
- +((x&0x0000F000UL)?8:0) \
- +((x&0x000F0000UL)?16:0) \
- +((x&0x00F00000UL)?32:0) \
- +((x&0x0F000000UL)?64:0) \
- +((x&0xF0000000UL)?128:0))
-
-#define TU_BIN8(d) ((uint8_t) _B8__(0x##d##UL))
-#define TU_BIN16(dmsb,dlsb) (((uint16_t)TU_BIN8(dmsb)<<8) + TU_BIN8(dlsb))
-#define TU_BIN32(dmsb,db2,db3,dlsb) \
- (((uint32_t)TU_BIN8(dmsb)<<24) \
- + ((uint32_t)TU_BIN8(db2)<<16) \
- + ((uint32_t)TU_BIN8(db3)<<8) \
- + TU_BIN8(dlsb))
-#endif
-
// for declaration of reserved field, make use of _TU_COUNTER_
#define TU_RESERVED XSTRING_CONCAT_(reserved, _TU_COUNTER_)
@@ -190,7 +162,7 @@ static inline bool tu_within(uint32_t lower, uint32_t value, uint32_t upper)
}
// log2 of a value is its MSB's position
-// TODO use clz
+// TODO use clz TODO remove
static inline uint8_t tu_log2(uint32_t value)
{
uint8_t result = 0;
@@ -237,6 +209,35 @@ static inline bool tu_bit_test(uint32_t value, uint8_t n) { return (value & TU_B
9,8,7,6,5,4,3,2,1,0
#endif
+// To be removed
+//------------- Binary constant -------------//
+#if defined(__GNUC__) && !defined(__CC_ARM)
+
+#define TU_BIN8(x) ((uint8_t) (0b##x))
+#define TU_BIN16(b1, b2) ((uint16_t) (0b##b1##b2))
+#define TU_BIN32(b1, b2, b3, b4) ((uint32_t) (0b##b1##b2##b3##b4))
+
+#else
+
+// internal macro of B8, B16, B32
+#define _B8__(x) (((x&0x0000000FUL)?1:0) \
+ +((x&0x000000F0UL)?2:0) \
+ +((x&0x00000F00UL)?4:0) \
+ +((x&0x0000F000UL)?8:0) \
+ +((x&0x000F0000UL)?16:0) \
+ +((x&0x00F00000UL)?32:0) \
+ +((x&0x0F000000UL)?64:0) \
+ +((x&0xF0000000UL)?128:0))
+
+#define TU_BIN8(d) ((uint8_t) _B8__(0x##d##UL))
+#define TU_BIN16(dmsb,dlsb) (((uint16_t)TU_BIN8(dmsb)<<8) + TU_BIN8(dlsb))
+#define TU_BIN32(dmsb,db2,db3,dlsb) \
+ (((uint32_t)TU_BIN8(dmsb)<<24) \
+ + ((uint32_t)TU_BIN8(db2)<<16) \
+ + ((uint32_t)TU_BIN8(db3)<<8) \
+ + TU_BIN8(dlsb))
+#endif
+
#ifdef __cplusplus
}
#endif
diff --git a/src/common/tusb_compiler.h b/src/common/tusb_compiler.h
index 613db4d3d..c0813e8ef 100644
--- a/src/common/tusb_compiler.h
+++ b/src/common/tusb_compiler.h
@@ -52,14 +52,6 @@
#define TU_VERIFY_STATIC(const_expr, _mess) enum { XSTRING_CONCAT_(_verify_static_, _TU_COUNTER_) = 1/(!!(const_expr)) }
#endif
-// allow debugger to watch any module-wide variables anywhere
-#if CFG_TUSB_DEBUG
-#define STATIC_VAR
-#else
-#define STATIC_VAR static
-#endif
-
-
#if defined(__GNUC__)
#include "compiler/tusb_compiler_gcc.h"
#elif defined __ICCARM__
diff --git a/src/common/tusb_verify.h b/src/common/tusb_verify.h
index 74bc41230..05af66205 100644
--- a/src/common/tusb_verify.h
+++ b/src/common/tusb_verify.h
@@ -50,7 +50,7 @@
//--------------------------------------------------------------------+
// TU_VERIFY Helper
//--------------------------------------------------------------------+
-#if CFG_TUSB_DEBUG >= 1
+#if CFG_TUSB_DEBUG
#include <stdio.h>
#define _MESS_ERR(_err) printf("%s: %d: failed, error = %s\n", __func__, __LINE__, tusb_strerr[_err])
#define _MESS_FAILED() printf("%s: %d: failed\n", __func__, __LINE__)
diff --git a/src/host/hub.c b/src/host/hub.c
index 157a77937..92a16ae0f 100644
--- a/src/host/hub.c
+++ b/src/host/hub.c
@@ -44,8 +44,8 @@ typedef struct
uint8_t status_change; // data from status change interrupt endpoint
}usbh_hub_t;
-CFG_TUSB_MEM_SECTION STATIC_VAR usbh_hub_t hub_data[CFG_TUSB_HOST_DEVICE_MAX];
-ATTR_ALIGNED(4) CFG_TUSB_MEM_SECTION STATIC_VAR uint8_t hub_enum_buffer[sizeof(descriptor_hub_desc_t)];
+CFG_TUSB_MEM_SECTION static usbh_hub_t hub_data[CFG_TUSB_HOST_DEVICE_MAX];
+ATTR_ALIGNED(4) CFG_TUSB_MEM_SECTION static uint8_t hub_enum_buffer[sizeof(descriptor_hub_desc_t)];
//OSAL_SEM_DEF(hub_enum_semaphore);
//static osal_semaphore_handle_t hub_enum_sem_hdl;
diff --git a/src/tusb_option.h b/src/tusb_option.h
index 4e55132b1..492e1c574 100644
--- a/src/tusb_option.h
+++ b/src/tusb_option.h
@@ -119,13 +119,8 @@
//--------------------------------------------------------------------+
// COMMON OPTIONS
//--------------------------------------------------------------------+
-/**
- determines the debug level for the stack
- - Level 3: TBD
- - Level 2: TBD
- - Level 1: Print out if Assert failed. STATIC_VAR is NULL --> accessible when debugging
- - Level 0: no debug information is generated
-*/
+
+// Debug enable to print out error message
#ifndef CFG_TUSB_DEBUG
#define CFG_TUSB_DEBUG 0
#endif