Repostiory containing DAPLink source code with Reset Pin workaround for HANI_IOT board.

Upstream: https://github.com/ARMmbed/DAPLink

Committer:
Pawel Zarembski
Date:
Tue Apr 07 12:55:42 2020 +0200
Revision:
0:01f31e923fe2
hani: DAPLink with reset workaround

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Pawel Zarembski 0:01f31e923fe2 1 /**
Pawel Zarembski 0:01f31e923fe2 2 * @file usb_config.c
Pawel Zarembski 0:01f31e923fe2 3 * @brief
Pawel Zarembski 0:01f31e923fe2 4 *
Pawel Zarembski 0:01f31e923fe2 5 * DAPLink Interface Firmware
Pawel Zarembski 0:01f31e923fe2 6 * Copyright (c) 2009-2019, ARM Limited, All Rights Reserved
Pawel Zarembski 0:01f31e923fe2 7 * SPDX-License-Identifier: Apache-2.0
Pawel Zarembski 0:01f31e923fe2 8 *
Pawel Zarembski 0:01f31e923fe2 9 * Licensed under the Apache License, Version 2.0 (the "License"); you may
Pawel Zarembski 0:01f31e923fe2 10 * not use this file except in compliance with the License.
Pawel Zarembski 0:01f31e923fe2 11 * You may obtain a copy of the License at
Pawel Zarembski 0:01f31e923fe2 12 *
Pawel Zarembski 0:01f31e923fe2 13 * http://www.apache.org/licenses/LICENSE-2.0
Pawel Zarembski 0:01f31e923fe2 14 *
Pawel Zarembski 0:01f31e923fe2 15 * Unless required by applicable law or agreed to in writing, software
Pawel Zarembski 0:01f31e923fe2 16 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
Pawel Zarembski 0:01f31e923fe2 17 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Pawel Zarembski 0:01f31e923fe2 18 * See the License for the specific language governing permissions and
Pawel Zarembski 0:01f31e923fe2 19 * limitations under the License.
Pawel Zarembski 0:01f31e923fe2 20 */
Pawel Zarembski 0:01f31e923fe2 21
Pawel Zarembski 0:01f31e923fe2 22 #include "util.h"
Pawel Zarembski 0:01f31e923fe2 23
Pawel Zarembski 0:01f31e923fe2 24 // <e> USB Device
Pawel Zarembski 0:01f31e923fe2 25 // <i> Enable the USB Device functionality
Pawel Zarembski 0:01f31e923fe2 26 #define USBD_ENABLE 1
Pawel Zarembski 0:01f31e923fe2 27 #define USBD_RTX_CORE_STACK 0
Pawel Zarembski 0:01f31e923fe2 28 #define USBD_RTX_DEVICE_STACK 0
Pawel Zarembski 0:01f31e923fe2 29 #define USBD_RTX_ENDPOINT0_STACK 0
Pawel Zarembski 0:01f31e923fe2 30
Pawel Zarembski 0:01f31e923fe2 31 // <o0.0> High-speed
Pawel Zarembski 0:01f31e923fe2 32 // <i> Enable high-speed functionality (if device supports it)
Pawel Zarembski 0:01f31e923fe2 33 #define USBD_HS_ENABLE 0
Pawel Zarembski 0:01f31e923fe2 34 #if (defined(WEBUSB_INTERFACE) || defined(WINUSB_INTERFACE) || defined(BULK_ENDPOINT))
Pawel Zarembski 0:01f31e923fe2 35 #define USBD_BOS_ENABLE 1
Pawel Zarembski 0:01f31e923fe2 36 #else
Pawel Zarembski 0:01f31e923fe2 37 #define USBD_BOS_ENABLE 0
Pawel Zarembski 0:01f31e923fe2 38 #endif
Pawel Zarembski 0:01f31e923fe2 39 // <h> Device Settings
Pawel Zarembski 0:01f31e923fe2 40 // <i> These settings affect Device Descriptor
Pawel Zarembski 0:01f31e923fe2 41 // <o0> Power
Pawel Zarembski 0:01f31e923fe2 42 // <i> Default Power Setting
Pawel Zarembski 0:01f31e923fe2 43 // <0=> Bus-powered
Pawel Zarembski 0:01f31e923fe2 44 // <1=> Self-powered
Pawel Zarembski 0:01f31e923fe2 45 // <o1> Max Endpoint 0 Packet Size
Pawel Zarembski 0:01f31e923fe2 46 // <i> Maximum packet size for endpoint zero (bMaxPacketSize0)
Pawel Zarembski 0:01f31e923fe2 47 // <8=> 8 Bytes <16=> 16 Bytes <32=> 32 Bytes <64=> 64 Bytes
Pawel Zarembski 0:01f31e923fe2 48 // <o2.0..15> Vendor ID <0x0000-0xFFFF>
Pawel Zarembski 0:01f31e923fe2 49 // <i> Vendor ID assigned by the USB-IF (idVendor)
Pawel Zarembski 0:01f31e923fe2 50 // <o3.0..15> Product ID <0x0000-0xFFFF>
Pawel Zarembski 0:01f31e923fe2 51 // <i> Product ID assigned by the manufacturer (idProduct)
Pawel Zarembski 0:01f31e923fe2 52 // <o4.0..15> Device Release Number <0x0000-0xFFFF>
Pawel Zarembski 0:01f31e923fe2 53 // <i> Device release number in binary-coded decimal (bcdDevice)
Pawel Zarembski 0:01f31e923fe2 54 // </h>
Pawel Zarembski 0:01f31e923fe2 55 #define USBD_POWER 0
Pawel Zarembski 0:01f31e923fe2 56 #define USBD_MAX_PACKET0 64
Pawel Zarembski 0:01f31e923fe2 57 #define USBD_DEVDESC_IDVENDOR 0x0D28
Pawel Zarembski 0:01f31e923fe2 58 #define USBD_DEVDESC_IDPRODUCT 0x0204
Pawel Zarembski 0:01f31e923fe2 59 #define USBD_DEVDESC_BCDDEVICE 0x0100
Pawel Zarembski 0:01f31e923fe2 60
Pawel Zarembski 0:01f31e923fe2 61 // <h> Configuration Settings
Pawel Zarembski 0:01f31e923fe2 62 // <i> These settings affect Configuration Descriptor
Pawel Zarembski 0:01f31e923fe2 63 // <o0.5> Remote Wakeup
Pawel Zarembski 0:01f31e923fe2 64 // <i> Configuration support for remote wakeup (D5: of bmAttributes)
Pawel Zarembski 0:01f31e923fe2 65 // <o1.0..7> Maximum Power Consumption (in mA) <0-510><#/2>
Pawel Zarembski 0:01f31e923fe2 66 // <i> Maximum power consumption of the USB device
Pawel Zarembski 0:01f31e923fe2 67 // <i> from the bus in this specific configuration
Pawel Zarembski 0:01f31e923fe2 68 // <i> when the device is fully operational (bMaxPower)
Pawel Zarembski 0:01f31e923fe2 69 // </h>
Pawel Zarembski 0:01f31e923fe2 70 #define USBD_CFGDESC_BMATTRIBUTES 0x80
Pawel Zarembski 0:01f31e923fe2 71 #define USBD_CFGDESC_BMAXPOWER 0xFA
Pawel Zarembski 0:01f31e923fe2 72
Pawel Zarembski 0:01f31e923fe2 73 // <h> String Settings
Pawel Zarembski 0:01f31e923fe2 74 // <i> These settings affect String Descriptor
Pawel Zarembski 0:01f31e923fe2 75 // <o0.0..15> Language ID <0x0000-0xFCFF>
Pawel Zarembski 0:01f31e923fe2 76 // <i> English (United States) = 0x0409
Pawel Zarembski 0:01f31e923fe2 77 // <s0.126> Manufacturer String
Pawel Zarembski 0:01f31e923fe2 78 // <i> String descriptor describing manufacturer
Pawel Zarembski 0:01f31e923fe2 79 // <s1.126> Product String
Pawel Zarembski 0:01f31e923fe2 80 // <i> String descriptor describing product
Pawel Zarembski 0:01f31e923fe2 81 // <e1.0> Serial Number
Pawel Zarembski 0:01f31e923fe2 82 // <i> Enable serial number string
Pawel Zarembski 0:01f31e923fe2 83 // <i> If disabled serial number string will not be assigned to the USB Device
Pawel Zarembski 0:01f31e923fe2 84 // <s2.126> Serial Number String
Pawel Zarembski 0:01f31e923fe2 85 // <i> String descriptor describing device's serial number
Pawel Zarembski 0:01f31e923fe2 86 // </e>
Pawel Zarembski 0:01f31e923fe2 87 // </h>
Pawel Zarembski 0:01f31e923fe2 88 #define USBD_STRDESC_LANGID 0x0409
Pawel Zarembski 0:01f31e923fe2 89 #define USBD_STRDESC_MAN L"ARM"
Pawel Zarembski 0:01f31e923fe2 90 #ifndef USB_PROD_STR
Pawel Zarembski 0:01f31e923fe2 91 #define USBD_STRDESC_PROD L"DAPLink CMSIS-DAP"
Pawel Zarembski 0:01f31e923fe2 92 #else
Pawel Zarembski 0:01f31e923fe2 93 #define _TOWIDE(x) L ## #x
Pawel Zarembski 0:01f31e923fe2 94 #define TOWIDE(x) _TOWIDE(x)
Pawel Zarembski 0:01f31e923fe2 95 #define USBD_STRDESC_PROD TOWIDE(USB_PROD_STR)
Pawel Zarembski 0:01f31e923fe2 96 #endif
Pawel Zarembski 0:01f31e923fe2 97 #define USBD_STRDESC_SER_ENABLE 1
Pawel Zarembski 0:01f31e923fe2 98 #define USBD_STRDESC_SER L"0001A0000000"
Pawel Zarembski 0:01f31e923fe2 99
Pawel Zarembski 0:01f31e923fe2 100 // <e0> Class Support
Pawel Zarembski 0:01f31e923fe2 101 // <i> Enables USB Device Class specific Requests
Pawel Zarembski 0:01f31e923fe2 102 #define USBD_CLASS_ENABLE 1
Pawel Zarembski 0:01f31e923fe2 103
Pawel Zarembski 0:01f31e923fe2 104 // <e0.0> Human Interface Device (HID)
Pawel Zarembski 0:01f31e923fe2 105 // <i> Enable class support for Human Interface Device (HID)
Pawel Zarembski 0:01f31e923fe2 106 // <h> Interrupt Endpoint Settings
Pawel Zarembski 0:01f31e923fe2 107 // <o1.0..4> Interrupt In Endpoint Number <1=> 1 <2=> 2 <3=> 3
Pawel Zarembski 0:01f31e923fe2 108 // <4=> 4 <5=> 5 <6=> 6 <7=> 7
Pawel Zarembski 0:01f31e923fe2 109 // <8=> 8 <9=> 9 <10=> 10 <11=> 11
Pawel Zarembski 0:01f31e923fe2 110 // <12=> 12 <13=> 13 <14=> 14 <15=> 15
Pawel Zarembski 0:01f31e923fe2 111 // <o2.0..4> Interrupt Out Endpoint Number <0=> Not used <1=> 1 <2=> 2 <3=> 3
Pawel Zarembski 0:01f31e923fe2 112 // <4=> 4 <5=> 5 <6=> 6 <7=> 7
Pawel Zarembski 0:01f31e923fe2 113 // <8=> 8 <9=> 9 <10=> 10 <11=> 11
Pawel Zarembski 0:01f31e923fe2 114 // <12=> 12 <13=> 13 <14=> 14 <15=> 15
Pawel Zarembski 0:01f31e923fe2 115 // <i> If interrupt out endpoint is not used select "Not used"
Pawel Zarembski 0:01f31e923fe2 116 // <h> Endpoint Settings
Pawel Zarembski 0:01f31e923fe2 117 // <o3.0..7> Maximum Endpoint Packet Size (in bytes) <0-64>
Pawel Zarembski 0:01f31e923fe2 118 // <o4.0..7> Endpoint polling Interval (in ms) <1-255>
Pawel Zarembski 0:01f31e923fe2 119 // <e5> High-speed
Pawel Zarembski 0:01f31e923fe2 120 // <i> If high-speed is enabled set endpoint settings for it
Pawel Zarembski 0:01f31e923fe2 121 // <o6.0..10> Maximum Endpoint Packet Size (in bytes) <0-1024>
Pawel Zarembski 0:01f31e923fe2 122 // <o6.11..12> Additional transactions per microframe <0=> None <1=> 1 additional <2=> 2 additional
Pawel Zarembski 0:01f31e923fe2 123 // <o7.0..7> Endpoint polling Interval (in ms) <1=> 1 <2=> 2 <3=> 4 <4=> 8
Pawel Zarembski 0:01f31e923fe2 124 // <5=> 16 <6=> 32 <7=> 64 <8=> 128
Pawel Zarembski 0:01f31e923fe2 125 // <9=> 256 <10=> 512 <11=> 1024 <12=> 2048
Pawel Zarembski 0:01f31e923fe2 126 // <13=> 4096 <14=> 8192 <15=> 16384 <16=> 32768
Pawel Zarembski 0:01f31e923fe2 127 // </e>
Pawel Zarembski 0:01f31e923fe2 128 // </h>
Pawel Zarembski 0:01f31e923fe2 129 // </h>
Pawel Zarembski 0:01f31e923fe2 130 // <h> Human Interface Device Settings
Pawel Zarembski 0:01f31e923fe2 131 // <i> Device specific settings
Pawel Zarembski 0:01f31e923fe2 132 // <s0.126> HID Interface String
Pawel Zarembski 0:01f31e923fe2 133 // <o8.0..4> Number of Input Reports <1-32>
Pawel Zarembski 0:01f31e923fe2 134 // <o9.0..4> Number of Output Reports <1-32>
Pawel Zarembski 0:01f31e923fe2 135 // <o10.0..15> Maximum Input Report Size (in bytes) <1-65535>
Pawel Zarembski 0:01f31e923fe2 136 // <o11.0..15> Maximum Output Report Size (in bytes) <1-65535>
Pawel Zarembski 0:01f31e923fe2 137 // <o12.0..15> Maximum Feature Report Size (in bytes) <1-65535>
Pawel Zarembski 0:01f31e923fe2 138 // </h>
Pawel Zarembski 0:01f31e923fe2 139 // </e>
Pawel Zarembski 0:01f31e923fe2 140 #ifndef HID_ENDPOINT
Pawel Zarembski 0:01f31e923fe2 141 #define HID_ENDPOINT 0
Pawel Zarembski 0:01f31e923fe2 142 #else
Pawel Zarembski 0:01f31e923fe2 143 #define HID_ENDPOINT 1
Pawel Zarembski 0:01f31e923fe2 144 #endif
Pawel Zarembski 0:01f31e923fe2 145
Pawel Zarembski 0:01f31e923fe2 146 #ifndef WEBUSB_INTERFACE
Pawel Zarembski 0:01f31e923fe2 147 #define WEBUSB_INTERFACE 0
Pawel Zarembski 0:01f31e923fe2 148 #else
Pawel Zarembski 0:01f31e923fe2 149 #define WEBUSB_INTERFACE 1
Pawel Zarembski 0:01f31e923fe2 150 #endif
Pawel Zarembski 0:01f31e923fe2 151
Pawel Zarembski 0:01f31e923fe2 152 #define USBD_HID_ENABLE HID_ENDPOINT
Pawel Zarembski 0:01f31e923fe2 153 #define USBD_HID_EP_INTIN 1
Pawel Zarembski 0:01f31e923fe2 154 #define USBD_HID_EP_INTOUT 1
Pawel Zarembski 0:01f31e923fe2 155
Pawel Zarembski 0:01f31e923fe2 156 #define USBD_HID_ENABLE HID_ENDPOINT
Pawel Zarembski 0:01f31e923fe2 157 #define USBD_HID_EP_INTIN_STACK 0
Pawel Zarembski 0:01f31e923fe2 158 #define USBD_HID_WMAXPACKETSIZE 64
Pawel Zarembski 0:01f31e923fe2 159 #define USBD_HID_BINTERVAL 1
Pawel Zarembski 0:01f31e923fe2 160 #define USBD_HID_HS_ENABLE 0
Pawel Zarembski 0:01f31e923fe2 161 #define USBD_HID_HS_WMAXPACKETSIZE 64
Pawel Zarembski 0:01f31e923fe2 162 #define USBD_HID_HS_BINTERVAL 6
Pawel Zarembski 0:01f31e923fe2 163 #define USBD_HID_STRDESC L"CMSIS-DAP v1"
Pawel Zarembski 0:01f31e923fe2 164 #define USBD_WEBUSB_STRDESC L"WebUSB: CMSIS-DAP"
Pawel Zarembski 0:01f31e923fe2 165 #define USBD_HID_INREPORT_NUM 1
Pawel Zarembski 0:01f31e923fe2 166 #define USBD_HID_OUTREPORT_NUM 1
Pawel Zarembski 0:01f31e923fe2 167 #define USBD_HID_INREPORT_MAX_SZ 64
Pawel Zarembski 0:01f31e923fe2 168 #define USBD_HID_OUTREPORT_MAX_SZ 64
Pawel Zarembski 0:01f31e923fe2 169 #define USBD_HID_FEATREPORT_MAX_SZ 1
Pawel Zarembski 0:01f31e923fe2 170
Pawel Zarembski 0:01f31e923fe2 171 // <e0.0> Mass Storage Device (MSC)
Pawel Zarembski 0:01f31e923fe2 172 // <i> Enable class support for Mass Storage Device (MSC)
Pawel Zarembski 0:01f31e923fe2 173 // <h> Bulk Endpoint Settings
Pawel Zarembski 0:01f31e923fe2 174 // <o1.0..4> Bulk In Endpoint Number <1=> 1 <2=> 2 <3=> 3
Pawel Zarembski 0:01f31e923fe2 175 // <4=> 4 <5=> 5 <6=> 6 <7=> 7
Pawel Zarembski 0:01f31e923fe2 176 // <8=> 8 <9=> 9 <10=> 10 <11=> 11
Pawel Zarembski 0:01f31e923fe2 177 // <12=> 12 <13=> 13 <14=> 14 <15=> 15
Pawel Zarembski 0:01f31e923fe2 178 // <o2.0..4> Bulk Out Endpoint Number <1=> 1 <2=> 2 <3=> 3
Pawel Zarembski 0:01f31e923fe2 179 // <4=> 4 <5=> 5 <6=> 6 <7=> 7
Pawel Zarembski 0:01f31e923fe2 180 // <8=> 8 <9=> 9 <10=> 10 <11=> 11
Pawel Zarembski 0:01f31e923fe2 181 // <12=> 12 <13=> 13 <14=> 14 <15=> 15
Pawel Zarembski 0:01f31e923fe2 182 // <h> Endpoint Settings
Pawel Zarembski 0:01f31e923fe2 183 // <o3> Maximum Packet Size <1-1024>
Pawel Zarembski 0:01f31e923fe2 184 // <e4> High-speed
Pawel Zarembski 0:01f31e923fe2 185 // <i> If high-speed is enabled set endpoint settings for it
Pawel Zarembski 0:01f31e923fe2 186 // <o5> Maximum Packet Size <1-1024>
Pawel Zarembski 0:01f31e923fe2 187 // <o6> Maximum NAK Rate <0-255>
Pawel Zarembski 0:01f31e923fe2 188 // </e>
Pawel Zarembski 0:01f31e923fe2 189 // </h>
Pawel Zarembski 0:01f31e923fe2 190 // </h>
Pawel Zarembski 0:01f31e923fe2 191 // <h> Mass Storage Device Settings
Pawel Zarembski 0:01f31e923fe2 192 // <i> Device specific settings
Pawel Zarembski 0:01f31e923fe2 193 // <s0.126> MSC Interface String
Pawel Zarembski 0:01f31e923fe2 194 // <h> Inquiry Data
Pawel Zarembski 0:01f31e923fe2 195 // <s1.8> Vendor Identification
Pawel Zarembski 0:01f31e923fe2 196 // <s2.16> Product Identification
Pawel Zarembski 0:01f31e923fe2 197 // <s3.4> Product Revision Level
Pawel Zarembski 0:01f31e923fe2 198 // </h>
Pawel Zarembski 0:01f31e923fe2 199 // </h>
Pawel Zarembski 0:01f31e923fe2 200 // </e>
Pawel Zarembski 0:01f31e923fe2 201 #ifndef MSC_ENDPOINT
Pawel Zarembski 0:01f31e923fe2 202 #define MSC_ENDPOINT 0
Pawel Zarembski 0:01f31e923fe2 203 #else
Pawel Zarembski 0:01f31e923fe2 204 #define MSC_ENDPOINT 1
Pawel Zarembski 0:01f31e923fe2 205 #endif
Pawel Zarembski 0:01f31e923fe2 206 #define USBD_MSC_ENABLE MSC_ENDPOINT
Pawel Zarembski 0:01f31e923fe2 207 #define USBD_MSC_EP_BULKIN 2
Pawel Zarembski 0:01f31e923fe2 208 #define USBD_MSC_EP_BULKOUT 2
Pawel Zarembski 0:01f31e923fe2 209 #define USBD_MSC_EP_BULKIN_STACK 0
Pawel Zarembski 0:01f31e923fe2 210 #define USBD_MSC_WMAXPACKETSIZE 64
Pawel Zarembski 0:01f31e923fe2 211 #define USBD_MSC_HS_ENABLE 0
Pawel Zarembski 0:01f31e923fe2 212 #define USBD_MSC_HS_WMAXPACKETSIZE 512
Pawel Zarembski 0:01f31e923fe2 213 #define USBD_MSC_HS_BINTERVAL 0
Pawel Zarembski 0:01f31e923fe2 214 #define USBD_MSC_STRDESC L"USB_MSC"
Pawel Zarembski 0:01f31e923fe2 215 // Make sure changes to USBD_MSC_INQUIRY_DATA are coordinated with mbed-ls
Pawel Zarembski 0:01f31e923fe2 216 // since this is used to detect DAPLink drives
Pawel Zarembski 0:01f31e923fe2 217 #define USBD_MSC_INQUIRY_DATA "MBED " \
Pawel Zarembski 0:01f31e923fe2 218 "VFS " \
Pawel Zarembski 0:01f31e923fe2 219 "0.1"
Pawel Zarembski 0:01f31e923fe2 220
Pawel Zarembski 0:01f31e923fe2 221 // <e0.0> Audio Device (ADC)
Pawel Zarembski 0:01f31e923fe2 222 // <i> Enable class support for Audio Device (ADC)
Pawel Zarembski 0:01f31e923fe2 223 // <h> Isochronous Endpoint Settings
Pawel Zarembski 0:01f31e923fe2 224 // <o1.0..4> Isochronous Out Endpoint Number <1=> 1 <2=> 2 <3=> 3
Pawel Zarembski 0:01f31e923fe2 225 // <4=> 4 <5=> 5 <6=> 6 <7=> 7
Pawel Zarembski 0:01f31e923fe2 226 // <8=> 8 <9=> 9 <10=> 10 <11=> 11
Pawel Zarembski 0:01f31e923fe2 227 // <12=> 12 <13=> 13 <14=> 14 <15=> 15
Pawel Zarembski 0:01f31e923fe2 228 // <h> Endpoint Settings
Pawel Zarembski 0:01f31e923fe2 229 // <o2.0..10> Maximum Endpoint Packet Size (in bytes) <0-1024>
Pawel Zarembski 0:01f31e923fe2 230 // <o3.0..10> Endpoint polling Interval (in ms) <1=> 1 <2=> 2 <3=> 4 <4=> 8
Pawel Zarembski 0:01f31e923fe2 231 // <5=> 16 <6=> 32 <7=> 64 <8=> 128
Pawel Zarembski 0:01f31e923fe2 232 // <9=> 256 <10=> 512 <11=> 1024 <12=> 2048
Pawel Zarembski 0:01f31e923fe2 233 // <13=> 4096 <14=> 8192 <15=> 16384 <16=> 32768
Pawel Zarembski 0:01f31e923fe2 234 // <e4> High-speed
Pawel Zarembski 0:01f31e923fe2 235 // <i> If high-speed is enabled set endpoint settings for it
Pawel Zarembski 0:01f31e923fe2 236 // <o5.0..10> Maximum Endpoint Packet Size (in bytes) <0-1024>
Pawel Zarembski 0:01f31e923fe2 237 // <o5.11..12> Additional transactions per microframe <0=> None <1=> 1 additional <2=> 2 additional
Pawel Zarembski 0:01f31e923fe2 238 // </e>
Pawel Zarembski 0:01f31e923fe2 239 // </h>
Pawel Zarembski 0:01f31e923fe2 240 // </h>
Pawel Zarembski 0:01f31e923fe2 241 // <h> Audio Device Settings
Pawel Zarembski 0:01f31e923fe2 242 // <i> Device specific settings
Pawel Zarembski 0:01f31e923fe2 243 // <s0.126> Audio Control Interface String
Pawel Zarembski 0:01f31e923fe2 244 // <s1.126> Audio Streaming (Zero Bandwidth) Interface String
Pawel Zarembski 0:01f31e923fe2 245 // <s2.126> Audio Streaming (Operational) Interface String
Pawel Zarembski 0:01f31e923fe2 246 // <o6.0..7> Audio Subframe Size (in bytes) <0-255>
Pawel Zarembski 0:01f31e923fe2 247 // <o7.0..7> Sample Resolution (in bits) <0-255>
Pawel Zarembski 0:01f31e923fe2 248 // <o8.0..23> Sample Frequency (in Hz) <0-16777215>
Pawel Zarembski 0:01f31e923fe2 249 // <o9> Packet Size (in bytes) <1-256>
Pawel Zarembski 0:01f31e923fe2 250 // <o10> Packet Count <1-16>
Pawel Zarembski 0:01f31e923fe2 251 // </h>
Pawel Zarembski 0:01f31e923fe2 252 // </e>
Pawel Zarembski 0:01f31e923fe2 253 #define USBD_ADC_ENABLE 0
Pawel Zarembski 0:01f31e923fe2 254 #define USBD_ADC_EP_ISOOUT 3
Pawel Zarembski 0:01f31e923fe2 255 #define USBD_ADC_WMAXPACKETSIZE 64
Pawel Zarembski 0:01f31e923fe2 256 #define USBD_ADC_BINTERVAL 1
Pawel Zarembski 0:01f31e923fe2 257 #define USBD_ADC_HS_ENABLE 0
Pawel Zarembski 0:01f31e923fe2 258 #define USBD_ADC_HS_WMAXPACKETSIZE 64
Pawel Zarembski 0:01f31e923fe2 259 #define USBD_ADC_CIF_STRDESC L"USB_ADC"
Pawel Zarembski 0:01f31e923fe2 260 #define USBD_ADC_SIF1_STRDESC L"USB_ADC1"
Pawel Zarembski 0:01f31e923fe2 261 #define USBD_ADC_SIF2_STRDESC L"USB_ADC2"
Pawel Zarembski 0:01f31e923fe2 262 #define USBD_ADC_BSUBFRAMESIZE 2
Pawel Zarembski 0:01f31e923fe2 263 #define USBD_ADC_BBITRESOLUTION 16
Pawel Zarembski 0:01f31e923fe2 264 #define USBD_ADC_TSAMFREQ 32000
Pawel Zarembski 0:01f31e923fe2 265 #define USBD_ADC_CFG_P_S 32
Pawel Zarembski 0:01f31e923fe2 266 #define USBD_ADC_CFG_P_C 1
Pawel Zarembski 0:01f31e923fe2 267
Pawel Zarembski 0:01f31e923fe2 268 // <e0> Communication Device (CDC) - Abstract Control Model (ACM)
Pawel Zarembski 0:01f31e923fe2 269 // <i> Enable class support for Communication Device (CDC) - Abstract Control Model (ACM)
Pawel Zarembski 0:01f31e923fe2 270 // <h> Interrupt Endpoint Settings
Pawel Zarembski 0:01f31e923fe2 271 // <o1.0..4> Interrupt In Endpoint Number <1=> 1 <2=> 2 <3=> 3
Pawel Zarembski 0:01f31e923fe2 272 // <4=> 4 <5=> 5 <6=> 6 <7=> 7
Pawel Zarembski 0:01f31e923fe2 273 // <8=> 8 <9=> 9 <10=> 10 <11=> 11
Pawel Zarembski 0:01f31e923fe2 274 // <12=> 12 <13=> 13 <14=> 14 <15=> 15
Pawel Zarembski 0:01f31e923fe2 275 // <h> Endpoint Settings
Pawel Zarembski 0:01f31e923fe2 276 // <o2.0..10> Maximum Endpoint Packet Size (in bytes) <0-1024>
Pawel Zarembski 0:01f31e923fe2 277 // <o3.0..10> Endpoint polling Interval (in ms) <0-255>
Pawel Zarembski 0:01f31e923fe2 278 // <e4> High-speed
Pawel Zarembski 0:01f31e923fe2 279 // <i> If high-speed is enabled set endpoint settings for it
Pawel Zarembski 0:01f31e923fe2 280 // <o5.0..10> Maximum Endpoint Packet Size (in bytes) <0-1024>
Pawel Zarembski 0:01f31e923fe2 281 // <o5.11..12> Additional transactions per microframe <0=> None <1=> 1 additional <2=> 2 additional
Pawel Zarembski 0:01f31e923fe2 282 // <o6.0..10> Endpoint polling Interval (in ms) <1=> 1 <2=> 2 <3=> 4 <4=> 8
Pawel Zarembski 0:01f31e923fe2 283 // <5=> 16 <6=> 32 <7=> 64 <8=> 128
Pawel Zarembski 0:01f31e923fe2 284 // <9=> 256 <10=> 512 <11=> 1024 <12=> 2048
Pawel Zarembski 0:01f31e923fe2 285 // <13=> 4096 <14=> 8192 <15=> 16384 <16=> 32768
Pawel Zarembski 0:01f31e923fe2 286 // </e4>
Pawel Zarembski 0:01f31e923fe2 287 // </h>
Pawel Zarembski 0:01f31e923fe2 288 // </h>
Pawel Zarembski 0:01f31e923fe2 289 // <h> Bulk Endpoint Settings
Pawel Zarembski 0:01f31e923fe2 290 // <o7.0..4> Bulk In Endpoint Number <1=> 1 <2=> 2 <3=> 3
Pawel Zarembski 0:01f31e923fe2 291 // <4=> 4 <5=> 5 <6=> 6 <7=> 7
Pawel Zarembski 0:01f31e923fe2 292 // <8=> 8 <9=> 9 <10=> 10 <11=> 11
Pawel Zarembski 0:01f31e923fe2 293 // <12=> 12 <13=> 13 <14=> 14 <15=> 15
Pawel Zarembski 0:01f31e923fe2 294 // <o8.0..4> Bulk Out Endpoint Number <1=> 1 <2=> 2 <3=> 3
Pawel Zarembski 0:01f31e923fe2 295 // <4=> 4 <5=> 5 <6=> 6 <7=> 7
Pawel Zarembski 0:01f31e923fe2 296 // <8=> 8 <9=> 9 <10=> 10 <11=> 11
Pawel Zarembski 0:01f31e923fe2 297 // <12=> 12 <13=> 13 <14=> 14 <15=> 15
Pawel Zarembski 0:01f31e923fe2 298 // <h> Endpoint Settings
Pawel Zarembski 0:01f31e923fe2 299 // <o9> Maximum Packet Size <1-1024>
Pawel Zarembski 0:01f31e923fe2 300 // <e10> High-speed
Pawel Zarembski 0:01f31e923fe2 301 // <i> If high-speed is enabled set endpoint settings for it
Pawel Zarembski 0:01f31e923fe2 302 // <o11> Maximum Packet Size <1-1024>
Pawel Zarembski 0:01f31e923fe2 303 // <o12> Maximum NAK Rate <0-255>
Pawel Zarembski 0:01f31e923fe2 304 // </e10>
Pawel Zarembski 0:01f31e923fe2 305 // </h>
Pawel Zarembski 0:01f31e923fe2 306 // </h>
Pawel Zarembski 0:01f31e923fe2 307 // <h> Communication Device Settings
Pawel Zarembski 0:01f31e923fe2 308 // <i> Device specific settings
Pawel Zarembski 0:01f31e923fe2 309 // <s0.126> Communication Class Interface String
Pawel Zarembski 0:01f31e923fe2 310 // <s1.126> Data Class Interface String
Pawel Zarembski 0:01f31e923fe2 311 // <o13> Maximum Communication Device Send Buffer Size
Pawel Zarembski 0:01f31e923fe2 312 // <8=> 8 Bytes <16=> 16 Bytes <32=> 32 Bytes <64=> 64 Bytes <128=> 128 Bytes
Pawel Zarembski 0:01f31e923fe2 313 // <256=> 256 Bytes <512=> 512 Bytes <1024=> 1024 Bytes
Pawel Zarembski 0:01f31e923fe2 314 // <o14> Maximum Communication Device Receive Buffer Size
Pawel Zarembski 0:01f31e923fe2 315 // <i> Minimum size must be as big as maximum packet size for Bulk Out Endpoint
Pawel Zarembski 0:01f31e923fe2 316 // <8=> 8 Bytes <16=> 16 Bytes <32=> 32 Bytes <64=> 64 Bytes <128=> 128 Bytes
Pawel Zarembski 0:01f31e923fe2 317 // <256=> 256 Bytes <512=> 512 Bytes <1024=> 1024 Bytes
Pawel Zarembski 0:01f31e923fe2 318 // </h>
Pawel Zarembski 0:01f31e923fe2 319 // </e>
Pawel Zarembski 0:01f31e923fe2 320
Pawel Zarembski 0:01f31e923fe2 321 #ifndef CDC_ENDPOINT
Pawel Zarembski 0:01f31e923fe2 322 #define CDC_ENDPOINT 0
Pawel Zarembski 0:01f31e923fe2 323 #else
Pawel Zarembski 0:01f31e923fe2 324 #define CDC_ENDPOINT 1
Pawel Zarembski 0:01f31e923fe2 325 #endif
Pawel Zarembski 0:01f31e923fe2 326 #define USBD_CDC_ACM_ENABLE CDC_ENDPOINT
Pawel Zarembski 0:01f31e923fe2 327 #define USBD_CDC_ACM_EP_INTIN 3
Pawel Zarembski 0:01f31e923fe2 328 #define USBD_CDC_ACM_EP_INTIN_STACK 0
Pawel Zarembski 0:01f31e923fe2 329 #define USBD_CDC_ACM_WMAXPACKETSIZE 16
Pawel Zarembski 0:01f31e923fe2 330 #define USBD_CDC_ACM_BINTERVAL 32
Pawel Zarembski 0:01f31e923fe2 331 #define USBD_CDC_ACM_HS_ENABLE 0
Pawel Zarembski 0:01f31e923fe2 332 #define USBD_CDC_ACM_HS_WMAXPACKETSIZE 16
Pawel Zarembski 0:01f31e923fe2 333 #define USBD_CDC_ACM_HS_BINTERVAL 2
Pawel Zarembski 0:01f31e923fe2 334 #define USBD_CDC_ACM_EP_BULKIN 4
Pawel Zarembski 0:01f31e923fe2 335 #define USBD_CDC_ACM_EP_BULKOUT 4
Pawel Zarembski 0:01f31e923fe2 336 #define USBD_CDC_ACM_EP_BULKIN_STACK 0
Pawel Zarembski 0:01f31e923fe2 337 #define USBD_CDC_ACM_WMAXPACKETSIZE1 64
Pawel Zarembski 0:01f31e923fe2 338 #define USBD_CDC_ACM_HS_ENABLE1 0
Pawel Zarembski 0:01f31e923fe2 339 #define USBD_CDC_ACM_HS_WMAXPACKETSIZE1 64
Pawel Zarembski 0:01f31e923fe2 340 #define USBD_CDC_ACM_HS_BINTERVAL1 0
Pawel Zarembski 0:01f31e923fe2 341 #define USBD_CDC_ACM_CIF_STRDESC L"mbed Serial Port"
Pawel Zarembski 0:01f31e923fe2 342 #define USBD_CDC_ACM_DIF_STRDESC L"mbed Serial Port"
Pawel Zarembski 0:01f31e923fe2 343 #define USBD_CDC_ACM_SENDBUF_SIZE 64
Pawel Zarembski 0:01f31e923fe2 344 #define USBD_CDC_ACM_RECEIVEBUF_SIZE 64
Pawel Zarembski 0:01f31e923fe2 345 #if (((USBD_CDC_ACM_HS_ENABLE1) && (USBD_CDC_ACM_SENDBUF_SIZE < USBD_CDC_ACM_HS_WMAXPACKETSIZE1)) || (USBD_CDC_ACM_SENDBUF_SIZE < USBD_CDC_ACM_WMAXPACKETSIZE1))
Pawel Zarembski 0:01f31e923fe2 346 #error "Send Buffer size must be larger or equal to Bulk In maximum packet size!"
Pawel Zarembski 0:01f31e923fe2 347 #endif
Pawel Zarembski 0:01f31e923fe2 348 #if (((USBD_CDC_ACM_HS_ENABLE1) && (USBD_CDC_ACM_RECEIVEBUF_SIZE < USBD_CDC_ACM_HS_WMAXPACKETSIZE1)) || (USBD_CDC_ACM_RECEIVEBUF_SIZE < USBD_CDC_ACM_WMAXPACKETSIZE1))
Pawel Zarembski 0:01f31e923fe2 349 #error "Receive Buffer size must be larger or equal to Bulk Out maximum packet size!"
Pawel Zarembski 0:01f31e923fe2 350 #endif
Pawel Zarembski 0:01f31e923fe2 351
Pawel Zarembski 0:01f31e923fe2 352 // <e0> Custom Class Device
Pawel Zarembski 0:01f31e923fe2 353 // <i> Enables USB Custom Class Requests
Pawel Zarembski 0:01f31e923fe2 354 // <i> Class IDs:
Pawel Zarembski 0:01f31e923fe2 355 // <i> 0x00 - Class Reserved ID
Pawel Zarembski 0:01f31e923fe2 356 // <i> 0x01 - Class Audio ID
Pawel Zarembski 0:01f31e923fe2 357 // <i> 0x02 - Class Communications ID
Pawel Zarembski 0:01f31e923fe2 358 // <i> 0x03 - Class Human Interface ID
Pawel Zarembski 0:01f31e923fe2 359 // <i> 0x04 - Class Monitor ID
Pawel Zarembski 0:01f31e923fe2 360 // <i> 0x05 - Class Physical Interface ID
Pawel Zarembski 0:01f31e923fe2 361 // <i> 0x06 - Class Power ID
Pawel Zarembski 0:01f31e923fe2 362 // <i> 0x07 - Class Printer ID
Pawel Zarembski 0:01f31e923fe2 363 // <i> 0x08 - Class Storage ID
Pawel Zarembski 0:01f31e923fe2 364 // <i> 0x09 - Class HUB ID
Pawel Zarembski 0:01f31e923fe2 365 // <i> 0xEF - Class Miscellaneous ID
Pawel Zarembski 0:01f31e923fe2 366 // <i> 0xFF - Class Vendor Specific ID
Pawel Zarembski 0:01f31e923fe2 367 // </e>
Pawel Zarembski 0:01f31e923fe2 368 #define USBD_CLS_ENABLE 0
Pawel Zarembski 0:01f31e923fe2 369
Pawel Zarembski 0:01f31e923fe2 370 // WebUSB support
Pawel Zarembski 0:01f31e923fe2 371 #define USBD_WEBUSB_ENABLE WEBUSB_INTERFACE
Pawel Zarembski 0:01f31e923fe2 372 #define USBD_WEBUSB_VENDOR_CODE 0x21
Pawel Zarembski 0:01f31e923fe2 373 #define USBD_WEBUSB_LANDING_URL "os.mbed.com/webusb/landing-page/?bid="
Pawel Zarembski 0:01f31e923fe2 374 #define USBD_WEBUSB_ORIGIN_URL "os.mbed.com/"
Pawel Zarembski 0:01f31e923fe2 375
Pawel Zarembski 0:01f31e923fe2 376 // Microsoft OS Descriptors 2.0 (WinUSB) support
Pawel Zarembski 0:01f31e923fe2 377 #define USBD_WINUSB_ENABLE WINUSB_INTERFACE
Pawel Zarembski 0:01f31e923fe2 378 #define USBD_WINUSB_VENDOR_CODE 0x20
Pawel Zarembski 0:01f31e923fe2 379 // </e>
Pawel Zarembski 0:01f31e923fe2 380 // </e>
Pawel Zarembski 0:01f31e923fe2 381
Pawel Zarembski 0:01f31e923fe2 382 #ifndef BULK_ENDPOINT
Pawel Zarembski 0:01f31e923fe2 383 #define BULK_ENDPOINT 0
Pawel Zarembski 0:01f31e923fe2 384 #else
Pawel Zarembski 0:01f31e923fe2 385 #define BULK_ENDPOINT 1
Pawel Zarembski 0:01f31e923fe2 386 #endif
Pawel Zarembski 0:01f31e923fe2 387 #define USBD_BULK_ENABLE BULK_ENDPOINT
Pawel Zarembski 0:01f31e923fe2 388 #define USBD_BULK_EP_BULKIN 5
Pawel Zarembski 0:01f31e923fe2 389 #define USBD_BULK_EP_BULKOUT 5
Pawel Zarembski 0:01f31e923fe2 390 #define USBD_BULK_WMAXPACKETSIZE 64
Pawel Zarembski 0:01f31e923fe2 391 #define USBD_BULK_HS_ENABLE 0
Pawel Zarembski 0:01f31e923fe2 392 #define USBD_BULK_HS_WMAXPACKETSIZE 512
Pawel Zarembski 0:01f31e923fe2 393 #define USBD_BULK_STRDESC L"CMSIS-DAP v2"
Pawel Zarembski 0:01f31e923fe2 394
Pawel Zarembski 0:01f31e923fe2 395 /* USB Device Calculations ---------------------------------------------------*/
Pawel Zarembski 0:01f31e923fe2 396
Pawel Zarembski 0:01f31e923fe2 397 #define USBD_IF_NUM_MAX (USBD_BULK_ENABLE+USBD_WEBUSB_ENABLE+USBD_HID_ENABLE+USBD_MSC_ENABLE+(USBD_ADC_ENABLE*2)+(USBD_CDC_ACM_ENABLE*2)+USBD_CLS_ENABLE)
Pawel Zarembski 0:01f31e923fe2 398 #define USBD_MULTI_IF (USBD_CDC_ACM_ENABLE*(USBD_HID_ENABLE|USBD_MSC_ENABLE|USBD_ADC_ENABLE|USBD_CLS_ENABLE|USBD_WEBUSB_ENABLE|USBD_BULK_ENABLE))
Pawel Zarembski 0:01f31e923fe2 399 // #define MAX(x, y) (((x) < (y)) ? (y) : (x))
Pawel Zarembski 0:01f31e923fe2 400 #define USBD_EP_NUM_CALC0 MAX((USBD_HID_ENABLE *(USBD_HID_EP_INTIN )), (USBD_HID_ENABLE *(USBD_HID_EP_INTOUT!=0)*(USBD_HID_EP_INTOUT)))
Pawel Zarembski 0:01f31e923fe2 401 #define USBD_EP_NUM_CALC1 MAX((USBD_MSC_ENABLE *(USBD_MSC_EP_BULKIN )), (USBD_MSC_ENABLE *(USBD_MSC_EP_BULKOUT)))
Pawel Zarembski 0:01f31e923fe2 402 #define USBD_EP_NUM_CALC2 MAX((USBD_ADC_ENABLE *(USBD_ADC_EP_ISOOUT )), (USBD_CDC_ACM_ENABLE*(USBD_CDC_ACM_EP_INTIN)))
Pawel Zarembski 0:01f31e923fe2 403 #define USBD_EP_NUM_CALC3 MAX((USBD_CDC_ACM_ENABLE*(USBD_CDC_ACM_EP_BULKIN)), (USBD_CDC_ACM_ENABLE*(USBD_CDC_ACM_EP_BULKOUT)))
Pawel Zarembski 0:01f31e923fe2 404 #define USBD_EP_NUM_CALC4 MAX(USBD_EP_NUM_CALC0, USBD_EP_NUM_CALC1)
Pawel Zarembski 0:01f31e923fe2 405 #define USBD_EP_NUM_CALC5 MAX(USBD_EP_NUM_CALC2, USBD_EP_NUM_CALC3)
Pawel Zarembski 0:01f31e923fe2 406 #define USBD_EP_NUM_CALC6 MAX(USBD_EP_NUM_CALC4, USBD_EP_NUM_CALC5)
Pawel Zarembski 0:01f31e923fe2 407 #define USBD_EP_NUM_CALC7 MAX((USBD_BULK_ENABLE*(USBD_BULK_EP_BULKIN)), (USBD_BULK_ENABLE*(USBD_BULK_EP_BULKOUT)))
Pawel Zarembski 0:01f31e923fe2 408 #define USBD_EP_NUM MAX(USBD_EP_NUM_CALC6, USBD_EP_NUM_CALC7)
Pawel Zarembski 0:01f31e923fe2 409
Pawel Zarembski 0:01f31e923fe2 410
Pawel Zarembski 0:01f31e923fe2 411 #if (USBD_HID_ENABLE)
Pawel Zarembski 0:01f31e923fe2 412 #if (USBD_MSC_ENABLE)
Pawel Zarembski 0:01f31e923fe2 413 #if ((((USBD_HID_EP_INTIN == USBD_MSC_EP_BULKIN) || \
Pawel Zarembski 0:01f31e923fe2 414 (USBD_HID_EP_INTIN == USBD_MSC_EP_BULKOUT))) || \
Pawel Zarembski 0:01f31e923fe2 415 ((USBD_HID_EP_INTOUT != 0) && \
Pawel Zarembski 0:01f31e923fe2 416 (USBD_HID_EP_INTOUT == USBD_MSC_EP_BULKIN) || \
Pawel Zarembski 0:01f31e923fe2 417 (USBD_HID_EP_INTOUT == USBD_MSC_EP_BULKOUT)))
Pawel Zarembski 0:01f31e923fe2 418 #error "HID and Mass Storage Device Interface can not use same Endpoints!"
Pawel Zarembski 0:01f31e923fe2 419 #endif
Pawel Zarembski 0:01f31e923fe2 420 #endif
Pawel Zarembski 0:01f31e923fe2 421 #if (USBD_ADC_ENABLE)
Pawel Zarembski 0:01f31e923fe2 422 #if ((USBD_HID_EP_INTIN == USBD_ADC_EP_ISOOUT) || \
Pawel Zarembski 0:01f31e923fe2 423 ((USBD_HID_EP_INTOUT != 0) && \
Pawel Zarembski 0:01f31e923fe2 424 (USBD_HID_EP_INTOUT == USBD_ADC_EP_ISOOUT)))
Pawel Zarembski 0:01f31e923fe2 425 #error "HID and Audio Device Interface can not use same Endpoints!"
Pawel Zarembski 0:01f31e923fe2 426 #endif
Pawel Zarembski 0:01f31e923fe2 427 #endif
Pawel Zarembski 0:01f31e923fe2 428 #if (USBD_CDC_ACM_ENABLE)
Pawel Zarembski 0:01f31e923fe2 429 #if (((USBD_HID_EP_INTIN == USBD_CDC_ACM_EP_INTIN) || \
Pawel Zarembski 0:01f31e923fe2 430 (USBD_HID_EP_INTIN == USBD_CDC_ACM_EP_BULKIN) || \
Pawel Zarembski 0:01f31e923fe2 431 (USBD_HID_EP_INTIN == USBD_CDC_ACM_EP_BULKOUT))|| \
Pawel Zarembski 0:01f31e923fe2 432 ((USBD_HID_EP_INTOUT != 0) && \
Pawel Zarembski 0:01f31e923fe2 433 ((USBD_HID_EP_INTOUT == USBD_CDC_ACM_EP_INTIN) || \
Pawel Zarembski 0:01f31e923fe2 434 (USBD_HID_EP_INTOUT == USBD_CDC_ACM_EP_BULKIN) || \
Pawel Zarembski 0:01f31e923fe2 435 (USBD_HID_EP_INTOUT == USBD_CDC_ACM_EP_BULKOUT))))
Pawel Zarembski 0:01f31e923fe2 436 #error "HID and Communication Device Interface can not use same Endpoints!"
Pawel Zarembski 0:01f31e923fe2 437 #endif
Pawel Zarembski 0:01f31e923fe2 438 #endif
Pawel Zarembski 0:01f31e923fe2 439 #endif
Pawel Zarembski 0:01f31e923fe2 440
Pawel Zarembski 0:01f31e923fe2 441 #if (USBD_MSC_ENABLE)
Pawel Zarembski 0:01f31e923fe2 442 #if (USBD_ADC_ENABLE)
Pawel Zarembski 0:01f31e923fe2 443 #if ((USBD_MSC_EP_BULKIN == USBD_ADC_EP_ISOOUT) || \
Pawel Zarembski 0:01f31e923fe2 444 (USBD_MSC_EP_BULKOUT == USBD_ADC_EP_ISOOUT))
Pawel Zarembski 0:01f31e923fe2 445 #error "Mass Storage Device and Audio Device Interface can not use same Endpoints!"
Pawel Zarembski 0:01f31e923fe2 446 #endif
Pawel Zarembski 0:01f31e923fe2 447 #endif
Pawel Zarembski 0:01f31e923fe2 448 #if (USBD_CDC_ACM_ENABLE)
Pawel Zarembski 0:01f31e923fe2 449 #if ((USBD_MSC_EP_BULKIN == USBD_CDC_ACM_EP_INTIN) || \
Pawel Zarembski 0:01f31e923fe2 450 (USBD_MSC_EP_BULKIN == USBD_CDC_ACM_EP_BULKIN) || \
Pawel Zarembski 0:01f31e923fe2 451 (USBD_MSC_EP_BULKIN == USBD_CDC_ACM_EP_BULKOUT) || \
Pawel Zarembski 0:01f31e923fe2 452 (USBD_MSC_EP_BULKOUT == USBD_CDC_ACM_EP_INTIN) || \
Pawel Zarembski 0:01f31e923fe2 453 (USBD_MSC_EP_BULKOUT == USBD_CDC_ACM_EP_BULKIN) || \
Pawel Zarembski 0:01f31e923fe2 454 (USBD_MSC_EP_BULKOUT == USBD_CDC_ACM_EP_BULKOUT))
Pawel Zarembski 0:01f31e923fe2 455 #error "Mass Storage Device and Communication Device Interface can not use same Endpoints!"
Pawel Zarembski 0:01f31e923fe2 456 #endif
Pawel Zarembski 0:01f31e923fe2 457 #endif
Pawel Zarembski 0:01f31e923fe2 458 #endif
Pawel Zarembski 0:01f31e923fe2 459
Pawel Zarembski 0:01f31e923fe2 460 #if (USBD_ADC_ENABLE)
Pawel Zarembski 0:01f31e923fe2 461 #if (USBD_CDC_ACM_ENABLE)
Pawel Zarembski 0:01f31e923fe2 462 #if ((USBD_ADC_EP_ISOOUT == USBD_CDC_ACM_EP_INTIN) || \
Pawel Zarembski 0:01f31e923fe2 463 (USBD_ADC_EP_ISOOUT == USBD_CDC_ACM_EP_BULKIN) || \
Pawel Zarembski 0:01f31e923fe2 464 (USBD_ADC_EP_ISOOUT == USBD_CDC_ACM_EP_BULKOUT))
Pawel Zarembski 0:01f31e923fe2 465 #error "Audio Device and Communication Device Interface can not use same Endpoints!"
Pawel Zarembski 0:01f31e923fe2 466 #endif
Pawel Zarembski 0:01f31e923fe2 467 #endif
Pawel Zarembski 0:01f31e923fe2 468 #endif
Pawel Zarembski 0:01f31e923fe2 469
Pawel Zarembski 0:01f31e923fe2 470 #define USBD_ADC_CIF_NUM (0)
Pawel Zarembski 0:01f31e923fe2 471 #define USBD_ADC_SIF1_NUM (1)
Pawel Zarembski 0:01f31e923fe2 472 #define USBD_ADC_SIF2_NUM (2)
Pawel Zarembski 0:01f31e923fe2 473
Pawel Zarembski 0:01f31e923fe2 474
Pawel Zarembski 0:01f31e923fe2 475 #define USBD_ADC_CIF_STR_NUM (3+USBD_STRDESC_SER_ENABLE+0)
Pawel Zarembski 0:01f31e923fe2 476 #define USBD_ADC_SIF1_STR_NUM (3+USBD_STRDESC_SER_ENABLE+1)
Pawel Zarembski 0:01f31e923fe2 477 #define USBD_ADC_SIF2_STR_NUM (3+USBD_STRDESC_SER_ENABLE+2)
Pawel Zarembski 0:01f31e923fe2 478 #define USBD_CDC_ACM_CIF_STR_NUM (3+USBD_STRDESC_SER_ENABLE+USBD_ADC_ENABLE*3+0)
Pawel Zarembski 0:01f31e923fe2 479 #define USBD_CDC_ACM_DIF_STR_NUM (3+USBD_STRDESC_SER_ENABLE+USBD_ADC_ENABLE*3+1)
Pawel Zarembski 0:01f31e923fe2 480 #define USBD_HID_IF_STR_NUM (3+USBD_STRDESC_SER_ENABLE+USBD_ADC_ENABLE*3+USBD_CDC_ACM_ENABLE*2)
Pawel Zarembski 0:01f31e923fe2 481 #define USBD_WEBUSB_IF_STR_NUM (3+USBD_STRDESC_SER_ENABLE+USBD_ADC_ENABLE*3+USBD_CDC_ACM_ENABLE*2+USBD_HID_ENABLE)
Pawel Zarembski 0:01f31e923fe2 482 #define USBD_MSC_IF_STR_NUM (3+USBD_STRDESC_SER_ENABLE+USBD_ADC_ENABLE*3+USBD_CDC_ACM_ENABLE*2+USBD_HID_ENABLE+USBD_WEBUSB_ENABLE)
Pawel Zarembski 0:01f31e923fe2 483 #define USBD_BULK_IF_STR_NUM (3+USBD_STRDESC_SER_ENABLE+USBD_ADC_ENABLE*3+USBD_CDC_ACM_ENABLE*2+USBD_HID_ENABLE+USBD_WEBUSB_ENABLE+USBD_BULK_ENABLE)
Pawel Zarembski 0:01f31e923fe2 484
Pawel Zarembski 0:01f31e923fe2 485
Pawel Zarembski 0:01f31e923fe2 486 #if (USBD_HID_ENABLE)
Pawel Zarembski 0:01f31e923fe2 487 #if (USBD_HID_HS_ENABLE)
Pawel Zarembski 0:01f31e923fe2 488 #define USBD_HID_MAX_PACKET ((USBD_HID_HS_WMAXPACKETSIZE > USBD_HID_WMAXPACKETSIZE) ? USBD_HID_HS_WMAXPACKETSIZE : USBD_HID_WMAXPACKETSIZE)
Pawel Zarembski 0:01f31e923fe2 489 #else
Pawel Zarembski 0:01f31e923fe2 490 #define USBD_HID_MAX_PACKET (USBD_HID_WMAXPACKETSIZE)
Pawel Zarembski 0:01f31e923fe2 491 #endif
Pawel Zarembski 0:01f31e923fe2 492 #else
Pawel Zarembski 0:01f31e923fe2 493 #define USBD_HID_MAX_PACKET (0)
Pawel Zarembski 0:01f31e923fe2 494 #endif
Pawel Zarembski 0:01f31e923fe2 495 #if (USBD_MSC_ENABLE)
Pawel Zarembski 0:01f31e923fe2 496 #if (USBD_MSC_HS_ENABLE)
Pawel Zarembski 0:01f31e923fe2 497 #define USBD_MSC_MAX_PACKET ((USBD_MSC_HS_WMAXPACKETSIZE > USBD_MSC_WMAXPACKETSIZE) ? USBD_MSC_HS_WMAXPACKETSIZE : USBD_MSC_WMAXPACKETSIZE)
Pawel Zarembski 0:01f31e923fe2 498 #else
Pawel Zarembski 0:01f31e923fe2 499 #define USBD_MSC_MAX_PACKET (USBD_MSC_WMAXPACKETSIZE)
Pawel Zarembski 0:01f31e923fe2 500 #endif
Pawel Zarembski 0:01f31e923fe2 501 #else
Pawel Zarembski 0:01f31e923fe2 502 #define USBD_MSC_MAX_PACKET (0)
Pawel Zarembski 0:01f31e923fe2 503 #endif
Pawel Zarembski 0:01f31e923fe2 504 #if (USBD_ADC_ENABLE)
Pawel Zarembski 0:01f31e923fe2 505 #if (USBD_ADC_HS_ENABLE)
Pawel Zarembski 0:01f31e923fe2 506 #define USBD_ADC_MAX_PACKET ((USBD_ADC_HS_WMAXPACKETSIZE > USBD_ADC_WMAXPACKETSIZE) ? USBD_ADC_HS_WMAXPACKETSIZE : USBD_ADC_WMAXPACKETSIZE)
Pawel Zarembski 0:01f31e923fe2 507 #else
Pawel Zarembski 0:01f31e923fe2 508 #define USBD_ADC_MAX_PACKET (USBD_ADC_WMAXPACKETSIZE)
Pawel Zarembski 0:01f31e923fe2 509 #endif
Pawel Zarembski 0:01f31e923fe2 510 #else
Pawel Zarembski 0:01f31e923fe2 511 #define USBD_ADC_MAX_PACKET (0)
Pawel Zarembski 0:01f31e923fe2 512 #endif
Pawel Zarembski 0:01f31e923fe2 513 #if (USBD_CDC_ACM_ENABLE)
Pawel Zarembski 0:01f31e923fe2 514 #if (USBD_CDC_ACM_HS_ENABLE)
Pawel Zarembski 0:01f31e923fe2 515 #define USBD_CDC_ACM_MAX_PACKET ((USBD_CDC_ACM_HS_WMAXPACKETSIZE > USBD_CDC_ACM_WMAXPACKETSIZE) ? USBD_CDC_ACM_HS_WMAXPACKETSIZE : USBD_CDC_ACM_WMAXPACKETSIZE)
Pawel Zarembski 0:01f31e923fe2 516 #else
Pawel Zarembski 0:01f31e923fe2 517 #define USBD_CDC_ACM_MAX_PACKET (USBD_CDC_ACM_WMAXPACKETSIZE)
Pawel Zarembski 0:01f31e923fe2 518 #endif
Pawel Zarembski 0:01f31e923fe2 519 #if (USBD_CDC_ACM_HS_ENABLE1)
Pawel Zarembski 0:01f31e923fe2 520 #define USBD_CDC_ACM_MAX_PACKET1 ((USBD_CDC_ACM_HS_WMAXPACKETSIZE1 > USBD_CDC_ACM_WMAXPACKETSIZE1) ? USBD_CDC_ACM_HS_WMAXPACKETSIZE1 : USBD_CDC_ACM_WMAXPACKETSIZE1)
Pawel Zarembski 0:01f31e923fe2 521 #else
Pawel Zarembski 0:01f31e923fe2 522 #define USBD_CDC_ACM_MAX_PACKET1 (USBD_CDC_ACM_WMAXPACKETSIZE1)
Pawel Zarembski 0:01f31e923fe2 523 #endif
Pawel Zarembski 0:01f31e923fe2 524 #else
Pawel Zarembski 0:01f31e923fe2 525 #define USBD_CDC_ACM_MAX_PACKET (0)
Pawel Zarembski 0:01f31e923fe2 526 #define USBD_CDC_ACM_MAX_PACKET1 (0)
Pawel Zarembski 0:01f31e923fe2 527 #endif
Pawel Zarembski 0:01f31e923fe2 528
Pawel Zarembski 0:01f31e923fe2 529 #if (USBD_BULK_ENABLE)
Pawel Zarembski 0:01f31e923fe2 530 #if (USBD_BULK_HS_ENABLE)
Pawel Zarembski 0:01f31e923fe2 531 #define USBD_BULK_MAX_PACKET ((USBD_BULK_HS_WMAXPACKETSIZE > USBD_BULK_WMAXPACKETSIZE) ? USBD_BULK_HS_WMAXPACKETSIZE : USBD_BULK_WMAXPACKETSIZE)
Pawel Zarembski 0:01f31e923fe2 532 #else
Pawel Zarembski 0:01f31e923fe2 533 #define USBD_BULK_MAX_PACKET (USBD_BULK_WMAXPACKETSIZE)
Pawel Zarembski 0:01f31e923fe2 534 #endif
Pawel Zarembski 0:01f31e923fe2 535 #else
Pawel Zarembski 0:01f31e923fe2 536 #define USBD_BULK_MAX_PACKET (0)
Pawel Zarembski 0:01f31e923fe2 537 #endif
Pawel Zarembski 0:01f31e923fe2 538
Pawel Zarembski 0:01f31e923fe2 539 #define USBD_MAX_PACKET_CALC0 ((USBD_HID_MAX_PACKET > USBD_HID_MAX_PACKET ) ? (USBD_HID_MAX_PACKET ) : (USBD_HID_MAX_PACKET ))
Pawel Zarembski 0:01f31e923fe2 540 #define USBD_MAX_PACKET_CALC1 ((USBD_ADC_MAX_PACKET > USBD_CDC_ACM_MAX_PACKET ) ? (USBD_ADC_MAX_PACKET ) : (USBD_CDC_ACM_MAX_PACKET ))
Pawel Zarembski 0:01f31e923fe2 541 #define USBD_MAX_PACKET_CALC2 ((USBD_MAX_PACKET_CALC0 > USBD_MAX_PACKET_CALC1 ) ? (USBD_MAX_PACKET_CALC0) : (USBD_MAX_PACKET_CALC1 ))
Pawel Zarembski 0:01f31e923fe2 542 #define USBD_MAX_PACKET_CALC3 ((USBD_BULK_MAX_PACKET > USBD_CDC_ACM_MAX_PACKET1 ) ? (USBD_BULK_MAX_PACKET) : (USBD_CDC_ACM_MAX_PACKET1 ))
Pawel Zarembski 0:01f31e923fe2 543 #define USBD_MAX_PACKET ((USBD_MAX_PACKET_CALC3 > USBD_MAX_PACKET_CALC2 ) ? (USBD_MAX_PACKET_CALC3) : (USBD_MAX_PACKET_CALC2 ))
Pawel Zarembski 0:01f31e923fe2 544
Pawel Zarembski 0:01f31e923fe2 545
Pawel Zarembski 0:01f31e923fe2 546 /*------------------------------------------------------------------------------
Pawel Zarembski 0:01f31e923fe2 547 * USB Config Functions
Pawel Zarembski 0:01f31e923fe2 548 *----------------------------------------------------------------------------*/
Pawel Zarembski 0:01f31e923fe2 549
Pawel Zarembski 0:01f31e923fe2 550 #ifndef __USB_CONFIG___
Pawel Zarembski 0:01f31e923fe2 551 #define __USB_CONFIG__
Pawel Zarembski 0:01f31e923fe2 552
Pawel Zarembski 0:01f31e923fe2 553 #ifndef __NO_USB_LIB_C
Pawel Zarembski 0:01f31e923fe2 554 #include "usb_lib.c"
Pawel Zarembski 0:01f31e923fe2 555 #endif
Pawel Zarembski 0:01f31e923fe2 556
Pawel Zarembski 0:01f31e923fe2 557 #endif /* __USB_CONFIG__ */