Kinetis Bootloader  2.0.0
Common bootloader for Kinetis devices
composite.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_COMPOSITE_H__
32 #define __USB_DEVICE_COMPOSITE_H__ 1
33 
34 #include "msc_disk.h"
35 #include "hid_bootloader.h"
36 #include "usb_device_config.h"
37 
38 #if defined(USB_DEVICE_CONFIG_EHCI) && (USB_DEVICE_CONFIG_EHCI > 0U)
39 #define CONTROLLER_ID kUSB_ControllerEhci0
40 #endif
41 #if defined(USB_DEVICE_CONFIG_KHCI) && (USB_DEVICE_CONFIG_KHCI > 0U)
42 #define CONTROLLER_ID kUSB_ControllerKhci0
43 #endif
44 
45 #define USB_DEVICE_INTERRUPT_PRIORITY (4)
46 
47 typedef struct _usb_device_composite_struct
48 {
49  usb_device_handle device_handle; // USB device handle.
50 #if ((defined(USB_DEVICE_CONFIG_HID)) && (USB_DEVICE_CONFIG_HID > 0U))
51  usb_hid_generic_struct_t hid_generic; // HID device structure
52 #endif
53 #if USB_DEVICE_CONFIG_MSC
54  usb_msc_struct_t msc_disk; // MSC disk device structure.
55 #endif // USB_DEVICE_CONFIG_MSC
56  uint8_t speed; // Speed of USB device. USB_SPEED_FULL/USB_SPEED_LOW/USB_SPEED_HIGH.
57  uint8_t attach; // A flag to indicate whether a usb device is attached. 1: attached, 0: not attached
58  uint8_t current_configuration; // Current configuration value.
59  uint8_t current_interface_alternate_setting[USB_COMPOSITE_INTERFACE_COUNT]; // Current alternate setting value for
60  // each interface.
62 
63 extern usb_status_t usb_device_callback(usb_device_handle handle, uint32_t event, void *param);
64 
65 #if (BL_CONFIG_USB_HID || BL_CONFIG_HS_USB_HID)
66 // HID device initialization function
67 extern usb_status_t usb_device_hid_generic_init(usb_device_composite_struct_t *device_composite);
68 // HID class specific callback function
69 extern usb_status_t usb_device_hid_generic_callback(class_handle_t handle, uint32_t event, void *param);
70 // HID device set configuration function
71 extern usb_status_t usb_device_hid_generic_set_configure(class_handle_t handle, uint8_t configure);
72 // HID device set interface function
73 extern usb_status_t usb_device_hid_generic_set_interface(class_handle_t handle,
74  uint8_t interface,
75  uint8_t alternate_setting);
76 // HID device de-initialization function
77 extern usb_status_t usb_device_hid_generic_deinit(usb_device_composite_struct_t *device_composite);
78 #endif // #if BL_CONFIG_USB_HID
79 
80 #if (BL_CONFIG_USB_MSC || BL_CONFIG_HS_USB_MSC)
81 // MSC disk device initialization function
82 extern usb_status_t usb_device_msc_disk_init(usb_device_composite_struct_t *device_composite);
83 // MSC class specific callback function
84 extern usb_status_t usb_device_msc_callback(class_handle_t handle, uint32_t event, void *param);
85 // MSC disk device set configuration function
86 extern usb_status_t usb_device_msc_disk_set_configure(class_handle_t handle, uint8_t configure);
87 // MSC disk device de-initialization function
88 extern usb_status_t usb_device_msc_disk_deinit(usb_device_composite_struct_t *device_composite);
89 
90 void usb_device_msc_disk_pump(void);
91 #endif // #if BL_CONFIG_USB_MSC
92 
93 extern usb_device_class_config_list_struct_t g_composite_device_config_list;
94 
95 #endif
Definition: msc_disk.h:185
Definition: composite.h:47
usb_status_t usb_device_msc_callback(class_handle_t handle, uint32_t event, void *param)
device msc callback function.
Definition: msc_disk.c:431
Definition: hid_bootloader.h:61