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 /* CMSIS-DAP Interface Firmware
Pawel Zarembski 0:01f31e923fe2 2 * Copyright (c) 2009-2019 ARM Limited
Pawel Zarembski 0:01f31e923fe2 3 *
Pawel Zarembski 0:01f31e923fe2 4 * Licensed under the Apache License, Version 2.0 (the "License");
Pawel Zarembski 0:01f31e923fe2 5 * you may not use this file except in compliance with the License.
Pawel Zarembski 0:01f31e923fe2 6 * You may obtain a copy of the License at
Pawel Zarembski 0:01f31e923fe2 7 *
Pawel Zarembski 0:01f31e923fe2 8 * http://www.apache.org/licenses/LICENSE-2.0
Pawel Zarembski 0:01f31e923fe2 9 *
Pawel Zarembski 0:01f31e923fe2 10 * Unless required by applicable law or agreed to in writing, software
Pawel Zarembski 0:01f31e923fe2 11 * distributed under the License is distributed on an "AS IS" BASIS,
Pawel Zarembski 0:01f31e923fe2 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Pawel Zarembski 0:01f31e923fe2 13 * See the License for the specific language governing permissions and
Pawel Zarembski 0:01f31e923fe2 14 * limitations under the License.
Pawel Zarembski 0:01f31e923fe2 15 */
Pawel Zarembski 0:01f31e923fe2 16
Pawel Zarembski 0:01f31e923fe2 17 #include "util.h"
Pawel Zarembski 0:01f31e923fe2 18
Pawel Zarembski 0:01f31e923fe2 19 /*------------------------------------------------------------------------------
Pawel Zarembski 0:01f31e923fe2 20 * USB Device Configuration
Pawel Zarembski 0:01f31e923fe2 21 *----------------------------------------------------------------------------*/
Pawel Zarembski 0:01f31e923fe2 22
Pawel Zarembski 0:01f31e923fe2 23 // <e> USB Device
Pawel Zarembski 0:01f31e923fe2 24 // <i> Enable the USB Device functionality
Pawel Zarembski 0:01f31e923fe2 25 #define USBD_ENABLE 1
Pawel Zarembski 0:01f31e923fe2 26 #define USBD_RTX_CORE_STACK 0
Pawel Zarembski 0:01f31e923fe2 27 #define USBD_RTX_DEVICE_STACK 0
Pawel Zarembski 0:01f31e923fe2 28 #define USBD_RTX_ENDPOINT0_STACK 0
Pawel Zarembski 0:01f31e923fe2 29
Pawel Zarembski 0:01f31e923fe2 30 // <o0.0> High-speed
Pawel Zarembski 0:01f31e923fe2 31 // <i> Enable high-speed functionality (if device supports it)
Pawel Zarembski 0:01f31e923fe2 32 #define USBD_HS_ENABLE 0
Pawel Zarembski 0:01f31e923fe2 33 #if (defined(WEBUSB_INTERFACE) || defined(WINUSB_INTERFACE) || defined(BULK_ENDPOINT))
Pawel Zarembski 0:01f31e923fe2 34 #define USBD_BOS_ENABLE 1
Pawel Zarembski 0:01f31e923fe2 35 #else
Pawel Zarembski 0:01f31e923fe2 36 #define USBD_BOS_ENABLE 0
Pawel Zarembski 0:01f31e923fe2 37 #endif
Pawel Zarembski 0:01f31e923fe2 38 // <h> Device Settings
Pawel Zarembski 0:01f31e923fe2 39 // <i> These settings affect Device Descriptor
Pawel Zarembski 0:01f31e923fe2 40 // <o0> Power
Pawel Zarembski 0:01f31e923fe2 41 // <i> Default Power Setting
Pawel Zarembski 0:01f31e923fe2 42 // <0=> Bus-powered
Pawel Zarembski 0:01f31e923fe2 43 // <1=> Self-powered
Pawel Zarembski 0:01f31e923fe2 44 // <o1> Max Endpoint 0 Packet Size
Pawel Zarembski 0:01f31e923fe2 45 // <i> Maximum packet size for endpoint zero (bMaxPacketSize0)
Pawel Zarembski 0:01f31e923fe2 46 // <8=> 8 Bytes <16=> 16 Bytes <32=> 32 Bytes <64=> 64 Bytes
Pawel Zarembski 0:01f31e923fe2 47 // <o2.0..15> Vendor ID <0x0000-0xFFFF>
Pawel Zarembski 0:01f31e923fe2 48 // <i> Vendor ID assigned by the USB-IF (idVendor)
Pawel Zarembski 0:01f31e923fe2 49 // <o3.0..15> Product ID <0x0000-0xFFFF>
Pawel Zarembski 0:01f31e923fe2 50 // <i> Product ID assigned by the manufacturer (idProduct)
Pawel Zarembski 0:01f31e923fe2 51 // <o4.0..15> Device Release Number <0x0000-0xFFFF>
Pawel Zarembski 0:01f31e923fe2 52 // <i> Device release number in binary-coded decimal (bcdDevice)
Pawel Zarembski 0:01f31e923fe2 53 // </h>
Pawel Zarembski 0:01f31e923fe2 54 #define USBD_POWER 0
Pawel Zarembski 0:01f31e923fe2 55 #define USBD_MAX_PACKET0 64
Pawel Zarembski 0:01f31e923fe2 56 #define USBD_DEVDESC_IDVENDOR 0x0D28
Pawel Zarembski 0:01f31e923fe2 57 #define USBD_DEVDESC_IDPRODUCT 0x0204
Pawel Zarembski 0:01f31e923fe2 58 #define USBD_DEVDESC_BCDDEVICE 0x1000 //was 0x0100
Pawel Zarembski 0:01f31e923fe2 59
Pawel Zarembski 0:01f31e923fe2 60 // <h> Configuration Settings
Pawel Zarembski 0:01f31e923fe2 61 // <i> These settings affect Configuration Descriptor
Pawel Zarembski 0:01f31e923fe2 62 // <o0.5> Remote Wakeup
Pawel Zarembski 0:01f31e923fe2 63 // <i> Configuration support for remote wakeup (D5: of bmAttributes)
Pawel Zarembski 0:01f31e923fe2 64 // <o1.0..7> Maximum Power Consumption (in mA) <0-510><#/2>
Pawel Zarembski 0:01f31e923fe2 65 // <i> Maximum power consumption of the USB device
Pawel Zarembski 0:01f31e923fe2 66 // <i> from the bus in this specific configuration
Pawel Zarembski 0:01f31e923fe2 67 // <i> when the device is fully operational (bMaxPower)
Pawel Zarembski 0:01f31e923fe2 68 // </h>
Pawel Zarembski 0:01f31e923fe2 69 #define USBD_CFGDESC_BMATTRIBUTES 0x80
Pawel Zarembski 0:01f31e923fe2 70 #define USBD_CFGDESC_BMAXPOWER 0xFA
Pawel Zarembski 0:01f31e923fe2 71
Pawel Zarembski 0:01f31e923fe2 72 // <h> String Settings
Pawel Zarembski 0:01f31e923fe2 73 // <i> These settings affect String Descriptor
Pawel Zarembski 0:01f31e923fe2 74 // <o0.0..15> Language ID <0x0000-0xFCFF>
Pawel Zarembski 0:01f31e923fe2 75 // <i> English (United States) = 0x0409
Pawel Zarembski 0:01f31e923fe2 76 // <s0.126> Manufacturer String
Pawel Zarembski 0:01f31e923fe2 77 // <i> String descriptor describing manufacturer
Pawel Zarembski 0:01f31e923fe2 78 // <s1.126> Product String
Pawel Zarembski 0:01f31e923fe2 79 // <i> String descriptor describing product
Pawel Zarembski 0:01f31e923fe2 80 // <e1.0> Serial Number
Pawel Zarembski 0:01f31e923fe2 81 // <i> Enable serial number string
Pawel Zarembski 0:01f31e923fe2 82 // <i> If disabled serial number string will not be assigned to the USB Device
Pawel Zarembski 0:01f31e923fe2 83 // <s2.126> Serial Number String
Pawel Zarembski 0:01f31e923fe2 84 // <i> String descriptor describing device's serial number
Pawel Zarembski 0:01f31e923fe2 85 // </e>
Pawel Zarembski 0:01f31e923fe2 86 // </h>
Pawel Zarembski 0:01f31e923fe2 87 #define USBD_STRDESC_LANGID 0x0409
Pawel Zarembski 0:01f31e923fe2 88 #define USBD_STRDESC_MAN L"ARM"
Pawel Zarembski 0:01f31e923fe2 89 #ifndef USB_PROD_STR
Pawel Zarembski 0:01f31e923fe2 90 #define USBD_STRDESC_PROD L"DAPLink CMSIS-DAP"
Pawel Zarembski 0:01f31e923fe2 91 #else
Pawel Zarembski 0:01f31e923fe2 92 #define _TOWIDE(x) L ## #x
Pawel Zarembski 0:01f31e923fe2 93 #define TOWIDE(x) _TOWIDE(x)
Pawel Zarembski 0:01f31e923fe2 94 #define USBD_STRDESC_PROD TOWIDE(USB_PROD_STR)
Pawel Zarembski 0:01f31e923fe2 95 #endif
Pawel Zarembski 0:01f31e923fe2 96 #define USBD_STRDESC_SER_ENABLE 1
Pawel Zarembski 0:01f31e923fe2 97 #define USBD_STRDESC_SER L"0001A0000000"
Pawel Zarembski 0:01f31e923fe2 98
Pawel Zarembski 0:01f31e923fe2 99 // <e0> Class Support
Pawel Zarembski 0:01f31e923fe2 100 // <i> Enables USB Device Class specific Requests
Pawel Zarembski 0:01f31e923fe2 101 #define USBD_CLASS_ENABLE 1
Pawel Zarembski 0:01f31e923fe2 102
Pawel Zarembski 0:01f31e923fe2 103 // <e0.0> Human Interface Device (HID)
Pawel Zarembski 0:01f31e923fe2 104 // <i> Enable class support for Human Interface Device (HID)
Pawel Zarembski 0:01f31e923fe2 105 // <h> Interrupt Endpoint Settings
Pawel Zarembski 0:01f31e923fe2 106 // <o1.0..4> Interrupt In Endpoint Number <1=> 1 <2=> 2 <3=> 3
Pawel Zarembski 0:01f31e923fe2 107 // <4=> 4 <5=> 5 <6=> 6 <7=> 7
Pawel Zarembski 0:01f31e923fe2 108 // <8=> 8 <9=> 9 <10=> 10 <11=> 11
Pawel Zarembski 0:01f31e923fe2 109 // <12=> 12 <13=> 13 <14=> 14 <15=> 15
Pawel Zarembski 0:01f31e923fe2 110 // <o2.0..4> Interrupt Out Endpoint Number <0=> Not used <1=> 1 <2=> 2 <3=> 3
Pawel Zarembski 0:01f31e923fe2 111 // <4=> 4 <5=> 5 <6=> 6 <7=> 7
Pawel Zarembski 0:01f31e923fe2 112 // <8=> 8 <9=> 9 <10=> 10 <11=> 11
Pawel Zarembski 0:01f31e923fe2 113 // <12=> 12 <13=> 13 <14=> 14 <15=> 15
Pawel Zarembski 0:01f31e923fe2 114 // <i> If interrupt out endpoint is not used select "Not used"
Pawel Zarembski 0:01f31e923fe2 115 // <h> Endpoint Settings
Pawel Zarembski 0:01f31e923fe2 116 // <o3.0..7> Maximum Endpoint Packet Size (in bytes) <0-64>
Pawel Zarembski 0:01f31e923fe2 117 // <o4.0..7> Endpoint polling Interval (in ms) <1-255>
Pawel Zarembski 0:01f31e923fe2 118 // <e5> High-speed
Pawel Zarembski 0:01f31e923fe2 119 // <i> If high-speed is enabled set endpoint settings for it
Pawel Zarembski 0:01f31e923fe2 120 // <o6.0..10> Maximum Endpoint Packet Size (in bytes) <0-1024>
Pawel Zarembski 0:01f31e923fe2 121 // <o6.11..12> Additional transactions per microframe <0=> None <1=> 1 additional <2=> 2 additional
Pawel Zarembski 0:01f31e923fe2 122 // <o7.0..7> Endpoint polling Interval (in ms) <1=> 1 <2=> 2 <3=> 4 <4=> 8
Pawel Zarembski 0:01f31e923fe2 123 // <5=> 16 <6=> 32 <7=> 64 <8=> 128
Pawel Zarembski 0:01f31e923fe2 124 // <9=> 256 <10=> 512 <11=> 1024 <12=> 2048
Pawel Zarembski 0:01f31e923fe2 125 // <13=> 4096 <14=> 8192 <15=> 16384 <16=> 32768
Pawel Zarembski 0:01f31e923fe2 126 // </e>
Pawel Zarembski 0:01f31e923fe2 127 // </h>
Pawel Zarembski 0:01f31e923fe2 128 // </h>
Pawel Zarembski 0:01f31e923fe2 129 // <h> Human Interface Device Settings
Pawel Zarembski 0:01f31e923fe2 130 // <i> Device specific settings
Pawel Zarembski 0:01f31e923fe2 131 // <s0.126> HID Interface String
Pawel Zarembski 0:01f31e923fe2 132 // <o8.0..4> Number of Input Reports <1-32>
Pawel Zarembski 0:01f31e923fe2 133 // <o9.0..4> Number of Output Reports <1-32>
Pawel Zarembski 0:01f31e923fe2 134 // <o10.0..15> Maximum Input Report Size (in bytes) <1-65535>
Pawel Zarembski 0:01f31e923fe2 135 // <o11.0..15> Maximum Output Report Size (in bytes) <1-65535>
Pawel Zarembski 0:01f31e923fe2 136 // <o12.0..15> Maximum Feature Report Size (in bytes) <1-65535>
Pawel Zarembski 0:01f31e923fe2 137 // </h>
Pawel Zarembski 0:01f31e923fe2 138 // </e>
Pawel Zarembski 0:01f31e923fe2 139 #ifndef HID_ENDPOINT
Pawel Zarembski 0:01f31e923fe2 140 #define HID_ENDPOINT 0
Pawel Zarembski 0:01f31e923fe2 141 #else
Pawel Zarembski 0:01f31e923fe2 142 #define HID_ENDPOINT 1
Pawel Zarembski 0:01f31e923fe2 143 #endif
Pawel Zarembski 0:01f31e923fe2 144
Pawel Zarembski 0:01f31e923fe2 145 #ifndef WEBUSB_INTERFACE
Pawel Zarembski 0:01f31e923fe2 146 #define WEBUSB_INTERFACE 0
Pawel Zarembski 0:01f31e923fe2 147 #else
Pawel Zarembski 0:01f31e923fe2 148 #define WEBUSB_INTERFACE 1
Pawel Zarembski 0:01f31e923fe2 149 #endif
Pawel Zarembski 0:01f31e923fe2 150
Pawel Zarembski 0:01f31e923fe2 151 #define USBD_HID_ENABLE HID_ENDPOINT
Pawel Zarembski 0:01f31e923fe2 152 #ifndef BULK_ENDPOINT //check if bulk endpoint is not enabled
Pawel Zarembski 0:01f31e923fe2 153 #define USBD_HID_EP_INTIN 1
Pawel Zarembski 0:01f31e923fe2 154 #define USBD_HID_EP_INTOUT 2
Pawel Zarembski 0:01f31e923fe2 155 #else //if bulk endpoint is enabled remove interrupt endpoints from the hid
Pawel Zarembski 0:01f31e923fe2 156 #define USBD_HID_EP_INTIN 0
Pawel Zarembski 0:01f31e923fe2 157 #define USBD_HID_EP_INTOUT 0
Pawel Zarembski 0:01f31e923fe2 158 #endif
Pawel Zarembski 0:01f31e923fe2 159 #define USBD_HID_EP_INTIN_STACK 0
Pawel Zarembski 0:01f31e923fe2 160 #define USBD_HID_WMAXPACKETSIZE 64
Pawel Zarembski 0:01f31e923fe2 161 #define USBD_HID_BINTERVAL 1
Pawel Zarembski 0:01f31e923fe2 162 #define USBD_HID_HS_ENABLE 0
Pawel Zarembski 0:01f31e923fe2 163 #define USBD_HID_HS_WMAXPACKETSIZE 64
Pawel Zarembski 0:01f31e923fe2 164 #define USBD_HID_HS_BINTERVAL 6
Pawel Zarembski 0:01f31e923fe2 165 #define USBD_HID_STRDESC L"CMSIS-DAP v1"
Pawel Zarembski 0:01f31e923fe2 166 #define USBD_WEBUSB_STRDESC L"WebUSB: CMSIS-DAP"
Pawel Zarembski 0:01f31e923fe2 167 #define USBD_HID_INREPORT_NUM 1
Pawel Zarembski 0:01f31e923fe2 168 #define USBD_HID_OUTREPORT_NUM 1
Pawel Zarembski 0:01f31e923fe2 169 #define USBD_HID_INREPORT_MAX_SZ 64
Pawel Zarembski 0:01f31e923fe2 170 #define USBD_HID_OUTREPORT_MAX_SZ 64
Pawel Zarembski 0:01f31e923fe2 171 #define USBD_HID_FEATREPORT_MAX_SZ 1
Pawel Zarembski 0:01f31e923fe2 172
Pawel Zarembski 0:01f31e923fe2 173 // <e0.0> Mass Storage Device (MSC)
Pawel Zarembski 0:01f31e923fe2 174 // <i> Enable class support for Mass Storage Device (MSC)
Pawel Zarembski 0:01f31e923fe2 175 // <h> Bulk Endpoint Settings
Pawel Zarembski 0:01f31e923fe2 176 // <o1.0..4> Bulk In Endpoint Number <1=> 1 <2=> 2 <3=> 3
Pawel Zarembski 0:01f31e923fe2 177 // <4=> 4 <5=> 5 <6=> 6 <7=> 7
Pawel Zarembski 0:01f31e923fe2 178 // <8=> 8 <9=> 9 <10=> 10 <11=> 11
Pawel Zarembski 0:01f31e923fe2 179 // <12=> 12 <13=> 13 <14=> 14 <15=> 15
Pawel Zarembski 0:01f31e923fe2 180 // <o2.0..4> Bulk Out Endpoint Number <1=> 1 <2=> 2 <3=> 3
Pawel Zarembski 0:01f31e923fe2 181 // <4=> 4 <5=> 5 <6=> 6 <7=> 7
Pawel Zarembski 0:01f31e923fe2 182 // <8=> 8 <9=> 9 <10=> 10 <11=> 11
Pawel Zarembski 0:01f31e923fe2 183 // <12=> 12 <13=> 13 <14=> 14 <15=> 15
Pawel Zarembski 0:01f31e923fe2 184 // <h> Endpoint Settings
Pawel Zarembski 0:01f31e923fe2 185 // <o3> Maximum Packet Size <1-1024>
Pawel Zarembski 0:01f31e923fe2 186 // <e4> High-speed
Pawel Zarembski 0:01f31e923fe2 187 // <i> If high-speed is enabled set endpoint settings for it
Pawel Zarembski 0:01f31e923fe2 188 // <o5> Maximum Packet Size <1-1024>
Pawel Zarembski 0:01f31e923fe2 189 // <o6> Maximum NAK Rate <0-255>
Pawel Zarembski 0:01f31e923fe2 190 // </e>
Pawel Zarembski 0:01f31e923fe2 191 // </h>
Pawel Zarembski 0:01f31e923fe2 192 // </h>
Pawel Zarembski 0:01f31e923fe2 193 // <h> Mass Storage Device Settings
Pawel Zarembski 0:01f31e923fe2 194 // <i> Device specific settings
Pawel Zarembski 0:01f31e923fe2 195 // <s0.126> MSC Interface String
Pawel Zarembski 0:01f31e923fe2 196 // <h> Inquiry Data
Pawel Zarembski 0:01f31e923fe2 197 // <s1.8> Vendor Identification
Pawel Zarembski 0:01f31e923fe2 198 // <s2.16> Product Identification
Pawel Zarembski 0:01f31e923fe2 199 // <s3.4> Product Revision Level
Pawel Zarembski 0:01f31e923fe2 200 // </h>
Pawel Zarembski 0:01f31e923fe2 201 // </h>
Pawel Zarembski 0:01f31e923fe2 202 // </e>
Pawel Zarembski 0:01f31e923fe2 203 #ifndef MSC_ENDPOINT
Pawel Zarembski 0:01f31e923fe2 204 #define MSC_ENDPOINT 0
Pawel Zarembski 0:01f31e923fe2 205 #else
Pawel Zarembski 0:01f31e923fe2 206 #define MSC_ENDPOINT 1
Pawel Zarembski 0:01f31e923fe2 207 #endif
Pawel Zarembski 0:01f31e923fe2 208 #define USBD_MSC_ENABLE MSC_ENDPOINT
Pawel Zarembski 0:01f31e923fe2 209 #define USBD_MSC_EP_BULKIN 3
Pawel Zarembski 0:01f31e923fe2 210 #define USBD_MSC_EP_BULKOUT 4
Pawel Zarembski 0:01f31e923fe2 211 #define USBD_MSC_EP_BULKIN_STACK 0
Pawel Zarembski 0:01f31e923fe2 212 #define USBD_MSC_WMAXPACKETSIZE 64
Pawel Zarembski 0:01f31e923fe2 213 #define USBD_MSC_HS_ENABLE 0
Pawel Zarembski 0:01f31e923fe2 214 #define USBD_MSC_HS_WMAXPACKETSIZE 512
Pawel Zarembski 0:01f31e923fe2 215 #define USBD_MSC_HS_BINTERVAL 0
Pawel Zarembski 0:01f31e923fe2 216 #define USBD_MSC_STRDESC L"USB_MSC"
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 #ifndef CDC_ENDPOINT
Pawel Zarembski 0:01f31e923fe2 321 #define CDC_ENDPOINT 0
Pawel Zarembski 0:01f31e923fe2 322 #else
Pawel Zarembski 0:01f31e923fe2 323 #define CDC_ENDPOINT 1
Pawel Zarembski 0:01f31e923fe2 324 #endif
Pawel Zarembski 0:01f31e923fe2 325 #define USBD_CDC_ACM_ENABLE CDC_ENDPOINT
Pawel Zarembski 0:01f31e923fe2 326 #define USBD_CDC_ACM_EP_INTIN 5
Pawel Zarembski 0:01f31e923fe2 327 #define USBD_CDC_ACM_EP_INTIN_STACK 0
Pawel Zarembski 0:01f31e923fe2 328 #define USBD_CDC_ACM_WMAXPACKETSIZE 16
Pawel Zarembski 0:01f31e923fe2 329 #define USBD_CDC_ACM_BINTERVAL 32
Pawel Zarembski 0:01f31e923fe2 330 #define USBD_CDC_ACM_HS_ENABLE 0
Pawel Zarembski 0:01f31e923fe2 331 #define USBD_CDC_ACM_HS_WMAXPACKETSIZE 16
Pawel Zarembski 0:01f31e923fe2 332 #define USBD_CDC_ACM_HS_BINTERVAL 2
Pawel Zarembski 0:01f31e923fe2 333 #define USBD_CDC_ACM_EP_BULKIN 6
Pawel Zarembski 0:01f31e923fe2 334 #define USBD_CDC_ACM_EP_BULKOUT 7
Pawel Zarembski 0:01f31e923fe2 335 #define USBD_CDC_ACM_EP_BULKIN_STACK 0
Pawel Zarembski 0:01f31e923fe2 336 #define USBD_CDC_ACM_WMAXPACKETSIZE1 64
Pawel Zarembski 0:01f31e923fe2 337 #define USBD_CDC_ACM_HS_ENABLE1 0
Pawel Zarembski 0:01f31e923fe2 338 #define USBD_CDC_ACM_HS_WMAXPACKETSIZE1 64
Pawel Zarembski 0:01f31e923fe2 339 #define USBD_CDC_ACM_HS_BINTERVAL1 0
Pawel Zarembski 0:01f31e923fe2 340 #define USBD_CDC_ACM_CIF_STRDESC L"mbed Serial Port"
Pawel Zarembski 0:01f31e923fe2 341 #define USBD_CDC_ACM_DIF_STRDESC L"mbed Serial Port"
Pawel Zarembski 0:01f31e923fe2 342 #define USBD_CDC_ACM_SENDBUF_SIZE 64
Pawel Zarembski 0:01f31e923fe2 343 #define USBD_CDC_ACM_RECEIVEBUF_SIZE 64
Pawel Zarembski 0:01f31e923fe2 344 #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 345 #error "Send Buffer size must be larger or equal to Bulk In maximum packet size!"
Pawel Zarembski 0:01f31e923fe2 346 #endif
Pawel Zarembski 0:01f31e923fe2 347 #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 348 #error "Receive Buffer size must be larger or equal to Bulk Out maximum packet size!"
Pawel Zarembski 0:01f31e923fe2 349 #endif
Pawel Zarembski 0:01f31e923fe2 350
Pawel Zarembski 0:01f31e923fe2 351 // <e0> Custom Class Device
Pawel Zarembski 0:01f31e923fe2 352 // <i> Enables USB Custom Class Requests
Pawel Zarembski 0:01f31e923fe2 353 // <i> Class IDs:
Pawel Zarembski 0:01f31e923fe2 354 // <i> 0x00 - Class Reserved ID
Pawel Zarembski 0:01f31e923fe2 355 // <i> 0x01 - Class Audio ID
Pawel Zarembski 0:01f31e923fe2 356 // <i> 0x02 - Class Communications ID
Pawel Zarembski 0:01f31e923fe2 357 // <i> 0x03 - Class Human Interface ID
Pawel Zarembski 0:01f31e923fe2 358 // <i> 0x04 - Class Monitor ID
Pawel Zarembski 0:01f31e923fe2 359 // <i> 0x05 - Class Physical Interface ID
Pawel Zarembski 0:01f31e923fe2 360 // <i> 0x06 - Class Power ID
Pawel Zarembski 0:01f31e923fe2 361 // <i> 0x07 - Class Printer ID
Pawel Zarembski 0:01f31e923fe2 362 // <i> 0x08 - Class Storage ID
Pawel Zarembski 0:01f31e923fe2 363 // <i> 0x09 - Class HUB ID
Pawel Zarembski 0:01f31e923fe2 364 // <i> 0xEF - Class Miscellaneous ID
Pawel Zarembski 0:01f31e923fe2 365 // <i> 0xFF - Class Vendor Specific ID
Pawel Zarembski 0:01f31e923fe2 366 // </e>
Pawel Zarembski 0:01f31e923fe2 367 #define USBD_CLS_ENABLE 0
Pawel Zarembski 0:01f31e923fe2 368
Pawel Zarembski 0:01f31e923fe2 369 // WebUSB support
Pawel Zarembski 0:01f31e923fe2 370 #define USBD_WEBUSB_ENABLE WEBUSB_INTERFACE
Pawel Zarembski 0:01f31e923fe2 371 #define USBD_WEBUSB_VENDOR_CODE 0x21
Pawel Zarembski 0:01f31e923fe2 372 #define USBD_WEBUSB_LANDING_URL "os.mbed.com/webusb/landing-page/?bid="
Pawel Zarembski 0:01f31e923fe2 373 #define USBD_WEBUSB_ORIGIN_URL "os.mbed.com/"
Pawel Zarembski 0:01f31e923fe2 374
Pawel Zarembski 0:01f31e923fe2 375 // Microsoft OS Descriptors 2.0 (WinUSB) support
Pawel Zarembski 0:01f31e923fe2 376 #define USBD_WINUSB_ENABLE WINUSB_INTERFACE
Pawel Zarembski 0:01f31e923fe2 377 #define USBD_WINUSB_VENDOR_CODE 0x20
Pawel Zarembski 0:01f31e923fe2 378 // </e>
Pawel Zarembski 0:01f31e923fe2 379 // </e>
Pawel Zarembski 0:01f31e923fe2 380
Pawel Zarembski 0:01f31e923fe2 381 #ifndef BULK_ENDPOINT
Pawel Zarembski 0:01f31e923fe2 382 #define BULK_ENDPOINT 0
Pawel Zarembski 0:01f31e923fe2 383 #else
Pawel Zarembski 0:01f31e923fe2 384 #define BULK_ENDPOINT 1
Pawel Zarembski 0:01f31e923fe2 385 #endif
Pawel Zarembski 0:01f31e923fe2 386 #define USBD_BULK_ENABLE BULK_ENDPOINT
Pawel Zarembski 0:01f31e923fe2 387 #define USBD_BULK_EP_BULKIN 1
Pawel Zarembski 0:01f31e923fe2 388 #define USBD_BULK_EP_BULKOUT 2
Pawel Zarembski 0:01f31e923fe2 389 #define USBD_BULK_EP_BULKIN_SWO 10
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 #if (USBD_EP_NUM > 7)
Pawel Zarembski 0:01f31e923fe2 411 #error "Max32620 only have 8 individual endpoints including EP0!"
Pawel Zarembski 0:01f31e923fe2 412 #endif
Pawel Zarembski 0:01f31e923fe2 413
Pawel Zarembski 0:01f31e923fe2 414 #if (USBD_HID_ENABLE)
Pawel Zarembski 0:01f31e923fe2 415 #if (USBD_MSC_ENABLE)
Pawel Zarembski 0:01f31e923fe2 416 #if ((((USBD_HID_EP_INTIN == USBD_MSC_EP_BULKIN) || \
Pawel Zarembski 0:01f31e923fe2 417 (USBD_HID_EP_INTIN == USBD_MSC_EP_BULKOUT))) || \
Pawel Zarembski 0:01f31e923fe2 418 ((USBD_HID_EP_INTOUT != 0) && \
Pawel Zarembski 0:01f31e923fe2 419 (USBD_HID_EP_INTOUT == USBD_MSC_EP_BULKIN) || \
Pawel Zarembski 0:01f31e923fe2 420 (USBD_HID_EP_INTOUT == USBD_MSC_EP_BULKOUT)))
Pawel Zarembski 0:01f31e923fe2 421 #error "HID and Mass Storage Device Interface can not use same Endpoints!"
Pawel Zarembski 0:01f31e923fe2 422 #endif
Pawel Zarembski 0:01f31e923fe2 423 #endif
Pawel Zarembski 0:01f31e923fe2 424 #if (USBD_ADC_ENABLE)
Pawel Zarembski 0:01f31e923fe2 425 #if ((USBD_HID_EP_INTIN == USBD_ADC_EP_ISOOUT) || \
Pawel Zarembski 0:01f31e923fe2 426 ((USBD_HID_EP_INTOUT != 0) && \
Pawel Zarembski 0:01f31e923fe2 427 (USBD_HID_EP_INTOUT == USBD_ADC_EP_ISOOUT)))
Pawel Zarembski 0:01f31e923fe2 428 #error "HID and Audio Device Interface can not use same Endpoints!"
Pawel Zarembski 0:01f31e923fe2 429 #endif
Pawel Zarembski 0:01f31e923fe2 430 #endif
Pawel Zarembski 0:01f31e923fe2 431 #if (USBD_CDC_ACM_ENABLE)
Pawel Zarembski 0:01f31e923fe2 432 #if (((USBD_HID_EP_INTIN == USBD_CDC_ACM_EP_INTIN) || \
Pawel Zarembski 0:01f31e923fe2 433 (USBD_HID_EP_INTIN == USBD_CDC_ACM_EP_BULKIN) || \
Pawel Zarembski 0:01f31e923fe2 434 (USBD_HID_EP_INTIN == USBD_CDC_ACM_EP_BULKOUT))|| \
Pawel Zarembski 0:01f31e923fe2 435 ((USBD_HID_EP_INTOUT != 0) && \
Pawel Zarembski 0:01f31e923fe2 436 ((USBD_HID_EP_INTOUT == USBD_CDC_ACM_EP_INTIN) || \
Pawel Zarembski 0:01f31e923fe2 437 (USBD_HID_EP_INTOUT == USBD_CDC_ACM_EP_BULKIN) || \
Pawel Zarembski 0:01f31e923fe2 438 (USBD_HID_EP_INTOUT == USBD_CDC_ACM_EP_BULKOUT))))
Pawel Zarembski 0:01f31e923fe2 439 #error "HID and Communication Device Interface can not use same Endpoints!"
Pawel Zarembski 0:01f31e923fe2 440 #endif
Pawel Zarembski 0:01f31e923fe2 441 #endif
Pawel Zarembski 0:01f31e923fe2 442 #endif
Pawel Zarembski 0:01f31e923fe2 443
Pawel Zarembski 0:01f31e923fe2 444 #if (USBD_MSC_ENABLE)
Pawel Zarembski 0:01f31e923fe2 445 #if (USBD_ADC_ENABLE)
Pawel Zarembski 0:01f31e923fe2 446 #if ((USBD_MSC_EP_BULKIN == USBD_ADC_EP_ISOOUT) || \
Pawel Zarembski 0:01f31e923fe2 447 (USBD_MSC_EP_BULKOUT == USBD_ADC_EP_ISOOUT))
Pawel Zarembski 0:01f31e923fe2 448 #error "Mass Storage Device and Audio Device Interface can not use same Endpoints!"
Pawel Zarembski 0:01f31e923fe2 449 #endif
Pawel Zarembski 0:01f31e923fe2 450 #endif
Pawel Zarembski 0:01f31e923fe2 451 #if (USBD_CDC_ACM_ENABLE)
Pawel Zarembski 0:01f31e923fe2 452 #if ((USBD_MSC_EP_BULKIN == USBD_CDC_ACM_EP_INTIN) || \
Pawel Zarembski 0:01f31e923fe2 453 (USBD_MSC_EP_BULKIN == USBD_CDC_ACM_EP_BULKIN) || \
Pawel Zarembski 0:01f31e923fe2 454 (USBD_MSC_EP_BULKIN == USBD_CDC_ACM_EP_BULKOUT) || \
Pawel Zarembski 0:01f31e923fe2 455 (USBD_MSC_EP_BULKOUT == USBD_CDC_ACM_EP_INTIN) || \
Pawel Zarembski 0:01f31e923fe2 456 (USBD_MSC_EP_BULKOUT == USBD_CDC_ACM_EP_BULKIN) || \
Pawel Zarembski 0:01f31e923fe2 457 (USBD_MSC_EP_BULKOUT == USBD_CDC_ACM_EP_BULKOUT))
Pawel Zarembski 0:01f31e923fe2 458 #error "Mass Storage Device and Communication Device Interface can not use same Endpoints!"
Pawel Zarembski 0:01f31e923fe2 459 #endif
Pawel Zarembski 0:01f31e923fe2 460 #endif
Pawel Zarembski 0:01f31e923fe2 461 #endif
Pawel Zarembski 0:01f31e923fe2 462
Pawel Zarembski 0:01f31e923fe2 463 #if (USBD_ADC_ENABLE)
Pawel Zarembski 0:01f31e923fe2 464 #if (USBD_CDC_ACM_ENABLE)
Pawel Zarembski 0:01f31e923fe2 465 #if ((USBD_ADC_EP_ISOOUT == USBD_CDC_ACM_EP_INTIN) || \
Pawel Zarembski 0:01f31e923fe2 466 (USBD_ADC_EP_ISOOUT == USBD_CDC_ACM_EP_BULKIN) || \
Pawel Zarembski 0:01f31e923fe2 467 (USBD_ADC_EP_ISOOUT == USBD_CDC_ACM_EP_BULKOUT))
Pawel Zarembski 0:01f31e923fe2 468 #error "Audio Device and Communication Device Interface can not use same Endpoints!"
Pawel Zarembski 0:01f31e923fe2 469 #endif
Pawel Zarembski 0:01f31e923fe2 470 #endif
Pawel Zarembski 0:01f31e923fe2 471 #endif
Pawel Zarembski 0:01f31e923fe2 472 #define USBD_ADC_CIF_NUM (0)
Pawel Zarembski 0:01f31e923fe2 473 #define USBD_ADC_SIF1_NUM (1)
Pawel Zarembski 0:01f31e923fe2 474 #define USBD_ADC_SIF2_NUM (2)
Pawel Zarembski 0:01f31e923fe2 475
Pawel Zarembski 0:01f31e923fe2 476
Pawel Zarembski 0:01f31e923fe2 477 #define USBD_ADC_CIF_STR_NUM (3+USBD_STRDESC_SER_ENABLE+0)
Pawel Zarembski 0:01f31e923fe2 478 #define USBD_ADC_SIF1_STR_NUM (3+USBD_STRDESC_SER_ENABLE+1)
Pawel Zarembski 0:01f31e923fe2 479 #define USBD_ADC_SIF2_STR_NUM (3+USBD_STRDESC_SER_ENABLE+2)
Pawel Zarembski 0:01f31e923fe2 480 #define USBD_CDC_ACM_CIF_STR_NUM (3+USBD_STRDESC_SER_ENABLE+USBD_ADC_ENABLE*3+0)
Pawel Zarembski 0:01f31e923fe2 481 #define USBD_CDC_ACM_DIF_STR_NUM (3+USBD_STRDESC_SER_ENABLE+USBD_ADC_ENABLE*3+1)
Pawel Zarembski 0:01f31e923fe2 482 #define USBD_HID_IF_STR_NUM (3+USBD_STRDESC_SER_ENABLE+USBD_ADC_ENABLE*3+USBD_CDC_ACM_ENABLE*2)
Pawel Zarembski 0:01f31e923fe2 483 #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 484 #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 485 #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 486
Pawel Zarembski 0:01f31e923fe2 487 #if (USBD_HID_ENABLE)
Pawel Zarembski 0:01f31e923fe2 488 #if (USBD_HID_HS_ENABLE)
Pawel Zarembski 0:01f31e923fe2 489 #define USBD_HID_MAX_PACKET ((USBD_HID_HS_WMAXPACKETSIZE > USBD_HID_WMAXPACKETSIZE) ? USBD_HID_HS_WMAXPACKETSIZE : USBD_HID_WMAXPACKETSIZE)
Pawel Zarembski 0:01f31e923fe2 490 #else
Pawel Zarembski 0:01f31e923fe2 491 #define USBD_HID_MAX_PACKET (USBD_HID_WMAXPACKETSIZE)
Pawel Zarembski 0:01f31e923fe2 492 #endif
Pawel Zarembski 0:01f31e923fe2 493 #else
Pawel Zarembski 0:01f31e923fe2 494 #define USBD_HID_MAX_PACKET (0)
Pawel Zarembski 0:01f31e923fe2 495 #endif
Pawel Zarembski 0:01f31e923fe2 496 #if (USBD_MSC_ENABLE)
Pawel Zarembski 0:01f31e923fe2 497 #if (USBD_MSC_HS_ENABLE)
Pawel Zarembski 0:01f31e923fe2 498 #define USBD_MSC_MAX_PACKET ((USBD_MSC_HS_WMAXPACKETSIZE > USBD_MSC_WMAXPACKETSIZE) ? USBD_MSC_HS_WMAXPACKETSIZE : USBD_MSC_WMAXPACKETSIZE)
Pawel Zarembski 0:01f31e923fe2 499 #else
Pawel Zarembski 0:01f31e923fe2 500 #define USBD_MSC_MAX_PACKET (USBD_MSC_WMAXPACKETSIZE)
Pawel Zarembski 0:01f31e923fe2 501 #endif
Pawel Zarembski 0:01f31e923fe2 502 #else
Pawel Zarembski 0:01f31e923fe2 503 #define USBD_MSC_MAX_PACKET (0)
Pawel Zarembski 0:01f31e923fe2 504 #endif
Pawel Zarembski 0:01f31e923fe2 505 #if (USBD_ADC_ENABLE)
Pawel Zarembski 0:01f31e923fe2 506 #if (USBD_ADC_HS_ENABLE)
Pawel Zarembski 0:01f31e923fe2 507 #define USBD_ADC_MAX_PACKET ((USBD_ADC_HS_WMAXPACKETSIZE > USBD_ADC_WMAXPACKETSIZE) ? USBD_ADC_HS_WMAXPACKETSIZE : USBD_ADC_WMAXPACKETSIZE)
Pawel Zarembski 0:01f31e923fe2 508 #else
Pawel Zarembski 0:01f31e923fe2 509 #define USBD_ADC_MAX_PACKET (USBD_ADC_WMAXPACKETSIZE)
Pawel Zarembski 0:01f31e923fe2 510 #endif
Pawel Zarembski 0:01f31e923fe2 511 #else
Pawel Zarembski 0:01f31e923fe2 512 #define USBD_ADC_MAX_PACKET (0)
Pawel Zarembski 0:01f31e923fe2 513 #endif
Pawel Zarembski 0:01f31e923fe2 514 #if (USBD_CDC_ACM_ENABLE)
Pawel Zarembski 0:01f31e923fe2 515 #if (USBD_CDC_ACM_HS_ENABLE)
Pawel Zarembski 0:01f31e923fe2 516 #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 517 #else
Pawel Zarembski 0:01f31e923fe2 518 #define USBD_CDC_ACM_MAX_PACKET (USBD_CDC_ACM_WMAXPACKETSIZE)
Pawel Zarembski 0:01f31e923fe2 519 #endif
Pawel Zarembski 0:01f31e923fe2 520 #if (USBD_CDC_ACM_HS_ENABLE1)
Pawel Zarembski 0:01f31e923fe2 521 #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 522 #else
Pawel Zarembski 0:01f31e923fe2 523 #define USBD_CDC_ACM_MAX_PACKET1 (USBD_CDC_ACM_WMAXPACKETSIZE1)
Pawel Zarembski 0:01f31e923fe2 524 #endif
Pawel Zarembski 0:01f31e923fe2 525 #else
Pawel Zarembski 0:01f31e923fe2 526 #define USBD_CDC_ACM_MAX_PACKET (0)
Pawel Zarembski 0:01f31e923fe2 527 #define USBD_CDC_ACM_MAX_PACKET1 (0)
Pawel Zarembski 0:01f31e923fe2 528 #endif
Pawel Zarembski 0:01f31e923fe2 529
Pawel Zarembski 0:01f31e923fe2 530 #if (USBD_BULK_ENABLE)
Pawel Zarembski 0:01f31e923fe2 531 #if (USBD_BULK_HS_ENABLE)
Pawel Zarembski 0:01f31e923fe2 532 #define USBD_BULK_MAX_PACKET ((USBD_BULK_HS_WMAXPACKETSIZE > USBD_BULK_WMAXPACKETSIZE) ? USBD_BULK_HS_WMAXPACKETSIZE : USBD_BULK_WMAXPACKETSIZE)
Pawel Zarembski 0:01f31e923fe2 533 #else
Pawel Zarembski 0:01f31e923fe2 534 #define USBD_BULK_MAX_PACKET (USBD_BULK_WMAXPACKETSIZE)
Pawel Zarembski 0:01f31e923fe2 535 #endif
Pawel Zarembski 0:01f31e923fe2 536 #else
Pawel Zarembski 0:01f31e923fe2 537 #define USBD_BULK_MAX_PACKET (0)
Pawel Zarembski 0:01f31e923fe2 538 #endif
Pawel Zarembski 0:01f31e923fe2 539
Pawel Zarembski 0:01f31e923fe2 540 #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 541 #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 542 #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 543 #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 544 #define USBD_MAX_PACKET ((USBD_MAX_PACKET_CALC3 > USBD_MAX_PACKET_CALC2 ) ? (USBD_MAX_PACKET_CALC3) : (USBD_MAX_PACKET_CALC2 ))
Pawel Zarembski 0:01f31e923fe2 545
Pawel Zarembski 0:01f31e923fe2 546
Pawel Zarembski 0:01f31e923fe2 547 /*------------------------------------------------------------------------------
Pawel Zarembski 0:01f31e923fe2 548 * USB Config Functions
Pawel Zarembski 0:01f31e923fe2 549 *----------------------------------------------------------------------------*/
Pawel Zarembski 0:01f31e923fe2 550
Pawel Zarembski 0:01f31e923fe2 551 #ifndef __USB_CONFIG___
Pawel Zarembski 0:01f31e923fe2 552 #define __USB_CONFIG__
Pawel Zarembski 0:01f31e923fe2 553
Pawel Zarembski 0:01f31e923fe2 554 #ifndef __NO_USB_LIB_C
Pawel Zarembski 0:01f31e923fe2 555 #include "usb_lib.c"
Pawel Zarembski 0:01f31e923fe2 556 #endif
Pawel Zarembski 0:01f31e923fe2 557
Pawel Zarembski 0:01f31e923fe2 558 #endif /* __USB_CONFIG__ */