summaryrefslogtreecommitdiffstats
path: root/tinyusb/src/common
diff options
context:
space:
mode:
authorWillian Paixao <willian@ufpa.br>2021-12-05 19:16:34 +0100
committerWillian Paixao <willian@ufpa.br>2021-12-05 19:16:34 +0100
commitac2e205ae9f465c27297ea542c72e8cfe4966f8c (patch)
tree16e4d1268b2631ba7e17dcda8f366f070fbd7475 /tinyusb/src/common
parentbbd394a19aaa334a179c36cf2ed2a066f1bb312c (diff)
downloadSensor-Watch-ac2e205ae9f465c27297ea542c72e8cfe4966f8c.tar.gz
Sensor-Watch-ac2e205ae9f465c27297ea542c72e8cfe4966f8c.tar.bz2
Sensor-Watch-ac2e205ae9f465c27297ea542c72e8cfe4966f8c.zip
remove tinyusb directory
Diffstat (limited to 'tinyusb/src/common')
-rwxr-xr-xtinyusb/src/common/tusb_common.h429
-rwxr-xr-xtinyusb/src/common/tusb_compiler.h215
-rwxr-xr-xtinyusb/src/common/tusb_error.h75
-rwxr-xr-xtinyusb/src/common/tusb_fifo.c1000
-rwxr-xr-xtinyusb/src/common/tusb_fifo.h151
-rwxr-xr-xtinyusb/src/common/tusb_timeout.h80
-rwxr-xr-xtinyusb/src/common/tusb_types.h534
-rwxr-xr-xtinyusb/src/common/tusb_verify.h181
8 files changed, 0 insertions, 2665 deletions
diff --git a/tinyusb/src/common/tusb_common.h b/tinyusb/src/common/tusb_common.h
deleted file mode 100755
index c2356ffe..00000000
--- a/tinyusb/src/common/tusb_common.h
+++ /dev/null
@@ -1,429 +0,0 @@
-/*
- * The MIT License (MIT)
- *
- * Copyright (c) 2019 Ha Thach (tinyusb.org)
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- * This file is part of the TinyUSB stack.
- */
-
-#ifndef _TUSB_COMMON_H_
-#define _TUSB_COMMON_H_
-
-#ifdef __cplusplus
- extern "C" {
-#endif
-
-//--------------------------------------------------------------------+
-// Macros Helper
-//--------------------------------------------------------------------+
-#define TU_ARRAY_SIZE(_arr) ( sizeof(_arr) / sizeof(_arr[0]) )
-#define TU_MIN(_x, _y) ( ( (_x) < (_y) ) ? (_x) : (_y) )
-#define TU_MAX(_x, _y) ( ( (_x) > (_y) ) ? (_x) : (_y) )
-
-#define TU_U16_HIGH(u16) ((uint8_t) (((u16) >> 8) & 0x00ff))
-#define TU_U16_LOW(u16) ((uint8_t) ((u16) & 0x00ff))
-#define U16_TO_U8S_BE(u16) TU_U16_HIGH(u16), TU_U16_LOW(u16)
-#define U16_TO_U8S_LE(u16) TU_U16_LOW(u16), TU_U16_HIGH(u16)
-
-#define TU_U32_BYTE3(u32) ((uint8_t) ((((uint32_t) u32) >> 24) & 0x000000ff)) // MSB
-#define TU_U32_BYTE2(u32) ((uint8_t) ((((uint32_t) u32) >> 16) & 0x000000ff))
-#define TU_U32_BYTE1(u32) ((uint8_t) ((((uint32_t) u32) >> 8) & 0x000000ff))
-#define TU_U32_BYTE0(u32) ((uint8_t) (((uint32_t) u32) & 0x000000ff)) // LSB
-
-#define U32_TO_U8S_BE(u32) TU_U32_BYTE3(u32), TU_U32_BYTE2(u32), TU_U32_BYTE1(u32), TU_U32_BYTE0(u32)
-#define U32_TO_U8S_LE(u32) TU_U32_BYTE0(u32), TU_U32_BYTE1(u32), TU_U32_BYTE2(u32), TU_U32_BYTE3(u32)
-
-#define TU_BIT(n) (1UL << (n))
-
-//--------------------------------------------------------------------+
-// Includes
-//--------------------------------------------------------------------+
-
-// Standard Headers
-#include <stdbool.h>
-#include <stdint.h>
-#include <stddef.h>
-#include <string.h>
-#include <stdio.h>
-
-// Tinyusb Common Headers
-#include "tusb_option.h"
-#include "tusb_compiler.h"
-#include "tusb_verify.h"
-#include "tusb_types.h"
-
-#include "tusb_error.h" // TODO remove
-#include "tusb_timeout.h" // TODO remove
-
-//--------------------------------------------------------------------+
-// Internal Helper used by Host and Device Stack
-//--------------------------------------------------------------------+
-
-// Check if endpoint descriptor is valid per USB specs
-bool tu_edpt_validate(tusb_desc_endpoint_t const * desc_ep, tusb_speed_t speed);
-
-// Bind all endpoint of a interface descriptor to class driver
-void tu_edpt_bind_driver(uint8_t ep2drv[][2], tusb_desc_interface_t const* p_desc, uint16_t desc_len, uint8_t driver_id);
-
-// Calculate total length of n interfaces (depending on IAD)
-uint16_t tu_desc_get_interface_total_len(tusb_desc_interface_t const* desc_itf, uint8_t itf_count, uint16_t max_len);
-
-//--------------------------------------------------------------------+
-// Internal Inline Functions
-//--------------------------------------------------------------------+
-
-//------------- Mem -------------//
-#define tu_memclr(buffer, size) memset((buffer), 0, (size))
-#define tu_varclr(_var) tu_memclr(_var, sizeof(*(_var)))
-
-//------------- Bytes -------------//
-TU_ATTR_ALWAYS_INLINE static inline uint32_t tu_u32(uint8_t b3, uint8_t b2, uint8_t b1, uint8_t b0)
-{
- return ( ((uint32_t) b3) << 24) | ( ((uint32_t) b2) << 16) | ( ((uint32_t) b1) << 8) | b0;
-}
-
-TU_ATTR_ALWAYS_INLINE static inline uint16_t tu_u16(uint8_t high, uint8_t low)
-{
- return (uint16_t) ((((uint16_t) high) << 8) | low);
-}
-
-TU_ATTR_ALWAYS_INLINE static inline uint8_t tu_u32_byte3(uint32_t u32) { return TU_U32_BYTE3(u32); }
-TU_ATTR_ALWAYS_INLINE static inline uint8_t tu_u32_byte2(uint32_t u32) { return TU_U32_BYTE2(u32); }
-TU_ATTR_ALWAYS_INLINE static inline uint8_t tu_u32_byte1(uint32_t u32) { return TU_U32_BYTE1(u32); }
-TU_ATTR_ALWAYS_INLINE static inline uint8_t tu_u32_byte0(uint32_t u32) { return TU_U32_BYTE0(u32); }
-
-TU_ATTR_ALWAYS_INLINE static inline uint8_t tu_u16_high(uint16_t u16) { return TU_U16_HIGH(u16); }
-TU_ATTR_ALWAYS_INLINE static inline uint8_t tu_u16_low (uint16_t u16) { return TU_U16_LOW(u16); }
-
-//------------- Bits -------------//
-TU_ATTR_ALWAYS_INLINE static inline uint32_t tu_bit_set (uint32_t value, uint8_t pos) { return value | TU_BIT(pos); }
-TU_ATTR_ALWAYS_INLINE static inline uint32_t tu_bit_clear(uint32_t value, uint8_t pos) { return value & (~TU_BIT(pos)); }
-TU_ATTR_ALWAYS_INLINE static inline bool tu_bit_test (uint32_t value, uint8_t pos) { return (value & TU_BIT(pos)) ? true : false; }
-
-//------------- Min -------------//
-TU_ATTR_ALWAYS_INLINE static inline uint8_t tu_min8 (uint8_t x, uint8_t y ) { return (x < y) ? x : y; }
-TU_ATTR_ALWAYS_INLINE static inline uint16_t tu_min16 (uint16_t x, uint16_t y) { return (x < y) ? x : y; }
-TU_ATTR_ALWAYS_INLINE static inline uint32_t tu_min32 (uint32_t x, uint32_t y) { return (x < y) ? x : y; }
-
-//------------- Max -------------//
-TU_ATTR_ALWAYS_INLINE static inline uint8_t tu_max8 (uint8_t x, uint8_t y ) { return (x > y) ? x : y; }
-TU_ATTR_ALWAYS_INLINE static inline uint16_t tu_max16 (uint16_t x, uint16_t y) { return (x > y) ? x : y; }
-TU_ATTR_ALWAYS_INLINE static inline uint32_t tu_max32 (uint32_t x, uint32_t y) { return (x > y) ? x : y; }
-
-//------------- Align -------------//
-TU_ATTR_ALWAYS_INLINE static inline uint32_t tu_align(uint32_t value, uint32_t alignment)
-{
- return value & ((uint32_t) ~(alignment-1));
-}
-
-TU_ATTR_ALWAYS_INLINE static inline uint32_t tu_align16 (uint32_t value) { return (value & 0xFFFFFFF0UL); }
-TU_ATTR_ALWAYS_INLINE static inline uint32_t tu_align32 (uint32_t value) { return (value & 0xFFFFFFE0UL); }
-TU_ATTR_ALWAYS_INLINE static inline uint32_t tu_align4k (uint32_t value) { return (value & 0xFFFFF000UL); }
-TU_ATTR_ALWAYS_INLINE static inline uint32_t tu_offset4k(uint32_t value) { return (value & 0xFFFUL); }
-
-//------------- Mathematics -------------//
-TU_ATTR_ALWAYS_INLINE static inline uint32_t tu_div_ceil(uint32_t v, uint32_t d) { return (v + d -1)/d; }
-
-/// inclusive range checking TODO remove
-TU_ATTR_ALWAYS_INLINE static inline bool tu_within(uint32_t lower, uint32_t value, uint32_t upper)
-{
- return (lower <= value) && (value <= upper);
-}
-
-// log2 of a value is its MSB's position
-// TODO use clz TODO remove
-static inline uint8_t tu_log2(uint32_t value)
-{
- uint8_t result = 0;
- while (value >>= 1) { result++; }
- return result;
-}
-
-//------------- Unaligned Access -------------//
-#if TUP_ARCH_STRICT_ALIGN
-
-// Rely on compiler to generate correct code for unaligned access
-
-typedef struct { uint16_t val; } TU_ATTR_PACKED tu_unaligned_uint16_t;
-typedef struct { uint32_t val; } TU_ATTR_PACKED tu_unaligned_uint32_t;
-
-TU_ATTR_ALWAYS_INLINE static inline uint32_t tu_unaligned_read32(const void* mem)
-{
- tu_unaligned_uint32_t const* ua32 = (tu_unaligned_uint32_t const*) mem;
- return ua32->val;
-}
-
-TU_ATTR_ALWAYS_INLINE static inline void tu_unaligned_write32(void* mem, uint32_t value)
-{
- tu_unaligned_uint32_t* ua32 = (tu_unaligned_uint32_t*) mem;
- ua32->val = value;
-}
-
-TU_ATTR_ALWAYS_INLINE static inline uint16_t tu_unaligned_read16(const void* mem)
-{
- tu_unaligned_uint16_t const* ua16 = (tu_unaligned_uint16_t const*) mem;
- return ua16->val;
-}
-
-TU_ATTR_ALWAYS_INLINE static inline void tu_unaligned_write16(void* mem, uint16_t value)
-{
- tu_unaligned_uint16_t* ua16 = (tu_unaligned_uint16_t*) mem;
- ua16->val = value;
-}
-
-#elif TUP_MCU_STRICT_ALIGN
-
-// MCU such as LPC_IP3511 Highspeed cannot access unaligned memory on USB_RAM although it is ARM M4.
-// We have to manually pick up bytes since tu_unaligned_uint32_t will still generate unaligned code
-// NOTE: volatile cast to memory to prevent compiler to optimize and generate unaligned code
-// TODO Big Endian may need minor changes
-TU_ATTR_ALWAYS_INLINE static inline uint32_t tu_unaligned_read32(const void* mem)
-{
- volatile uint8_t const* buf8 = (uint8_t const*) mem;
- return tu_u32(buf8[3], buf8[2], buf8[1], buf8[0]);
-}
-
-TU_ATTR_ALWAYS_INLINE static inline void tu_unaligned_write32(void* mem, uint32_t value)
-{
- volatile uint8_t* buf8 = (uint8_t*) mem;
- buf8[0] = tu_u32_byte0(value);
- buf8[1] = tu_u32_byte1(value);
- buf8[2] = tu_u32_byte2(value);
- buf8[3] = tu_u32_byte3(value);
-}
-
-TU_ATTR_ALWAYS_INLINE static inline uint16_t tu_unaligned_read16(const void* mem)
-{
- volatile uint8_t const* buf8 = (uint8_t const*) mem;
- return tu_u16(buf8[1], buf8[0]);
-}
-
-TU_ATTR_ALWAYS_INLINE static inline void tu_unaligned_write16(void* mem, uint16_t value)
-{
- volatile uint8_t* buf8 = (uint8_t*) mem;
- buf8[0] = tu_u16_low(value);
- buf8[1] = tu_u16_high(value);
-}
-
-
-#else
-
-// MCU that could access unaligned memory natively
-TU_ATTR_ALWAYS_INLINE static inline uint32_t tu_unaligned_read32 (const void* mem ) { return *((uint32_t*) mem); }
-TU_ATTR_ALWAYS_INLINE static inline uint16_t tu_unaligned_read16 (const void* mem ) { return *((uint16_t*) mem); }
-
-TU_ATTR_ALWAYS_INLINE static inline void tu_unaligned_write32 (void* mem, uint32_t value ) { *((uint32_t*) mem) = value; }
-TU_ATTR_ALWAYS_INLINE static inline void tu_unaligned_write16 (void* mem, uint16_t value ) { *((uint16_t*) mem) = value; }
-
-#endif
-
-/*------------------------------------------------------------------*/
-/* Count number of arguments of __VA_ARGS__
- * - reference https://groups.google.com/forum/#!topic/comp.std.c/d-6Mj5Lko_s
- * - _GET_NTH_ARG() takes args >= N (64) but only expand to Nth one (64th)
- * - _RSEQ_N() is reverse sequential to N to add padding to have
- * Nth position is the same as the number of arguments
- * - ##__VA_ARGS__ is used to deal with 0 paramerter (swallows comma)
- *------------------------------------------------------------------*/
-#ifndef TU_ARGS_NUM
-
-#define TU_ARGS_NUM(...) _TU_NARG(_0, ##__VA_ARGS__,_RSEQ_N())
-
-#define _TU_NARG(...) _GET_NTH_ARG(__VA_ARGS__)
-#define _GET_NTH_ARG( \
- _1, _2, _3, _4, _5, _6, _7, _8, _9,_10, \
- _11,_12,_13,_14,_15,_16,_17,_18,_19,_20, \
- _21,_22,_23,_24,_25,_26,_27,_28,_29,_30, \
- _31,_32,_33,_34,_35,_36,_37,_38,_39,_40, \
- _41,_42,_43,_44,_45,_46,_47,_48,_49,_50, \
- _51,_52,_53,_54,_55,_56,_57,_58,_59,_60, \
- _61,_62,_63,N,...) N
-#define _RSEQ_N() \
- 62,61,60, \
- 59,58,57,56,55,54,53,52,51,50, \
- 49,48,47,46,45,44,43,42,41,40, \
- 39,38,37,36,35,34,33,32,31,30, \
- 29,28,27,26,25,24,23,22,21,20, \
- 19,18,17,16,15,14,13,12,11,10, \
- 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
-
-//--------------------------------------------------------------------+
-// Debug Function
-//--------------------------------------------------------------------+
-
-// CFG_TUSB_DEBUG for debugging
-// 0 : no debug
-// 1 : print error
-// 2 : print warning
-// 3 : print info
-#if CFG_TUSB_DEBUG
-
-void tu_print_mem(void const *buf, uint32_t count, uint8_t indent);
-
-#ifdef CFG_TUSB_DEBUG_PRINTF
- extern int CFG_TUSB_DEBUG_PRINTF(const char *format, ...);
- #define tu_printf CFG_TUSB_DEBUG_PRINTF
-#else
- #define tu_printf printf
-#endif
-
-static inline
-void tu_print_var(uint8_t const* buf, uint32_t bufsize)
-{
- for(uint32_t i=0; i<bufsize; i++) tu_printf("%02X ", buf[i]);
-}
-
-// Log with Level
-#define TU_LOG(n, ...) TU_XSTRCAT(TU_LOG, n)(__VA_ARGS__)
-#define TU_LOG_MEM(n, ...) TU_XSTRCAT3(TU_LOG, n, _MEM)(__VA_ARGS__)
-#define TU_LOG_VAR(n, ...) TU_XSTRCAT3(TU_LOG, n, _VAR)(__VA_ARGS__)
-#define TU_LOG_INT(n, ...) TU_XSTRCAT3(TU_LOG, n, _INT)(__VA_ARGS__)
-#define TU_LOG_HEX(n, ...) TU_XSTRCAT3(TU_LOG, n, _HEX)(__VA_ARGS__)
-#define TU_LOG_LOCATION() tu_printf("%s: %d:\r\n", __PRETTY_FUNCTION__, __LINE__)
-#define TU_LOG_FAILED() tu_printf("%s: %d: Failed\r\n", __PRETTY_FUNCTION__, __LINE__)
-
-// Log Level 1: Error
-#define TU_LOG1 tu_printf
-#define TU_LOG1_MEM tu_print_mem
-#define TU_LOG1_VAR(_x) tu_print_var((uint8_t const*)(_x), sizeof(*(_x)))
-#define TU_LOG1_INT(_x) tu_printf(#_x " = %ld\r\n", (uint32_t) (_x) )
-#define TU_LOG1_HEX(_x) tu_printf(#_x " = %lX\r\n", (uint32_t) (_x) )
-
-// Log Level 2: Warn
-#if CFG_TUSB_DEBUG >= 2
- #define TU_LOG2 TU_LOG1
- #define TU_LOG2_MEM TU_LOG1_MEM
- #define TU_LOG2_VAR TU_LOG1_VAR
- #define TU_LOG2_INT TU_LOG1_INT
- #define TU_LOG2_HEX TU_LOG1_HEX
-#endif
-
-// Log Level 3: Info
-#if CFG_TUSB_DEBUG >= 3
- #define TU_LOG3 TU_LOG1
- #define TU_LOG3_MEM TU_LOG1_MEM
- #define TU_LOG3_VAR TU_LOG1_VAR
- #define TU_LOG3_INT TU_LOG1_INT
- #define TU_LOG3_HEX TU_LOG1_HEX
-#endif
-
-typedef struct
-{
- uint32_t key;
- const char* data;
-} tu_lookup_entry_t;
-
-typedef struct
-{
- uint16_t count;
- tu_lookup_entry_t const* items;
-} tu_lookup_table_t;
-
-static inline const char* tu_lookup_find(tu_lookup_table_t const* p_table, uint32_t key)
-{
- for(uint16_t i=0; i<p_table->count; i++)
- {
- if (p_table->items[i].key == key) return p_table->items[i].data;
- }
-
- return NULL;
-}
-
-#endif // CFG_TUSB_DEBUG
-
-#ifndef TU_LOG
-#define TU_LOG(n, ...)
-#define TU_LOG_MEM(n, ...)
-#define TU_LOG_VAR(n, ...)
-#define TU_LOG_INT(n, ...)
-#define TU_LOG_HEX(n, ...)
-#define TU_LOG_LOCATION()
-#define TU_LOG_FAILED()
-#endif
-
-// TODO replace all TU_LOGn with TU_LOG(n)
-
-#define TU_LOG0(...)
-#define TU_LOG0_MEM(...)
-#define TU_LOG0_VAR(...)
-#define TU_LOG0_INT(...)
-#define TU_LOG0_HEX(...)
-
-
-#ifndef TU_LOG1
- #define TU_LOG1(...)
- #define TU_LOG1_MEM(...)
- #define TU_LOG1_VAR(...)
- #define TU_LOG1_INT(...)
- #define TU_LOG1_HEX(...)
-#endif
-
-#ifndef TU_LOG2
- #define TU_LOG2(...)
- #define TU_LOG2_MEM(...)
- #define TU_LOG2_VAR(...)
- #define TU_LOG2_INT(...)
- #define TU_LOG2_HEX(...)
-#endif
-
-#ifndef TU_LOG3
- #define TU_LOG3(...)
- #define TU_LOG3_MEM(...)
- #define TU_LOG3_VAR(...)
- #define TU_LOG3_INT(...)
- #define TU_LOG3_HEX(...)
-#endif
-
-#ifdef __cplusplus
- }
-#endif
-
-#endif /* _TUSB_COMMON_H_ */
diff --git a/tinyusb/src/common/tusb_compiler.h b/tinyusb/src/common/tusb_compiler.h
deleted file mode 100755
index d3adbbc2..00000000
--- a/tinyusb/src/common/tusb_compiler.h
+++ /dev/null
@@ -1,215 +0,0 @@
-/*
- * The MIT License (MIT)
- *
- * Copyright (c) 2019 Ha Thach (tinyusb.org)
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- * This file is part of the TinyUSB stack.
- */
-
-/** \ingroup Group_Common
- * \defgroup Group_Compiler Compiler
- * \brief Group_Compiler brief
- * @{ */
-
-#ifndef _TUSB_COMPILER_H_
-#define _TUSB_COMPILER_H_
-
-#define TU_STRING(x) #x ///< stringify without expand
-#define TU_XSTRING(x) TU_STRING(x) ///< expand then stringify
-
-#define TU_STRCAT(a, b) a##b ///< concat without expand
-#define TU_STRCAT3(a, b, c) a##b##c ///< concat without expand
-
-#define TU_XSTRCAT(a, b) TU_STRCAT(a, b) ///< expand then concat
-#define TU_XSTRCAT3(a, b, c) TU_STRCAT3(a, b, c) ///< expand then concat 3 tokens
-
-#if defined __COUNTER__ && __COUNTER__ != __COUNTER__
- #define _TU_COUNTER_ __COUNTER__
-#else
- #define _TU_COUNTER_ __LINE__
-#endif
-
-// Compile-time Assert
-#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
- #define TU_VERIFY_STATIC _Static_assert
-#elif defined (__cplusplus) && __cplusplus >= 201103L
- #define TU_VERIFY_STATIC static_assert
-#elif defined(__CCRX__)
- #define TU_VERIFY_STATIC(const_expr, _mess) typedef char TU_XSTRCAT(Line, __LINE__)[(const_expr) ? 1 : 0];
-#else
- #define TU_VERIFY_STATIC(const_expr, _mess) enum { TU_XSTRCAT(_verify_static_, _TU_COUNTER_) = 1/(!!(const_expr)) }
-#endif
-
-// for declaration of reserved field, make use of _TU_COUNTER_
-#define TU_RESERVED TU_XSTRCAT(reserved, _TU_COUNTER_)
-
-#define TU_LITTLE_ENDIAN (0x12u)
-#define TU_BIG_ENDIAN (0x21u)
-
-//--------------------------------------------------------------------+
-// Compiler porting with Attribute and Endian
-//--------------------------------------------------------------------+
-
-// TODO refactor since __attribute__ is supported across many compiler
-#if defined(__GNUC__)
- #define TU_ATTR_ALIGNED(Bytes) __attribute__ ((aligned(Bytes)))
- #define TU_ATTR_SECTION(sec_name) __attribute__ ((section(#sec_name)))
- #define TU_ATTR_PACKED __attribute__ ((packed))
- #define TU_ATTR_WEAK __attribute__ ((weak))
- #define TU_ATTR_ALWAYS_INLINE __attribute__ ((always_inline))
- #define TU_ATTR_DEPRECATED(mess) __attribute__ ((deprecated(mess))) // warn if function with this attribute is used
- #define TU_ATTR_UNUSED __attribute__ ((unused)) // Function/Variable is meant to be possibly unused
- #define TU_ATTR_USED __attribute__ ((used)) // Function/Variable is meant to be used
-
- #define TU_ATTR_PACKED_BEGIN
- #define TU_ATTR_PACKED_END
- #define TU_ATTR_BIT_FIELD_ORDER_BEGIN
- #define TU_ATTR_BIT_FIELD_ORDER_END
-
- // Endian conversion use well-known host to network (big endian) naming
- #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
- #define TU_BYTE_ORDER TU_LITTLE_ENDIAN
- #else
- #define TU_BYTE_ORDER TU_BIG_ENDIAN
- #endif
-
- #define TU_BSWAP16(u16) (__builtin_bswap16(u16))
- #define TU_BSWAP32(u32) (__builtin_bswap32(u32))
-
- // List of obsolete callback function that is renamed and should not be defined.
- // Put it here since only gcc support this pragma
- #pragma GCC poison tud_vendor_control_request_cb
-
-#elif defined(__TI_COMPILER_VERSION__)
- #define TU_ATTR_ALIGNED(Bytes) __attribute__ ((aligned(Bytes)))
- #define TU_ATTR_SECTION(sec_name) __attribute__ ((section(#sec_name)))
- #define TU_ATTR_PACKED __attribute__ ((packed))
- #define TU_ATTR_WEAK __attribute__ ((weak))
- #define TU_ATTR_ALWAYS_INLINE __attribute__ ((always_inline))
- #define TU_ATTR_DEPRECATED(mess) __attribute__ ((deprecated(mess))) // warn if function with this attribute is used
- #define TU_ATTR_UNUSED __attribute__ ((unused)) // Function/Variable is meant to be possibly unused
- #define TU_ATTR_USED __attribute__ ((used))
-
- #define TU_ATTR_PACKED_BEGIN
- #define TU_ATTR_PACKED_END
- #define TU_ATTR_BIT_FIELD_ORDER_BEGIN
- #define TU_ATTR_BIT_FIELD_ORDER_END
-
- // __BYTE_ORDER is defined in the TI ARM compiler, but not MSP430 (which is little endian)
- #if ((__BYTE_ORDER__) == (__ORDER_LITTLE_ENDIAN__)) || defined(__MSP430__)
- #define TU_BYTE_ORDER TU_LITTLE_ENDIAN
- #else
- #define TU_BYTE_ORDER TU_BIG_ENDIAN
- #endif
-
- #define TU_BSWAP16(u16) (__builtin_bswap16(u16))
- #define TU_BSWAP32(u32) (__builtin_bswap32(u32))
-
-#elif defined(__ICCARM__)
- #include <intrinsics.h>
- #define TU_ATTR_ALIGNED(Bytes) __attribute__ ((aligned(Bytes)))
- #define TU_ATTR_SECTION(sec_name) __attribute__ ((section(#sec_name)))
- #define TU_ATTR_PACKED __attribute__ ((packed))
- #define TU_ATTR_WEAK __attribute__ ((weak))
- #define TU_ATTR_ALWAYS_INLINE __attribute__ ((always_inline))
- #define TU_ATTR_DEPRECATED(mess) __attribute__ ((deprecated(mess))) // warn if function with this attribute is used
- #define TU_ATTR_UNUSED __attribute__ ((unused)) // Function/Variable is meant to be possibly unused
- #define TU_ATTR_USED __attribute__ ((used)) // Function/Variable is meant to be used
-
- #define TU_ATTR_PACKED_BEGIN
- #define TU_ATTR_PACKED_END
- #define TU_ATTR_BIT_FIELD_ORDER_BEGIN
- #define TU_ATTR_BIT_FIELD_ORDER_END
-
- // Endian conversion use well-known host to network (big endian) naming
- #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
- #define TU_BYTE_ORDER TU_LITTLE_ENDIAN
- #else
- #define TU_BYTE_ORDER TU_BIG_ENDIAN
- #endif
-
- #define TU_BSWAP16(u16) (__iar_builtin_REV16(u16))
- #define TU_BSWAP32(u32) (__iar_builtin_REV(u32))
-
-#elif defined(__CCRX__)
- #define TU_ATTR_ALIGNED(Bytes)
- #define TU_ATTR_SECTION(sec_name)
- #define TU_ATTR_PACKED
- #define TU_ATTR_WEAK
- #define TU_ATTR_ALWAYS_INLINE
- #define TU_ATTR_DEPRECATED(mess)
- #define TU_ATTR_UNUSED
- #define TU_ATTR_USED
-
- #define TU_ATTR_PACKED_BEGIN _Pragma("pack")
- #define TU_ATTR_PACKED_END _Pragma("packoption")
- #define TU_ATTR_BIT_FIELD_ORDER_BEGIN _Pragma("bit_order right")
- #define TU_ATTR_BIT_FIELD_ORDER_END _Pragma("bit_order")
-
- // Endian conversion use well-known host to network (big endian) naming
- #if defined(__LIT)
- #define TU_BYTE_ORDER TU_LITTLE_ENDIAN
- #else
- #define TU_BYTE_ORDER TU_BIG_ENDIAN
- #endif
-
- #define TU_BSWAP16(u16) ((unsigned short)_builtin_revw((unsigned long)u16))
- #define TU_BSWAP32(u32) (_builtin_revl(u32))
-
-#else
- #error "Compiler attribute porting is required"
-#endif
-
-#if (TU_BYTE_ORDER == TU_LITTLE_ENDIAN)
-
- #define tu_htons(u16) (TU_BSWAP16(u16))
- #define tu_ntohs(u16) (TU_BSWAP16(u16))
-
- #define tu_htonl(u32) (TU_BSWAP32(u32))
- #define tu_ntohl(u32) (TU_BSWAP32(u32))
-
- #define tu_htole16(u16) (u16)
- #define tu_le16toh(u16) (u16)
-
- #define tu_htole32(u32) (u32)
- #define tu_le32toh(u32) (u32)
-
-#elif (TU_BYTE_ORDER == TU_BIG_ENDIAN)
-
- #define tu_htons(u16) (u16)
- #define tu_ntohs(u16) (u16)
-
- #define tu_htonl(u32) (u32)
- #define tu_ntohl(u32) (u32)
-
- #define tu_htole16(u16) (TU_BSWAP16(u16))
- #define tu_le16toh(u16) (TU_BSWAP16(u16))
-
- #define tu_htole32(u32) (TU_BSWAP32(u32))
- #define tu_le32toh(u32) (TU_BSWAP32(u32))
-
-#else
- #error Byte order is undefined
-#endif
-
-#endif /* _TUSB_COMPILER_H_ */
-
-/// @}
diff --git a/tinyusb/src/common/tusb_error.h b/tinyusb/src/common/tusb_error.h
deleted file mode 100755
index d7ad8c31..00000000
--- a/tinyusb/src/common/tusb_error.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * The MIT License (MIT)
- *
- * Copyright (c) 2019 Ha Thach (tinyusb.org)
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- * This file is part of the TinyUSB stack.
- */
-
-/** \ingroup Group_Common
- * \defgroup Group_Error Error Codes
- * @{ */
-
-#ifndef _TUSB_ERRORS_H_
-#define _TUSB_ERRORS_H_
-
-#include "tusb_option.h"
-
-#ifdef __cplusplus
- extern "C" {
-#endif
-
-#define ERROR_ENUM(x) x,
-#define ERROR_STRING(x) #x,
-
-#define ERROR_TABLE(ENTRY) \
- ENTRY(TUSB_ERROR_NONE )\
- ENTRY(TUSB_ERROR_INVALID_PARA )\
- ENTRY(TUSB_ERROR_DEVICE_NOT_READY )\
- ENTRY(TUSB_ERROR_INTERFACE_IS_BUSY )\
- ENTRY(TUSB_ERROR_HCD_OPEN_PIPE_FAILED )\
- ENTRY(TUSB_ERROR_OSAL_TIMEOUT )\
- ENTRY(TUSB_ERROR_CDCH_DEVICE_NOT_MOUNTED )\
- ENTRY(TUSB_ERROR_MSCH_DEVICE_NOT_MOUNTED )\
- ENTRY(TUSB_ERROR_NOT_SUPPORTED )\
- ENTRY(TUSB_ERROR_NOT_ENOUGH_MEMORY )\
- ENTRY(TUSB_ERROR_FAILED )\
-
-/// \brief Error Code returned
-/// TODO obsolete and to be remove
-typedef enum
-{
- ERROR_TABLE(ERROR_ENUM)
- TUSB_ERROR_COUNT
-}tusb_error_t;
-
-#if CFG_TUSB_DEBUG
-/// Enum to String for debugging purposes. Only available if \ref CFG_TUSB_DEBUG > 0
-extern char const* const tusb_strerr[TUSB_ERROR_COUNT];
-#endif
-
-#ifdef __cplusplus
- }
-#endif
-
-#endif /* _TUSB_ERRORS_H_ */
-
-/** @} */
diff --git a/tinyusb/src/common/tusb_fifo.c b/tinyusb/src/common/tusb_fifo.c
deleted file mode 100755
index 11b8fc5f..00000000
--- a/tinyusb/src/common/tusb_fifo.c
+++ /dev/null
@@ -1,1000 +0,0 @@
-/*
- * The MIT License (MIT)
- *
- * Copyright (c) 2019 Ha Thach (tinyusb.org)
- * Copyright (c) 2020 Reinhard Panhuber - rework to unmasked pointers
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- * This file is part of the TinyUSB stack.
- */
-
-#include "osal/osal.h"
-#include "tusb_fifo.h"
-
-// Supress IAR warning
-// Warning[Pa082]: undefined behavior: the order of volatile accesses is undefined in this statement
-#if defined(__ICCARM__)
-#pragma diag_suppress = Pa082
-#endif
-
-// implement mutex lock and unlock
-#if CFG_FIFO_MUTEX
-
-static inline void _ff_lock(tu_fifo_mutex_t mutex)
-{
- if (mutex) osal_mutex_lock(mutex, OSAL_TIMEOUT_WAIT_FOREVER);
-}
-
-static inline void _ff_unlock(tu_fifo_mutex_t mutex)
-{
- if (mutex) osal_mutex_unlock(mutex);
-}
-
-#else
-
-#define _ff_lock(_mutex)
-#define _ff_unlock(_mutex)
-
-#endif
-
-/** \enum tu_fifo_copy_mode_t
- * \brief Write modes intended to allow special read and write functions to be able to
- * copy data to and from USB hardware FIFOs as needed for e.g. STM32s and others
- */
-typedef enum
-{
- TU_FIFO_COPY_INC, ///< Copy from/to an increasing source/destination address - default mode
- TU_FIFO_COPY_CST_FULL_WORDS, ///< Copy from/to a constant source/destination address - required for e.g. STM32 to write into USB hardware FIFO
-} tu_fifo_copy_mode_t;
-
-bool tu_fifo_config(tu_fifo_t *f, void* buffer, uint16_t depth, uint16_t item_size, bool overwritable)
-{
- if (depth > 0x8000) return false; // Maximum depth is 2^15 items
-
- _ff_lock(f->mutex_wr);
- _ff_lock(f->mutex_rd);
-
- f->buffer = (uint8_t*) buffer;
- f->depth = depth;
- f->item_size = item_size;
- f->overwritable = overwritable;
-
- // Limit index space to 2*depth - this allows for a fast "modulo" calculation
- // but limits the maximum depth to 2^16/2 = 2^15 and buffer overflows are detectable
- // only if overflow happens once (important for unsupervised DMA applications)
- f->max_pointer_idx = 2*depth - 1;
- f->non_used_index_space = UINT16_MAX - f->max_pointer_idx;
-
- f->rd_idx = f->wr_idx = 0;
-
- _ff_unlock(f->mutex_wr);
- _ff_unlock(f->mutex_rd);
-
- return true;
-}
-
-// Static functions are intended to work on local variables
-static inline uint16_t _ff_mod(uint16_t idx, uint16_t depth)
-{
- while ( idx >= depth) idx -= depth;
- return idx;
-}
-
-// Intended to be used to read from hardware USB FIFO in e.g. STM32 where all data is read from a constant address
-// Code adapted from dcd_synopsis.c
-// TODO generalize with configurable 1 byte or 4 byte each read
-static void _ff_push_const_addr(uint8_t * ff_buf, const void * app_buf, uint16_t len)
-{
- volatile uint32_t * rx_fifo = (volatile uint32_t *) app_buf;
-
- // Reading full available 32 bit words from const app address
- uint16_t full_words = len >> 2;
- while(full_words--)
- {
- tu_unaligned_write32(ff_buf, *rx_fifo);
- ff_buf += 4;
- }
-
- // Read the remaining 1-3 bytes from const app address
- uint8_t const bytes_rem = len & 0x03;
- if ( bytes_rem )
- {
- uint32_t tmp32 = *rx_fifo;
- memcpy(ff_buf, &tmp32, bytes_rem);
- }
-}
-
-// Intended to be used to write to hardware USB FIFO in e.g. STM32
-// where all data is written to a constant address in full word copies
-static void _ff_pull_const_addr(void * app_buf, const uint8_t * ff_buf, uint16_t len)
-{
- volatile uint32_t * tx_fifo = (volatile uint32_t *) app_buf;
-
- // Pushing full available 32 bit words to const app address
- uint16_t full_words = len >> 2;
- while(full_words--)
- {
- *tx_fifo = tu_unaligned_read32(ff_buf);
- ff_buf += 4;
- }
-
- // Write the remaining 1-3 bytes into const app address
- uint8_t const bytes_rem = len & 0x03;
- if ( bytes_rem )
- {
- uint32_t tmp32 = 0;
- memcpy(&tmp32, ff_buf, bytes_rem);
-
- *tx_fifo = tmp32;
- }
-}
-
-// send one item to FIFO WITHOUT updating write pointer
-static inline void _ff_push(tu_fifo_t* f, void const * app_buf, uint16_t rel)
-{
- memcpy(f->buffer + (rel * f->item_size), app_buf, f->item_size);
-}
-
-// send n items to FIFO WITHOUT updating write pointer
-static void _ff_push_n(tu_fifo_t* f, void const * app_buf, uint16_t n, uint16_t rel, tu_fifo_copy_mode_t copy_mode)
-{
- uint16_t const nLin = f->depth - rel;
- uint16_t const nWrap = n - nLin;
-
- uint16_t nLin_bytes = nLin * f->item_size;
- uint16_t nWrap_bytes = nWrap * f->item_size;
-
- // current buffer of fifo
- uint8_t* ff_buf = f->buffer + (rel * f->item_size);
-
- switch (copy_mode)
- {
- case TU_FIFO_COPY_INC:
- if(n <= nLin)
- {
- // Linear only
- memcpy(ff_buf, app_buf, n*f->item_size);
- }
- else
- {
- // Wrap around
-
- // Write data to linear part of buffer
- memcpy(ff_buf, app_buf, nLin_bytes);
-
- // Write data wrapped around
- memcpy(f->buffer, ((uint8_t const*) app_buf) + nLin_bytes, nWrap_bytes);
- }
- break;
-
- case TU_FIFO_COPY_CST_FULL_WORDS:
- // Intended for hardware buffers from which it can be read word by word only
- if(n <= nLin)
- {
- // Linear only
- _ff_push_const_addr(ff_buf, app_buf, n*f->item_size);
- }
- else
- {
- // Wrap around case
-
- // Write full words to linear part of buffer
- uint16_t nLin_4n_bytes = nLin_bytes & 0xFFFC;
- _ff_push_const_addr(ff_buf, app_buf, nLin_4n_bytes);
- ff_buf += nLin_4n_bytes;
-
- // There could be odd 1-3 bytes before the wrap-around boundary
- volatile uint32_t * rx_fifo = (volatile uint32_t *) app_buf;
- uint8_t rem = nLin_bytes & 0x03;
- if (rem > 0)
- {
- uint8_t remrem = tu_min16(nWrap_bytes, 4-rem);
- nWrap_bytes -= remrem;
-
- uint32_t tmp32 = *rx_fifo;
- uint8_t * src_u8 = ((uint8_t *) &tmp32);
-
- // Write 1-3 bytes before wrapped boundary
- while(rem--) *ff_buf++ = *src_u8++;
-
- // Read more bytes to beginning to complete a word
- ff_buf = f->buffer;
- while(remrem--) *ff_buf++ = *src_u8++;
- }
- else
- {
- ff_buf = f->buffer; // wrap around to beginning
- }
-
- // Write data wrapped part
- if (nWrap_bytes > 0) _ff_push_const_addr(ff_buf, app_buf, nWrap_bytes);
- }
- break;
- }
-}
-
-// get one item from FIFO WITHOUT updating read pointer
-static inline void _ff_pull(tu_fifo_t* f, void * app_buf, uint16_t rel)
-{
- memcpy(app_buf, f->buffer + (rel * f->item_size), f->item_size);
-}
-
-// get n items from FIFO WITHOUT updating read pointer
-static void _ff_pull_n(tu_fifo_t* f, void* app_buf, uint16_t n, uint16_t rel, tu_fifo_copy_mode_t copy_mode)
-{
- uint16_t const nLin = f->depth - rel;
- uint16_t const nWrap = n - nLin; // only used if wrapped
-
- uint16_t nLin_bytes = nLin * f->item_size;
- uint16_t nWrap_bytes = nWrap * f->item_size;
-
- // current buffer of fifo
- uint8_t* ff_buf = f->buffer + (rel * f->item_size);
-
- switch (copy_mode)
- {
- case TU_FIFO_COPY_INC:
- if ( n <= nLin )
- {
- // Linear only
- memcpy(app_buf, ff_buf, n*f->item_size);
- }
- else
- {
- // Wrap around
-
- // Read data from linear part of buffer
- memcpy(app_buf, ff_buf, nLin_bytes);
-
- // Read data wrapped part
- memcpy((uint8_t*) app_buf + nLin_bytes, f->buffer, nWrap_bytes);
- }
- break;
-
- case TU_FIFO_COPY_CST_FULL_WORDS:
- if ( n <= nLin )
- {
- // Linear only
- _ff_pull_const_addr(app_buf, ff_buf, n*f->item_size);
- }
- else
- {
- // Wrap around case
-
- // Read full words from linear part of buffer
- uint16_t nLin_4n_bytes = nLin_bytes & 0xFFFC;
- _ff_pull_const_addr(app_buf, ff_buf, nLin_4n_bytes);
- ff_buf += nLin_4n_bytes;
-
- // There could be odd 1-3 bytes before the wrap-around boundary
- volatile uint32_t * tx_fifo = (volatile uint32_t *) app_buf;
- uint8_t rem = nLin_bytes & 0x03;
- if (rem > 0)
- {
- uint8_t remrem = tu_min16(nWrap_bytes, 4-rem);
- nWrap_bytes -= remrem;
-
- uint32_t tmp32=0;
- uint8_t * dst_u8 = (uint8_t *)&tmp32;
-
- // Read 1-3 bytes before wrapped boundary
- while(rem--) *dst_u8++ = *ff_buf++;
-
- // Read more bytes from beginning to complete a word
- ff_buf = f->buffer;
- while(remrem--) *dst_u8++ = *ff_buf++;
-
- *tx_fifo = tmp32;
- }
- else
- {
- ff_buf = f->buffer; // wrap around to beginning
- }
-
- // Read data wrapped part
- if (nWrap_bytes > 0) _ff_pull_const_addr(app_buf, ff_buf, nWrap_bytes);
- }
- break;
-
- default: break;
- }
-}
-
-// Advance an absolute pointer
-static uint16_t advance_pointer(tu_fifo_t* f, uint16_t p, uint16_t offset)
-{
- // We limit the index space of p such that a correct wrap around happens
- // Check for a wrap around or if we are in unused index space - This has to be checked first!!
- // We are exploiting the wrap around to the correct index
- if ((p > (uint16_t)(p + offset)) || ((uint16_t)(p + offset) > f->max_pointer_idx))
- {
- p = (p + offset) + f->non_used_index_space;
- }
- else
- {
- p += offset;
- }
- return p;
-}
-
-// Backward an absolute pointer
-static uint16_t backward_pointer(tu_fifo_t* f, uint16_t p, uint16_t offset)
-{
- // We limit the index space of p such that a correct wrap around happens
- // Check for a wrap around or if we are in unused index space - This has to be checked first!!
- // We are exploiting the wrap around to the correct index
- if ((p < (uint16_t)(p - offset)) || ((uint16_t)(p - offset) > f->max_pointer_idx))
- {
- p = (p - offset) - f->non_used_index_space;
- }
- else
- {
- p -= offset;
- }
- return p;
-}
-
-// get relative from absolute pointer
-static uint16_t get_relative_pointer(tu_fifo_t* f, uint16_t p)
-{
- return _ff_mod(p, f->depth);
-}
-
-// Works on local copies of w and r - return only the difference and as such can be used to determine an overflow
-static inline uint16_t _tu_fifo_count(tu_fifo_t* f, uint16_t wAbs, uint16_t rAbs)
-{
- uint16_t cnt = wAbs-rAbs;
-
- // In case we have non-power of two depth we need a further modification
- if (rAbs > wAbs) cnt -= f->non_used_index_space;
-
- return cnt;
-}
-
-// Works on local copies of w and r
-static inline bool _tu_fifo_empty(uint16_t wAbs, uint16_t rAbs)
-{
- return wAbs == rAbs;
-}
-
-// Works on local copies of w and r
-static inline bool _tu_fifo_full(tu_fifo_t* f, uint16_t wAbs, uint16_t rAbs)
-{
- return (_tu_fifo_count(f, wAbs, rAbs) == f->depth);
-}
-
-// Works on local copies of w and r
-// BE AWARE - THIS FUNCTION MIGHT NOT GIVE A CORRECT ANSWERE IN CASE WRITE POINTER "OVERFLOWS"
-// Only one overflow is allowed for this function to work e.g. if depth = 100, you must not
-// write more than 2*depth-1 items in one rush without updating write pointer. Otherwise
-// write pointer wraps and you pointer states are messed up. This can only happen if you
-// use DMAs, write functions do not allow such an error.
-static inline bool _tu_fifo_overflowed(tu_fifo_t* f, uint16_t wAbs, uint16_t rAbs)
-{
- return (_tu_fifo_count(f, wAbs, rAbs) > f->depth);
-}
-
-// Works on local copies of w
-// For more details see _tu_fifo_overflow()!
-static inline void _tu_fifo_correct_read_pointer(tu_fifo_t* f, uint16_t wAbs)
-{
- f->rd_idx = backward_pointer(f, wAbs, f->depth);
-}
-
-// Works on local copies of w and r
-// Must be protected by mutexes since in case of an overflow read pointer gets modified
-static bool _tu_fifo_peek(tu_fifo_t* f, void * p_buffer, uint16_t wAbs, uint16_t rAbs)
-{
- uint16_t cnt = _tu_fifo_count(f, wAbs, rAbs);
-
- // Check overflow and correct if required
- if (cnt > f->depth)
- {
- _tu_fifo_correct_read_pointer(f, wAbs);
- cnt = f->depth;
- }
-
- // Skip beginning of buffer
- if (cnt == 0) return false;
-
- uint16_t rRel = get_relative_pointer(f, rAbs);
-
- // Peek data
- _ff_pull(f, p_buffer, rRel);
-
- return true;
-}
-
-// Works on local copies of w and r
-// Must be protected by mutexes since in case of an overflow read pointer gets modified
-static uint16_t _tu_fifo_peek_n(tu_fifo_t* f, void * p_buffer, uint16_t n, uint16_t wAbs, uint16_t rAbs, tu_fifo_copy_mode_t copy_mode)
-{
- uint16_t cnt = _tu_fifo_count(f, wAbs, rAbs);
-
- // Check overflow and correct if required
- if (cnt > f->depth)
- {
- _tu_fifo_correct_read_pointer(f, wAbs);
- rAbs = f->rd_idx;
- cnt = f->depth;
- }
-
- // Skip beginning of buffer
- if (cnt == 0) return 0;
-
- // Check if we can read something at and after offset - if too less is available we read what remains
- if (cnt < n) n = cnt;
-
- uint16_t rRel = get_relative_pointer(f, rAbs);
-
- // Peek data
- _ff_pull_n(f, p_buffer, n, rRel, copy_mode);
-
- return n;
-}
-
-// Works on local copies of w and r
-static inline uint16_t _tu_fifo_remaining(tu_fifo_t* f, uint16_t wAbs, uint16_t rAbs)
-{
- return f->depth - _tu_fifo_count(f, wAbs, rAbs);
-}
-
-static uint16_t _tu_fifo_write_n(tu_fifo_t* f, const void * data, uint16_t n, tu_fifo_copy_mode_t copy_mode)
-{
- if ( n == 0 ) return 0;
-
- _ff_lock(f->mutex_wr);
-
- uint16_t w = f->wr_idx, r = f->rd_idx;
- uint8_t const* buf8 = (uint8_t const*) data;
-
- if (!f->overwritable)
- {
- // Not overwritable limit up to full
- n = tu_min16(n, _tu_fifo_remaining(f, w, r));
- }
- else if (n >= f->depth)
- {
- // Only copy last part
- buf8 = buf8 + (n - f->depth) * f->item_size;
- n = f->depth;
-
- // We start writing at the read pointer's position since we fill the complete
- // buffer and we do not want to modify the read pointer within a write function!
- // This would end up in a race condition with read functions!
- w = r;
- }
-
- uint16_t wRel = get_relative_pointer(f, w);
-
- // Write data
- _ff_push_n(f, buf8, n, wRel, copy_mode);
-
- // Advance pointer
- f->wr_idx = advance_pointer(f, w, n);
-
- _ff_unlock(f->mutex_wr);
-
- return n;
-}
-
-static uint16_t _tu_fifo_read_n(tu_fifo_t* f, void * buffer, uint16_t n, tu_fifo_copy_mode_t copy_mode)
-{
- _ff_lock(f->mutex_rd);
-
- // Peek the data
- // f->rd_idx might get modified in case of an overflow so we can not use a local variable
- n = _tu_fifo_peek_n(f, buffer, n, f->wr_idx, f->rd_idx, copy_mode);
-
- // Advance read pointer
- f->rd_idx = advance_pointer(f, f->rd_idx, n);
-
- _ff_unlock(f->mutex_rd);
- return n;
-}
-
-/******************************************************************************/
-/*!
- @brief Get number of items in FIFO.
-
- As this function only reads the read and write pointers once, this function is
- reentrant and thus thread and ISR save without any mutexes. In case an
- overflow occurred, this function return f.depth at maximum. Overflows are
- checked and corrected for in the read functions!
-
- @param[in] f
- Pointer to the FIFO buffer to manipulate
-
- @returns Number of items in FIFO
- */
-/******************************************************************************/
-uint16_t tu_fifo_count(tu_fifo_t* f)
-{
- return tu_min16(_tu_fifo_count(f, f->wr_idx, f->rd_idx), f->depth);
-}
-
-/******************************************************************************/
-/*!
- @brief Check if FIFO is empty.
-
- As this function only reads the read and write pointers once, this function is
- reentrant and thus thread and ISR save without any mutexes.
-
- @param[in] f
- Pointer to the FIFO buffer to manipulate
-
- @returns Number of items in FIFO
- */
-/******************************************************************************/
-bool tu_fifo_empty(tu_fifo_t* f)
-{
- return _tu_fifo_empty(f->wr_idx, f->rd_idx);
-}
-
-/******************************************************************************/
-/*!
- @brief Check if FIFO is full.
-
- As this function only reads the read and write pointers once, this function is
- reentrant and thus thread and ISR save without any mutexes.
-
- @param[in] f
- Pointer to the FIFO buffer to manipulate
-
- @returns Number of items in FIFO
- */
-/******************************************************************************/
-bool tu_fifo_full(tu_fifo_t* f)
-{
- return _tu_fifo_full(f, f->wr_idx, f->rd_idx);
-}
-
-/******************************************************************************/
-/*!
- @brief Get remaining space in FIFO.
-
- As this function only reads the read and write pointers once, this function is
- reentrant and thus thread and ISR save without any mutexes.
-
- @param[in] f
- Pointer to the FIFO buffer to manipulate
-
- @returns Number of items in FIFO
- */
-/******************************************************************************/
-uint16_t tu_fifo_remaining(tu_fifo_t* f)
-{
- return _tu_fifo_remaining(f, f->wr_idx, f->rd_idx);
-}
-
-/******************************************************************************/
-/*!
- @brief Check if overflow happened.
-
- BE AWARE - THIS FUNCTION MIGHT NOT GIVE A CORRECT ANSWERE IN CASE WRITE POINTER "OVERFLOWS"
- Only one overflow is allowed for this function to work e.g. if depth = 100, you must not
- write more than 2*depth-1 items in one rush without updating write pointer. Otherwise
- write pointer wraps and your pointer states are messed up. This can only happen if you
- use DMAs, write functions do not allow such an error. Avoid such nasty things!
-
- All reading functions (read, peek) check for overflows and correct read pointer on their own such
- that latest items are read.
- If required (e.g. for DMA use) you can also correct the read pointer by
- tu_fifo_correct_read_pointer().
-
- @param[in] f
- Pointer to the FIFO buffer to manipulate
-
- @returns True if overflow happened
- */
-/******************************************************************************/
-bool tu_fifo_overflowed(tu_fifo_t* f)
-{
- return _tu_fifo_overflowed(f, f->wr_idx, f->rd_idx);
-}
-
-// Only use in case tu_fifo_overflow() returned true!
-void tu_fifo_correct_read_pointer(tu_fifo_t* f)
-{
- _ff_lock(f->mutex_rd);
- _tu_fifo_correct_read_pointer(f, f->wr_idx);
- _ff_unlock(f->mutex_rd);
-}
-
-/******************************************************************************/
-/*!
- @brief Read one element out of the buffer.
-
- This function will return the element located at the array index of the
- read pointer, and then increment the read pointer index.
- This function checks for an overflow and corrects read pointer if required.
-
- @param[in] f
- Pointer to the FIFO buffer to manipulate
- @param[in] buffer
- Pointer to the place holder for data read from the buffer
-
- @returns TRUE if the queue is not empty
- */
-/******************************************************************************/
-bool tu_fifo_read(tu_fifo_t* f, void * buffer)
-{
- _ff_lock(f->mutex_rd);
-
- // Peek the data
- // f->rd_idx might get modified in case of an overflow so we can not use a local variable
- bool ret = _tu_fifo_peek(f, buffer, f->wr_idx, f->rd_idx);
-
- // Advance pointer
- f->rd_idx = advance_pointer(f, f->rd_idx, ret);
-
- _ff_unlock(f->mutex_rd);
- return ret;
-}
-
-/******************************************************************************/
-/*!
- @brief This function will read n elements from the array index specified by
- the read pointer and increment the read index.
- This function checks for an overflow and corrects read pointer if required.
-
- @param[in] f
- Pointer to the FIFO buffer to manipulate
- @param[in] buffer
- The pointer to data location
- @param[in] n
- Number of element that buffer can afford
-
- @returns number of items read from the FIFO
- */
-/******************************************************************************/
-uint16_t tu_fifo_read_n(tu_fifo_t* f, void * buffer, uint16_t n)
-{
- return _tu_fifo_read_n(f, buffer, n, TU_FIFO_COPY_INC);
-}
-
-uint16_t tu_fifo_read_n_const_addr_full_words(tu_fifo_t* f, void * buffer, uint16_t n)
-{
- return _tu_fifo_read_n(f, buffer, n, TU_FIFO_COPY_CST_FULL_WORDS);
-}
-
-/******************************************************************************/
-/*!
- @brief Read one item without removing it from the FIFO.
- This function checks for an overflow and corrects read pointer if required.
-
- @param[in] f
- Pointer to the FIFO buffer to manipulate
- @param[in] offset
- Position to read from in the FIFO buffer with respect to read pointer
- @param[in] p_buffer
- Pointer to the place holder for data read from the buffer
-
- @returns TRUE if the queue is not empty
- */
-/******************************************************************************/
-bool tu_fifo_peek(tu_fifo_t* f, void * p_buffer)
-{
- _ff_lock(f->mutex_rd);
- bool ret = _tu_fifo_peek(f, p_buffer, f->wr_idx, f->rd_idx);
- _ff_unlock(f->mutex_rd);
- return ret;
-}
-
-/******************************************************************************/
-/*!
- @brief Read n items without removing it from the FIFO
- This function checks for an overflow and corrects read pointer if required.
-
- @param[in] f
- Pointer to the FIFO buffer to manipulate
- @param[in] p_buffer
- Pointer to the place holder for data read from the buffer
- @param[in] n
- Number of items to peek
-
- @returns Number of bytes written to p_buffer
- */
-/******************************************************************************/
-uint16_t tu_fifo_peek_n(tu_fifo_t* f, void * p_buffer, uint16_t n)
-{
- _ff_lock(f->mutex_rd);
- bool ret = _tu_fifo_peek_n(f, p_buffer, n, f->wr_idx, f->rd_idx, TU_FIFO_COPY_INC);
- _ff_unlock(f->mutex_rd);
- return ret;
-}
-
-/******************************************************************************/
-/*!
- @brief Write one element into the buffer.
-
- This function will write one element into the array index specified by
- the write pointer and increment the write index.
-
- @param[in] f
- Pointer to the FIFO buffer to manipulate
- @param[in] data
- The byte to add to the FIFO
-
- @returns TRUE if the data was written to the FIFO (overwrittable
- FIFO will always return TRUE)
- */
-/******************************************************************************/
-bool tu_fifo_write(tu_fifo_t* f, const void * data)
-{
- _ff_lock(f->mutex_wr);
-
- uint16_t w = f->wr_idx;
-
- if ( _tu_fifo_full(f, w, f->rd_idx) && !f->overwritable ) return false;
-
- uint16_t wRel = get_relative_pointer(f, w);
-
- // Write data
- _ff_push(f, data, wRel);
-
- // Advance pointer
- f->wr_idx = advance_pointer(f, w, 1);
-
- _ff_unlock(f->mutex_wr);
-
- return true;
-}
-
-/******************************************************************************/
-/*!
- @brief This function will write n elements into the array index specified by
- the write pointer and increment the write index.
-
- @param[in] f
- Pointer to the FIFO buffer to manipulate
- @param[in] data
- The pointer to data to add to the FIFO
- @param[in] count
- Number of element
- @return Number of written elements
- */
-/******************************************************************************/
-uint16_t tu_fifo_write_n(tu_fifo_t* f, const void * data, uint16_t n)
-{
- return _tu_fifo_write_n(f, data, n, TU_FIFO_COPY_INC);
-}
-
-/******************************************************************************/
-/*!
- @brief This function will write n elements into the array index specified by
- the write pointer and increment the write index. The source address will
- not be incremented which is useful for reading from registers.
-
- @param[in] f
- Pointer to the FIFO buffer to manipulate
- @param[in] data
- The pointer to data to add to the FIFO
- @param[in] count
- Number of element
- @return Number of written elements
- */
-/******************************************************************************/
-uint16_t tu_fifo_write_n_const_addr_full_words(tu_fifo_t* f, const void * data, uint16_t n)
-{
- return _tu_fifo_write_n(f, data, n, TU_FIFO_COPY_CST_FULL_WORDS);
-}
-
-/******************************************************************************/
-/*!
- @brief Clear the fifo read and write pointers
-
- @param[in] f
- Pointer to the FIFO buffer to manipulate
- */
-/******************************************************************************/
-bool tu_fifo_clear(tu_fifo_t *f)
-{
- _ff_lock(f->mutex_wr);
- _ff_lock(f->mutex_rd);
-
- f->rd_idx = f->wr_idx = 0;
- f->max_pointer_idx = 2*f->depth-1;
- f->non_used_index_space = UINT16_MAX - f->max_pointer_idx;
-
- _ff_unlock(f->mutex_wr);
- _ff_unlock(f->mutex_rd);
- return true;
-}
-
-/******************************************************************************/
-/*!
- @brief Change the fifo mode to overwritable or not overwritable
-
- @param[in] f
- Pointer to the FIFO buffer to manipulate
- @param[in] overwritable
- Overwritable mode the fifo is set to
- */
-/******************************************************************************/
-bool tu_fifo_set_overwritable(tu_fifo_t *f, bool overwritable)
-{
- _ff_lock(f->mutex_wr);
- _ff_lock(f->mutex_rd);
-
- f->overwritable = overwritable;
-
- _ff_unlock(f->mutex_wr);
- _ff_unlock(f->mutex_rd);
-
- return true;
-}
-
-/******************************************************************************/
-/*!
- @brief Advance write pointer - intended to be used in combination with DMA.
- It is possible to fill the FIFO by use of a DMA in circular mode. Within
- DMA ISRs you may update the write pointer to be able to read from the FIFO.
- As long as the DMA is the only process writing into the FIFO this is safe
- to use.
-
- USE WITH CARE - WE DO NOT CONDUCT SAFTY CHECKS HERE!
-
- @param[in] f
- Pointer to the FIFO buffer to manipulate
- @param[in] n
- Number of items the write pointer moves forward
- */
-/******************************************************************************/
-void tu_fifo_advance_write_pointer(tu_fifo_t *f, uint16_t n)
-{
- f->wr_idx = advance_pointer(f, f->wr_idx, n);
-}
-
-/******************************************************************************/
-/*!
- @brief Advance read pointer - intended to be used in combination with DMA.
- It is possible to read from the FIFO by use of a DMA in linear mode. Within
- DMA ISRs you may update the read pointer to be able to again write into the
- FIFO. As long as the DMA is the only process reading from the FIFO this is
- safe to use.
-
- USE WITH CARE - WE DO NOT CONDUCT SAFTY CHECKS HERE!
-
- @param[in] f
- Pointer to the FIFO buffer to manipulate
- @param[in] n
- Number of items the read pointer moves forward
- */
-/******************************************************************************/
-void tu_fifo_advance_read_pointer(tu_fifo_t *f, uint16_t n)
-{
- f->rd_idx = advance_pointer(f, f->rd_idx, n);
-}
-
-/******************************************************************************/
-/*!
- @brief Get read info
-
- Returns the length and pointer from which bytes can be read in a linear manner.
- This is of major interest for DMA transmissions. If returned length is zero the
- corresponding pointer is invalid.
- The read pointer does NOT get advanced, use tu_fifo_advance_read_pointer() to
- do so!
- @param[in] f
- Pointer to FIFO
- @param[out] *info
- Pointer to struct which holds the desired infos
- */
-/******************************************************************************/
-void tu_fifo_get_read_info(tu_fifo_t *f, tu_fifo_buffer_info_t *info)
-{
- // Operate on temporary values in case they change in between
- uint16_t w = f->wr_idx, r = f->rd_idx;
-
- uint16_t cnt = _tu_fifo_count(f, w, r);
-
- // Check overflow and correct if required - may happen in case a DMA wrote too fast
- if (cnt > f->depth)
- {
- _ff_lock(f->mutex_rd);
- _tu_fifo_correct_read_pointer(f, w);
- _ff_unlock(f->mutex_rd);
- r = f->rd_idx;
- cnt = f->depth;
- }
-
- // Check if fifo is empty
- if (cnt == 0)
- {
- info->len_lin = 0;
- info->len_wrap = 0;
- info->ptr_lin = NULL;
- info->ptr_wrap = NULL;
- return;
- }
-
- // Get relative pointers
- w = get_relative_pointer(f, w);
- r = get_relative_pointer(f, r);
-
- // Copy pointer to buffer to start reading from
- info->ptr_lin = &f->buffer[r];
-
- // Check if there is a wrap around necessary
- if (w > r) {
- // Non wrapping case
- info->len_lin = cnt;
- info->len_wrap = 0;
- info->ptr_wrap = NULL;
- }
- else
- {
- info->len_lin = f->depth - r; // Also the case if FIFO was full
- info->len_wrap = cnt - info->len_lin;
- info->ptr_wrap = f->buffer;
- }
-}
-
-/******************************************************************************/
-/*!
- @brief Get linear write info
-
- Returns the length and pointer to which bytes can be written into FIFO in a linear manner.
- This is of major interest for DMA transmissions not using circular mode. If a returned length is zero the
- corresponding pointer is invalid. The returned lengths summed up are the currently free space in the FIFO.
- The write pointer does NOT get advanced, use tu_fifo_advance_write_pointer() to do so!
- TAKE CARE TO NOT OVERFLOW THE BUFFER MORE THAN TWO TIMES THE FIFO DEPTH - IT CAN NOT RECOVERE OTHERWISE!
- @param[in] f
- Pointer to FIFO
- @param[out] *info
- Pointer to struct which holds the desired infos
- */
-/******************************************************************************/
-void tu_fifo_get_write_info(tu_fifo_t *f, tu_fifo_buffer_info_t *info)
-{
- uint16_t w = f->wr_idx, r = f->rd_idx;
- uint16_t free = _tu_fifo_remaining(f, w, r);
-
- if (free == 0)
- {
- info->len_lin = 0;
- info->len_wrap = 0;
- info->ptr_lin = NULL;
- info->ptr_wrap = NULL;
- return;
- }
-
- // Get relative pointers
- w = get_relative_pointer(f, w);
- r = get_relative_pointer(f, r);
-
- // Copy pointer to buffer to start writing to
- info->ptr_lin = &f->buffer[w];
-
- if (w < r)
- {
- // Non wrapping case
- info->len_lin = r-w;
- info->len_wrap = 0;
- info->ptr_wrap = NULL;
- }
- else
- {
- info->len_lin = f->depth - w;
- info->len_wrap = free - info->len_lin; // Remaining length - n already was limited to free or FIFO depth
- info->ptr_wrap = f->buffer; // Always start of buffer
- }
-}
diff --git a/tinyusb/src/common/tusb_fifo.h b/tinyusb/src/common/tusb_fifo.h
deleted file mode 100755
index 18db289a..00000000
--- a/tinyusb/src/common/tusb_fifo.h
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * The MIT License (MIT)
- *
- * Copyright (c) 2019 Ha Thach (tinyusb.org)
- * Copyright (c) 2020 Reinhard Panhuber - rework to unmasked pointers
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- * This file is part of the TinyUSB stack.
- */
-
-#ifndef _TUSB_FIFO_H_
-#define _TUSB_FIFO_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-// Due to the use of unmasked pointers, this FIFO does not suffer from loosing
-// one item slice. Furthermore, write and read operations are completely
-// decoupled as write and read functions do not modify a common state. Henceforth,
-// writing or reading from the FIFO within an ISR is safe as long as no other
-// process (thread or ISR) interferes.
-// Also, this FIFO is ready to be used in combination with a DMA as the write and
-// read pointers can be updated from within a DMA ISR. Overflows are detectable
-// within a certain number (see tu_fifo_overflow()).
-
-#include "common/tusb_common.h"
-
-// mutex is only needed for RTOS
-// for OS None, we don't get preempted
-#define CFG_FIFO_MUTEX (CFG_TUSB_OS != OPT_OS_NONE)
-
-#if CFG_FIFO_MUTEX
-#include "osal/osal.h"
-#define tu_fifo_mutex_t osal_mutex_t
-#endif
-
-typedef struct
-{
- uint8_t* buffer ; ///< buffer pointer
- uint16_t depth ; ///< max items
- uint16_t item_size ; ///< size of each item
- bool overwritable ;
-
- uint16_t non_used_index_space ; ///< required for non-power-of-two buffer length
- uint16_t max_pointer_idx ; ///< maximum absolute pointer index
-
- volatile uint16_t wr_idx ; ///< write pointer
- volatile uint16_t rd_idx ; ///< read pointer
-
-#if CFG_FIFO_MUTEX
- tu_fifo_mutex_t mutex_wr;
- tu_fifo_mutex_t mutex_rd;
-#endif
-
-} tu_fifo_t;
-
-typedef struct
-{
- uint16_t len_lin ; ///< linear length in item size
- uint16_t len_wrap ; ///< wrapped length in item size
- void * ptr_lin ; ///< linear part start pointer
- void * ptr_wrap ; ///< wrapped part start pointer
-} tu_fifo_buffer_info_t;
-
-#define TU_FIFO_INIT(_buffer, _depth, _type, _overwritable) \
-{ \
- .buffer = _buffer, \
- .depth = _depth, \
- .item_size = sizeof(_type), \
- .overwritable = _overwritable, \
- .non_used_index_space = UINT16_MAX - (2*(_depth)-1), \
- .max_pointer_idx = 2*(_depth)-1, \
-}
-
-#define TU_FIFO_DEF(_name, _depth, _type, _overwritable) \
- uint8_t _name##_buf[_depth*sizeof(_type)]; \
- tu_fifo_t _name = TU_FIFO_INIT(_name##_buf, _depth, _type, _overwritable)
-
-
-bool tu_fifo_set_overwritable(tu_fifo_t *f, bool overwritable);
-bool tu_fifo_clear(tu_fifo_t *f);
-bool tu_fifo_config(tu_fifo_t *f, void* buffer, uint16_t depth, uint16_t item_size, bool overwritable);
-
-#if CFG_FIFO_MUTEX
-TU_ATTR_ALWAYS_INLINE static inline
-void tu_fifo_config_mutex(tu_fifo_t *f, tu_fifo_mutex_t write_mutex_hdl, tu_fifo_mutex_t read_mutex_hdl)
-{
- f->mutex_wr = write_mutex_hdl;
- f->mutex_rd = read_mutex_hdl;
-}
-#endif
-
-bool tu_fifo_write (tu_fifo_t* f, void const * p_data);
-uint16_t tu_fifo_write_n (tu_fifo_t* f, void const * p_data, uint16_t n);
-uint16_t tu_fifo_write_n_const_addr_full_words (tu_fifo_t* f, const void * data, uint16_t n);
-
-bool tu_fifo_read (tu_fifo_t* f, void * p_buffer);
-uint16_t tu_fifo_read_n (tu_fifo_t* f, void * p_buffer, uint16_t n);
-uint16_t tu_fifo_read_n_const_addr_full_words (tu_fifo_t* f, void * buffer, uint16_t n);
-
-bool tu_fifo_peek (tu_fifo_t* f, void * p_buffer);
-uint16_t tu_fifo_peek_n (tu_fifo_t* f, void * p_buffer, uint16_t n);
-
-uint16_t tu_fifo_count (tu_fifo_t* f);
-uint16_t tu_fifo_remaining (tu_fifo_t* f);
-bool tu_fifo_empty (tu_fifo_t* f);
-bool tu_fifo_full (tu_fifo_t* f);
-bool tu_fifo_overflowed (tu_fifo_t* f);
-void tu_fifo_correct_read_pointer (tu_fifo_t* f);
-
-TU_ATTR_ALWAYS_INLINE static inline
-uint16_t tu_fifo_depth(tu_fifo_t* f)
-{
- return f->depth;
-}
-
-// Pointer modifications intended to be used in combinations with DMAs.
-// USE WITH CARE - NO SAFTY CHECKS CONDUCTED HERE! NOT MUTEX PROTECTED!
-void tu_fifo_advance_write_pointer(tu_fifo_t *f, uint16_t n);
-void tu_fifo_advance_read_pointer (tu_fifo_t *f, uint16_t n);
-
-// If you want to read/write from/to the FIFO by use of a DMA, you may need to conduct two copies
-// to handle a possible wrapping part. These functions deliver a pointer to start
-// reading/writing from/to and a valid linear length along which no wrap occurs.
-void tu_fifo_get_read_info (tu_fifo_t *f, tu_fifo_buffer_info_t *info);
-void tu_fifo_get_write_info(tu_fifo_t *f, tu_fifo_buffer_info_t *info);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _TUSB_FIFO_H_ */
diff --git a/tinyusb/src/common/tusb_timeout.h b/tinyusb/src/common/tusb_timeout.h
deleted file mode 100755
index ce53955f..00000000
--- a/tinyusb/src/common/tusb_timeout.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * The MIT License (MIT)
- *
- * Copyright (c) 2019 Ha Thach (tinyusb.org)
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- * This file is part of the TinyUSB stack.
- */
-
-/** \ingroup Group_Common Common Files
- * \defgroup Group_TimeoutTimer timeout timer
- * @{ */
-
-#ifndef _TUSB_TIMEOUT_H_
-#define _TUSB_TIMEOUT_H_
-
-#include <stdbool.h>
-#include <stdint.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef struct {
- uint32_t start;
- uint32_t interval;
-}tu_timeout_t;
-
-#if 0
-
-extern uint32_t tusb_hal_millis(void);
-
-static inline void tu_timeout_set(tu_timeout_t* tt, uint32_t msec)
-{
- tt->interval = msec;
- tt->start = tusb_hal_millis();
-}
-
-static inline bool tu_timeout_expired(tu_timeout_t* tt)
-{
- return ( tusb_hal_millis() - tt->start ) >= tt->interval;
-}
-
-// For used with periodic event to prevent drift
-static inline void tu_timeout_reset(tu_timeout_t* tt)
-{
- tt->start += tt->interval;
-}
-
-static inline void tu_timeout_restart(tu_timeout_t* tt)
-{
- tt->start = tusb_hal_millis();
-}
-
-#endif
-
-#ifdef __cplusplus
- }
-#endif
-
-#endif /* _TUSB_TIMEOUT_H_ */
-
-/** @} */
diff --git a/tinyusb/src/common/tusb_types.h b/tinyusb/src/common/tusb_types.h
deleted file mode 100755
index d23c6b2d..00000000
--- a/tinyusb/src/common/tusb_types.h
+++ /dev/null
@@ -1,534 +0,0 @@
-/*
- * The MIT License (MIT)
- *
- * Copyright (c) 2019 Ha Thach (tinyusb.org)
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- * This file is part of the TinyUSB stack.
- */
-
-/** \ingroup group_usb_definitions
- * \defgroup USBDef_Type USB Types
- * @{ */
-
-#ifndef _TUSB_TYPES_H_
-#define _TUSB_TYPES_H_
-
-#include <stdbool.h>
-#include <stdint.h>
-#include "tusb_compiler.h"
-
-#ifdef __cplusplus
- extern "C" {
-#endif
-
-/*------------------------------------------------------------------*/
-/* CONSTANTS
- *------------------------------------------------------------------*/
-
-/// defined base on EHCI specs value for Endpoint Speed
-typedef enum
-{
- TUSB_SPEED_FULL = 0,
- TUSB_SPEED_LOW ,
- TUSB_SPEED_HIGH,
- TUSB_SPEED_INVALID = 0xff,
-}tusb_speed_t;
-
-/// defined base on USB Specs Endpoint's bmAttributes
-typedef enum
-{
- TUSB_XFER_CONTROL = 0 ,
- TUSB_XFER_ISOCHRONOUS ,
- TUSB_XFER_BULK ,
- TUSB_XFER_INTERRUPT
-}tusb_xfer_type_t;
-
-typedef enum
-{
- TUSB_DIR_OUT = 0,
- TUSB_DIR_IN = 1,
-
- TUSB_DIR_IN_MASK = 0x80
-}tusb_dir_t;
-
-/// USB Descriptor Types
-typedef enum
-{
- TUSB_DESC_DEVICE = 0x01,
- TUSB_DESC_CONFIGURATION = 0x02,
- TUSB_DESC_STRING = 0x03,
- TUSB_DESC_INTERFACE = 0x04,
- TUSB_DESC_ENDPOINT = 0x05,
- TUSB_DESC_DEVICE_QUALIFIER = 0x06,
- TUSB_DESC_OTHER_SPEED_CONFIG = 0x07,
- TUSB_DESC_INTERFACE_POWER = 0x08,
- TUSB_DESC_OTG = 0x09,
- TUSB_DESC_DEBUG = 0x0A,
- TUSB_DESC_INTERFACE_ASSOCIATION = 0x0B,
-
- TUSB_DESC_BOS = 0x0F,
- TUSB_DESC_DEVICE_CAPABILITY = 0x10,
-
- TUSB_DESC_FUNCTIONAL = 0x21,
-
- // Class Specific Descriptor
- TUSB_DESC_CS_DEVICE = 0x21,
- TUSB_DESC_CS_CONFIGURATION = 0x22,
- TUSB_DESC_CS_STRING = 0x23,
- TUSB_DESC_CS_INTERFACE = 0x24,
- TUSB_DESC_CS_ENDPOINT = 0x25,
-
- TUSB_DESC_SUPERSPEED_ENDPOINT_COMPANION = 0x30,
- TUSB_DESC_SUPERSPEED_ISO_ENDPOINT_COMPANION = 0x31
-}tusb_desc_type_t;
-
-typedef enum
-{
- TUSB_REQ_GET_STATUS = 0 ,
- TUSB_REQ_CLEAR_FEATURE = 1 ,
- TUSB_REQ_RESERVED = 2 ,
- TUSB_REQ_SET_FEATURE = 3 ,
- TUSB_REQ_RESERVED2 = 4 ,
- TUSB_REQ_SET_ADDRESS = 5 ,
- TUSB_REQ_GET_DESCRIPTOR = 6 ,
- TUSB_REQ_SET_DESCRIPTOR = 7 ,
- TUSB_REQ_GET_CONFIGURATION = 8 ,
- TUSB_REQ_SET_CONFIGURATION = 9 ,
- TUSB_REQ_GET_INTERFACE = 10 ,
- TUSB_REQ_SET_INTERFACE = 11 ,
- TUSB_REQ_SYNCH_FRAME = 12
-}tusb_request_code_t;
-
-typedef enum
-{
- TUSB_REQ_FEATURE_EDPT_HALT = 0,
- TUSB_REQ_FEATURE_REMOTE_WAKEUP = 1,
- TUSB_REQ_FEATURE_TEST_MODE = 2
-}tusb_request_feature_selector_t;
-
-typedef enum
-{
- TUSB_REQ_TYPE_STANDARD = 0,
- TUSB_REQ_TYPE_CLASS,
- TUSB_REQ_TYPE_VENDOR,
- TUSB_REQ_TYPE_INVALID
-} tusb_request_type_t;
-
-typedef enum
-{
- TUSB_REQ_RCPT_DEVICE =0,
- TUSB_REQ_RCPT_INTERFACE,
- TUSB_REQ_RCPT_ENDPOINT,
- TUSB_REQ_RCPT_OTHER
-} tusb_request_recipient_t;
-
-// https://www.usb.org/defined-class-codes
-typedef enum
-{
- TUSB_CLASS_UNSPECIFIED = 0 ,
- TUSB_CLASS_AUDIO = 1 ,
- TUSB_CLASS_CDC = 2 ,
- TUSB_CLASS_HID = 3 ,
- TUSB_CLASS_RESERVED_4 = 4 ,
- TUSB_CLASS_PHYSICAL = 5 ,
- TUSB_CLASS_IMAGE = 6 ,
- TUSB_CLASS_PRINTER = 7 ,
- TUSB_CLASS_MSC = 8 ,
- TUSB_CLASS_HUB = 9 ,
- TUSB_CLASS_CDC_DATA = 10 ,
- TUSB_CLASS_SMART_CARD = 11 ,
- TUSB_CLASS_RESERVED_12 = 12 ,
- TUSB_CLASS_CONTENT_SECURITY = 13 ,
- TUSB_CLASS_VIDEO = 14 ,
- TUSB_CLASS_PERSONAL_HEALTHCARE = 15 ,
- TUSB_CLASS_AUDIO_VIDEO = 16 ,
-
- TUSB_CLASS_DIAGNOSTIC = 0xDC ,
- TUSB_CLASS_WIRELESS_CONTROLLER = 0xE0 ,
- TUSB_CLASS_MISC = 0xEF ,
- TUSB_CLASS_APPLICATION_SPECIFIC = 0xFE ,
- TUSB_CLASS_VENDOR_SPECIFIC = 0xFF
-}tusb_class_code_t;
-
-typedef enum
-{
- MISC_SUBCLASS_COMMON = 2
-}misc_subclass_type_t;
-
-typedef enum
-{
- MISC_PROTOCOL_IAD = 1
-}misc_protocol_type_t;
-
-typedef enum
-{
- APP_SUBCLASS_USBTMC = 0x03,
- APP_SUBCLASS_DFU_RUNTIME = 0x01
-} app_subclass_type_t;
-
-typedef enum
-{
- DEVICE_CAPABILITY_WIRELESS_USB = 0x01,
- DEVICE_CAPABILITY_USB20_EXTENSION = 0x02,
- DEVICE_CAPABILITY_SUPERSPEED_USB = 0x03,
- DEVICE_CAPABILITY_CONTAINER_id = 0x04,
- DEVICE_CAPABILITY_PLATFORM = 0x05,
- DEVICE_CAPABILITY_POWER_DELIVERY = 0x06,
- DEVICE_CAPABILITY_BATTERY_INFO = 0x07,
- DEVICE_CAPABILITY_PD_CONSUMER_PORT = 0x08,
- DEVICE_CAPABILITY_PD_PROVIDER_PORT = 0x09,
- DEVICE_CAPABILITY_SUPERSPEED_PLUS = 0x0A,
- DEVICE_CAPABILITY_PRECESION_TIME_MEASUREMENT = 0x0B,
- DEVICE_CAPABILITY_WIRELESS_USB_EXT = 0x0C,
- DEVICE_CAPABILITY_BILLBOARD = 0x0D,
- DEVICE_CAPABILITY_AUTHENTICATION = 0x0E,
- DEVICE_CAPABILITY_BILLBOARD_EX = 0x0F,
- DEVICE_CAPABILITY_CONFIGURATION_SUMMARY = 0x10
-}device_capability_type_t;
-
-enum {
- TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP = TU_BIT(5),
- TUSB_DESC_CONFIG_ATT_SELF_POWERED = TU_BIT(6),
-};
-
-#define TUSB_DESC_CONFIG_POWER_MA(x) ((x)/2)
-
-/// Device State TODO remove
-typedef enum
-{
- TUSB_DEVICE_STATE_UNPLUG = 0 ,
- TUSB_DEVICE_STATE_CONFIGURED ,
- TUSB_DEVICE_STATE_SUSPENDED ,
-}tusb_device_state_t;
-
-typedef enum
-{
- XFER_RESULT_SUCCESS,
- XFER_RESULT_FAILED,
- XFER_RESULT_STALLED,
-}xfer_result_t;
-
-enum // TODO remove
-{
- DESC_OFFSET_LEN = 0,
- DESC_OFFSET_TYPE = 1
-};
-
-enum
-{
- INTERFACE_INVALID_NUMBER = 0xff
-};
-
-
-typedef enum
-{
- MS_OS_20_SET_HEADER_DESCRIPTOR = 0x00,
- MS_OS_20_SUBSET_HEADER_CONFIGURATION = 0x01,
- MS_OS_20_SUBSET_HEADER_FUNCTION = 0x02,
- MS_OS_20_FEATURE_COMPATBLE_ID = 0x03,
- MS_OS_20_FEATURE_REG_PROPERTY = 0x04,
- MS_OS_20_FEATURE_MIN_RESUME_TIME = 0x05,
- MS_OS_20_FEATURE_MODEL_ID = 0x06,
- MS_OS_20_FEATURE_CCGP_DEVICE = 0x07,
- MS_OS_20_FEATURE_VENDOR_REVISION = 0x08
-} microsoft_os_20_type_t;
-
-enum
-{
- CONTROL_STAGE_SETUP,
- CONTROL_STAGE_DATA,
- CONTROL_STAGE_ACK
-};
-
-//--------------------------------------------------------------------+
-// USB Descriptors
-//--------------------------------------------------------------------+
-
-// Start of all packed definitions for compiler without per-type packed
-TU_ATTR_PACKED_BEGIN
-TU_ATTR_BIT_FIELD_ORDER_BEGIN
-
-/// USB Device Descriptor
-typedef struct TU_ATTR_PACKED
-{
- uint8_t bLength ; ///< Size of this descriptor in bytes.
- uint8_t bDescriptorType ; ///< DEVICE Descriptor Type.
- uint16_t bcdUSB ; ///< BUSB Specification Release Number in Binary-Coded Decimal (i.e., 2.10 is 210H). This field identifies the release of the USB Specification with which the device and its descriptors are compliant.
-
- uint8_t bDeviceClass ; ///< Class code (assigned by the USB-IF). \li If this field is reset to zero, each interface within a configuration specifies its own class information and the various interfaces operate independently. \li If this field is set to a value between 1 and FEH, the device supports different class specifications on different interfaces and the interfaces may not operate independently. This value identifies the class definition used for the aggregate interfaces. \li If this field is set to FFH, the device class is vendor-specific.
- uint8_t bDeviceSubClass ; ///< Subclass code (assigned by the USB-IF). These codes are qualified by the value of the bDeviceClass field. \li If the bDeviceClass field is reset to zero, this field must also be reset to zero. \li If the bDeviceClass field is not set to FFH, all values are reserved for assignment by the USB-IF.
- uint8_t bDeviceProtocol ; ///< Protocol code (assigned by the USB-IF). These codes are qualified by the value of the bDeviceClass and the bDeviceSubClass fields. If a device supports class-specific protocols on a device basis as opposed to an interface basis, this code identifies the protocols that the device uses as defined by the specification of the device class. \li If this field is reset to zero, the device does not use class-specific protocols on a device basis. However, it may use classspecific protocols on an interface basis. \li If this field is set to FFH, the device uses a vendor-specific protocol on a device basis.
- uint8_t bMaxPacketSize0 ; ///< Maximum packet size for endpoint zero (only 8, 16, 32, or 64 are valid). For HS devices is fixed to 64.
-
- uint16_t idVendor ; ///< Vendor ID (assigned by the USB-IF).
- uint16_t idProduct ; ///< Product ID (assigned by the manufacturer).
- uint16_t bcdDevice ; ///< Device release number in binary-coded decimal.
- uint8_t iManufacturer ; ///< Index of string descriptor describing manufacturer.
- uint8_t iProduct ; ///< Index of string descriptor describing product.
- uint8_t iSerialNumber ; ///< Index of string descriptor describing the device's serial number.
-
- uint8_t bNumConfigurations ; ///< Number of possible configurations.
-} tusb_desc_device_t;
-
-TU_VERIFY_STATIC( sizeof(tusb_desc_device_t) == 18, "size is not correct");
-
-// USB Binary Device Object Store (BOS) Descriptor
-typedef struct TU_ATTR_PACKED
-{
- uint8_t bLength ; ///< Size of this descriptor in bytes
- uint8_t bDescriptorType ; ///< CONFIGURATION Descriptor Type
- uint16_t wTotalLength ; ///< Total length of data returned for this descriptor
- uint8_t bNumDeviceCaps ; ///< Number of device capability descriptors in the BOS
-} tusb_desc_bos_t;
-
-TU_VERIFY_STATIC( sizeof(tusb_desc_bos_t) == 5, "size is not correct");
-
-/// USB Configuration Descriptor
-typedef struct TU_ATTR_PACKED
-{
- uint8_t bLength ; ///< Size of this descriptor in bytes
- uint8_t bDescriptorType ; ///< CONFIGURATION Descriptor Type
- uint16_t wTotalLength ; ///< Total length of data returned for this configuration. Includes the combined length of all descriptors (configuration, interface, endpoint, and class- or vendor-specific) returned for this configuration.
-
- uint8_t bNumInterfaces ; ///< Number of interfaces supported by this configuration
- uint8_t bConfigurationValue ; ///< Value to use as an argument to the SetConfiguration() request to select this configuration.
- uint8_t iConfiguration ; ///< Index of string descriptor describing this configuration
- uint8_t bmAttributes ; ///< Configuration characteristics \n D7: Reserved (set to one)\n D6: Self-powered \n D5: Remote Wakeup \n D4...0: Reserved (reset to zero) \n D7 is reserved and must be set to one for historical reasons. \n A device configuration that uses power from the bus and a local source reports a non-zero value in bMaxPower to indicate the amount of bus power required and sets D6. The actual power source at runtime may be determined using the GetStatus(DEVICE) request (see USB 2.0 spec Section 9.4.5). \n If a device configuration supports remote wakeup, D5 is set to one.
- uint8_t bMaxPower ; ///< Maximum power consumption of the USB device from the bus in this specific configuration when the device is fully operational. Expressed in 2 mA units (i.e., 50 = 100 mA).
-} tusb_desc_configuration_t;
-
-TU_VERIFY_STATIC( sizeof(tusb_desc_configuration_t) == 9, "size is not correct");
-
-/// USB Interface Descriptor
-typedef struct TU_ATTR_PACKED
-{
- uint8_t bLength ; ///< Size of this descriptor in bytes
- uint8_t bDescriptorType ; ///< INTERFACE Descriptor Type
-
- uint8_t bInterfaceNumber ; ///< Number of this interface. Zero-based value identifying the index in the array of concurrent interfaces supported by this configuration.
- uint8_t bAlternateSetting ; ///< Value used to select this alternate setting for the interface identified in the prior field
- uint8_t bNumEndpoints ; ///< Number of endpoints used by this interface (excluding endpoint zero). If this value is zero, this interface only uses the Default Control Pipe.
- uint8_t bInterfaceClass ; ///< Class code (assigned by the USB-IF). \li A value of zero is reserved for future standardization. \li If this field is set to FFH, the interface class is vendor-specific. \li All other values are reserved for assignment by the USB-IF.
- uint8_t bInterfaceSubClass ; ///< Subclass code (assigned by the USB-IF). \n These codes are qualified by the value of the bInterfaceClass field. \li If the bInterfaceClass field is reset to zero, this field must also be reset to zero. \li If the bInterfaceClass field is not set to FFH, all values are reserved for assignment by the USB-IF.
- uint8_t bInterfaceProtocol ; ///< Protocol code (assigned by the USB). \n These codes are qualified by the value of the bInterfaceClass and the bInterfaceSubClass fields. If an interface supports class-specific requests, this code identifies the protocols that the device uses as defined by the specification of the device class. \li If this field is reset to zero, the device does not use a class-specific protocol on this interface. \li If this field is set to FFH, the device uses a vendor-specific protocol for this interface.
- uint8_t iInterface ; ///< Index of string descriptor describing this interface
-} tusb_desc_interface_t;
-
-TU_VERIFY_STATIC( sizeof(tusb_desc_interface_t) == 9, "size is not correct");
-
-/// USB Endpoint Descriptor
-typedef struct TU_ATTR_PACKED
-{
- uint8_t bLength ; ///< Size of this descriptor in bytes
- uint8_t bDescriptorType ; ///< ENDPOINT Descriptor Type
-
- uint8_t bEndpointAddress ; ///< The address of the endpoint on the USB device described by this descriptor. The address is encoded as follows: \n Bit 3...0: The endpoint number \n Bit 6...4: Reserved, reset to zero \n Bit 7: Direction, ignored for control endpoints 0 = OUT endpoint 1 = IN endpoint.
-
- struct TU_ATTR_PACKED {
- uint8_t xfer : 2;
- uint8_t sync : 2;
- uint8_t usage : 2;
- uint8_t : 2;
- } bmAttributes ; ///< This field describes the endpoint's attributes when it is configured using the bConfigurationValue. \n Bits 1..0: Transfer Type \n- 00 = Control \n- 01 = Isochronous \n- 10 = Bulk \n- 11 = Interrupt \n If not an isochronous endpoint, bits 5..2 are reserved and must be set to zero. If isochronous, they are defined as follows: \n Bits 3..2: Synchronization Type \n- 00 = No Synchronization \n- 01 = Asynchronous \n- 10 = Adaptive \n- 11 = Synchronous \n Bits 5..4: Usage Type \n- 00 = Data endpoint \n- 01 = Feedback endpoint \n- 10 = Implicit feedback Data endpoint \n- 11 = Reserved \n Refer to Chapter 5 of USB 2.0 specification for more information. \n All other bits are reserved and must be reset to zero. Reserved bits must be ignored by the host.
-
- struct TU_ATTR_PACKED {
-#if defined(__CCRX__)
- //FIXME the original defined bit field has a problem with the CCRX toolchain, so only a size field is defined
- uint16_t size;
-#else
- uint16_t size : 11; ///< Maximum packet size this endpoint is capable of sending or receiving when this configuration is selected. \n For isochronous endpoints, this value is used to reserve the bus time in the schedule, required for the per-(micro)frame data payloads. The pipe may, on an ongoing basis, actually use less bandwidth than that reserved. The device reports, if necessary, the actual bandwidth used via its normal, non-USB defined mechanisms. \n For all endpoints, bits 10..0 specify the maximum packet size (in bytes). \n For high-speed isochronous and interrupt endpoints: \n Bits 12..11 specify the number of additional transaction opportunities per microframe: \n- 00 = None (1 transaction per microframe) \n- 01 = 1 additional (2 per microframe) \n- 10 = 2 additional (3 per microframe) \n- 11 = Reserved \n Bits 15..13 are reserved and must be set to zero.
- uint16_t hs_period_mult : 2;
- uint16_t TU_RESERVED : 3;
-#endif
- }wMaxPacketSize;
-
- uint8_t bInterval ; ///< Interval for polling endpoint for data transfers. Expressed in frames or microframes depending on the device operating speed (i.e., either 1 millisecond or 125 us units). \n- For full-/high-speed isochronous endpoints, this value must be in the range from 1 to 16. The bInterval value is used as the exponent for a \f$ 2^(bInterval-1) \f$ value; e.g., a bInterval of 4 means a period of 8 (\f$ 2^(4-1) \f$). \n- For full-/low-speed interrupt endpoints, the value of this field may be from 1 to 255. \n- For high-speed interrupt endpoints, the bInterval value is used as the exponent for a \f$ 2^(bInterval-1) \f$ value; e.g., a bInterval of 4 means a period of 8 (\f$ 2^(4-1) \f$) . This value must be from 1 to 16. \n- For high-speed bulk/control OUT endpoints, the bInterval must specify the maximum NAK rate of the endpoint. A value of 0 indicates the endpoint never NAKs. Other values indicate at most 1 NAK each bInterval number of microframes. This value must be in the range from 0 to 255. \n Refer to Chapter 5 of USB 2.0 specification for more information.
-} tusb_desc_endpoint_t;
-
-/// USB Other Speed Configuration Descriptor
-typedef struct TU_ATTR_PACKED
-{
- uint8_t bLength ; ///< Size of descriptor
- uint8_t bDescriptorType ; ///< Other_speed_Configuration Type
- uint16_t wTotalLength ; ///< Total length of data returned
-
- uint8_t bNumInterfaces ; ///< Number of interfaces supported by this speed configuration
- uint8_t bConfigurationValue ; ///< Value to use to select configuration
- uint8_t IConfiguration ; ///< Index of string descriptor
- uint8_t bmAttributes ; ///< Same as Configuration descriptor
- uint8_t bMaxPower ; ///< Same as Configuration descriptor
-} tusb_desc_other_speed_t;
-
-/// USB Device Qualifier Descriptor
-typedef struct TU_ATTR_PACKED
-{
- uint8_t bLength ; ///< Size of descriptor
- uint8_t bDescriptorType ; ///< Device Qualifier Type
- uint16_t bcdUSB ; ///< USB specification version number (e.g., 0200H for V2.00)
-
- uint8_t bDeviceClass ; ///< Class Code
- uint8_t bDeviceSubClass ; ///< SubClass Code
- uint8_t bDeviceProtocol ; ///< Protocol Code
- uint8_t bMaxPacketSize0 ; ///< Maximum packet size for other speed
- uint8_t bNumConfigurations ; ///< Number of Other-speed Configurations
- uint8_t bReserved ; ///< Reserved for future use, must be zero
-} tusb_desc_device_qualifier_t;
-
-/// USB Interface Association Descriptor (IAD ECN)
-typedef struct TU_ATTR_PACKED
-{
- uint8_t bLength ; ///< Size of descriptor
- uint8_t bDescriptorType ; ///< Other_speed_Configuration Type
-
- uint8_t bFirstInterface ; ///< Index of the first associated interface.
- uint8_t bInterfaceCount ; ///< Total number of associated interfaces.
-
- uint8_t bFunctionClass ; ///< Interface class ID.
- uint8_t bFunctionSubClass ; ///< Interface subclass ID.
- uint8_t bFunctionProtocol ; ///< Interface protocol ID.
-
- uint8_t iFunction ; ///< Index of the string descriptor describing the interface association.
-} tusb_desc_interface_assoc_t;
-
-// USB String Descriptor
-typedef struct TU_ATTR_PACKED
-{
- uint8_t bLength ; ///< Size of this descriptor in bytes
- uint8_t bDescriptorType ; ///< Descriptor Type
- uint16_t unicode_string[];
-} tusb_desc_string_t;
-
-// USB Binary Device Object Store (BOS)
-typedef struct TU_ATTR_PACKED
-{
- uint8_t bLength;
- uint8_t bDescriptorType ;
- uint8_t bDevCapabilityType;
- uint8_t bReserved;
- uint8_t PlatformCapabilityUUID[16];
- uint8_t CapabilityData[];
-} tusb_desc_bos_platform_t;
-
-// USB WebuSB URL Descriptor
-typedef struct TU_ATTR_PACKED
-{
- uint8_t bLength;
- uint8_t bDescriptorType;
- uint8_t bScheme;
- char url[];
-} tusb_desc_webusb_url_t;
-
-// DFU Functional Descriptor
-typedef struct TU_ATTR_PACKED
-{
- uint8_t bLength;
- uint8_t bDescriptorType;
-
- union {
- struct TU_ATTR_PACKED {
- uint8_t bitCanDnload : 1;
- uint8_t bitCanUpload : 1;
- uint8_t bitManifestationTolerant : 1;
- uint8_t bitWillDetach : 1;
- uint8_t reserved : 4;
- } bmAttributes;
-
- uint8_t bAttributes;
- };
-
- uint16_t wDetachTimeOut;
- uint16_t wTransferSize;
- uint16_t bcdDFUVersion;
-} tusb_desc_dfu_functional_t;
-
-/*------------------------------------------------------------------*/
-/* Types
- *------------------------------------------------------------------*/
-typedef struct TU_ATTR_PACKED{
- union {
- struct TU_ATTR_PACKED {
- uint8_t recipient : 5; ///< Recipient type tusb_request_recipient_t.
- uint8_t type : 2; ///< Request type tusb_request_type_t.
- uint8_t direction : 1; ///< Direction type. tusb_dir_t
- } bmRequestType_bit;
-
- uint8_t bmRequestType;
- };
-
- uint8_t bRequest;
- uint16_t wValue;
- uint16_t wIndex;
- uint16_t wLength;
-} tusb_control_request_t;
-
-TU_VERIFY_STATIC( sizeof(tusb_control_request_t) == 8, "size is not correct");
-
-
-TU_ATTR_PACKED_END // End of all packed definitions
-TU_ATTR_BIT_FIELD_ORDER_END
-
-//--------------------------------------------------------------------+
-// Endpoint helper
-//--------------------------------------------------------------------+
-
-// Get direction from Endpoint address
-static inline tusb_dir_t tu_edpt_dir(uint8_t addr)
-{
- return (addr & TUSB_DIR_IN_MASK) ? TUSB_DIR_IN : TUSB_DIR_OUT;
-}
-
-// Get Endpoint number from address
-static inline uint8_t tu_edpt_number(uint8_t addr)
-{
- return (uint8_t)(addr & (~TUSB_DIR_IN_MASK));
-}
-
-static inline uint8_t tu_edpt_addr(uint8_t num, uint8_t dir)
-{
- return (uint8_t)(num | (dir ? TUSB_DIR_IN_MASK : 0));
-}
-
-//--------------------------------------------------------------------+
-// Descriptor helper
-//--------------------------------------------------------------------+
-static inline uint8_t const * tu_desc_next(void const* desc)
-{
- uint8_t const* desc8 = (uint8_t const*) desc;
- return desc8 + desc8[DESC_OFFSET_LEN];
-}
-
-static inline uint8_t tu_desc_type(void const* desc)
-{
- return ((uint8_t const*) desc)[DESC_OFFSET_TYPE];
-}
-
-static inline uint8_t tu_desc_len(void const* desc)
-{
- return ((uint8_t const*) desc)[DESC_OFFSET_LEN];
-}
-
-#ifdef __cplusplus
- }
-#endif
-
-#endif /* _TUSB_TYPES_H_ */
-
-/** @} */
diff --git a/tinyusb/src/common/tusb_verify.h b/tinyusb/src/common/tusb_verify.h
deleted file mode 100755
index 56ba8bcd..00000000
--- a/tinyusb/src/common/tusb_verify.h
+++ /dev/null
@@ -1,181 +0,0 @@
-/*
- * The MIT License (MIT)
- *
- * Copyright (c) 2019 Ha Thach (tinyusb.org)
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- * This file is part of the TinyUSB stack.
- */
-#ifndef TUSB_VERIFY_H_
-#define TUSB_VERIFY_H_
-
-#include <stdbool.h>
-#include <stdint.h>
-#include "tusb_option.h"
-#include "tusb_compiler.h"
-
-/*------------------------------------------------------------------*/
-/* This file use an advanced macro technique to mimic the default parameter
- * as C++ for the sake of code simplicity. Beware of a headache macro
- * manipulation that you are told to stay away.
- *
- * This contains macros for both VERIFY and ASSERT:
- *
- * VERIFY: Used when there is an error condition which is not the
- * fault of the MCU. For example, bounds checking on data
- * sent to the micro over USB should use this function.
- * Another example is checking for buffer overflows, where
- * returning from the active function causes a NAK.
- *
- * ASSERT: Used for error conditions that are caused by MCU firmware
- * bugs. This is used to discover bugs in the code more
- * quickly. One example would be adding assertions in library
- * function calls to confirm a function's (untainted)
- * parameters are valid.
- *
- * The difference in behavior is that ASSERT triggers a breakpoint while
- * verify does not.
- *
- * #define TU_VERIFY(cond) if(cond) return false;
- * #define TU_VERIFY(cond,ret) if(cond) return ret;
- *
- * #define TU_VERIFY_HDLR(cond,handler) if(cond) {handler; return false;}
- * #define TU_VERIFY_HDLR(cond,ret,handler) if(cond) {handler; return ret;}
- *
- * #define TU_ASSERT(cond) if(cond) {_MESS_FAILED(); TU_BREAKPOINT(), return false;}
- * #define TU_ASSERT(cond,ret) if(cond) {_MESS_FAILED(); TU_BREAKPOINT(), return ret;}
- *
- *------------------------------------------------------------------*/
-
-#ifdef __cplusplus
- extern "C" {
-#endif
-
-//--------------------------------------------------------------------+
-// TU_VERIFY Helper
-//--------------------------------------------------------------------+
-
-#if CFG_TUSB_DEBUG
- #include <stdio.h>
- #define _MESS_ERR(_err) tu_printf("%s %d: failed, error = %s\r\n", __func__, __LINE__, tusb_strerr[_err])
- #define _MESS_FAILED() tu_printf("%s %d: ASSERT FAILED\r\n", __func__, __LINE__)
-#else
- #define _MESS_ERR(_err) do {} while (0)
- #define _MESS_FAILED() do {} while (0)
-#endif
-
-// Halt CPU (breakpoint) when hitting error, only apply for Cortex M3, M4, M7
-#if defined(__ARM_ARCH_7M__) || defined (__ARM_ARCH_7EM__)
- #define TU_BREAKPOINT() do \
- { \
- volatile uint32_t* ARM_CM_DHCSR = ((volatile uint32_t*) 0xE000EDF0UL); /* Cortex M CoreDebug->DHCSR */ \
- if ( (*ARM_CM_DHCSR) & 1UL ) __asm("BKPT #0\n"); /* Only halt mcu if debugger is attached */ \
- } while(0)
-
-#elif defined(__riscv)
- #define TU_BREAKPOINT() do { __asm("ebreak\n"); } while(0)
-
-#else
- #define TU_BREAKPOINT() do {} while (0)
-#endif
-
-/*------------------------------------------------------------------*/
-/* Macro Generator
- *------------------------------------------------------------------*/
-
-// Helper to implement optional parameter for TU_VERIFY Macro family
-#define GET_3RD_ARG(arg1, arg2, arg3, ...) arg3
-#define GET_4TH_ARG(arg1, arg2, arg3, arg4, ...) arg4
-
-/*------------- Generator for TU_VERIFY and TU_VERIFY_HDLR -------------*/
-#define TU_VERIFY_DEFINE(_cond, _handler, _ret) do \
-{ \
- if ( !(_cond) ) { _handler; return _ret; } \
-} while(0)
-
-/*------------------------------------------------------------------*/
-/* TU_VERIFY
- * - TU_VERIFY_1ARGS : return false if failed
- * - TU_VERIFY_2ARGS : return provided value if failed
- *------------------------------------------------------------------*/
-#define TU_VERIFY_1ARGS(_cond) TU_VERIFY_DEFINE(_cond, , false)
-#define TU_VERIFY_2ARGS(_cond, _ret) TU_VERIFY_DEFINE(_cond, , _ret)
-
-#define TU_VERIFY(...) GET_3RD_ARG(__VA_ARGS__, TU_VERIFY_2ARGS, TU_VERIFY_1ARGS, UNUSED)(__VA_ARGS__)
-
-
-/*------------------------------------------------------------------*/
-/* TU_VERIFY WITH HANDLER
- * - TU_VERIFY_HDLR_2ARGS : execute handler, return false if failed
- * - TU_VERIFY_HDLR_3ARGS : execute handler, return provided error if failed
- *------------------------------------------------------------------*/
-#define TU_VERIFY_HDLR_2ARGS(_cond, _handler) TU_VERIFY_DEFINE(_cond, _handler, false)
-#define TU_VERIFY_HDLR_3ARGS(_cond, _handler, _ret) TU_VERIFY_DEFINE(_cond, _handler, _ret)
-
-#define TU_VERIFY_HDLR(...) GET_4TH_ARG(__VA_ARGS__, TU_VERIFY_HDLR_3ARGS, TU_VERIFY_HDLR_2ARGS,UNUSED)(__VA_ARGS__)
-
-/*------------------------------------------------------------------*/
-/* ASSERT
- * basically TU_VERIFY with TU_BREAKPOINT() as handler
- * - 1 arg : return false if failed
- * - 2 arg : return error if failed
- *------------------------------------------------------------------*/
-#define ASSERT_1ARGS(_cond) TU_VERIFY_DEFINE(_cond, _MESS_FAILED(); TU_BREAKPOINT(), false)
-#define ASSERT_2ARGS(_cond, _ret) TU_VERIFY_DEFINE(_cond, _MESS_FAILED(); TU_BREAKPOINT(), _ret)
-
-#ifndef TU_ASSERT
-#define TU_ASSERT(...) GET_3RD_ARG(__VA_ARGS__, ASSERT_2ARGS, ASSERT_1ARGS,UNUSED)(__VA_ARGS__)
-#endif
-
-// TODO remove TU_ASSERT_ERR() later
-
-/*------------- Generator for TU_VERIFY_ERR and TU_VERIFY_ERR_HDLR -------------*/
-#define TU_VERIFY_ERR_DEF2(_error, _handler) do \
-{ \
- uint32_t _err = (uint32_t)(_error); \
- if ( 0 != _err ) { _MESS_ERR(_err); _handler; return _err; } \
-} while(0)
-
-#define TU_VERIFY_ERR_DEF3(_error, _handler, _ret) do \
-{ \
- uint32_t _err = (uint32_t)(_error); \
- if ( 0 != _err ) { _MESS_ERR(_err); _handler; return _ret; } \
-} while(0)
-
-/*------------------------------------------------------------------*/
-/* ASSERT Error
- * basically TU_VERIFY Error with TU_BREAKPOINT() as handler
- *------------------------------------------------------------------*/
-#define ASSERT_ERR_1ARGS(_error) TU_VERIFY_ERR_DEF2(_error, TU_BREAKPOINT())
-#define ASSERT_ERR_2ARGS(_error, _ret) TU_VERIFY_ERR_DEF3(_error, TU_BREAKPOINT(), _ret)
-
-#ifndef TU_ASSERT_ERR
-#define TU_ASSERT_ERR(...) GET_3RD_ARG(__VA_ARGS__, ASSERT_ERR_2ARGS, ASSERT_ERR_1ARGS,UNUSED)(__VA_ARGS__)
-#endif
-
-/*------------------------------------------------------------------*/
-/* ASSERT HDLR
- *------------------------------------------------------------------*/
-
-#ifdef __cplusplus
- }
-#endif
-
-#endif /* TUSB_VERIFY_H_ */