2 * The Clear BSD License
3 * Copyright (c) 2015, Freescale Semiconductor, Inc.
4 * Copyright 2016-2017 NXP
7 * Redistribution and use in source and binary forms, with or without modification,
8 * are permitted (subject to the limitations in the disclaimer below) provided
9 * that the following conditions are met:
11 * o Redistributions of source code must retain the above copyright notice, this list
12 * of conditions and the following disclaimer.
14 * o Redistributions in binary form must reproduce the above copyright notice, this
15 * list of conditions and the following disclaimer in the documentation and/or
16 * other materials provided with the distribution.
18 * o Neither the name of the copyright holder nor the names of its
19 * contributors may be used to endorse or promote products derived from this
20 * software without specific prior written permission.
22 * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE.
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
27 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
30 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 #ifndef _USB_CDC_VCOM_H_
35 #define _USB_CDC_VCOM_H_ 1
37 #include "usb_device_descriptor.h"
38 #include "fsl_common.h"
40 /*******************************************************************************
42 ******************************************************************************/
43 #if defined(USB_DEVICE_CONFIG_EHCI) && (USB_DEVICE_CONFIG_EHCI > 0)
44 #define CONTROLLER_ID kUSB_ControllerEhci0
45 #define DATA_BUFF_SIZE HS_CDC_VCOM_BULK_OUT_PACKET_SIZE
46 #endif /* USB_DEVICE_CONFIG_EHCI */
48 #if defined(USB_DEVICE_CONFIG_KHCI) && (USB_DEVICE_CONFIG_KHCI > 0)
49 #define CONTROLLER_ID kUSB_ControllerKhci0
50 #define DATA_BUFF_SIZE FS_CDC_VCOM_BULK_OUT_PACKET_SIZE
51 #endif /* USB_DEVICE_CONFIG_KHCI */
53 #if defined(USB_DEVICE_CONFIG_LPCIP3511FS) && (USB_DEVICE_CONFIG_LPCIP3511FS > 0U)
54 #define CONTROLLER_ID kUSB_ControllerLpcIp3511Fs0
55 #define DATA_BUFF_SIZE FS_CDC_VCOM_BULK_OUT_PACKET_SIZE
56 #endif /* USB_DEVICE_CONFIG_LPCIP3511FS */
58 #if defined(USB_DEVICE_CONFIG_LPCIP3511HS) && (USB_DEVICE_CONFIG_LPCIP3511HS > 0U)
59 #define CONTROLLER_ID kUSB_ControllerLpcIp3511Hs0
60 #define DATA_BUFF_SIZE HS_CDC_VCOM_BULK_OUT_PACKET_SIZE
61 #endif /* USB_DEVICE_CONFIG_LPCIP3511HS */
63 #if defined(USB_DEVICE_CONFIG_LPCIP3511FS) && (USB_DEVICE_CONFIG_LPCIP3511FS > 0U)
64 #define CONTROLLER_ID kUSB_ControllerLpcIp3511Fs0
65 #define DATA_BUFF_SIZE FS_CDC_VCOM_BULK_OUT_PACKET_SIZE
69 #if defined(USB_DEVICE_CONFIG_LPCIP3511HS) && (USB_DEVICE_CONFIG_LPCIP3511HS > 0U)
70 #define CONTROLLER_ID kUSB_ControllerLpcIp3511Hs0
71 #define DATA_BUFF_SIZE HS_CDC_VCOM_BULK_OUT_PACKET_SIZE
74 #define USB_DEVICE_INTERRUPT_PRIORITY (3U)
76 /* Currently configured line coding */
77 #define LINE_CODING_SIZE (0x07)
78 #define LINE_CODING_DTERATE (115200)
79 #define LINE_CODING_CHARFORMAT (0x00)
80 #define LINE_CODING_PARITYTYPE (0x00)
81 #define LINE_CODING_DATABITS (0x08)
83 /* Communications feature */
84 #define COMM_FEATURE_DATA_SIZE (0x02)
85 #define STATUS_ABSTRACT_STATE (0x0000)
86 #define COUNTRY_SETTING (0x0000)
88 /* Notification of serial state */
89 #define NOTIF_PACKET_SIZE (0x08)
90 #define UART_BITMAP_SIZE (0x02)
91 #define NOTIF_REQUEST_TYPE (0xA1)
93 /* Define the types for application */
94 typedef struct _usb_cdc_vcom_struct
96 usb_device_handle deviceHandle; /* USB device handle. */
97 volatile uint8_t attach; /* A flag to indicate whether a usb device is attached. 1: attached, 0: not attached */
98 uint8_t speed; /* Speed of USB device. USB_SPEED_FULL/USB_SPEED_LOW/USB_SPEED_HIGH. */
100 startTransactions; /* A flag to indicate whether a CDC device is ready to transmit and receive data. */
101 uint8_t currentConfiguration; /* Current configuration value. */
102 uint8_t currentInterfaceAlternateSetting
103 [USB_CDC_VCOM_INTERFACE_COUNT]; /* Current alternate setting value for each interface. */
104 } usb_cdc_vcom_struct_t;
106 /* Define the infomation relates to abstract control model */
107 typedef struct _usb_cdc_acm_info
109 uint8_t serialStateBuf[NOTIF_PACKET_SIZE + UART_BITMAP_SIZE]; /* Serial state buffer of the CDC device to notify the
110 serial state to host. */
111 bool dtePresent; /* A flag to indicate whether DTE is present. */
112 uint16_t breakDuration; /* Length of time in milliseconds of the break signal */
113 uint8_t dteStatus; /* Status of data terminal equipment */
114 uint8_t currentInterface; /* Current interface index. */
115 uint16_t uartState; /* UART state of the CDC device. */
116 } usb_cdc_acm_info_t;
118 /*******************************************************************************
120 ******************************************************************************/
122 * @brief Application initialization function.
124 * This function initializes the application.
126 * @return pointer to USB device handle.
128 usb_device_handle USB_VcomInit (uint16_t vid, uint16_t pid);
131 * @brief Application initialization function.
133 * This function initializes the application.
135 * @return pointer to USB device handle.
137 void USB_VcomDeinit (void);
139 #endif /* _USB_CDC_VCOM_H_ */