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 OTGFS2_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 128 50 #define USBD2_EP0_TX_SIZE 24 51 #define USBD2_EP1_TX_SIZE 20 52 #define USBD2_EP2_TX_SIZE 20 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 128 71 #define USBH2_NP_TX_FIFO_SIZE 96 72 #define USBH2_P_TX_FIFO_SIZE 96 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 low power wakeup handler enable 86 */ 87 // #define USB_LOW_POWER_WAKUP 88 89 #if defined(BSP_USING_HOST_USBOTG1) 90 #undef BSP_USING_HOST_USBOTG2 91 #undef BSP_USING_DEVICE_USBOTG1 92 #define USBOTG1_CONFIG \ 93 { \ 94 .name = "usbh1", \ 95 .id = USB_OTG1_ID, \ 96 .dev_spd = USB_FULL_SPEED_CORE_ID, \ 97 .irqn = OTGFS1_IRQn, \ 98 } 99 #endif /* BSP_USING_HOST_USBOTG1 */ 100 101 #if defined(BSP_USING_DEVICE_USBOTG1) 102 #undef BSP_USING_DEVICE_USBOTG2 103 #define USBOTG1_CONFIG \ 104 { \ 105 .name = "usbd", \ 106 .id = USB_OTG1_ID, \ 107 .dev_spd = USB_FULL_SPEED_CORE_ID, \ 108 .irqn = OTGFS1_IRQn, \ 109 } 110 #endif /* BSP_USING_DEVICE_USBOTG1 */ 111 112 #if defined(BSP_USING_HOST_USBOTG2) 113 #undef BSP_USING_HOST_USBOTG1 114 #undef BSP_USING_DEVICE_USBOTG2 115 #define USBOTG2_CONFIG \ 116 { \ 117 .name = "usbh2", \ 118 .id = USB_OTG2_ID, \ 119 .dev_spd = USB_FULL_SPEED_CORE_ID, \ 120 .irqn = OTGFS2_IRQn, \ 121 } 122 #endif /* BSP_USING_HOST_USBOTG2 */ 123 124 #if defined(BSP_USING_DEVICE_USBOTG2) 125 #undef BSP_USING_DEVICE_USBOTG1 126 #define USBOTG2_CONFIG \ 127 { \ 128 .name = "usbd", \ 129 .id = USB_OTG2_ID, \ 130 .dev_spd = USB_FULL_SPEED_CORE_ID, \ 131 .irqn = OTGFS2_IRQn, \ 132 } 133 #endif /* BSP_USING_DEVICE_USBOTG2 */ 134 135 #ifdef __cplusplus 136 } 137 #endif 138 139 #endif 140