summaryrefslogtreecommitdiff
path: root/CMSIS/Driver/Include/Driver_USB.h
blob: 4f3a1b87add6ddabd634dba9c0f1b5658ce9abfd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/* -----------------------------------------------------------------------------
 * Copyright (c) 2013-2014 ARM Ltd.
 *
 * This software is provided 'as-is', without any express or implied warranty.
 * In no event will the authors be held liable for any damages arising from
 * the use of this software. Permission is granted to anyone to use this
 * software for any purpose, including commercial applications, and to alter
 * it and redistribute it freely, subject to the following restrictions:
 *
 * 1. The origin of this software must not be misrepresented; you must not
 *    claim that you wrote the original software. If you use this software in
 *    a product, an acknowledgment in the product documentation would be
 *    appreciated but is not required.
 *
 * 2. Altered source versions must be plainly marked as such, and must not be
 *    misrepresented as being the original software.
 *
 * 3. This notice may not be removed or altered from any source distribution.
 *
 *
 * $Date:        20. May 2014
 * $Revision:    V2.00
 *
 * Project:      USB Driver common definitions
 * -------------------------------------------------------------------------- */

/* History:
 *  Version 2.00
 *  Version 1.10
 *    Namespace prefix ARM_ added
 *  Version 1.01
 *    Added PID Types
 *  Version 1.00
 *    Initial release
 */

#ifndef __DRIVER_USB_H
#define __DRIVER_USB_H

#include "Driver_Common.h"

/* USB Role */
#define ARM_USB_ROLE_NONE                0
#define ARM_USB_ROLE_HOST                1
#define ARM_USB_ROLE_DEVICE              2

/* USB Pins */
#define ARM_USB_PIN_DP                  (1 << 0) ///< USB D+ pin
#define ARM_USB_PIN_DM                  (1 << 1) ///< USB D- pin
#define ARM_USB_PIN_VBUS                (1 << 2) ///< USB VBUS pin
#define ARM_USB_PIN_OC                  (1 << 3) ///< USB OverCurrent pin
#define ARM_USB_PIN_ID                  (1 << 4) ///< USB ID pin

/* USB Speed */
#define ARM_USB_SPEED_LOW                0       ///< Low-speed USB
#define ARM_USB_SPEED_FULL               1       ///< Full-speed USB
#define ARM_USB_SPEED_HIGH               2       ///< High-speed USB

/* USB PID Types */
#define ARM_USB_PID_OUT                  1
#define ARM_USB_PID_IN                   9
#define ARM_USB_PID_SOF                  5
#define ARM_USB_PID_SETUP                13
#define ARM_USB_PID_DATA0                3
#define ARM_USB_PID_DATA1                11
#define ARM_USB_PID_DATA2                7
#define ARM_USB_PID_MDATA                15
#define ARM_USB_PID_ACK                  2
#define ARM_USB_PID_NAK                  10
#define ARM_USB_PID_STALL                14
#define ARM_USB_PID_NYET                 6
#define ARM_USB_PID_PRE                  12
#define ARM_USB_PID_ERR                  12
#define ARM_USB_PID_SPLIT                8
#define ARM_USB_PID_PING                 4
#define ARM_USB_PID_RESERVED             0

/* USB Endpoint Address (bEndpointAddress) */
#define ARM_USB_ENDPOINT_NUMBER_MASK     0x0F
#define ARM_USB_ENDPOINT_DIRECTION_MASK  0x80

/* USB Endpoint Type */
#define ARM_USB_ENDPOINT_CONTROL         0       ///< Control Endpoint
#define ARM_USB_ENDPOINT_ISOCHRONOUS     1       ///< Isochronous Endpoint
#define ARM_USB_ENDPOINT_BULK            2       ///< Bulk Endpoint
#define ARM_USB_ENDPOINT_INTERRUPT       3       ///< Interrupt Endpoint

/* USB Endpoint Maximum Packet Size (wMaxPacketSize) */
#define ARM_USB_ENDPOINT_MAX_PACKET_SIZE_MASK           0x07FF
#define ARM_USB_ENDPOINT_MICROFRAME_TRANSACTIONS_MASK   0x1800
#define ARM_USB_ENDPOINT_MICROFRAME_TRANSACTIONS_1      0x0000
#define ARM_USB_ENDPOINT_MICROFRAME_TRANSACTIONS_2      0x0800
#define ARM_USB_ENDPOINT_MICROFRAME_TRANSACTIONS_3      0x1000

#endif /* __DRIVER_USB_H */