mirror of
https://github.com/hathach/tinyusb.git
synced 2025-02-19 06:40:45 +00:00
clean up
This commit is contained in:
parent
fdc12db431
commit
6135019230
@ -46,7 +46,7 @@
|
||||
#endif
|
||||
|
||||
#define CFG_TUSB_OS OPT_OS_NONE
|
||||
#define CFG_TUSB_DEBUG 2
|
||||
#define CFG_TUSB_DEBUG 1
|
||||
|
||||
/* USB DMA on some MCUs can only access a specific SRAM region with restriction on alignment.
|
||||
* Tinyusb use follows macros to declare transferring memory so that they can be put
|
||||
|
@ -46,7 +46,7 @@
|
||||
#endif
|
||||
|
||||
#define CFG_TUSB_OS OPT_OS_FREERTOS
|
||||
#define CFG_TUSB_DEBUG 2
|
||||
#define CFG_TUSB_DEBUG 1
|
||||
|
||||
/* USB DMA on some MCUs can only access a specific SRAM region with restriction on alignment.
|
||||
* Tinyusb use follows macros to declare transferring memory so that they can be put
|
||||
|
@ -46,7 +46,7 @@
|
||||
#endif
|
||||
|
||||
#define CFG_TUSB_OS OPT_OS_NONE
|
||||
#define CFG_TUSB_DEBUG 2
|
||||
#define CFG_TUSB_DEBUG 1
|
||||
|
||||
/* USB DMA on some MCUs can only access a specific SRAM region with restriction on alignment.
|
||||
* Tinyusb use follows macros to declare transferring memory so that they can be put
|
||||
|
@ -46,7 +46,7 @@
|
||||
#endif
|
||||
|
||||
#define CFG_TUSB_OS OPT_OS_NONE
|
||||
#define CFG_TUSB_DEBUG 2
|
||||
#define CFG_TUSB_DEBUG 1
|
||||
|
||||
/* USB DMA on some MCUs can only access a specific SRAM region with restriction on alignment.
|
||||
* Tinyusb use follows macros to declare transferring memory so that they can be put
|
||||
|
@ -46,7 +46,7 @@
|
||||
#define CFG_TUSB_RHPORT0_MODE OPT_MODE_HOST
|
||||
#endif
|
||||
|
||||
#define CFG_TUSB_DEBUG 2
|
||||
#define CFG_TUSB_DEBUG 1
|
||||
#define CFG_TUSB_OS OPT_OS_NONE
|
||||
|
||||
/* USB DMA on some MCUs can only access a specific SRAM region with restriction on alignment.
|
||||
|
@ -54,7 +54,7 @@
|
||||
//--------------------------------------------------------------------+
|
||||
// COMMON CONFIGURATION
|
||||
//--------------------------------------------------------------------+
|
||||
#define CFG_TUSB_DEBUG 2
|
||||
#define CFG_TUSB_DEBUG 1
|
||||
|
||||
//#define CFG_TUSB_OS OPT_OS_NONE // defined using eclipse build
|
||||
//#define CFG_TUD_TASK_PRIO 0 // defined using eclipse build
|
||||
|
@ -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
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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[])
|
||||
|
@ -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
|
||||
|
@ -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__
|
||||
|
@ -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__)
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -47,7 +47,7 @@
|
||||
#define CFG_TUH_HID_KEYBOARD 1
|
||||
#define CFG_TUH_HID_MOUSE 1
|
||||
#define CFG_TUH_MSC 1
|
||||
#define CFG_TUSB_HOST_HID_GENERIC 0
|
||||
#define CFG_TUSB_HOST_HID_GENERIC 0
|
||||
#define CFG_TUH_CDC 1
|
||||
#define CFG_TUH_CDC_RNDIS 0
|
||||
|
||||
@ -71,9 +71,9 @@
|
||||
// COMMON CONFIGURATION
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
#define CFG_TUSB_DEBUG 3
|
||||
#define CFG_TUSB_DEBUG 1
|
||||
|
||||
#define CFG_TUSB_OS OPT_OS_NONE
|
||||
#define CFG_TUSB_OS OPT_OS_NONE
|
||||
#define CFG_TUSB_MEM_SECTION
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
Loading…
x
Reference in New Issue
Block a user