2 **************************************************************************
6 * @brief usb config header file
7 **************************************************************************
8 * Copyright notice & Disclaimer
10 * The software Board Support Package (BSP) that is made available to
11 * download from Artery official website is the copyrighted work of Artery.
12 * Artery authorizes customers to use, copy, and distribute the BSP
13 * software and its related documentation for the purpose of design and
14 * development in conjunction with Artery microcontrollers. Use of the
15 * software is governed by this copyright notice and the following disclaimer.
17 * THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
18 * GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS,
19 * TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR
20 * STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS,
21 * INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
24 **************************************************************************
27 /* define to prevent recursive inclusion -------------------------------------*/
35 #include "at32f435_437_usb.h"
36 #include "at32f435_437.h"
39 /** @addtogroup AT32F437_periph_examples
43 /** @addtogroup 437_USB_device_vcp_loopback
48 * @brief enable usb device mode
50 #define USE_OTG_DEVICE_MODE
53 * @brief enable usb host mode
55 /* #define USE_OTG_HOST_MODE */
58 * @brief select otgfs1 or otgfs2 define
65 //#define OTG_USB_ID 2
69 #define OTG_CLOCK CRM_OTGFS1_PERIPH_CLOCK
70 #define OTG_IRQ OTGFS1_IRQn
71 #define OTG_IRQ_HANDLER OTGFS1_IRQHandler
72 #define OTG_WKUP_IRQ OTGFS1_WKUP_IRQn
73 #define OTG_WKUP_HANDLER OTGFS1_WKUP_IRQHandler
74 #define OTG_WKUP_EXINT_LINE EXINT_LINE_18
76 #define OTG_PIN_GPIO GPIOA
77 #define OTG_PIN_GPIO_CLOCK CRM_GPIOA_PERIPH_CLOCK
79 #define OTG_PIN_DP GPIO_PINS_12
80 #define OTG_PIN_DP_SOURCE GPIO_PINS_SOURCE12
82 #define OTG_PIN_DM GPIO_PINS_11
83 #define OTG_PIN_DM_SOURCE GPIO_PINS_SOURCE11
85 #define OTG_PIN_VBUS GPIO_PINS_9
86 #define OTG_PIN_VBUS_SOURCE GPIO_PINS_SOURCE9
88 #define OTG_PIN_ID GPIO_PINS_10
89 #define OTG_PIN_ID_SOURCE GPIO_PINS_SOURCE10
91 #define OTG_PIN_SOF_GPIO GPIOA
92 #define OTG_PIN_SOF_GPIO_CLOCK CRM_GPIOA_PERIPH_CLOCK
93 #define OTG_PIN_SOF GPIO_PINS_8
94 #define OTG_PIN_SOF_SOURCE GPIO_PINS_SOURCE8
96 #define OTG_PIN_MUX GPIO_MUX_10
101 #define OTG_CLOCK CRM_OTGFS2_PERIPH_CLOCK
102 #define OTG_IRQ OTGFS2_IRQn
103 #define OTG_IRQ_HANDLER OTGFS2_IRQHandler
104 #define OTG_WKUP_IRQ OTGFS2_WKUP_IRQn
105 #define OTG_WKUP_HANDLER OTGFS2_WKUP_IRQHandler
106 #define OTG_WKUP_EXINT_LINE EXINT_LINE_20
108 #define OTG_PIN_GPIO GPIOB
109 #define OTG_PIN_GPIO_CLOCK CRM_GPIOB_PERIPH_CLOCK
111 #define OTG_PIN_DP GPIO_PINS_15
112 #define OTG_PIN_DP_SOURCE GPIO_PINS_SOURCE15
114 #define OTG_PIN_DM GPIO_PINS_14
115 #define OTG_PIN_DM_SOURCE GPIO_PINS_SOURCE14
117 #define OTG_PIN_VBUS GPIO_PINS_13
118 #define OTG_PIN_VBUS_SOURCE GPIO_PINS_SOURCE13
120 #define OTG_PIN_ID GPIO_PINS_12
121 #define OTG_PIN_ID_SOURCE GPIO_PINS_SOURCE10
123 #define OTG_PIN_SOF_GPIO GPIOA
124 #define OTG_PIN_SOF_GPIO_CLOCK CRM_GPIOA_PERIPH_CLOCK
125 #define OTG_PIN_SOF GPIO_PINS_4
126 #define OTG_PIN_SOF_SOURCE GPIO_PINS_SOURCE4
128 #define OTG_PIN_MUX GPIO_MUX_12
132 * @brief usb device mode config
134 #ifdef USE_OTG_DEVICE_MODE
136 * @brief usb device mode fifo
138 /* otg1 device fifo */
139 #define USBD_RX_SIZE 128
140 #define USBD_EP0_TX_SIZE 24
141 #define USBD_EP1_TX_SIZE 20
142 #define USBD_EP2_TX_SIZE 20
143 #define USBD_EP3_TX_SIZE 20
144 #define USBD_EP4_TX_SIZE 20
145 #define USBD_EP5_TX_SIZE 20
146 #define USBD_EP6_TX_SIZE 20
147 #define USBD_EP7_TX_SIZE 20
149 /* otg2 device fifo */
150 #define USBD2_RX_SIZE 128
151 #define USBD2_EP0_TX_SIZE 24
152 #define USBD2_EP1_TX_SIZE 20
153 #define USBD2_EP2_TX_SIZE 20
154 #define USBD2_EP3_TX_SIZE 20
155 #define USBD2_EP4_TX_SIZE 20
156 #define USBD2_EP5_TX_SIZE 20
157 #define USBD2_EP6_TX_SIZE 20
158 #define USBD2_EP7_TX_SIZE 20
161 * @brief usb endpoint max num define
163 #ifndef USB_EPT_MAX_NUM
164 #define USB_EPT_MAX_NUM 8
169 * @brief usb host mode config
171 #ifdef USE_OTG_HOST_MODE
172 #ifndef USB_HOST_CHANNEL_NUM
173 #define USB_HOST_CHANNEL_NUM 16
177 * @brief usb host mode fifo
180 #define USBH_RX_FIFO_SIZE 128
181 #define USBH_NP_TX_FIFO_SIZE 96
182 #define USBH_P_TX_FIFO_SIZE 96
185 #define USBH2_RX_FIFO_SIZE 128
186 #define USBH2_NP_TX_FIFO_SIZE 96
187 #define USBH2_P_TX_FIFO_SIZE 96
191 * @brief usb sof output enable
193 /* #define USB_SOF_OUTPUT_ENABLE */
196 * @brief usb vbus ignore, not use vbus pin
198 #define USB_VBUS_IGNORE
201 * @brief usb low power wakeup handler enable
203 /* #define USB_LOW_POWER_WAKUP */
205 void usb_delay_ms(uint32_t ms
);
206 void usb_delay_us(uint32_t us
);