forked from espressif/arduino-esp32
IDF release/v4.4 6a7d83af19
* Update toolchain to 2021r2 (#5828) * Update C3 libs to support only ECO3 and newer
This commit is contained in:
@ -111,6 +111,9 @@ TU_ATTR_ALWAYS_INLINE static inline uint8_t tu_u32_byte2(uint32_t ui32) { return
|
||||
TU_ATTR_ALWAYS_INLINE static inline uint8_t tu_u32_byte1(uint32_t ui32) { return TU_U32_BYTE1(ui32); }
|
||||
TU_ATTR_ALWAYS_INLINE static inline uint8_t tu_u32_byte0(uint32_t ui32) { return TU_U32_BYTE0(ui32); }
|
||||
|
||||
TU_ATTR_ALWAYS_INLINE static inline uint16_t tu_u32_high16(uint32_t ui32) { return (uint16_t) (ui32 >> 16); }
|
||||
TU_ATTR_ALWAYS_INLINE static inline uint16_t tu_u32_low16 (uint32_t ui32) { return (uint16_t) (ui32 & 0x0000ffffu); }
|
||||
|
||||
TU_ATTR_ALWAYS_INLINE static inline uint8_t tu_u16_high(uint16_t ui16) { return TU_U16_HIGH(ui16); }
|
||||
TU_ATTR_ALWAYS_INLINE static inline uint8_t tu_u16_low (uint16_t ui16) { return TU_U16_LOW(ui16); }
|
||||
|
||||
@ -235,37 +238,6 @@ TU_ATTR_ALWAYS_INLINE static inline void tu_unaligned_write16 (void* mem, ui
|
||||
|
||||
#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)
|
||||
@ -334,8 +306,8 @@ void tu_print_var(uint8_t const* buf, uint32_t bufsize)
|
||||
#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) )
|
||||
#define TU_LOG1_INT(_x) tu_printf(#_x " = %ld\r\n", (unsigned long) (_x) )
|
||||
#define TU_LOG1_HEX(_x) tu_printf(#_x " = %lX\r\n", (unsigned long) (_x) )
|
||||
|
||||
// Log Level 2: Warn
|
||||
#if CFG_TUSB_DEBUG >= 2
|
||||
|
@ -67,6 +67,46 @@
|
||||
#define TU_LITTLE_ENDIAN (0x12u)
|
||||
#define TU_BIG_ENDIAN (0x21u)
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* Count number of arguments of __VA_ARGS__
|
||||
* - reference https://stackoverflow.com/questions/2124339/c-preprocessor-va-args-number-of-arguments
|
||||
* - _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)
|
||||
*------------------------------------------------------------------*/
|
||||
#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
|
||||
|
||||
// Apply an macro X to each of the arguments with an separated of choice
|
||||
#define TU_ARGS_APPLY(_X, _s, ...) TU_XSTRCAT(_TU_ARGS_APPLY_, TU_ARGS_NUM(__VA_ARGS__))(_X, _s, __VA_ARGS__)
|
||||
|
||||
#define _TU_ARGS_APPLY_1(_X, _s, _a1) _X(_a1)
|
||||
#define _TU_ARGS_APPLY_2(_X, _s, _a1, _a2) _X(_a1) _s _X(_a2)
|
||||
#define _TU_ARGS_APPLY_3(_X, _s, _a1, _a2, _a3) _X(_a1) _s _TU_ARGS_APPLY_2(_X, _s, _a2, _a3)
|
||||
#define _TU_ARGS_APPLY_4(_X, _s, _a1, _a2, _a3, _a4) _X(_a1) _s _TU_ARGS_APPLY_3(_X, _s, _a2, _a3, _a4)
|
||||
#define _TU_ARGS_APPLY_5(_X, _s, _a1, _a2, _a3, _a4, _a5) _X(_a1) _s _TU_ARGS_APPLY_4(_X, _s, _a2, _a3, _a4, _a5)
|
||||
#define _TU_ARGS_APPLY_6(_X, _s, _a1, _a2, _a3, _a4, _a5, _a6) _X(_a1) _s _TU_ARGS_APPLY_5(_X, _s, _a2, _a3, _a4, _a5, _a6)
|
||||
#define _TU_ARGS_APPLY_7(_X, _s, _a1, _a2, _a3, _a4, _a5, _a6, _a7) _X(_a1) _s _TU_ARGS_APPLY_6(_X, _s, _a2, _a3, _a4, _a5, _a6, _a7)
|
||||
#define _TU_ARGS_APPLY_8(_X, _s, _a1, _a2, _a3, _a4, _a5, _a6, _a7, _a8) _X(_a1) _s _TU_ARGS_APPLY_7(_X, _s, _a2, _a3, _a4, _a5, _a6, _a7, _a8)
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Compiler porting with Attribute and Endian
|
||||
//--------------------------------------------------------------------+
|
||||
|
@ -47,8 +47,8 @@
|
||||
typedef enum
|
||||
{
|
||||
TUSB_SPEED_FULL = 0,
|
||||
TUSB_SPEED_LOW ,
|
||||
TUSB_SPEED_HIGH,
|
||||
TUSB_SPEED_LOW = 1,
|
||||
TUSB_SPEED_HIGH = 2,
|
||||
TUSB_SPEED_INVALID = 0xff,
|
||||
}tusb_speed_t;
|
||||
|
||||
|
@ -36,124 +36,155 @@
|
||||
// - PORT_HIGHSPEED: mask to indicate which port support highspeed mode, bit0 for port0 and so on.
|
||||
|
||||
//------------- NXP -------------//
|
||||
#if TU_CHECK_MCU(LPC11UXX) || TU_CHECK_MCU(LPC13XX) || TU_CHECK_MCU(LPC15XX)
|
||||
#if TU_CHECK_MCU(OPT_MCU_LPC11UXX, OPT_MCU_LPC13XX, OPT_MCU_LPC15XX)
|
||||
#define DCD_ATTR_ENDPOINT_MAX 5
|
||||
|
||||
#elif TU_CHECK_MCU(LPC175X_6X) || TU_CHECK_MCU(LPC177X_8X) || TU_CHECK_MCU(LPC40XX)
|
||||
#elif TU_CHECK_MCU(OPT_MCU_LPC175X_6X, OPT_MCU_LPC177X_8X, OPT_MCU_LPC40XX)
|
||||
#define DCD_ATTR_ENDPOINT_MAX 16
|
||||
|
||||
#elif TU_CHECK_MCU(LPC18XX) || TU_CHECK_MCU(LPC43XX)
|
||||
#elif TU_CHECK_MCU(OPT_MCU_LPC18XX, OPT_MCU_LPC43XX)
|
||||
// TODO USB0 has 6, USB1 has 4
|
||||
#define DCD_ATTR_ENDPOINT_MAX 6
|
||||
|
||||
#elif TU_CHECK_MCU(LPC51UXX)
|
||||
#elif TU_CHECK_MCU(OPT_MCU_LPC51UXX)
|
||||
#define DCD_ATTR_ENDPOINT_MAX 5
|
||||
|
||||
#elif TU_CHECK_MCU(LPC54XXX)
|
||||
#elif TU_CHECK_MCU(OPT_MCU_LPC54XXX)
|
||||
// TODO USB0 has 5, USB1 has 6
|
||||
#define DCD_ATTR_ENDPOINT_MAX 6
|
||||
|
||||
#elif TU_CHECK_MCU(LPC55XX)
|
||||
#elif TU_CHECK_MCU(OPT_MCU_LPC55XX)
|
||||
// TODO USB0 has 5, USB1 has 6
|
||||
#define DCD_ATTR_ENDPOINT_MAX 6
|
||||
|
||||
#elif TU_CHECK_MCU(MIMXRT10XX)
|
||||
#elif TU_CHECK_MCU(OPT_MCU_MIMXRT10XX)
|
||||
#define DCD_ATTR_ENDPOINT_MAX 8
|
||||
|
||||
#elif TU_CHECK_MCU(MKL25ZXX) || TU_CHECK_MCU(K32L2BXX)
|
||||
#elif TU_CHECK_MCU(OPT_MCU_MKL25ZXX, OPT_MCU_K32L2BXX)
|
||||
#define DCD_ATTR_ENDPOINT_MAX 16
|
||||
|
||||
#elif TU_CHECK_MCU(MM32F327X)
|
||||
#elif TU_CHECK_MCU(OPT_MCU_MM32F327X)
|
||||
#define DCD_ATTR_ENDPOINT_MAX 16
|
||||
|
||||
//------------- Nordic -------------//
|
||||
#elif TU_CHECK_MCU(NRF5X)
|
||||
#elif TU_CHECK_MCU(OPT_MCU_NRF5X)
|
||||
// 8 CBI + 1 ISO
|
||||
#define DCD_ATTR_ENDPOINT_MAX 9
|
||||
|
||||
//------------- Microchip -------------//
|
||||
#elif TU_CHECK_MCU(SAMD21) || TU_CHECK_MCU(SAMD51) || TU_CHECK_MCU(SAME5X) || \
|
||||
TU_CHECK_MCU(SAMD11) || TU_CHECK_MCU(SAML21) || TU_CHECK_MCU(SAML22)
|
||||
#elif TU_CHECK_MCU(OPT_MCU_SAMD21, OPT_MCU_SAMD51, OPT_MCU_SAME5X) || \
|
||||
TU_CHECK_MCU(OPT_MCU_SAMD11, OPT_MCU_SAML21, OPT_MCU_SAML22)
|
||||
#define DCD_ATTR_ENDPOINT_MAX 8
|
||||
|
||||
#elif TU_CHECK_MCU(SAMG)
|
||||
#elif TU_CHECK_MCU(OPT_MCU_SAMG)
|
||||
#define DCD_ATTR_ENDPOINT_MAX 6
|
||||
#define DCD_ATTR_ENDPOINT_EXCLUSIVE_NUMBER
|
||||
|
||||
#elif TU_CHECK_MCU(SAMX7X)
|
||||
#elif TU_CHECK_MCU(OPT_MCU_SAMX7X)
|
||||
#define DCD_ATTR_ENDPOINT_MAX 10
|
||||
#define DCD_ATTR_ENDPOINT_EXCLUSIVE_NUMBER
|
||||
|
||||
//------------- ST -------------//
|
||||
#elif TU_CHECK_MCU(STM32F0) || TU_CHECK_MCU(STM32F1) || TU_CHECK_MCU(STM32F3) || \
|
||||
TU_CHECK_MCU(STM32L0) || TU_CHECK_MCU(STM32L1) || TU_CHECK_MCU(STM32L4)
|
||||
// F1: F102, F103
|
||||
// L4: L4x2, L4x3
|
||||
#elif TU_CHECK_MCU(OPT_MCU_STM32F0)
|
||||
#define DCD_ATTR_ENDPOINT_MAX 8
|
||||
|
||||
#elif TU_CHECK_MCU(STM32F2) || TU_CHECK_MCU(STM32F4) || TU_CHECK_MCU(STM32F3)
|
||||
// F1: F105, F107 only has 4
|
||||
// L4: L4x5, L4x6 has 6
|
||||
// For most mcu, FS has 4, HS has 6
|
||||
#define DCD_ATTR_ENDPOINT_MAX 6
|
||||
#elif TU_CHECK_MCU(OPT_MCU_STM32F1)
|
||||
#if defined (STM32F105x8) || defined (STM32F105xB) || defined (STM32F105xC) || \
|
||||
defined (STM32F107xB) || defined (STM32F107xC)
|
||||
#define DCD_ATTR_ENDPOINT_MAX 4
|
||||
#define DCD_ATTR_DWC2_STM32
|
||||
#else
|
||||
#define DCD_ATTR_ENDPOINT_MAX 8
|
||||
#endif
|
||||
|
||||
#elif TU_CHECK_MCU(STM32F7)
|
||||
#elif TU_CHECK_MCU(OPT_MCU_STM32F2)
|
||||
// FS has 4 ep, HS has 5 ep
|
||||
#define DCD_ATTR_ENDPOINT_MAX 6
|
||||
#define DCD_ATTR_DWC2_STM32
|
||||
|
||||
#elif TU_CHECK_MCU(OPT_MCU_STM32F3)
|
||||
#define DCD_ATTR_ENDPOINT_MAX 8
|
||||
|
||||
#elif TU_CHECK_MCU(OPT_MCU_STM32F4)
|
||||
// For most mcu, FS has 4, HS has 6. TODO 446/469/479 HS has 9
|
||||
#define DCD_ATTR_ENDPOINT_MAX 6
|
||||
#define DCD_ATTR_DWC2_STM32
|
||||
|
||||
#elif TU_CHECK_MCU(OPT_MCU_STM32F7)
|
||||
// FS has 6, HS has 9
|
||||
#define DCD_ATTR_ENDPOINT_MAX 9
|
||||
#define DCD_ATTR_DWC2_STM32
|
||||
|
||||
#elif TU_CHECK_MCU(STM32H7)
|
||||
#elif TU_CHECK_MCU(OPT_MCU_STM32H7)
|
||||
#define DCD_ATTR_ENDPOINT_MAX 9
|
||||
#define DCD_ATTR_DWC2_STM32
|
||||
|
||||
#elif TU_CHECK_MCU(OPT_MCU_STM32L0, OPT_MCU_STM32L1)
|
||||
#define DCD_ATTR_ENDPOINT_MAX 8
|
||||
|
||||
#elif TU_CHECK_MCU(OPT_MCU_STM32L4)
|
||||
#if defined (STM32L475xx) || defined (STM32L476xx) || \
|
||||
defined (STM32L485xx) || defined (STM32L486xx) || defined (STM32L496xx) || \
|
||||
defined (STM32L4A6xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx) || \
|
||||
defined (STM32L4R5xx) || defined (STM32L4R7xx) || defined (STM32L4R9xx) || \
|
||||
defined (STM32L4S5xx) || defined (STM32L4S7xx) || defined (STM32L4S9xx)
|
||||
#define DCD_ATTR_ENDPOINT_MAX 6
|
||||
#define DCD_ATTR_DWC2_STM32
|
||||
#else
|
||||
#define DCD_ATTR_ENDPOINT_MAX 8
|
||||
#endif
|
||||
|
||||
//------------- Sony -------------//
|
||||
#elif TU_CHECK_MCU(CXD56)
|
||||
#elif TU_CHECK_MCU(OPT_MCU_CXD56)
|
||||
#define DCD_ATTR_ENDPOINT_MAX 7
|
||||
#define DCD_ATTR_ENDPOINT_EXCLUSIVE_NUMBER
|
||||
|
||||
//------------- TI -------------//
|
||||
#elif TU_CHECK_MCU(MSP430x5xx)
|
||||
#elif TU_CHECK_MCU(OPT_MCU_MSP430x5xx)
|
||||
#define DCD_ATTR_ENDPOINT_MAX 8
|
||||
|
||||
//------------- ValentyUSB -------------//
|
||||
#elif TU_CHECK_MCU(VALENTYUSB_EPTRI)
|
||||
#elif TU_CHECK_MCU(OPT_MCU_VALENTYUSB_EPTRI)
|
||||
#define DCD_ATTR_ENDPOINT_MAX 16
|
||||
|
||||
//------------- Nuvoton -------------//
|
||||
#elif TU_CHECK_MCU(NUC121) || TU_CHECK_MCU(NUC126)
|
||||
#elif TU_CHECK_MCU(OPT_MCU_NUC121, OPT_MCU_NUC126)
|
||||
#define DCD_ATTR_ENDPOINT_MAX 8
|
||||
|
||||
#elif TU_CHECK_MCU(NUC120)
|
||||
#elif TU_CHECK_MCU(OPT_MCU_NUC120)
|
||||
#define DCD_ATTR_ENDPOINT_MAX 6
|
||||
|
||||
#elif TU_CHECK_MCU(NUC505)
|
||||
#elif TU_CHECK_MCU(OPT_MCU_NUC505)
|
||||
#define DCD_ATTR_ENDPOINT_MAX 12
|
||||
|
||||
//------------- Espressif -------------//
|
||||
#elif TU_CHECK_MCU(ESP32S2) || TU_CHECK_MCU(ESP32S3)
|
||||
#elif TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3)
|
||||
#define DCD_ATTR_ENDPOINT_MAX 6
|
||||
|
||||
//------------- Dialog -------------//
|
||||
#elif TU_CHECK_MCU(DA1469X)
|
||||
#elif TU_CHECK_MCU(OPT_MCU_DA1469X)
|
||||
#define DCD_ATTR_ENDPOINT_MAX 4
|
||||
|
||||
//------------- Raspberry Pi -------------//
|
||||
#elif TU_CHECK_MCU(RP2040)
|
||||
#elif TU_CHECK_MCU(OPT_MCU_RP2040)
|
||||
#define DCD_ATTR_ENDPOINT_MAX 16
|
||||
|
||||
//------------- Silabs -------------//
|
||||
#elif TU_CHECK_MCU(EFM32GG) || TU_CHECK_MCU(EFM32GG11) || TU_CHECK_MCU(EFM32GG12)
|
||||
#elif TU_CHECK_MCU(OPT_MCU_EFM32GG)
|
||||
#define DCD_ATTR_ENDPOINT_MAX 7
|
||||
|
||||
//------------- Renesas -------------//
|
||||
#elif TU_CHECK_MCU(RX63X) || TU_CHECK_MCU(RX65X) || TU_CHECK_MCU(RX72N)
|
||||
#elif TU_CHECK_MCU(OPT_MCU_RX63X, OPT_MCU_RX65X, OPT_MCU_RX72N)
|
||||
#define DCD_ATTR_ENDPOINT_MAX 10
|
||||
|
||||
//#elif TU_CHECK_MCU(MM32F327X)
|
||||
// #define DCD_ATTR_ENDPOINT_MAX not known yet
|
||||
|
||||
//------------- GigaDevice -------------//
|
||||
#elif TU_CHECK_MCU(GD32VF103)
|
||||
#elif TU_CHECK_MCU(OPT_MCU_GD32VF103)
|
||||
#define DCD_ATTR_ENDPOINT_MAX 4
|
||||
|
||||
//------------- Broadcom -------------//
|
||||
#elif TU_CHECK_MCU(OPT_MCU_BCM2711)
|
||||
#define DCD_ATTR_ENDPOINT_MAX 8
|
||||
|
||||
#else
|
||||
#warning "DCD_ATTR_ENDPOINT_MAX is not defined for this MCU, default to 8"
|
||||
#define DCD_ATTR_ENDPOINT_MAX 8
|
||||
|
@ -34,64 +34,64 @@
|
||||
// - PORT_HIGHSPEED: mask to indicate which port support highspeed mode, bit0 for port0 and so on.
|
||||
|
||||
//------------- NXP -------------//
|
||||
#if TU_CHECK_MCU(LPC175X_6X) || TU_CHECK_MCU(LPC177X_8X) || TU_CHECK_MCU(LPC40XX)
|
||||
#if TU_CHECK_MCU(OPT_MCU_LPC175X_6X, OPT_MCU_LPC177X_8X, OPT_MCU_LPC40XX)
|
||||
#define HCD_ATTR_OHCI
|
||||
|
||||
#elif TU_CHECK_MCU(LPC18XX) || TU_CHECK_MCU(LPC43XX)
|
||||
#elif TU_CHECK_MCU(OPT_MCU_LPC18XX, OPT_MCU_LPC43XX)
|
||||
#define HCD_ATTR_EHCI_TRANSDIMENSION
|
||||
|
||||
#elif TU_CHECK_MCU(LPC54XXX)
|
||||
#elif TU_CHECK_MCU(OPT_MCU_LPC54XXX)
|
||||
// #define HCD_ATTR_EHCI_NXP_PTD
|
||||
|
||||
#elif TU_CHECK_MCU(LPC55XX)
|
||||
#elif TU_CHECK_MCU(OPT_MCU_LPC55XX)
|
||||
// #define HCD_ATTR_EHCI_NXP_PTD
|
||||
|
||||
#elif TU_CHECK_MCU(MIMXRT10XX)
|
||||
#elif TU_CHECK_MCU(OPT_MCU_MIMXRT10XX)
|
||||
#define HCD_ATTR_EHCI_TRANSDIMENSION
|
||||
|
||||
#elif TU_CHECK_MCU(MKL25ZXX)
|
||||
#elif TU_CHECK_MCU(OPT_MCU_MKL25ZXX)
|
||||
|
||||
//------------- Microchip -------------//
|
||||
#elif TU_CHECK_MCU(SAMD21) || TU_CHECK_MCU(SAMD51) || TU_CHECK_MCU(SAME5X) || \
|
||||
TU_CHECK_MCU(SAMD11) || TU_CHECK_MCU(SAML21) || TU_CHECK_MCU(SAML22)
|
||||
#elif TU_CHECK_MCU(OPT_MCU_SAMD21, OPT_MCU_SAMD51, OPT_MCU_SAME5X) || \
|
||||
TU_CHECK_MCU(OPT_MCU_SAMD11, OPT_MCU_SAML21, OPT_MCU_SAML22)
|
||||
|
||||
#elif TU_CHECK_MCU(SAMG)
|
||||
#elif TU_CHECK_MCU(OPT_MCU_SAMG)
|
||||
|
||||
#elif TU_CHECK_MCU(SAMX7X)
|
||||
#elif TU_CHECK_MCU(OPT_MCU_SAMX7X)
|
||||
|
||||
//------------- ST -------------//
|
||||
#elif TU_CHECK_MCU(STM32F0) || TU_CHECK_MCU(STM32F1) || TU_CHECK_MCU(STM32F3) || \
|
||||
TU_CHECK_MCU(STM32L0) || TU_CHECK_MCU(STM32L1) || TU_CHECK_MCU(STM32L4)
|
||||
#elif TU_CHECK_MCU(OPT_MCU_STM32F0, OPT_MCU_STM32F1, OPT_MCU_STM32F3) || \
|
||||
TU_CHECK_MCU(OPT_MCU_STM32L0, OPT_MCU_STM32L1, OPT_MCU_STM32L4)
|
||||
|
||||
#elif TU_CHECK_MCU(STM32F2) || TU_CHECK_MCU(STM32F4) || TU_CHECK_MCU(STM32F3)
|
||||
#elif TU_CHECK_MCU(OPT_MCU_STM32F2, OPT_MCU_STM32F3, OPT_MCU_STM32F4)
|
||||
|
||||
#elif TU_CHECK_MCU(STM32F7)
|
||||
#elif TU_CHECK_MCU(OPT_MCU_STM32F7)
|
||||
|
||||
#elif TU_CHECK_MCU(STM32H7)
|
||||
#elif TU_CHECK_MCU(OPT_MCU_STM32H7)
|
||||
|
||||
//------------- Sony -------------//
|
||||
#elif TU_CHECK_MCU(CXD56)
|
||||
#elif TU_CHECK_MCU(OPT_MCU_CXD56)
|
||||
|
||||
//------------- Nuvoton -------------//
|
||||
#elif TU_CHECK_MCU(NUC505)
|
||||
#elif TU_CHECK_MCU(OPT_MCU_NUC505)
|
||||
|
||||
//------------- Espressif -------------//
|
||||
#elif TU_CHECK_MCU(ESP32S2) || TU_CHECK_MCU(ESP32S3)
|
||||
#elif TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3)
|
||||
|
||||
//------------- Raspberry Pi -------------//
|
||||
#elif TU_CHECK_MCU(RP2040)
|
||||
#elif TU_CHECK_MCU(OPT_MCU_RP2040)
|
||||
|
||||
//------------- Silabs -------------//
|
||||
#elif TU_CHECK_MCU(EFM32GG) || TU_CHECK_MCU(EFM32GG11) || TU_CHECK_MCU(EFM32GG12)
|
||||
#elif TU_CHECK_MCU(OPT_MCU_EFM32GG)
|
||||
|
||||
//------------- Renesas -------------//
|
||||
#elif TU_CHECK_MCU(RX63X) || TU_CHECK_MCU(RX65X) || TU_CHECK_MCU(RX72N)
|
||||
#elif TU_CHECK_MCU(OPT_MCU_RX63X, OPT_MCU_RX65X, OPT_MCU_RX72N)
|
||||
|
||||
//#elif TU_CHECK_MCU(MM32F327X)
|
||||
//#elif TU_CHECK_MCU(OPT_MCU_MM32F327X)
|
||||
// #define DCD_ATTR_ENDPOINT_MAX not known yet
|
||||
|
||||
//------------- GigaDevice -------------//
|
||||
#elif TU_CHECK_MCU(GD32VF103)
|
||||
#elif TU_CHECK_MCU(OPT_MCU_GD32VF103)
|
||||
|
||||
#else
|
||||
// #warning "DCD_ATTR_ENDPOINT_MAX is not defined for this MCU, default to 8"
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,89 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2021, 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_DWC2_BCM_H_
|
||||
#define _TUSB_DWC2_BCM_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "broadcom/interrupts.h"
|
||||
#include "broadcom/caches.h"
|
||||
|
||||
#define DWC2_REG_BASE 0xFE980000UL
|
||||
#define DWC2_EP_MAX 8
|
||||
#define DWC2_EP_FIFO_SIZE 4096
|
||||
|
||||
#define dcache_clean(_addr, _size) data_clean(_addr, _size)
|
||||
#define dcache_invalidate(_addr, _size) data_invalidate(_addr, _size)
|
||||
#define dcache_clean_invalidate(_addr, _size) data_clean_and_invalidate(_addr, _size)
|
||||
|
||||
TU_ATTR_ALWAYS_INLINE
|
||||
static inline void dwc2_dcd_int_enable(uint8_t rhport)
|
||||
{
|
||||
(void) rhport;
|
||||
BP_EnableIRQ(USB_IRQn);
|
||||
__asm__ volatile("isb"); // needed if TIMER1 IRQ is not enabled !?
|
||||
}
|
||||
|
||||
TU_ATTR_ALWAYS_INLINE
|
||||
static inline void dwc2_dcd_int_disable (uint8_t rhport)
|
||||
{
|
||||
(void) rhport;
|
||||
BP_DisableIRQ(USB_IRQn);
|
||||
__asm__ volatile("isb"); // needed if TIMER1 IRQ is not enabled !?
|
||||
}
|
||||
|
||||
static inline void dwc2_remote_wakeup_delay(void)
|
||||
{
|
||||
// try to delay for 1 ms
|
||||
// TODO implement later
|
||||
}
|
||||
|
||||
// MCU specific PHY init, called BEFORE core reset
|
||||
static inline void dwc2_phy_init(dwc2_regs_t * dwc2, uint8_t hs_phy_type)
|
||||
{
|
||||
(void) dwc2;
|
||||
(void) hs_phy_type;
|
||||
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
// MCU specific PHY update, it is called AFTER init() and core reset
|
||||
static inline void dwc2_phy_update(dwc2_regs_t * dwc2, uint8_t hs_phy_type)
|
||||
{
|
||||
(void) dwc2;
|
||||
(void) hs_phy_type;
|
||||
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -0,0 +1,87 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2021 Rafael Silva (@perigoso)
|
||||
* Copyright (c) 2021, 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 _DWC2_EFM32_H_
|
||||
#define _DWC2_EFM32_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "em_device.h"
|
||||
|
||||
// EFM32 has custom control register before DWC registers
|
||||
#define DWC2_REG_BASE (USB_BASE + offsetof(USB_TypeDef, GOTGCTL))
|
||||
#define DWC2_EP_MAX 7
|
||||
#define DWC2_EP_FIFO_SIZE 2048
|
||||
|
||||
TU_ATTR_ALWAYS_INLINE
|
||||
static inline void dwc2_dcd_int_enable(uint8_t rhport)
|
||||
{
|
||||
(void) rhport;
|
||||
NVIC_EnableIRQ(USB_IRQn);
|
||||
}
|
||||
|
||||
TU_ATTR_ALWAYS_INLINE
|
||||
static inline void dwc2_dcd_int_disable (uint8_t rhport)
|
||||
{
|
||||
(void) rhport;
|
||||
NVIC_DisableIRQ(USB_IRQn);
|
||||
}
|
||||
|
||||
static inline void dwc2_remote_wakeup_delay(void)
|
||||
{
|
||||
// try to delay for 1 ms
|
||||
// uint32_t count = SystemCoreClock / 1000;
|
||||
// while ( count-- ) __NOP();
|
||||
}
|
||||
|
||||
// MCU specific PHY init, called BEFORE core reset
|
||||
static inline void dwc2_phy_init(dwc2_regs_t * dwc2, uint8_t hs_phy_type)
|
||||
{
|
||||
(void) dwc2;
|
||||
(void) hs_phy_type;
|
||||
|
||||
// Enable PHY
|
||||
USB->ROUTE = USB_ROUTE_PHYPEN;
|
||||
}
|
||||
|
||||
// MCU specific PHY update, it is called AFTER init() and core reset
|
||||
static inline void dwc2_phy_update(dwc2_regs_t * dwc2, uint8_t hs_phy_type)
|
||||
{
|
||||
(void) dwc2;
|
||||
(void) hs_phy_type;
|
||||
|
||||
// EFM32 Manual: turn around must be 5 (reset & default value)
|
||||
// dwc2->gusbcfg = (dwc2->gusbcfg & ~GUSBCFG_TRDT_Msk) | (5u << GUSBCFG_TRDT_Pos);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -0,0 +1,94 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2021, 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 _DWC2_ESP32_H_
|
||||
#define _DWC2_ESP32_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "esp_intr_alloc.h"
|
||||
#include "soc/periph_defs.h"
|
||||
//#include "soc/usb_periph.h"
|
||||
|
||||
#define DWC2_REG_BASE 0x60080000UL
|
||||
#define DWC2_EP_MAX 5 // USB_OUT_EP_NUM
|
||||
#define DWC2_EP_FIFO_SIZE 1024
|
||||
|
||||
// #define EP_FIFO_NUM 5
|
||||
|
||||
static intr_handle_t usb_ih;
|
||||
|
||||
static void dcd_int_handler_wrap(void* arg)
|
||||
{
|
||||
(void) arg;
|
||||
dcd_int_handler(0);
|
||||
}
|
||||
|
||||
TU_ATTR_ALWAYS_INLINE
|
||||
static inline void dwc2_dcd_int_enable (uint8_t rhport)
|
||||
{
|
||||
(void) rhport;
|
||||
esp_intr_alloc(ETS_USB_INTR_SOURCE, ESP_INTR_FLAG_LOWMED, dcd_int_handler_wrap, NULL, &usb_ih);
|
||||
}
|
||||
|
||||
TU_ATTR_ALWAYS_INLINE
|
||||
static inline void dwc2_dcd_int_disable (uint8_t rhport)
|
||||
{
|
||||
(void) rhport;
|
||||
esp_intr_free(usb_ih);
|
||||
}
|
||||
|
||||
static inline void dwc2_remote_wakeup_delay(void)
|
||||
{
|
||||
vTaskDelay(pdMS_TO_TICKS(1));
|
||||
}
|
||||
|
||||
// MCU specific PHY init, called BEFORE core reset
|
||||
static inline void dwc2_phy_init(dwc2_regs_t * dwc2, uint8_t hs_phy_type)
|
||||
{
|
||||
(void) dwc2;
|
||||
(void) hs_phy_type;
|
||||
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
// MCU specific PHY update, it is called AFTER init() and core reset
|
||||
static inline void dwc2_phy_update(dwc2_regs_t * dwc2, uint8_t hs_phy_type)
|
||||
{
|
||||
(void) dwc2;
|
||||
(void) hs_phy_type;
|
||||
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _DWC2_ESP32_H_ */
|
@ -0,0 +1,100 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2021, 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 DWC2_GD32_H_
|
||||
#define DWC2_GD32_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define DWC2_REG_BASE 0x50000000UL
|
||||
#define DWC2_EP_MAX 4
|
||||
#define DWC2_EP_FIFO_SIZE 1280
|
||||
#define RHPORT_IRQn 86
|
||||
|
||||
extern uint32_t SystemCoreClock;
|
||||
|
||||
// The GD32VF103 is a RISC-V MCU, which implements the ECLIC Core-Local
|
||||
// Interrupt Controller by Nuclei. It is nearly API compatible to the
|
||||
// NVIC used by ARM MCUs.
|
||||
#define ECLIC_INTERRUPT_ENABLE_BASE 0xD2001001UL
|
||||
|
||||
TU_ATTR_ALWAYS_INLINE
|
||||
static inline void __eclic_enable_interrupt (uint32_t irq) {
|
||||
*(volatile uint8_t*)(ECLIC_INTERRUPT_ENABLE_BASE + (irq * 4)) = 1;
|
||||
}
|
||||
|
||||
TU_ATTR_ALWAYS_INLINE
|
||||
static inline void __eclic_disable_interrupt (uint32_t irq){
|
||||
*(volatile uint8_t*)(ECLIC_INTERRUPT_ENABLE_BASE + (irq * 4)) = 0;
|
||||
}
|
||||
|
||||
TU_ATTR_ALWAYS_INLINE
|
||||
static inline void dwc2_dcd_int_enable(uint8_t rhport)
|
||||
{
|
||||
(void) rhport;
|
||||
__eclic_enable_interrupt(RHPORT_IRQn);
|
||||
}
|
||||
|
||||
TU_ATTR_ALWAYS_INLINE
|
||||
static inline void dwc2_dcd_int_disable (uint8_t rhport)
|
||||
{
|
||||
(void) rhport;
|
||||
__eclic_disable_interrupt(RHPORT_IRQn);
|
||||
}
|
||||
|
||||
static inline void dwc2_remote_wakeup_delay(void)
|
||||
{
|
||||
// try to delay for 1 ms
|
||||
uint32_t count = SystemCoreClock / 1000;
|
||||
while ( count-- ) __asm volatile ("nop");
|
||||
}
|
||||
|
||||
// MCU specific PHY init, called BEFORE core reset
|
||||
static inline void dwc2_phy_init(dwc2_regs_t * dwc2, uint8_t hs_phy_type)
|
||||
{
|
||||
(void) dwc2;
|
||||
(void) hs_phy_type;
|
||||
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
// MCU specific PHY update, it is called AFTER init() and core reset
|
||||
static inline void dwc2_phy_update(dwc2_regs_t * dwc2, uint8_t hs_phy_type)
|
||||
{
|
||||
(void) dwc2;
|
||||
(void) hs_phy_type;
|
||||
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DWC2_GD32_H_ */
|
@ -0,0 +1,205 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2021, 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 _DWC2_STM32_H_
|
||||
#define _DWC2_STM32_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// EP_MAX : Max number of bi-directional endpoints including EP0
|
||||
// EP_FIFO_SIZE : Size of dedicated USB SRAM
|
||||
#if CFG_TUSB_MCU == OPT_MCU_STM32F1
|
||||
#include "stm32f1xx.h"
|
||||
#define EP_MAX_FS 4
|
||||
#define EP_FIFO_SIZE_FS 1280
|
||||
|
||||
#elif CFG_TUSB_MCU == OPT_MCU_STM32F2
|
||||
#include "stm32f2xx.h"
|
||||
#define EP_MAX_FS USB_OTG_FS_MAX_IN_ENDPOINTS
|
||||
#define EP_FIFO_SIZE_FS USB_OTG_FS_TOTAL_FIFO_SIZE
|
||||
|
||||
#elif CFG_TUSB_MCU == OPT_MCU_STM32F4
|
||||
#include "stm32f4xx.h"
|
||||
#define EP_MAX_FS USB_OTG_FS_MAX_IN_ENDPOINTS
|
||||
#define EP_FIFO_SIZE_FS USB_OTG_FS_TOTAL_FIFO_SIZE
|
||||
#define EP_MAX_HS USB_OTG_HS_MAX_IN_ENDPOINTS
|
||||
#define EP_FIFO_SIZE_HS USB_OTG_HS_TOTAL_FIFO_SIZE
|
||||
|
||||
#elif CFG_TUSB_MCU == OPT_MCU_STM32H7
|
||||
#include "stm32h7xx.h"
|
||||
#define EP_MAX_FS 9
|
||||
#define EP_FIFO_SIZE_FS 4096
|
||||
#define EP_MAX_HS 9
|
||||
#define EP_FIFO_SIZE_HS 4096
|
||||
|
||||
#elif CFG_TUSB_MCU == OPT_MCU_STM32F7
|
||||
#include "stm32f7xx.h"
|
||||
#define EP_MAX_FS 6
|
||||
#define EP_FIFO_SIZE_FS 1280
|
||||
#define EP_MAX_HS 9
|
||||
#define EP_FIFO_SIZE_HS 4096
|
||||
|
||||
#elif CFG_TUSB_MCU == OPT_MCU_STM32L4
|
||||
#include "stm32l4xx.h"
|
||||
#define EP_MAX_FS 6
|
||||
#define EP_FIFO_SIZE_FS 1280
|
||||
|
||||
#else
|
||||
#error "Unsupported MCUs"
|
||||
#endif
|
||||
|
||||
// On STM32 we associate Port0 to OTG_FS, and Port1 to OTG_HS
|
||||
#if TUD_OPT_RHPORT == 0
|
||||
#define DWC2_REG_BASE USB_OTG_FS_PERIPH_BASE
|
||||
#define DWC2_EP_MAX EP_MAX_FS
|
||||
#define DWC2_EP_FIFO_SIZE EP_FIFO_SIZE_FS
|
||||
#define RHPORT_IRQn OTG_FS_IRQn
|
||||
|
||||
#else
|
||||
#define DWC2_REG_BASE USB_OTG_HS_PERIPH_BASE
|
||||
#define DWC2_EP_MAX EP_MAX_HS
|
||||
#define DWC2_EP_FIFO_SIZE EP_FIFO_SIZE_HS
|
||||
#define RHPORT_IRQn OTG_HS_IRQn
|
||||
|
||||
#endif
|
||||
|
||||
extern uint32_t SystemCoreClock;
|
||||
|
||||
TU_ATTR_ALWAYS_INLINE
|
||||
static inline void dwc2_dcd_int_enable(uint8_t rhport)
|
||||
{
|
||||
(void) rhport;
|
||||
NVIC_EnableIRQ(RHPORT_IRQn);
|
||||
}
|
||||
|
||||
TU_ATTR_ALWAYS_INLINE
|
||||
static inline void dwc2_dcd_int_disable (uint8_t rhport)
|
||||
{
|
||||
(void) rhport;
|
||||
NVIC_DisableIRQ(RHPORT_IRQn);
|
||||
}
|
||||
|
||||
TU_ATTR_ALWAYS_INLINE
|
||||
static inline void dwc2_remote_wakeup_delay(void)
|
||||
{
|
||||
// try to delay for 1 ms
|
||||
uint32_t count = SystemCoreClock / 1000;
|
||||
while ( count-- ) __NOP();
|
||||
}
|
||||
|
||||
// MCU specific PHY init, called BEFORE core reset
|
||||
static inline void dwc2_phy_init(dwc2_regs_t * dwc2, uint8_t hs_phy_type)
|
||||
{
|
||||
if ( hs_phy_type == HS_PHY_TYPE_NONE )
|
||||
{
|
||||
// Enable on-chip FS PHY
|
||||
dwc2->stm32_gccfg |= STM32_GCCFG_PWRDWN;
|
||||
}else
|
||||
{
|
||||
// Disable FS PHY
|
||||
dwc2->stm32_gccfg &= ~STM32_GCCFG_PWRDWN;
|
||||
|
||||
// Enable on-chip HS PHY
|
||||
if (hs_phy_type == HS_PHY_TYPE_UTMI || hs_phy_type == HS_PHY_TYPE_UTMI_ULPI)
|
||||
{
|
||||
#ifdef USB_HS_PHYC
|
||||
// Enable UTMI HS PHY
|
||||
dwc2->stm32_gccfg |= STM32_GCCFG_PHYHSEN;
|
||||
|
||||
// Enable LDO
|
||||
USB_HS_PHYC->USB_HS_PHYC_LDO |= USB_HS_PHYC_LDO_ENABLE;
|
||||
|
||||
// Wait until LDO ready
|
||||
while ( 0 == (USB_HS_PHYC->USB_HS_PHYC_LDO & USB_HS_PHYC_LDO_STATUS) ) {}
|
||||
|
||||
uint32_t phyc_pll = 0;
|
||||
|
||||
// TODO Try to get HSE_VALUE from registers instead of depending CFLAGS
|
||||
switch ( HSE_VALUE )
|
||||
{
|
||||
case 12000000: phyc_pll = USB_HS_PHYC_PLL1_PLLSEL_12MHZ ; break;
|
||||
case 12500000: phyc_pll = USB_HS_PHYC_PLL1_PLLSEL_12_5MHZ ; break;
|
||||
case 16000000: phyc_pll = USB_HS_PHYC_PLL1_PLLSEL_16MHZ ; break;
|
||||
case 24000000: phyc_pll = USB_HS_PHYC_PLL1_PLLSEL_24MHZ ; break;
|
||||
case 25000000: phyc_pll = USB_HS_PHYC_PLL1_PLLSEL_25MHZ ; break;
|
||||
case 32000000: phyc_pll = USB_HS_PHYC_PLL1_PLLSEL_Msk ; break; // Value not defined in header
|
||||
default:
|
||||
TU_ASSERT(false, );
|
||||
}
|
||||
USB_HS_PHYC->USB_HS_PHYC_PLL = phyc_pll;
|
||||
|
||||
// Control the tuning interface of the High Speed PHY
|
||||
// Use magic value (USB_HS_PHYC_TUNE_VALUE) from ST driver for F7
|
||||
USB_HS_PHYC->USB_HS_PHYC_TUNE |= 0x00000F13U;
|
||||
|
||||
// Enable PLL internal PHY
|
||||
USB_HS_PHYC->USB_HS_PHYC_PLL |= USB_HS_PHYC_PLL_PLLEN;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MCU specific PHY update, it is called AFTER init() and core reset
|
||||
static inline void dwc2_phy_update(dwc2_regs_t * dwc2, uint8_t hs_phy_type)
|
||||
{
|
||||
// used to set turnaround time for fullspeed, nothing to do in highspeed mode
|
||||
if ( hs_phy_type == HS_PHY_TYPE_NONE )
|
||||
{
|
||||
// Turnaround timeout depends on the AHB clock dictated by STM32 Reference Manual
|
||||
uint32_t turnaround;
|
||||
|
||||
if ( SystemCoreClock >= 32000000u )
|
||||
turnaround = 0x6u;
|
||||
else if ( SystemCoreClock >= 27500000u )
|
||||
turnaround = 0x7u;
|
||||
else if ( SystemCoreClock >= 24000000u )
|
||||
turnaround = 0x8u;
|
||||
else if ( SystemCoreClock >= 21800000u )
|
||||
turnaround = 0x9u;
|
||||
else if ( SystemCoreClock >= 20000000u )
|
||||
turnaround = 0xAu;
|
||||
else if ( SystemCoreClock >= 18500000u )
|
||||
turnaround = 0xBu;
|
||||
else if ( SystemCoreClock >= 17200000u )
|
||||
turnaround = 0xCu;
|
||||
else if ( SystemCoreClock >= 16000000u )
|
||||
turnaround = 0xDu;
|
||||
else if ( SystemCoreClock >= 15000000u )
|
||||
turnaround = 0xEu;
|
||||
else
|
||||
turnaround = 0xFu;
|
||||
|
||||
dwc2->gusbcfg = (dwc2->gusbcfg & ~GUSBCFG_TRDT_Msk) | (turnaround << GUSBCFG_TRDT_Pos);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _DWC2_STM32_H_ */
|
File diff suppressed because it is too large
Load Diff
@ -27,6 +27,8 @@
|
||||
#ifndef _TUSB_OPTION_H_
|
||||
#define _TUSB_OPTION_H_
|
||||
|
||||
#include "common/tusb_compiler.h"
|
||||
|
||||
#define TUSB_VERSION_MAJOR 0
|
||||
#define TUSB_VERSION_MINOR 12
|
||||
#define TUSB_VERSION_REVISION 0
|
||||
@ -36,7 +38,6 @@
|
||||
// Supported MCUs
|
||||
// CFG_TUSB_MCU must be defined to one of following value
|
||||
//--------------------------------------------------------------------+
|
||||
#define TU_CHECK_MCU(_m) (CFG_TUSB_MCU == OPT_MCU_##_m)
|
||||
|
||||
#define OPT_MCU_NONE 0
|
||||
|
||||
@ -112,8 +113,6 @@
|
||||
|
||||
// Silabs
|
||||
#define OPT_MCU_EFM32GG 1300 ///< Silabs EFM32GG
|
||||
#define OPT_MCU_EFM32GG11 1301 ///< Silabs EFM32GG11
|
||||
#define OPT_MCU_EFM32GG12 1302 ///< Silabs EFM32GG12
|
||||
|
||||
// Renesas RX
|
||||
#define OPT_MCU_RX63X 1400 ///< Renesas RX63N/631
|
||||
@ -126,6 +125,14 @@
|
||||
// GigaDevice
|
||||
#define OPT_MCU_GD32VF103 1600 ///< GigaDevice GD32VF103
|
||||
|
||||
// Broadcom
|
||||
#define OPT_MCU_BCM2711 1700 ///< Broadcom BCM2711
|
||||
|
||||
// Helper to check if configured MCU is one of listed
|
||||
// Apply _TU_CHECK_MCU with || as separator to list of input
|
||||
#define _TU_CHECK_MCU(_m) (CFG_TUSB_MCU == _m)
|
||||
#define TU_CHECK_MCU(...) (TU_ARGS_APPLY(_TU_CHECK_MCU, ||, __VA_ARGS__))
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Supported OS
|
||||
//--------------------------------------------------------------------+
|
||||
|
@ -575,5 +575,5 @@
|
||||
#define CONFIG_USB_MSC_BUFSIZE CONFIG_TINYUSB_MSC_BUFSIZE
|
||||
#define CONFIG_USB_MSC_ENABLED CONFIG_TINYUSB_MSC_ENABLED
|
||||
#define CONFIG_WARN_WRITE_STRINGS CONFIG_COMPILER_WARN_WRITE_STRINGS
|
||||
#define CONFIG_ARDUINO_IDF_COMMIT "2720d45e71"
|
||||
#define CONFIG_ARDUINO_IDF_COMMIT "6a7d83af19"
|
||||
#define CONFIG_ARDUINO_IDF_BRANCH "release/v4.4"
|
||||
|
@ -0,0 +1,208 @@
|
||||
// Copyright 2020-2021 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
|
||||
#ifndef _ekf_h_
|
||||
#define _ekf_h_
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <math.h>
|
||||
#include <stdint.h>
|
||||
#include <mat.h>
|
||||
|
||||
class ekf {
|
||||
public:
|
||||
// x - amount of states in EKF. x[n] = F*x[n-1] + G*u + W. Size of matrix F
|
||||
// w - amount of control measurements and noise inputs. Size of matrix G
|
||||
|
||||
ekf(int x, int w);
|
||||
|
||||
virtual ~ekf();
|
||||
virtual void Process(float *u, float dt);
|
||||
|
||||
virtual void Init() = 0;
|
||||
// x[n] = F*x[n-1] + G*u + W
|
||||
int NUMX; // number of states, X is the state vector (size of F matrix)
|
||||
int NUMW; // size of G matrix
|
||||
|
||||
// System state vector
|
||||
dspm::Mat &X;
|
||||
|
||||
// linearized system matrices
|
||||
dspm::Mat &F;
|
||||
dspm::Mat &G;
|
||||
|
||||
// covariance matrix and state vector
|
||||
dspm::Mat &P;
|
||||
|
||||
// input noise and measurement noise variances
|
||||
dspm::Mat &Q;
|
||||
|
||||
/**
|
||||
* Runge-Kutta state update method.
|
||||
* The method calculates derivatives of input vector x and control measurements u
|
||||
* Re
|
||||
* @param[in] x: state vector
|
||||
* @param[in] u: control measurement
|
||||
* @param[in] dt: time interval from last update in seconds
|
||||
*/
|
||||
void RungeKutta(dspm::Mat &x, float *u, float dt);
|
||||
|
||||
// System Dependent methods:
|
||||
|
||||
/**
|
||||
* Derivative of state vector X
|
||||
* Re
|
||||
* @param[in] x: state vector
|
||||
* @param[in] u: control measurement
|
||||
* @return
|
||||
* - derivative of input vector x and u
|
||||
*/
|
||||
virtual dspm::Mat StateXdot(dspm::Mat &x, float *u) = 0;
|
||||
/**
|
||||
* Calculation of system state matrices F and G
|
||||
* @param[in] x: state vector
|
||||
* @param[in] u: control measurement
|
||||
*/
|
||||
virtual void LinearizeFG(dspm::Mat &x, float *u) = 0;
|
||||
//
|
||||
|
||||
// System independent methods
|
||||
|
||||
/**
|
||||
* Calculates covariance prediction matrux P.
|
||||
* Update matrix P
|
||||
* @param[in] dt: time interval from last update
|
||||
*/
|
||||
virtual void CovariancePrediction(float dt);
|
||||
|
||||
/**
|
||||
* Update of current state by measured values.
|
||||
* Optimized method for non correlated values
|
||||
* Calculate Kalman gain and update matrix P and vector X.
|
||||
* @param[in] H: derivative matrix
|
||||
* @param[in] measured: array of measured values
|
||||
* @param[in] expected: array of expected values
|
||||
* @param[in] R: measurement noise covariance values
|
||||
*/
|
||||
virtual void Update(dspm::Mat &H, float *measured, float *expected, float *R);
|
||||
/**
|
||||
* Update of current state by measured values.
|
||||
* This method just as a reference for research purpose.
|
||||
* Not used in real calculations.
|
||||
* @param[in] H: derivative matrix
|
||||
* @param[in] measured: array of measured values
|
||||
* @param[in] expected: array of expected values
|
||||
* @param[in] R: measurement noise covariance values
|
||||
*/
|
||||
virtual void UpdateRef(dspm::Mat &H, float *measured, float *expected, float *R);
|
||||
|
||||
|
||||
float *HP;
|
||||
float *Km;
|
||||
|
||||
public:
|
||||
// Additional universal helper methods
|
||||
/**
|
||||
* Convert quaternion to rotation matrix.
|
||||
* @param[in] q: quaternion
|
||||
*
|
||||
* @return
|
||||
* - rotation matrix 3x3
|
||||
*/
|
||||
static dspm::Mat quat2rotm(float q[4]);
|
||||
|
||||
/**
|
||||
* Convert rotation matrix to quaternion.
|
||||
* @param[in] R: rotation matrix
|
||||
*
|
||||
* @return
|
||||
* - quaternion 4x1
|
||||
*/
|
||||
static dspm::Mat rotm2quat(dspm::Mat &R);
|
||||
|
||||
/**
|
||||
* Convert quaternion to Euler angels.
|
||||
* @param[in] R: quaternion
|
||||
*
|
||||
* @return
|
||||
* - Euler angels 3x1
|
||||
*/
|
||||
static dspm::Mat quat2eul(const float q[4]);
|
||||
/**
|
||||
* Convert Euler angels to rotation matrix.
|
||||
* @param[in] xyz: Euler angels
|
||||
*
|
||||
* @return
|
||||
* - rotation matrix 3x3
|
||||
*/
|
||||
static dspm::Mat eul2rotm(float xyz[3]);
|
||||
|
||||
/**
|
||||
* Convert rotation matrix to Euler angels.
|
||||
* @param[in] rotm: rotation matrix
|
||||
*
|
||||
* @return
|
||||
* - Euler angels 3x1
|
||||
*/
|
||||
static dspm::Mat rotm2eul(dspm::Mat &rotm);
|
||||
|
||||
/**
|
||||
* Df/dq: Derivative of vector by quaternion.
|
||||
* @param[in] vector: input vector
|
||||
* @param[in] quat: quaternion
|
||||
*
|
||||
* @return
|
||||
* - Derivative matrix 3x4
|
||||
*/
|
||||
static dspm::Mat dFdq(dspm::Mat &vector, dspm::Mat &quat);
|
||||
|
||||
/**
|
||||
* Df/dq: Derivative of vector by inverted quaternion.
|
||||
* @param[in] vector: input vector
|
||||
* @param[in] quat: quaternion
|
||||
*
|
||||
* @return
|
||||
* - Derivative matrix 3x4
|
||||
*/
|
||||
static dspm::Mat dFdq_inv(dspm::Mat &vector, dspm::Mat &quat);
|
||||
|
||||
/**
|
||||
* Make skew-symmetric matrix of vector.
|
||||
* @param[in] w: source vector
|
||||
*
|
||||
* @return
|
||||
* - skew-symmetric matrix 4x4
|
||||
*/
|
||||
static dspm::Mat SkewSym4x4(float *w);
|
||||
|
||||
// q product
|
||||
// Rl = [q(1) - q(2) - q(3) - q(4); ...
|
||||
// q(2) q(1) - q(4) q(3); ...
|
||||
// q(3) q(4) q(1) - q(2); ...
|
||||
// q(4) - q(3) q(2) q(1); ...
|
||||
|
||||
/**
|
||||
* Make right quaternion-product matrices.
|
||||
* @param[in] q: source quaternion
|
||||
*
|
||||
* @return
|
||||
* - right quaternion-product matrix 4x4
|
||||
*/
|
||||
static dspm::Mat qProduct(float *q);
|
||||
|
||||
};
|
||||
|
||||
#endif // _ekf_h_
|
@ -0,0 +1,83 @@
|
||||
// Copyright 2020-2021 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef _ekf_imu13states_H_
|
||||
#define _ekf_imu13states_H_
|
||||
|
||||
#include "ekf.h"
|
||||
|
||||
/**
|
||||
* @brief This class is used to process and calculate attitude from imu sensors.
|
||||
*
|
||||
* The class use state vector with 13 follows values
|
||||
* X[0..3] - attitude quaternion
|
||||
* X[4..6] - gyroscope bias error, rad/sec
|
||||
* X[7..9] - magnetometer vector value - magn_ampl
|
||||
* X[10..12] - magnetometer offset value - magn_offset
|
||||
*
|
||||
* where, reference magnetometer value = magn_ampl*rotation_matrix' + magn_offset
|
||||
*/
|
||||
class ekf_imu13states: public ekf {
|
||||
public:
|
||||
ekf_imu13states();
|
||||
virtual ~ekf_imu13states();
|
||||
virtual void Init();
|
||||
|
||||
// Method calculates Xdot values depends on U
|
||||
// U - gyroscope values in radian per seconds (rad/sec)
|
||||
virtual dspm::Mat StateXdot(dspm::Mat &x, float *u);
|
||||
virtual void LinearizeFG(dspm::Mat &x, float *u);
|
||||
|
||||
// Methods for tests only.
|
||||
void Test();
|
||||
void TestFull(bool enable_att);
|
||||
|
||||
// Initial reference valies magnetometer and accelerometer
|
||||
dspm::Mat mag0;
|
||||
dspm::Mat accel0;
|
||||
|
||||
int NUMU; // number of control measurements
|
||||
|
||||
/**
|
||||
* Update part of system state by reference measurements accelerometer and magnetometer.
|
||||
* Only attitude and gyro bias will be updated.
|
||||
* This method should be used as main method after calibration.
|
||||
*
|
||||
* @param[in] accel_data: accelerometer measurement vector XYZ in g, where 1 g ~ 9.81 m/s^2
|
||||
* @param[in] magn_data: magnetometer measurement vector XYZ
|
||||
* @param[in] R: measurement noise covariance values for diagonal covariance matrix. Then smaller value, then more you trust them.
|
||||
*/
|
||||
void UpdateRefMeasurement(float *accel_data, float *magn_data, float R[6]);
|
||||
/**
|
||||
* Update full system state by reference measurements accelerometer and magnetometer.
|
||||
* This method should be used at calibration phase.
|
||||
*
|
||||
* @param[in] accel_data: accelerometer measurement vector XYZ in g, where 1 g ~ 9.81 m/s^2
|
||||
* @param[in] magn_data: magnetometer measurement vector XYZ
|
||||
* @param[in] R: measurement noise covariance values for diagonal covariance matrix. Then smaller value, then more you trust them.
|
||||
*/
|
||||
void UpdateRefMeasurementMagn(float *accel_data, float *magn_data, float R[6]);
|
||||
/**
|
||||
* Update system state by reference measurements accelerometer, magnetometer and attitude quaternion.
|
||||
* This method could be used when system on constant state or in initialization phase.
|
||||
* @param[in] accel_data: accelerometer measurement vector XYZ in g, where 1 g ~ 9.81 m/s^2
|
||||
* @param[in] magn_data: magnetometer measurement vector XYZ
|
||||
* @param[in] attitude: attitude quaternion
|
||||
* @param[in] R: measurement noise covariance values for diagonal covariance matrix. Then smaller value, then more you trust them.
|
||||
*/
|
||||
void UpdateRefMeasurement(float *accel_data, float *magn_data, float *attitude, float R[10]);
|
||||
|
||||
};
|
||||
|
||||
#endif // _ekf_imu13states_H_
|
@ -52,6 +52,27 @@ public:
|
||||
* @param[in] src: source matrix
|
||||
*/
|
||||
Mat(const Mat &src);
|
||||
|
||||
/**
|
||||
* Make copy of matrix.
|
||||
* @param[in] src: source matrix
|
||||
* @param[in] row_pos: start row position of destination matrix
|
||||
* @param[in] col_pos: start col position of destination matrix
|
||||
*/
|
||||
void Copy(const Mat &src, int row_pos, int col_pos);
|
||||
|
||||
/**
|
||||
* Make copy of matrix.
|
||||
* @param[in] row_start: start row position of source matrix to copy
|
||||
* @param[in] row_size: size of wor elements of source matrix to copy
|
||||
* @param[in] col_start: start col position of source matrix to copy
|
||||
* @param[in] col_size: size of wor elements of source matrix to copy
|
||||
*
|
||||
* @return
|
||||
* - result matrix size row_size x col_size
|
||||
*/
|
||||
Mat Get(int row_start, int row_size, int col_start, int col_size);
|
||||
|
||||
/**
|
||||
* Copy operator
|
||||
*
|
||||
@ -356,10 +377,18 @@ public:
|
||||
int length; /*!< Total amount of data in data array*/
|
||||
|
||||
static float abs_tol; /*!< Max acceptable absolute tolerance*/
|
||||
|
||||
/**
|
||||
* Find determinant
|
||||
* @param[in] n: element number in first row
|
||||
*
|
||||
* @return
|
||||
* - determinant value
|
||||
*/
|
||||
float det(int n);
|
||||
private:
|
||||
Mat cofactor(int row, int col, int n);
|
||||
float det(int n);
|
||||
Mat adjoint();
|
||||
Mat cofactor(int row, int col, int n);
|
||||
Mat adjoint();
|
||||
|
||||
void allocate(); // Allocate buffer
|
||||
Mat expHelper(const Mat &m, int num);
|
||||
|
@ -91,9 +91,10 @@ namespace dl
|
||||
|
||||
typedef enum
|
||||
{
|
||||
CONSTANT,
|
||||
EDGE,
|
||||
REFLECT,
|
||||
SYMMETRIC,
|
||||
PADDING_EMPTY,
|
||||
PADDING_CONSTANT,
|
||||
PADDING_EDGE,
|
||||
PADDING_REFLECT,
|
||||
PADDING_SYMMETRIC,
|
||||
} padding_mode_t;
|
||||
} // namespace dl
|
||||
|
@ -72,7 +72,7 @@ namespace dl
|
||||
{
|
||||
this->output = new Tensor<feature_t>;
|
||||
}
|
||||
this->output->set_exponent(this->output_exponent);
|
||||
this->output->set_exponent(input0.exponent);
|
||||
this->output->set_shape(this->output_shape);
|
||||
this->output->free_element();
|
||||
}
|
||||
|
@ -0,0 +1,169 @@
|
||||
#pragma once
|
||||
|
||||
#include "dl_nn_pad.hpp"
|
||||
#include "dl_layer_base.hpp"
|
||||
|
||||
namespace dl
|
||||
{
|
||||
namespace layer
|
||||
{
|
||||
/**
|
||||
* @brief Pad.
|
||||
*
|
||||
* @tparam feature_t supports int16_t and int8_t,
|
||||
* - int16_t: stands for operation in int16_t quantize
|
||||
* - int8_t: stands for operation in int8_t quantize
|
||||
*/
|
||||
template <typename feature_t>
|
||||
class Pad : public Layer
|
||||
{
|
||||
private:
|
||||
std::vector<int> paddings;
|
||||
std::vector<feature_t> constant_values;
|
||||
padding_mode_t mode;
|
||||
Tensor<feature_t> *output; /*<! output ptr of Pad >*/
|
||||
std::vector<int> output_shape; /*<! output shape of Pad >*/
|
||||
|
||||
public:
|
||||
Pad(std::vector<int> paddings,
|
||||
std::vector<feature_t> constant_values = {0},
|
||||
padding_mode_t mode = PADDING_CONSTANT,
|
||||
const char *name = "Pad") : Layer(name),
|
||||
paddings(paddings),
|
||||
constant_values(constant_values),
|
||||
mode(mode)
|
||||
{
|
||||
this->output = new Tensor<feature_t>;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Destroy the Pad object.
|
||||
*
|
||||
*/
|
||||
~Pad()
|
||||
{
|
||||
if (this->output != NULL)
|
||||
{
|
||||
delete this->output;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Update output padding and input padding.
|
||||
*
|
||||
* @param input as an input
|
||||
* @param print_shape whether to print the output shape.
|
||||
*/
|
||||
void build(Tensor<feature_t> &input, bool print_shape = false)
|
||||
{
|
||||
assert(this->paddings.size() > 0);
|
||||
int input_dims = input.shape.size();
|
||||
int padding_dims = input_dims * 2;
|
||||
if (this->paddings.size() == 1)
|
||||
{
|
||||
std::vector<int> _paddings(padding_dims, 0);
|
||||
for (int i = 0; i < padding_dims; ++i)
|
||||
{
|
||||
_paddings[i] = this->paddings[0];
|
||||
}
|
||||
this->paddings = _paddings;
|
||||
}
|
||||
else if (this->paddings.size() == 2)
|
||||
{
|
||||
std::vector<int> _paddings(padding_dims, 0);
|
||||
for (int i = 0; i < input_dims; ++i)
|
||||
{
|
||||
_paddings[2 * i] = this->paddings[0];
|
||||
_paddings[2 * i + 1] = this->paddings[1];
|
||||
}
|
||||
this->paddings = _paddings;
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(this->paddings.size() == padding_dims);
|
||||
}
|
||||
|
||||
if (this->mode == PADDING_CONSTANT)
|
||||
{
|
||||
if (this->constant_values.size() == 1)
|
||||
{
|
||||
std::vector<feature_t> _constant_values(padding_dims, 0);
|
||||
for (int i = 0; i < padding_dims; ++i)
|
||||
{
|
||||
_constant_values[i] = this->constant_values[0];
|
||||
}
|
||||
this->constant_values = _constant_values;
|
||||
}
|
||||
else if (this->constant_values.size() == 2)
|
||||
{
|
||||
std::vector<feature_t> _constant_values(padding_dims, 0);
|
||||
for (int i = 0; i < input_dims; ++i)
|
||||
{
|
||||
_constant_values[2 * i] = this->constant_values[0];
|
||||
_constant_values[2 * i + 1] = this->constant_values[1];
|
||||
}
|
||||
this->constant_values = _constant_values;
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(constant_values.size() == padding_dims);
|
||||
}
|
||||
}
|
||||
this->output_shape = input.shape;
|
||||
for (int i = 0; i < input_dims; ++i)
|
||||
{
|
||||
this->output_shape[i] += (this->paddings[2 * i] + this->paddings[2 * i + 1]);
|
||||
}
|
||||
|
||||
this->output->set_shape(this->output_shape);
|
||||
this->output->set_exponent(input.exponent);
|
||||
this->output->free_element();
|
||||
|
||||
if (print_shape)
|
||||
{
|
||||
std::cout << this->name << " | ";
|
||||
this->output->print_shape();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the output
|
||||
*
|
||||
* @return Tensor<feature_t>& Pad result
|
||||
*/
|
||||
Tensor<feature_t> &get_output()
|
||||
{
|
||||
return *this->output;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Call Pad operation
|
||||
*
|
||||
* @param input as an input.
|
||||
* @param autoload_enable one of true or false,
|
||||
* - true: load input and output from PSRAM to CACHE automatically
|
||||
* - false: do not
|
||||
* @param assign_core not effective yet
|
||||
* @return Pad result
|
||||
*/
|
||||
Tensor<feature_t> &call(Tensor<feature_t> &input, const std::vector<int> &assign_core = CONFIG_DEFAULT_ASSIGN_CORE)
|
||||
{
|
||||
DL_LOG_LAYER_LATENCY_INIT();
|
||||
|
||||
DL_LOG_LAYER_LATENCY_START();
|
||||
if (this->output->shape != this->output_shape)
|
||||
{
|
||||
this->output->set_shape(this->output_shape);
|
||||
}
|
||||
this->output->malloc_element();
|
||||
this->output->set_exponent(input.exponent);
|
||||
DL_LOG_LAYER_LATENCY_END(this->name, "apply");
|
||||
|
||||
DL_LOG_LAYER_LATENCY_START();
|
||||
nn::pad(*this->output, input, this->paddings, this->constant_values, this->mode, assign_core);
|
||||
DL_LOG_LAYER_LATENCY_END(this->name, "pad");
|
||||
return *this->output;
|
||||
}
|
||||
};
|
||||
} // namespace layer
|
||||
} // namespace dl
|
120
tools/sdk/esp32s2/include/esp-face/include/nn/dl_nn_pad.hpp
Normal file
120
tools/sdk/esp32s2/include/esp-face/include/nn/dl_nn_pad.hpp
Normal file
@ -0,0 +1,120 @@
|
||||
#pragma once
|
||||
|
||||
#include "dl_constant.hpp"
|
||||
#include "dl_variable.hpp"
|
||||
#include "dl_nn.hpp"
|
||||
|
||||
namespace dl
|
||||
{
|
||||
namespace nn
|
||||
{
|
||||
/**
|
||||
* @brief pad(input)
|
||||
*
|
||||
* @tparam feature_t
|
||||
* @param output as an output
|
||||
* @param input as an input
|
||||
* @param paddings number of values padded to the edges of each dim
|
||||
* @param constant_values used in PADDING_CONSTANT, the values to set the padded values for each dim
|
||||
* @param mode One of the following: PADDING_EMPTY, PADDING_CONSTANT, PADDING_EDGE, PADDING_REFLECT, PADDING_SYMMETRIC
|
||||
* @param assign_core not effective yet
|
||||
*/
|
||||
template <typename feature_t>
|
||||
void pad(Tensor<feature_t> &output,
|
||||
Tensor<feature_t> &input,
|
||||
std::vector<int> paddings,
|
||||
std::vector<feature_t> constant_values,
|
||||
padding_mode_t mode,
|
||||
const std::vector<int> &assign_core = CONFIG_DEFAULT_ASSIGN_CORE);
|
||||
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @tparam feature_t
|
||||
* @param input as an input
|
||||
* @param paddings number of values padded to the edges of each dim
|
||||
* @param constant_values used in PADDING_CONSTANT, the values to set the padded values for each dim
|
||||
* @param mode One of the following: PADDING_EMPTY, PADDING_CONSTANT, PADDING_EDGE, PADDING_REFLECT, PADDING_SYMMETRIC
|
||||
* @param assign_core not effective yet
|
||||
* @return Tensor<feature_t> the padded Tensor
|
||||
*/
|
||||
template <typename feature_t>
|
||||
Tensor<feature_t> pad(Tensor<feature_t> &input,
|
||||
std::vector<int> paddings,
|
||||
std::vector<feature_t> constant_values,
|
||||
padding_mode_t mode,
|
||||
const std::vector<int> &assign_core = CONFIG_DEFAULT_ASSIGN_CORE)
|
||||
{
|
||||
DL_LOG_NN_LATENCY_INIT();
|
||||
|
||||
DL_LOG_NN_LATENCY_START();
|
||||
|
||||
assert(paddings.size() > 0);
|
||||
int input_dims = input.shape.size();
|
||||
int padding_dims = input_dims * 2;
|
||||
std::vector<int> _paddings(padding_dims, 0);
|
||||
if (paddings.size() == 1)
|
||||
{
|
||||
for (int i = 0; i < padding_dims; ++i)
|
||||
{
|
||||
_paddings[i] = paddings[0];
|
||||
}
|
||||
}
|
||||
else if (paddings.size() == 2)
|
||||
{
|
||||
for (int i = 0; i < input_dims; ++i)
|
||||
{
|
||||
_paddings[2 * i] = paddings[0];
|
||||
_paddings[2 * i + 1] = paddings[1];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(paddings.size() == padding_dims);
|
||||
_paddings = paddings;
|
||||
}
|
||||
|
||||
std::vector<feature_t> _constant_values(padding_dims, 0);
|
||||
if (mode == PADDING_CONSTANT)
|
||||
{
|
||||
if (constant_values.size() == 1)
|
||||
{
|
||||
for (int i = 0; i < padding_dims; ++i)
|
||||
{
|
||||
_constant_values[i] = constant_values[0];
|
||||
}
|
||||
}
|
||||
else if (constant_values.size() == 2)
|
||||
{
|
||||
for (int i = 0; i < input_dims; ++i)
|
||||
{
|
||||
_constant_values[2 * i] = constant_values[0];
|
||||
_constant_values[2 * i + 1] = constant_values[1];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(constant_values.size() == padding_dims);
|
||||
_constant_values = constant_values;
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<int> output_shape = input.shape;
|
||||
for (int i = 0; i < input_dims; ++i)
|
||||
{
|
||||
output_shape[i] += (_paddings[2 * i] + _paddings[2 * i + 1]);
|
||||
}
|
||||
|
||||
Tensor<feature_t> output;
|
||||
output.set_exponent(input.exponent).set_shape(output_shape).malloc_element();
|
||||
DL_LOG_NN_LATENCY_END("apply");
|
||||
|
||||
DL_LOG_NN_LATENCY_START();
|
||||
pad(output, input, _paddings, _constant_values, mode, assign_core);
|
||||
DL_LOG_NN_LATENCY_END("pad");
|
||||
|
||||
return output;
|
||||
}
|
||||
} // namespace nn
|
||||
} // namespace dl
|
@ -71,7 +71,7 @@ namespace dl
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
* @brief copy the element of the input Tensor.
|
||||
*
|
||||
* @param input an input Tensor
|
||||
* @param deep one of true or false
|
||||
@ -258,6 +258,56 @@ namespace dl
|
||||
return this->element[index];
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the all the element to value.
|
||||
*
|
||||
* @param value target value
|
||||
* @return Tensor<T>& self
|
||||
*/
|
||||
Tensor<T> &set_value(T value);
|
||||
|
||||
/**
|
||||
* @brief Set the the element to value
|
||||
*
|
||||
* @param value target value, it will be broadcast automatically.
|
||||
* @return Tensor<T>& self
|
||||
*/
|
||||
Tensor<T> &set_value(Tensor<T> &value);
|
||||
|
||||
/**
|
||||
* @brief Set the sliced element to value
|
||||
*
|
||||
* @param axis_index_range range of slices
|
||||
* @param value target value
|
||||
* @return Tensor<T>& self
|
||||
*/
|
||||
Tensor<T> &set_value(std::vector<int> axis_index_range, T value);
|
||||
|
||||
/**
|
||||
* @brief Set the sliced element to value
|
||||
*
|
||||
* @param axis_index_range range of slices
|
||||
* @param value target value, it will be broadcast automatically.
|
||||
* @return Tensor<T>& self
|
||||
*/
|
||||
Tensor<T> &set_value(std::vector<int> axis_index_range, Tensor<T> &value);
|
||||
|
||||
/**
|
||||
* @brief Extracts a slice from the Tensor.
|
||||
*
|
||||
* @param axis_index_range range of slices
|
||||
* @return Tensor<T> output
|
||||
*/
|
||||
Tensor<T> slice(std::vector<int> axis_index_range);
|
||||
|
||||
/**
|
||||
* @brief Reverses specific dims of the tensor.
|
||||
*
|
||||
* @param axis The dims to be reversed
|
||||
* @return Tensor<T>&
|
||||
*/
|
||||
Tensor<T> &reverse(std::vector<int> axis);
|
||||
|
||||
/**
|
||||
* @brief Get the size of Tensor.
|
||||
*
|
||||
@ -491,5 +541,16 @@ namespace dl
|
||||
return *this;
|
||||
}
|
||||
}
|
||||
|
||||
static Tensor<T> arange(int size)
|
||||
{
|
||||
Tensor<T> output;
|
||||
output.set_auto_free(true).set_exponent(0).set_shape({size}).malloc_element();
|
||||
for (int i = 0; i < size; ++i)
|
||||
{
|
||||
output.element[i] = i;
|
||||
}
|
||||
return output;
|
||||
}
|
||||
};
|
||||
} // namespace dl
|
@ -85,6 +85,13 @@ uint8_t phy_dig_reg_backup(bool backup_en, uint32_t *mem_addr);
|
||||
void phy_freq_mem_backup(bool backup_en, uint32_t *mem);
|
||||
#endif
|
||||
|
||||
#if CONFIG_ESP_PHY_ENABLE_USB
|
||||
/**
|
||||
* @brief Enable or disable USB when phy init.
|
||||
*/
|
||||
void phy_bbpll_en_usb(bool en);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -4,8 +4,7 @@
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
// Allow for this warning suppression only in IDF_CI_BUILD
|
||||
#if !defined(ESP_OPENSSL_SUPPRESS_LEGACY_WARNING) || !defined(IDF_CI_BUILD)
|
||||
#if !defined(ESP_OPENSSL_SUPPRESS_LEGACY_WARNING)
|
||||
#warning "OpenSSL component will be removed from ESP-IDF in v5.0, please use esp_tls instead"
|
||||
#endif
|
||||
|
||||
|
Binary file not shown.
BIN
tools/sdk/esp32s2/ld/libcolor_detect.a
Normal file
BIN
tools/sdk/esp32s2/ld/libcolor_detect.a
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
tools/sdk/esp32s2/ld/libmfn.a
Normal file
BIN
tools/sdk/esp32s2/ld/libmfn.a
Normal file
Binary file not shown.
@ -1,6 +1,6 @@
|
||||
/* Automatically generated file; DO NOT EDIT */
|
||||
/* Espressif IoT Development Framework Linker Script */
|
||||
/* Generated from: /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp_system/ld/esp32s2/sections.ld.in */
|
||||
/* Generated from: /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_system/ld/esp32s2/sections.ld.in */
|
||||
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user