1 /* 2 * Copyright (c) 2006-2021, RT-Thread Development Team 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 * 6 * Change Logs: 7 * Date Author Notes 8 * 2023-02-28 leo first version 9 */ 10 11 #ifndef __USB_CONFIG_H__ 12 #define __USB_CONFIG_H__ 13 14 #include <rtthread.h> 15 16 #ifdef __cplusplus 17 extern "C" { 18 #endif 19 20 #if defined BSP_USING_DEVICE_USBOTG1 || defined BSP_USING_DEVICE_USBOTG2 21 #define USE_OTG_DEVICE_MODE 22 #endif 23 24 #if defined BSP_USING_HOST_USBOTG1 || defined BSP_USING_HOST_USBOTG2 25 #define USE_OTG_HOST_MODE 26 #endif 27 28 /* usb irqhandler */ 29 #define OTGFS1_IRQHandler OTGFS1_IRQHandler 30 #define OTGFS2_IRQHandler OTGHS_IRQHandler 31 32 /** 33 * @brief usb device mode config 34 */ 35 #define USB_EPT_MAX_NUM 8 36 37 /* otg1 device fifo */ 38 #define USBD_RX_SIZE 128 39 #define USBD_EP0_TX_SIZE 24 40 #define USBD_EP1_TX_SIZE 20 41 #define USBD_EP2_TX_SIZE 20 42 #define USBD_EP3_TX_SIZE 20 43 #define USBD_EP4_TX_SIZE 20 44 #define USBD_EP5_TX_SIZE 20 45 #define USBD_EP6_TX_SIZE 20 46 #define USBD_EP7_TX_SIZE 20 47 48 /* otg2 device fifo */ 49 #define USBD2_RX_SIZE 256 50 #define USBD2_EP0_TX_SIZE 64 51 #define USBD2_EP1_TX_SIZE 256 52 #define USBD2_EP2_TX_SIZE 256 53 #define USBD2_EP3_TX_SIZE 20 54 #define USBD2_EP4_TX_SIZE 20 55 #define USBD2_EP5_TX_SIZE 20 56 #define USBD2_EP6_TX_SIZE 20 57 #define USBD2_EP7_TX_SIZE 20 58 59 /** 60 * @brief usb host mode config 61 */ 62 #define USB_HOST_CHANNEL_NUM 16 63 64 /* otg1 host fifo */ 65 #define USBH_RX_FIFO_SIZE 128 66 #define USBH_NP_TX_FIFO_SIZE 96 67 #define USBH_P_TX_FIFO_SIZE 96 68 69 /* otg2 host fifo */ 70 #define USBH2_RX_FIFO_SIZE 256 71 #define USBH2_NP_TX_FIFO_SIZE 256 72 #define USBH2_P_TX_FIFO_SIZE 256 73 74 /** 75 * @brief usb sof output enable 76 */ 77 // #define USB_SOF_OUTPUT_ENABLE 78 79 /** 80 * @brief usb vbus ignore, not use vbus pin 81 */ 82 #define USB_VBUS_IGNORE 83 84 /** 85 * @brief usb high speed support dma mode 86 */ 87 // #define OTG_USE_DMA 88 89 /** 90 * @brief usb low power wakeup handler enable 91 */ 92 // #define USB_LOW_POWER_WAKUP 93 94 #if defined(BSP_USING_HOST_USBOTG1) 95 #undef BSP_USING_HOST_USBOTG2 96 #undef BSP_USING_DEVICE_USBOTG1 97 #define USBOTG1_CONFIG \ 98 { \ 99 .name = "usbh1", \ 100 .id = USB_OTG1_ID, \ 101 .dev_spd = USB_FULL_SPEED_CORE_ID, \ 102 .irqn = OTGFS1_IRQn, \ 103 } 104 #endif /* BSP_USING_HOST_USBOTG1 */ 105 106 #if defined(BSP_USING_DEVICE_USBOTG1) 107 #undef BSP_USING_DEVICE_USBOTG2 108 #define USBOTG1_CONFIG \ 109 { \ 110 .name = "usbd", \ 111 .id = USB_OTG1_ID, \ 112 .dev_spd = USB_FULL_SPEED_CORE_ID, \ 113 .irqn = OTGFS1_IRQn, \ 114 } 115 #endif /* BSP_USING_DEVICE_USBOTG1 */ 116 117 #if defined(BSP_USING_HOST_USBOTG2) 118 #undef BSP_USING_HOST_USBOTG1 119 #undef BSP_USING_DEVICE_USBOTG2 120 #define USBOTG2_CONFIG \ 121 { \ 122 .name = "usbh2", \ 123 .id = USB_OTG2_ID, \ 124 .dev_spd = USB_HIGH_SPEED_CORE_ID, \ 125 .irqn = OTGHS_IRQn, \ 126 } 127 #endif /* BSP_USING_HOST_USBOTG2 */ 128 129 #if defined(BSP_USING_DEVICE_USBOTG2) 130 #undef BSP_USING_DEVICE_USBOTG1 131 #define USBOTG2_CONFIG \ 132 { \ 133 .name = "usbd", \ 134 .id = USB_OTG2_ID, \ 135 .dev_spd = USB_HIGH_SPEED_CORE_ID, \ 136 .irqn = OTGHS_IRQn, \ 137 } 138 #endif /* BSP_USING_DEVICE_USBOTG2 */ 139 140 #ifdef __cplusplus 141 } 142 #endif 143 144 #endif 145