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 * 2024-12-18 shelton 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 21 #define USE_OTG_DEVICE_MODE 22 #endif 23 24 #if defined BSP_USING_HOST_USBOTG1 25 #define USE_OTG_HOST_MODE 26 #endif 27 28 /* usb irqhandler */ 29 #define OTGFS1_IRQHandler OTGFS1_IRQHandler 30 31 /** 32 * @brief usb device mode config 33 */ 34 #define USB_EPT_MAX_NUM 8 35 36 /* otg1 device fifo */ 37 #define USBD_RX_SIZE 128 38 #define USBD_EP0_TX_SIZE 24 39 #define USBD_EP1_TX_SIZE 20 40 #define USBD_EP2_TX_SIZE 20 41 #define USBD_EP3_TX_SIZE 20 42 #define USBD_EP4_TX_SIZE 20 43 #define USBD_EP5_TX_SIZE 20 44 #define USBD_EP6_TX_SIZE 20 45 #define USBD_EP7_TX_SIZE 20 46 47 /* otg2 device fifo */ 48 #define USBD2_RX_SIZE 256 49 #define USBD2_EP0_TX_SIZE 64 50 #define USBD2_EP1_TX_SIZE 256 51 #define USBD2_EP2_TX_SIZE 256 52 #define USBD2_EP3_TX_SIZE 20 53 #define USBD2_EP4_TX_SIZE 20 54 #define USBD2_EP5_TX_SIZE 20 55 #define USBD2_EP6_TX_SIZE 20 56 #define USBD2_EP7_TX_SIZE 20 57 58 /** 59 * @brief usb host mode config 60 */ 61 #define USB_HOST_CHANNEL_NUM 16 62 63 /* otg1 host fifo */ 64 #define USBH_RX_FIFO_SIZE 128 65 #define USBH_NP_TX_FIFO_SIZE 96 66 #define USBH_P_TX_FIFO_SIZE 96 67 68 /* otg2 host fifo */ 69 #define USBH2_RX_FIFO_SIZE 256 70 #define USBH2_NP_TX_FIFO_SIZE 256 71 #define USBH2_P_TX_FIFO_SIZE 256 72 73 /** 74 * @brief usb sof output enable 75 */ 76 // #define USB_SOF_OUTPUT_ENABLE 77 78 /** 79 * @brief usb vbus ignore, not use vbus pin 80 */ 81 #define USB_VBUS_IGNORE 82 83 /** 84 * @brief usb high speed support dma mode 85 */ 86 // #define OTG_USE_DMA 87 88 /** 89 * @brief usb low power wakeup handler enable 90 */ 91 // #define USB_LOW_POWER_WAKUP 92 93 #if defined(BSP_USING_HOST_USBOTG1) 94 #undef BSP_USING_DEVICE_USBOTG1 95 #define USBOTG1_CONFIG \ 96 { \ 97 .name = "usbh1", \ 98 .id = USB_OTG1_ID, \ 99 .dev_spd = USB_FULL_SPEED_CORE_ID, \ 100 .irqn = OTGFS1_IRQn, \ 101 } 102 #endif /* BSP_USING_HOST_USBOTG1 */ 103 104 #if defined(BSP_USING_DEVICE_USBOTG1) 105 #define USBOTG1_CONFIG \ 106 { \ 107 .name = "usbd", \ 108 .id = USB_OTG1_ID, \ 109 .dev_spd = USB_FULL_SPEED_CORE_ID, \ 110 .irqn = OTGFS1_IRQn, \ 111 } 112 #endif /* BSP_USING_DEVICE_USBOTG1 */ 113 114 #ifdef __cplusplus 115 } 116 #endif 117 118 #endif 119