Kinetis Bootloader  2.0.0
Common bootloader for Kinetis devices
validation/embedded_host/src/disk/usb_descriptor.h
1 /*
2  * Copyright (c) 2015, Freescale Semiconductor, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without modification,
6  * are permitted provided that the following conditions are met:
7  *
8  * o Redistributions of source code must retain the above copyright notice, this list
9  * of conditions and the following disclaimer.
10  *
11  * o Redistributions in binary form must reproduce the above copyright notice, this
12  * list of conditions and the following disclaimer in the documentation and/or
13  * other materials provided with the distribution.
14  *
15  * o Neither the name of Freescale Semiconductor, Inc. nor the names of its
16  * contributors may be used to endorse or promote products derived from this
17  * software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
23  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
26  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30 
31 #ifndef __USB_DEVICE_DESCRIPTOR_H__
32 #define __USB_DEVICE_DESCRIPTOR_H__
33 
34 /*******************************************************************************
35  * Definitions
36  ******************************************************************************/
37 #define USB_DEVICE_SPECIFIC_BCD_VERSION (0x0200U)
38 #define USB_DEVICE_DEMO_BCD_VERSION (0x0101U)
39 #define USB_DEVICE_MAX_POWER (0x32U)
40 
41 #define USB_CONFIGURE_COUNT (1U)
42 #define USB_DEVICE_STRING_COUNT (4U)
43 #define USB_DEVICE_LANGUAGE_COUNT (1U)
44 #define USB_INTERFACE_COUNT (1U)
45 
46 #define USB_MSC_CONFIGURE_INDEX (1U)
47 
48 #define USB_MSC_ENDPOINT_COUNT (2U)
49 #define USB_MSC_BULK_IN_ENDPOINT (1U)
50 #define USB_MSC_BULK_OUT_ENDPOINT (2U)
51 
52 /* usb descritpor length */
53 #define USB_DESCRIPTOR_LENGTH_CONFIGURATION_ALL \
54  (USB_DESCRIPTOR_LENGTH_CONFIGURE + USB_DESCRIPTOR_LENGTH_INTERFACE + \
55  USB_DESCRIPTOR_LENGTH_ENDPOINT * USB_MSC_ENDPOINT_COUNT)
56 
57 #define HS_MSC_BULK_IN_PACKET_SIZE (512U)
58 #define HS_MSC_BULK_OUT_PACKET_SIZE (512U)
59 #define FS_MSC_BULK_IN_PACKET_SIZE (64U)
60 #define FS_MSC_BULK_OUT_PACKET_SIZE (64U)
61 
62 #define USB_STRING_DESCRIPTOR_HEADER_LENGTH (0x02U)
63 #define USB_STRING_DESCRIPTOR_0_LENGTH (0x02U)
64 #define USB_STRING_DESCRIPTOR_1_LENGTH (56U)
65 #define USB_STRING_DESCRIPTOR_2_LENGTH (32U)
66 #define USB_STRING_DESCRIPTOR_3_LENGTH (32U)
67 #define USB_STRING_DESCRIPTOR_ERROR_LENGTH (32U)
68 
69 #define USB_MSC_INTERFACE_INDEX (0U)
70 #define USB_MSC_INTERFACE_COUNT (1U)
71 
72 #define USB_DEVICE_CLASS (0x00U)
73 #define USB_DEVICE_SUBCLASS (0x00U)
74 #define USB_DEVICE_PROTOCOL (0x00U)
75 
76 #define USB_MSC_CLASS (0x08U)
77 /* scsi command set */
78 #define USB_MSC_SUBCLASS (0x06U)
79 /* bulk only transport protocol */
80 #define USB_MSC_PROTOCOL (0x50U)
81 
82 extern usb_device_class_struct_t g_UsbDeviceMscConfig;
83 extern usb_status_t USB_DeviceSetSpeed(usb_device_handle handle, uint8_t speed);
84 
85 usb_status_t USB_DeviceGetDeviceDescriptor(usb_device_handle handle,
86  usb_device_get_device_descriptor_struct_t *deviceDescriptor);
87 
88 usb_status_t USB_DeviceGetConfigurationDescriptor(
89  usb_device_handle handle, usb_device_get_configuration_descriptor_struct_t *configurationDescriptor);
90 
91 usb_status_t USB_DeviceGetStringDescriptor(usb_device_handle handle,
92  usb_device_get_string_descriptor_struct_t *stringDescriptor);
93 #endif