-
Notifications
You must be signed in to change notification settings - Fork 33
/
tusb_config.h
160 lines (119 loc) · 4.88 KB
/
tusb_config.h
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
/*
* tusb_config.h
*
* Created on: May 5, 2021
* Author: Jeremiah McCarthy
*/
#ifndef TUSB_CONFIG_H_
#define TUSB_CONFIG_H_
#ifdef __cplusplus
extern "C" {
#endif
#include "hardware.h"
#include "formats.h"
#if WITHTINYUSB
#define CFG_TUSB_MCU OPT_MCU_F1C100S
// Enable Device stack
//#define CFG_TUD_ENABLED 1
//------------- CLASS -------------//
#define CFG_TUD_CDC 1
//#define CFG_TUD_HID 1
//#define CFG_TUD_DFU 1
//#define CFG_TUD_AUDIO 2
#define CFG_TUD_MSC 0
#define CFG_TUD_MIDI 0
#define CFG_TUD_VENDOR 0
// CDC FIFO size of TX and RX
#define CFG_TUD_CDC_RX_BUFSIZE 64//(TUD_OPT_HIGH_SPEED ? 512 : 64)
#define CFG_TUD_CDC_TX_BUFSIZE 64//(TUD_OPT_HIGH_SPEED ? 512 : 64)
// CDC Endpoint transfer buffer size, more is faster
#define CFG_TUD_CDC_EP_BUFSIZE 64//(TUD_OPT_HIGH_SPEED ? 512 : 64)
#define CFG_TUH_ENABLED 1
#define TUP_USBIP_OHCI 1
//#define TUP_USBIP_EHCI 1
#define CFG_TUH_ENDPOINT_MAX 16
#define CFG_TUSB_RHPORT0_MODE OPT_MODE_HOST
//#define BOARD_TUD_MAX_SPEED OPT_MODE_HIGH_SPEED
//#define BOARD_TUH_MAX_SPEED OPT_MODE_HIGH_SPEED
#define CFG_TUH_MSC 1 // количество поддерживаемых устройств
#define CFG_TUH_HID 4
#define CFG_TUH_CDC 12 // количество поддерживаемых устройств
//#define CFG_TUH_CDC_FTDI 1 // 0/1 - поддержка FTDI CHIP
//#define CFG_TUH_CDC_CP210X 1 // 0/1
#define CFG_TUH_BTH 1 // количество поддерживаемых устройств
#define CFG_TUSB_DEBUG 0 // 0..3
#define TUP_OHCI_RHPORTS 1
#define CFG_TUH_HUB 12
#define CFG_TUH_DEVICE_MAX 12 // Не должно быть больше чем CFG_TUH_HUB
#define CFG_TUH_ENUMERATION_BUFSIZE 2048
//--------------------------------------------------------------------+
// Board Specific Configuration
//--------------------------------------------------------------------+
// RHPort number used for device can be defined by board.mk, default to port 0
#ifndef BOARD_TUD_RHPORT
#define BOARD_TUD_RHPORT 0
#endif
// RHPort max operational speed can defined by board.mk
//#ifndef BOARD_TUD_MAX_SPEED
//#define BOARD_TUD_MAX_SPEED OPT_MODE_DEFAULT_SPEED
//#endif
//--------------------------------------------------------------------
// COMMON CONFIGURATION
//--------------------------------------------------------------------
// defined by compiler flags for flexibility
#ifndef CFG_TUSB_MCU
#error CFG_TUSB_MCU must be defined
#endif
//#ifndef CFG_TUSB_OS
#define CFG_TUSB_OS OPT_OS_NONE
//#endif
#ifndef CFG_TUSB_DEBUG
#define CFG_TUSB_DEBUG 3
#endif
//#define BOARD_TUD_MAX_SPEED OPT_MODE_DEFAULT_SPEED
#define BOARD_TUD_MAX_SPEED OPT_MODE_HIGH_SPEED
// Default is max speed that hardware controller could support with on-chip PHY
#define CFG_TUD_MAX_SPEED BOARD_TUD_MAX_SPEED
/* USB DMA on some MCUs can only access a specific SRAM region with restriction on alignment.
* Tinyusb use follows macros to declare transferring memory so that they can be put
* into those specific section.
* e.g
* - CFG_TUSB_MEM SECTION : __attribute__ (( section(".usb_ram") ))
* - CFG_TUSB_MEM_ALIGN : __attribute__ ((aligned(4)))
*/
#define CFG_TUSB_MEM_SECTION RAMNC
//--------------------------------------------------------------------
// DEVICE CONFIGURATION
//--------------------------------------------------------------------
#ifndef CFG_TUD_ENDPOINT0_SIZE
#define CFG_TUD_ENDPOINT0_SIZE 64
#endif
//------------- CLASS -------------//
//#define CFG_TUD_DFU 1
// DFU buffer size, it has to be set to the buffer size used in TUD_DFU_DESCRIPTOR
#define CFG_TUD_DFU_XFER_BUFSIZE 64//(TUD_OPT_HIGH_SPEED ? 512 : 64)
#define LPC_USB_BASE WITHUSBHW_OHCI
#if defined (WITHUSBHW_EHCI) || defined (WITHUSBHW_OHCI)
#define CI_HS_REG(_port) ((void *) WITHUSBHW_EHCI)
//------------- DCD -------------//
#define CI_DCD_INT_ENABLE(_p) do { arm_hardware_enable_handler(WITHUSBHW_OTG_IRQ); } while (0)
#define CI_DCD_INT_DISABLE(_p) do { arm_hardware_disable_handler(WITHUSBHW_OTG_IRQ); } while (0)
//------------- HCD -------------//
#define CI_HCD_INT_ENABLE(_p) do { arm_hardware_enable_handler(WITHUSBHW_EHCI_IRQ); arm_hardware_enable_handler(WITHUSBHW_OHCI_IRQ); } while (0)
#define CI_HCD_INT_DISABLE(_p) do { arm_hardware_disable_handler(WITHUSBHW_OHCI_IRQ); arm_hardware_disable_handler(WITHUSBHW_EHCI_IRQ); } while (0)
#else
#define CI_HS_REG(_port) (NULL)
//------------- DCD -------------//
#define CI_DCD_INT_ENABLE(_p) do { } while (0)
#define CI_DCD_INT_DISABLE(_p) do { } while (0)
//------------- HCD -------------//
#define CI_HCD_INT_ENABLE(_p) do { } while (0)
#define CI_HCD_INT_DISABLE(_p) do { } while (0)
#endif
void ohciehci_clk_init(void);
void usbdevice_clk_init(void);
#endif /* WITHTINYUSB */
#ifdef __cplusplus
}
#endif
#endif /* TUSB_CONFIG_H_ */