aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--documentation/usb_cdc_echo.rst45
-rw-r--r--documentation/usb_device_cdc.rst46
-rw-r--r--usb/class/cdc/device/atmel_devices_cdc.catbin8352 -> 0 bytes
-rw-r--r--usb/class/cdc/device/atmel_devices_cdc.inf182
-rw-r--r--usb/class/cdc/device/cdcdf_acm.c379
-rw-r--r--usb/class/cdc/device/cdcdf_acm.h108
-rw-r--r--usb/class/cdc/device/cdcdf_acm_desc.h131
-rw-r--r--usb/class/cdc/usb_protocol_cdc.h426
8 files changed, 0 insertions, 1317 deletions
diff --git a/documentation/usb_cdc_echo.rst b/documentation/usb_cdc_echo.rst
deleted file mode 100644
index 5e4100d..0000000
--- a/documentation/usb_cdc_echo.rst
+++ /dev/null
@@ -1,45 +0,0 @@
-============
-USB CDC ECHO
-============
-
-This demo behaves like a virtual COM port based on USD device CDC. It echoes
-back bytes received from the console.
-
-Drivers
--------
-* USB Device
-
-Supported Evaluation Kit
-------------------------
-* SAM D21 Xplained Pro
-* SAM DA1 Xplained Pro
-* SAM R21 Xplained Pro
-* SAM D11 Xplained Pro
-* SAM L21 Xplained Pro
-* SAM L22 Xplained Pro
-* SAM V71 Xplained Ultra
-* SAM E70 Xplained
-* SAM G55 Xplained Pro
-* SAM E54 Xplained Pro
-
-Interface Settings
-------------------
-* No extra board or wire connection is needed.
-* The enumerated serial port does not bridge to any specific USRT hardware but
- simply loopback data, so whatever serial port setting works.
-
-Running the Demo
-----------------
-
-1. Download the selected example, or export the example to save the .atzip file.
-2. Import .atzip file into Atmel Studio 7, File->Import->Atmel Start Project.
-3. Build and flash into supported evaluation board.
-4. Connect PC host and TARGET USB plug with a USB cable.
-5. Press the RESET button.
-6. The serial port is detected by host PC. On Linux the driver will be installed
- automatically. On Windows The INF and CAT file required can be extracted from
- .atzip or found in generated Atmel Studio 7 project folder, relatively at
- ./usb/class/cdc/device.
-7. Open the detected/enumerated serial port using a serial port monitor
- (e.g., TeraTerm).
-8. Whatever sent from the serial port monitor will be echoed back then.
diff --git a/documentation/usb_device_cdc.rst b/documentation/usb_device_cdc.rst
deleted file mode 100644
index 305ff8f..0000000
--- a/documentation/usb_device_cdc.rst
+++ /dev/null
@@ -1,46 +0,0 @@
-==============
-USB Device CDC
-==============
-
-USB Device CDC (Communication Device Class)is a part of the USB Device Stack library.
-It provides support for Abstract Control Model, which is one of the USB PSTN Device
-Models. The device uses both a Data Class interface and a Communication Class interface
-for it. For more detailed definition and description about this model, user can refer to
-the related chapter in <Universal Serial Bus Communications Class Subclass Specification
-for PSTN Devices, Revision 1.2>
-
-Features
---------
-
-* Initialization/de-initialization.
-* Data transfer.
-* Callbacks management on:
-
- * Transmission done
- * Reception done
- * Setting a new Line coding
- * Line state changing
-
-Applications
-------------
-
-* Used as a vritual serial.
-
-
-Dependencies
-------------
-
-* USB Device Driver
-* USB Device Stack Core
-* USB Protocol CDC
-
-
-Limitations
------------
-
-* Only single instance can be supported, not applied for multiple case.
-* The INF and CAT file would be packed in atzip file. User can extract
- them from "./usb/class/cdc/device".
-* If user wants to combine CDC with other classes into one device, USB
- Device Stack Composite component should be added from the web page
- rather than USB Device Stack CDC ACM.
diff --git a/usb/class/cdc/device/atmel_devices_cdc.cat b/usb/class/cdc/device/atmel_devices_cdc.cat
deleted file mode 100644
index 09a0673..0000000
--- a/usb/class/cdc/device/atmel_devices_cdc.cat
+++ /dev/null
Binary files differ
diff --git a/usb/class/cdc/device/atmel_devices_cdc.inf b/usb/class/cdc/device/atmel_devices_cdc.inf
deleted file mode 100644
index d2df608..0000000
--- a/usb/class/cdc/device/atmel_devices_cdc.inf
+++ /dev/null
@@ -1,182 +0,0 @@
-; Windows 2000, XP, Vista, 7 and 8 (x32 and x64) setup file for Atmel CDC Devices
-; Copyright (c) 2000-2013 ATMEL, Inc.
-
-[Version]
-Signature = "$Windows NT$"
-Class = Ports
-ClassGuid = {4D36E978-E325-11CE-BFC1-08002BE10318}
-
-Provider = %Manufacturer%
-LayoutFile = layout.inf
-CatalogFile = atmel_devices_cdc.cat
-DriverVer = 01/08/2013,6.0.0.0
-
-;----------------------------------------------------------
-; Targets
-;----------------------------------------------------------
-[Manufacturer]
-%Manufacturer%=DeviceList, NTAMD64, NTIA64, NT
-
-[DeviceList]
-%ATMEL_CDC_XPLAINED%=DriverInstall, USB\VID_03EB&PID_2122
-%ATMEL_CDC_USB_ZIGBIT_Sub%=DriverInstall, USB\VID_03EB&PID_214B
-%ATMEL_CDC_USB_ZIGBIT_2_4%=DriverInstall, USB\VID_03EB&PID_214A
-%ATMEL_CDC_SFW_EXAMPLE%=DriverInstall, USB\VID_03EB&PID_2307
-%ATMEL_CDC_EVK1XXX%=DriverInstall, USB\VID_03EB&PID_2310
-%ATMEL_CDC_ASF_EXAMPLE%=DriverInstall, USB\VID_03EB&PID_2404
-%ATMEL_CDC_ASF_COMPOSITE_EXAMPLE2%=DriverInstall, USB\VID_03EB&PID_2421&MI_00
-%ATMEL_CDC_ASF_COMPOSITE_EXAMPLE4%=DriverInstall, USB\VID_03EB&PID_2424&MI_00
-%ATMEL_CDC_ASF_EXAMPLE2_COM1%=DriverInstall, USB\VID_03EB&PID_2425&MI_00
-%ATMEL_CDC_ASF_EXAMPLE2_COM2%=DriverInstall, USB\VID_03EB&PID_2425&MI_02
-%ATMEL_CDC_ASF_EXAMPLE3_COM1%=DriverInstall, USB\VID_03EB&PID_2426&MI_00
-%ATMEL_CDC_ASF_EXAMPLE3_COM2%=DriverInstall, USB\VID_03EB&PID_2426&MI_02
-%ATMEL_CDC_ASF_EXAMPLE3_COM3%=DriverInstall, USB\VID_03EB&PID_2426&MI_04
-%ATMEL_CDC_ASF_EXAMPLE3_COM4%=DriverInstall, USB\VID_03EB&PID_2426&MI_06
-%ATMEL_CDC_ASF_EXAMPLE3_COM5%=DriverInstall, USB\VID_03EB&PID_2426&MI_08
-%ATMEL_CDC_ASF_EXAMPLE3_COM6%=DriverInstall, USB\VID_03EB&PID_2426&MI_0A
-%ATMEL_CDC_ASF_EXAMPLE3_COM7%=DriverInstall, USB\VID_03EB&PID_2426&MI_0C
-
-[DeviceList.NTAMD64]
-%ATMEL_CDC_XPLAINED%=DriverInstall.NTamd64, USB\VID_03EB&PID_2122
-%ATMEL_CDC_USB_ZIGBIT_Sub%=DriverInstall.NTamd64, USB\VID_03EB&PID_214B
-%ATMEL_CDC_USB_ZIGBIT_2_4%=DriverInstall.NTamd64, USB\VID_03EB&PID_214A
-%ATMEL_CDC_SFW_EXAMPLE%=DriverInstall.NTamd64, USB\VID_03EB&PID_2307
-%ATMEL_CDC_EVK1XXX%=DriverInstall.NTamd64, USB\VID_03EB&PID_2310
-%ATMEL_CDC_ASF_EXAMPLE%=DriverInstall.NTamd64, USB\VID_03EB&PID_2404
-%ATMEL_CDC_ASF_COMPOSITE_EXAMPLE2%=DriverInstall.NTamd64, USB\VID_03EB&PID_2421&MI_00
-%ATMEL_CDC_ASF_COMPOSITE_EXAMPLE4%=DriverInstall.NTamd64, USB\VID_03EB&PID_2424&MI_00
-%ATMEL_CDC_ASF_EXAMPLE2_COM1%=DriverInstall.NTamd64, USB\VID_03EB&PID_2425&MI_00
-%ATMEL_CDC_ASF_EXAMPLE2_COM2%=DriverInstall.NTamd64, USB\VID_03EB&PID_2425&MI_02
-%ATMEL_CDC_ASF_EXAMPLE3_COM1%=DriverInstall.NTamd64, USB\VID_03EB&PID_2426&MI_00
-%ATMEL_CDC_ASF_EXAMPLE3_COM2%=DriverInstall.NTamd64, USB\VID_03EB&PID_2426&MI_02
-%ATMEL_CDC_ASF_EXAMPLE3_COM3%=DriverInstall.NTamd64, USB\VID_03EB&PID_2426&MI_04
-%ATMEL_CDC_ASF_EXAMPLE3_COM4%=DriverInstall.NTamd64, USB\VID_03EB&PID_2426&MI_06
-%ATMEL_CDC_ASF_EXAMPLE3_COM5%=DriverInstall.NTamd64, USB\VID_03EB&PID_2426&MI_08
-%ATMEL_CDC_ASF_EXAMPLE3_COM6%=DriverInstall.NTamd64, USB\VID_03EB&PID_2426&MI_0A
-%ATMEL_CDC_ASF_EXAMPLE3_COM7%=DriverInstall.NTamd64, USB\VID_03EB&PID_2426&MI_0C
-
-[DeviceList.NTIA64]
-%ATMEL_CDC_XPLAINED%=DriverInstall.NTamd64, USB\VID_03EB&PID_2122
-%ATMEL_CDC_USB_ZIGBIT_Sub%=DriverInstall.NTamd64, USB\VID_03EB&PID_214B
-%ATMEL_CDC_USB_ZIGBIT_2_4%=DriverInstall.NTamd64, USB\VID_03EB&PID_214A
-%ATMEL_CDC_SFW_EXAMPLE%=DriverInstall.NTamd64, USB\VID_03EB&PID_2307
-%ATMEL_CDC_EVK1XXX%=DriverInstall.NTamd64, USB\VID_03EB&PID_2310
-%ATMEL_CDC_ASF_EXAMPLE%=DriverInstall.NTamd64, USB\VID_03EB&PID_2404
-%ATMEL_CDC_ASF_COMPOSITE_EXAMPLE2%=DriverInstall.NTamd64, USB\VID_03EB&PID_2421&MI_00
-%ATMEL_CDC_ASF_COMPOSITE_EXAMPLE4%=DriverInstall.NTamd64, USB\VID_03EB&PID_2424&MI_00
-%ATMEL_CDC_ASF_EXAMPLE2_COM1%=DriverInstall.NTamd64, USB\VID_03EB&PID_2425&MI_00
-%ATMEL_CDC_ASF_EXAMPLE2_COM2%=DriverInstall.NTamd64, USB\VID_03EB&PID_2425&MI_02
-%ATMEL_CDC_ASF_EXAMPLE3_COM1%=DriverInstall.NTamd64, USB\VID_03EB&PID_2426&MI_00
-%ATMEL_CDC_ASF_EXAMPLE3_COM2%=DriverInstall.NTamd64, USB\VID_03EB&PID_2426&MI_02
-%ATMEL_CDC_ASF_EXAMPLE3_COM3%=DriverInstall.NTamd64, USB\VID_03EB&PID_2426&MI_04
-%ATMEL_CDC_ASF_EXAMPLE3_COM4%=DriverInstall.NTamd64, USB\VID_03EB&PID_2426&MI_06
-%ATMEL_CDC_ASF_EXAMPLE3_COM5%=DriverInstall.NTamd64, USB\VID_03EB&PID_2426&MI_08
-%ATMEL_CDC_ASF_EXAMPLE3_COM6%=DriverInstall.NTamd64, USB\VID_03EB&PID_2426&MI_0A
-%ATMEL_CDC_ASF_EXAMPLE3_COM7%=DriverInstall.NTamd64, USB\VID_03EB&PID_2426&MI_0C
-
-[DeviceList.NT]
-%ATMEL_CDC_XPLAINED%=DriverInstall.NT, USB\VID_03EB&PID_2122
-%ATMEL_CDC_USB_ZIGBIT_Sub%=DriverInstall.NT, USB\VID_03EB&PID_214B
-%ATMEL_CDC_USB_ZIGBIT_2_4%=DriverInstall.NT, USB\VID_03EB&PID_214A
-%ATMEL_CDC_SFW_EXAMPLE%=DriverInstall.NT, USB\VID_03EB&PID_2307
-%ATMEL_CDC_EVK1XXX%=DriverInstall.NT, USB\VID_03EB&PID_2310
-%ATMEL_CDC_ASF_EXAMPLE%=DriverInstall.NT, USB\VID_03EB&PID_2404
-%ATMEL_CDC_ASF_COMPOSITE_EXAMPLE2%=DriverInstall.NT, USB\VID_03EB&PID_2421&MI_00
-%ATMEL_CDC_ASF_COMPOSITE_EXAMPLE4%=DriverInstall.NT, USB\VID_03EB&PID_2424&MI_00
-%ATMEL_CDC_ASF_EXAMPLE2_COM1%=DriverInstall.NT, USB\VID_03EB&PID_2425&MI_00
-%ATMEL_CDC_ASF_EXAMPLE2_COM2%=DriverInstall.NT, USB\VID_03EB&PID_2425&MI_02
-%ATMEL_CDC_ASF_EXAMPLE3_COM1%=DriverInstall.NT, USB\VID_03EB&PID_2426&MI_00
-%ATMEL_CDC_ASF_EXAMPLE3_COM2%=DriverInstall.NT, USB\VID_03EB&PID_2426&MI_02
-%ATMEL_CDC_ASF_EXAMPLE3_COM3%=DriverInstall.NT, USB\VID_03EB&PID_2426&MI_04
-%ATMEL_CDC_ASF_EXAMPLE3_COM4%=DriverInstall.NT, USB\VID_03EB&PID_2426&MI_06
-%ATMEL_CDC_ASF_EXAMPLE3_COM5%=DriverInstall.NT, USB\VID_03EB&PID_2426&MI_08
-%ATMEL_CDC_ASF_EXAMPLE3_COM6%=DriverInstall.NT, USB\VID_03EB&PID_2426&MI_0A
-%ATMEL_CDC_ASF_EXAMPLE3_COM7%=DriverInstall.NT, USB\VID_03EB&PID_2426&MI_0C
-
-;----------------------------------------------------------
-; Windows 2000, XP, Vista, Windows 7, Windows 8 - 32bit
-;----------------------------------------------------------
-[Reader_Install.NTx86]
-
-
-[DestinationDirs]
-DefaultDestDir=12
-DriverInstall.NT.Copy=12
-
-[DriverInstall.NT]
-include=mdmcpq.inf
-CopyFiles=DriverInstall.NT.Copy
-AddReg=DriverInstall.NT.AddReg
-
-[DriverInstall.NT.Copy]
-usbser.sys
-
-[DriverInstall.NT.AddReg]
-HKR,,DevLoader,,*ntkern
-HKR,,NTMPDriver,,usbser.sys
-HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider"
-
-[DriverInstall.NT.Services]
-AddService = usbser, 0x00000002, DriverService.NT
-
-[DriverService.NT]
-DisplayName = %Serial.SvcDesc%
-ServiceType = 1 ; SERVICE_KERNEL_DRIVER
-StartType = 3 ; SERVICE_DEMAND_START
-ErrorControl = 1 ; SERVICE_ERROR_NORMAL
-ServiceBinary = %12%\usbser.sys
-LoadOrderGroup = Base
-
-;----------------------------------------------------------
-; Windows XP, Vista, Windows 7, Windows 8 - 64bit
-;----------------------------------------------------------
-
-[DriverInstall.NTamd64]
-include=mdmcpq.inf
-CopyFiles=DriverCopyFiles.NTamd64
-AddReg=DriverInstall.NTamd64.AddReg
-
-[DriverCopyFiles.NTamd64]
-usbser.sys,,,0x20
-
-[DriverInstall.NTamd64.AddReg]
-HKR,,DevLoader,,*ntkern
-HKR,,NTMPDriver,,usbser.sys
-HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider"
-
-[DriverInstall.NTamd64.Services]
-AddService=usbser, 0x00000002, DriverService.NTamd64
-
-[DriverService.NTamd64]
-DisplayName=%Serial.SvcDesc%
-ServiceType=1
-StartType=3
-ErrorControl=1
-ServiceBinary=%12%\usbser.sys
-
-;----------------------------------------------------------
-; String
-;----------------------------------------------------------
-
-[Strings]
-Manufacturer = "ATMEL, Inc."
-ATMEL_CDC_XPLAINED = "XPLAINED Virtual Com Port"
-ATMEL_CDC_USB_ZIGBIT_Sub = "ZigBit SubGHz USBstick Com Port"
-ATMEL_CDC_USB_ZIGBIT_2_4 = "ZigBit 2.4GHz USBstick Com Port"
-ATMEL_CDC_SFW_EXAMPLE = "Communication Device Class SFW example"
-ATMEL_CDC_EVK1XXX = "EVK1XXX Virtual Com Port"
-ATMEL_CDC_ASF_EXAMPLE = "Communication Device Class ASF example"
-ATMEL_CDC_ASF_COMPOSITE_EXAMPLE2 = "Communication Device Class ASF composite example 2"
-ATMEL_CDC_ASF_COMPOSITE_EXAMPLE4 = "Communication Device Class ASF composite example 4"
-ATMEL_CDC_ASF_EXAMPLE2_COM1 = "Communication Device Class ASF example2, COM1"
-ATMEL_CDC_ASF_EXAMPLE2_COM2 = "Communication Device Class ASF example2, COM2"
-ATMEL_CDC_ASF_EXAMPLE3_COM1 = "Communication Device Class ASF example3, COM1"
-ATMEL_CDC_ASF_EXAMPLE3_COM2 = "Communication Device Class ASF example3, COM2"
-ATMEL_CDC_ASF_EXAMPLE3_COM3 = "Communication Device Class ASF example3, COM3"
-ATMEL_CDC_ASF_EXAMPLE3_COM4 = "Communication Device Class ASF example3, COM4"
-ATMEL_CDC_ASF_EXAMPLE3_COM5 = "Communication Device Class ASF example3, COM5"
-ATMEL_CDC_ASF_EXAMPLE3_COM6 = "Communication Device Class ASF example3, COM6"
-ATMEL_CDC_ASF_EXAMPLE3_COM7 = "Communication Device Class ASF example3, COM7"
-
-Serial.SvcDesc = "USB Serial emulation driver"
-
diff --git a/usb/class/cdc/device/cdcdf_acm.c b/usb/class/cdc/device/cdcdf_acm.c
deleted file mode 100644
index 2691cc8..0000000
--- a/usb/class/cdc/device/cdcdf_acm.c
+++ /dev/null
@@ -1,379 +0,0 @@
-/**
- * \file
- *
- * \brief USB Device Stack CDC ACM Function Implementation.
- *
- * Copyright (c) 2015-2018 Microchip Technology Inc. and its subsidiaries.
- *
- * \asf_license_start
- *
- * \page License
- *
- * Subject to your compliance with these terms, you may use Microchip
- * software and any derivatives exclusively with Microchip products.
- * It is your responsibility to comply with third party license terms applicable
- * to your use of third party software (including open source software) that
- * may accompany Microchip software.
- *
- * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES,
- * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE,
- * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY,
- * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE
- * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL
- * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE
- * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE
- * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT
- * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY
- * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
- * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
- *
- * \asf_license_stop
- *
- */
-
-#include "cdcdf_acm.h"
-
-#define CDCDF_ACM_VERSION 0x00000001u
-#define CDCDF_ACM_COMM_EP_INDEX 0
-#define CDCDF_ACM_DATA_EP_INDEX 1
-
-/** USB Device CDC ACM Fucntion Specific Data */
-struct cdcdf_acm_func_data {
- /** CDC Device ACM Interface information */
- uint8_t func_iface[2];
- /** CDC Device ACM IN Endpoint */
- uint8_t func_ep_in[2];
- /** CDC Device ACM OUT Endpoint */
- uint8_t func_ep_out;
- /** CDC Device ACM Enable Flag */
- bool enabled;
-};
-
-static struct usbdf_driver _cdcdf_acm;
-static struct cdcdf_acm_func_data _cdcdf_acm_funcd;
-static struct usb_cdc_line_coding usbd_cdc_line_coding;
-
-static cdcdf_acm_notify_state_t cdcdf_acm_notify_state = NULL;
-static cdcdf_acm_set_line_coding_t cdcdf_acm_set_line_coding = NULL;
-
-/**
- * \brief Enable CDC ACM Function
- * \param[in] drv Pointer to USB device function driver
- * \param[in] desc Pointer to USB interface descriptor
- * \return Operation status.
- */
-static int32_t cdcdf_acm_enable(struct usbdf_driver *drv, struct usbd_descriptors *desc)
-{
- struct cdcdf_acm_func_data *func_data = (struct cdcdf_acm_func_data *)(drv->func_data);
-
- usb_ep_desc_t ep_desc;
- usb_iface_desc_t ifc_desc;
- uint8_t * ifc, *ep;
- uint8_t i;
-
- ifc = desc->sod;
- for (i = 0; i < 2; i++) {
- if (NULL == ifc) {
- return ERR_NOT_FOUND;
- }
-
- ifc_desc.bInterfaceNumber = ifc[2];
- ifc_desc.bInterfaceClass = ifc[5];
-
- if ((CDC_CLASS_COMM == ifc_desc.bInterfaceClass) || (CDC_CLASS_DATA == ifc_desc.bInterfaceClass)) {
- if (func_data->func_iface[i] == ifc_desc.bInterfaceNumber) { // Initialized
- return ERR_ALREADY_INITIALIZED;
- } else if (func_data->func_iface[i] != 0xFF) { // Occupied
- return ERR_NO_RESOURCE;
- } else {
- func_data->func_iface[i] = ifc_desc.bInterfaceNumber;
- }
- } else { // Not supported by this function driver
- return ERR_NOT_FOUND;
- }
-
- // Install endpoints
- ep = usb_find_desc(ifc, desc->eod, USB_DT_ENDPOINT);
- while (NULL != ep) {
- ep_desc.bEndpointAddress = ep[2];
- ep_desc.bmAttributes = ep[3];
- ep_desc.wMaxPacketSize = usb_get_u16(ep + 4);
- if (usb_d_ep_init(ep_desc.bEndpointAddress, ep_desc.bmAttributes, ep_desc.wMaxPacketSize)) {
- return ERR_NOT_INITIALIZED;
- }
- if (ep_desc.bEndpointAddress & USB_EP_DIR_IN) {
- func_data->func_ep_in[i] = ep_desc.bEndpointAddress;
- usb_d_ep_enable(func_data->func_ep_in[i]);
- } else {
- func_data->func_ep_out = ep_desc.bEndpointAddress;
- usb_d_ep_enable(func_data->func_ep_out);
- }
- desc->sod = ep;
- ep = usb_find_ep_desc(usb_desc_next(desc->sod), desc->eod);
- }
- ifc = usb_find_desc(usb_desc_next(desc->sod), desc->eod, USB_DT_INTERFACE);
- }
- // Installed
- _cdcdf_acm_funcd.enabled = true;
- return ERR_NONE;
-}
-
-/**
- * \brief Disable CDC ACM Function
- * \param[in] drv Pointer to USB device function driver
- * \param[in] desc Pointer to USB device descriptor
- * \return Operation status.
- */
-static int32_t cdcdf_acm_disable(struct usbdf_driver *drv, struct usbd_descriptors *desc)
-{
- struct cdcdf_acm_func_data *func_data = (struct cdcdf_acm_func_data *)(drv->func_data);
-
- usb_iface_desc_t ifc_desc;
- uint8_t i;
-
- if (desc) {
- ifc_desc.bInterfaceClass = desc->sod[5];
- // Check interface
- if ((ifc_desc.bInterfaceClass != CDC_CLASS_COMM) && (ifc_desc.bInterfaceClass != CDC_CLASS_DATA)) {
- return ERR_NOT_FOUND;
- }
- }
-
- for (i = 0; i < 2; i++) {
- if (func_data->func_iface[i] == 0xFF) {
- continue;
- } else {
- func_data->func_iface[i] = 0xFF;
- if (func_data->func_ep_in[i] != 0xFF) {
- usb_d_ep_deinit(func_data->func_ep_in[i]);
- func_data->func_ep_in[i] = 0xFF;
- }
- }
- }
-
- if (func_data->func_ep_out != 0xFF) {
- usb_d_ep_deinit(func_data->func_ep_out);
- func_data->func_ep_out = 0xFF;
- }
-
- _cdcdf_acm_funcd.enabled = false;
- return ERR_NONE;
-}
-
-/**
- * \brief CDC ACM Control Function
- * \param[in] drv Pointer to USB device function driver
- * \param[in] ctrl USB device general function control type
- * \param[in] param Parameter pointer
- * \return Operation status.
- */
-static int32_t cdcdf_acm_ctrl(struct usbdf_driver *drv, enum usbdf_control ctrl, void *param)
-{
- switch (ctrl) {
- case USBDF_ENABLE:
- return cdcdf_acm_enable(drv, (struct usbd_descriptors *)param);
-
- case USBDF_DISABLE:
- return cdcdf_acm_disable(drv, (struct usbd_descriptors *)param);
-
- case USBDF_GET_IFACE:
- return ERR_UNSUPPORTED_OP;
-
- default:
- return ERR_INVALID_ARG;
- }
-}
-
-/**
- * \brief Process the CDC class set request
- * \param[in] ep Endpoint address.
- * \param[in] req Pointer to the request.
- * \return Operation status.
- */
-static int32_t cdcdf_acm_set_req(uint8_t ep, struct usb_req *req, enum usb_ctrl_stage stage)
-{
- struct usb_cdc_line_coding line_coding_tmp;
- uint16_t len = req->wLength;
- uint8_t * ctrl_buf = usbdc_get_ctrl_buffer();
-
- switch (req->bRequest) {
- case USB_REQ_CDC_SET_LINE_CODING:
- if (sizeof(struct usb_cdc_line_coding) != len) {
- return ERR_INVALID_DATA;
- }
- if (USB_SETUP_STAGE == stage) {
- return usbdc_xfer(ep, ctrl_buf, len, false);
- } else {
- memcpy(&line_coding_tmp, ctrl_buf, sizeof(struct usb_cdc_line_coding));
- if ((NULL == cdcdf_acm_set_line_coding) || (true == cdcdf_acm_set_line_coding(&line_coding_tmp))) {
- usbd_cdc_line_coding = line_coding_tmp;
- }
- return ERR_NONE;
- }
- case USB_REQ_CDC_SET_CONTROL_LINE_STATE:
- usbdc_xfer(0, NULL, 0, 0);
- if (NULL != cdcdf_acm_notify_state) {
- cdcdf_acm_notify_state(req->wValue);
- }
- return ERR_NONE;
- default:
- return ERR_INVALID_ARG;
- }
-}
-
-/**
- * \brief Process the CDC class get request
- * \param[in] ep Endpoint address.
- * \param[in] req Pointer to the request.
- * \return Operation status.
- */
-static int32_t cdcdf_acm_get_req(uint8_t ep, struct usb_req *req, enum usb_ctrl_stage stage)
-{
- uint16_t len = req->wLength;
-
- if (USB_DATA_STAGE == stage) {
- return ERR_NONE;
- }
-
- switch (req->bRequest) {
- case USB_REQ_CDC_GET_LINE_CODING:
- if (sizeof(struct usb_cdc_line_coding) != len) {
- return ERR_INVALID_DATA;
- }
- return usbdc_xfer(ep, (uint8_t *)&usbd_cdc_line_coding, len, false);
- default:
- return ERR_INVALID_ARG;
- }
-}
-
-/**
- * \brief Process the CDC class request
- * \param[in] ep Endpoint address.
- * \param[in] req Pointer to the request.
- * \return Operation status.
- */
-static int32_t cdcdf_acm_req(uint8_t ep, struct usb_req *req, enum usb_ctrl_stage stage)
-{
- if (0x01 != ((req->bmRequestType >> 5) & 0x03)) { // class request
- return ERR_NOT_FOUND;
- }
- if ((req->wIndex == _cdcdf_acm_funcd.func_iface[0]) || (req->wIndex == _cdcdf_acm_funcd.func_iface[1])) {
- if (req->bmRequestType & USB_EP_DIR_IN) {
- return cdcdf_acm_get_req(ep, req, stage);
- } else {
- return cdcdf_acm_set_req(ep, req, stage);
- }
- } else {
- return ERR_NOT_FOUND;
- }
-}
-
-/** USB Device CDC ACM Handler Struct */
-static struct usbdc_handler cdcdf_acm_req_h = {NULL, (FUNC_PTR)cdcdf_acm_req};
-
-/**
- * \brief Initialize the USB CDC ACM Function Driver
- */
-int32_t cdcdf_acm_init(void)
-{
- if (usbdc_get_state() > USBD_S_POWER) {
- return ERR_DENIED;
- }
-
- _cdcdf_acm.ctrl = cdcdf_acm_ctrl;
- _cdcdf_acm.func_data = &_cdcdf_acm_funcd;
-
- usbdc_register_function(&_cdcdf_acm);
- usbdc_register_handler(USBDC_HDL_REQ, &cdcdf_acm_req_h);
- return ERR_NONE;
-}
-
-/**
- * \brief Deinitialize the USB CDC ACM Function Driver
- */
-void cdcdf_acm_deinit(void)
-{
- usb_d_ep_deinit(_cdcdf_acm_funcd.func_ep_in[CDCDF_ACM_COMM_EP_INDEX]);
- usb_d_ep_deinit(_cdcdf_acm_funcd.func_ep_in[CDCDF_ACM_DATA_EP_INDEX]);
- usb_d_ep_deinit(_cdcdf_acm_funcd.func_ep_out);
-}
-
-/**
- * \brief USB CDC ACM Function Read Data
- */
-int32_t cdcdf_acm_read(uint8_t *buf, uint32_t size)
-{
- if (!cdcdf_acm_is_enabled()) {
- return ERR_DENIED;
- }
- return usbdc_xfer(_cdcdf_acm_funcd.func_ep_out, buf, size, false);
-}
-
-/**
- * \brief USB CDC ACM Function Write Data
- */
-int32_t cdcdf_acm_write(uint8_t *buf, uint32_t size)
-{
- if (!cdcdf_acm_is_enabled()) {
- return ERR_DENIED;
- }
- return usbdc_xfer(_cdcdf_acm_funcd.func_ep_in[CDCDF_ACM_DATA_EP_INDEX], buf, size, true);
-}
-
-/**
- * \brief USB CDC ACM Stop the data transfer
- */
-void cdcdf_acm_stop_xfer(void)
-{
- /* Stop transfer. */
- usb_d_ep_abort(_cdcdf_acm_funcd.func_ep_in[CDCDF_ACM_DATA_EP_INDEX]);
- usb_d_ep_abort(_cdcdf_acm_funcd.func_ep_out);
-}
-
-/**
- * \brief USB CDC ACM Function Register Callback
- */
-int32_t cdcdf_acm_register_callback(enum cdcdf_acm_cb_type cb_type, FUNC_PTR func)
-{
- switch (cb_type) {
- case CDCDF_ACM_CB_READ:
- usb_d_ep_register_callback(_cdcdf_acm_funcd.func_ep_out, USB_D_EP_CB_XFER, func);
- break;
- case CDCDF_ACM_CB_WRITE:
- usb_d_ep_register_callback(_cdcdf_acm_funcd.func_ep_in[CDCDF_ACM_DATA_EP_INDEX], USB_D_EP_CB_XFER, func);
- break;
- case CDCDF_ACM_CB_LINE_CODING_C:
- cdcdf_acm_set_line_coding = (cdcdf_acm_set_line_coding_t)func;
- break;
- case CDCDF_ACM_CB_STATE_C:
- cdcdf_acm_notify_state = (cdcdf_acm_notify_state_t)func;
- break;
- default:
- return ERR_INVALID_ARG;
- }
- return ERR_NONE;
-}
-
-/**
- * \brief Check whether CDC ACM Function is enabled
- */
-bool cdcdf_acm_is_enabled(void)
-{
- return _cdcdf_acm_funcd.enabled;
-}
-
-/**
- * \brief Return the CDC ACM line coding structure start address
- */
-const struct usb_cdc_line_coding *cdcdf_acm_get_line_coding(void)
-{
- return (const struct usb_cdc_line_coding *)&usbd_cdc_line_coding;
-}
-
-/**
- * \brief Return version
- */
-uint32_t cdcdf_acm_get_version(void)
-{
- return CDCDF_ACM_VERSION;
-}
diff --git a/usb/class/cdc/device/cdcdf_acm.h b/usb/class/cdc/device/cdcdf_acm.h
deleted file mode 100644
index ad060bc..0000000
--- a/usb/class/cdc/device/cdcdf_acm.h
+++ /dev/null
@@ -1,108 +0,0 @@
-/**
- * \file
- *
- * \brief USB Device Stack CDC ACM Function Definition.
- *
- * Copyright (c) 2015-2018 Microchip Technology Inc. and its subsidiaries.
- *
- * \asf_license_start
- *
- * \page License
- *
- * Subject to your compliance with these terms, you may use Microchip
- * software and any derivatives exclusively with Microchip products.
- * It is your responsibility to comply with third party license terms applicable
- * to your use of third party software (including open source software) that
- * may accompany Microchip software.
- *
- * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES,
- * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE,
- * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY,
- * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE
- * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL
- * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE
- * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE
- * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT
- * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY
- * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
- * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
- *
- * \asf_license_stop
- */
-
-#ifndef USBDF_CDC_ACM_SER_H_
-#define USBDF_CDC_ACM_SER_H_
-
-#include "usbdc.h"
-#include "usb_protocol_cdc.h"
-
-/** CDC ACM Class Callback Type */
-enum cdcdf_acm_cb_type { CDCDF_ACM_CB_READ, CDCDF_ACM_CB_WRITE, CDCDF_ACM_CB_LINE_CODING_C, CDCDF_ACM_CB_STATE_C };
-
-/** CDC ACM Notify Line State Callback. */
-typedef void (*cdcdf_acm_notify_state_t)(uint16_t);
-
-/** CDC ACM Set Line Coding Callback. */
-typedef bool (*cdcdf_acm_set_line_coding_t)(struct usb_cdc_line_coding *);
-
-/**
- * \brief Initialize the USB CDC ACM Function Driver
- * \return Operation status.
- */
-int32_t cdcdf_acm_init(void);
-
-/**
- * \brief Deinitialize the USB CDC ACM Function Driver
- * \return Operation status.
- */
-void cdcdf_acm_deinit(void);
-
-/**
- * \brief USB CDC ACM Function Read Data
- * \param[in] buf Pointer to the buffer which receives data
- * \param[in] size the size of data to be received
- * \return Operation status.
- */
-int32_t cdcdf_acm_read(uint8_t *buf, uint32_t size);
-
-/**
- * \brief USB CDC ACM Function Write Data
- * \param[in] buf Pointer to the buffer which stores data
- * \param[in] size the size of data to be sent
- * \return Operation status.
- */
-int32_t cdcdf_acm_write(uint8_t *buf, uint32_t size);
-
-/**
- * \brief USB CDC ACM Stop the currnet data transfer
- */
-void cdcdf_acm_stop_xfer(void);
-
-/**
- * \brief USB CDC ACM Function Register Callback
- * \param[in] cb_type Callback type of CDC ACM Function
- * \param[in] func Pointer to callback function
- * \return Operation status.
- */
-int32_t cdcdf_acm_register_callback(enum cdcdf_acm_cb_type cb_type, FUNC_PTR func);
-
-/**
- * \brief Check whether CDC ACM Function is enabled
- * \return Operation status.
- * \return true CDC ACM Function is enabled
- * \return false CDC ACM Function is disabled
- */
-bool cdcdf_acm_is_enabled(void);
-
-/**
- * \brief Return the CDC ACM line coding structure start address
- * \return Pointer to USB CDC ACM line coding data.
- */
-const struct usb_cdc_line_coding *cdcdf_acm_get_line_coding(void);
-
-/**
- * \brief Return version
- */
-uint32_t cdcdf_acm_get_version(void);
-
-#endif /* USBDF_CDC_ACM_SER_H_ */
diff --git a/usb/class/cdc/device/cdcdf_acm_desc.h b/usb/class/cdc/device/cdcdf_acm_desc.h
deleted file mode 100644
index ca29d33..0000000
--- a/usb/class/cdc/device/cdcdf_acm_desc.h
+++ /dev/null
@@ -1,131 +0,0 @@
-/**
- * \file
- *
- * \brief USB Device Stack CDC ACM Function Descriptor Setting.
- *
- * Copyright (c) 2015-2018 Microchip Technology Inc. and its subsidiaries.
- *
- * \asf_license_start
- *
- * \page License
- *
- * Subject to your compliance with these terms, you may use Microchip
- * software and any derivatives exclusively with Microchip products.
- * It is your responsibility to comply with third party license terms applicable
- * to your use of third party software (including open source software) that
- * may accompany Microchip software.
- *
- * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES,
- * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE,
- * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY,
- * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE
- * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL
- * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE
- * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE
- * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT
- * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY
- * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
- * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
- *
- * \asf_license_stop
- */
-
-#ifndef USBDF_CDC_ACM_DESC_H_
-#define USBDF_CDC_ACM_DESC_H_
-
-#include "usb_protocol.h"
-#include "usb_protocol_cdc.h"
-#include "usbd_config.h"
-
-#define CDCD_ACM_DEV_DESC \
- USB_DEV_DESC_BYTES(CONF_USB_CDCD_ACM_BCDUSB, \
- 0x02, \
- 0x00, \
- 0x00, \
- CONF_USB_CDCD_ACM_BMAXPKSZ0, \
- CONF_USB_CDCD_ACM_IDVENDER, \
- CONF_USB_CDCD_ACM_IDPRODUCT, \
- CONF_USB_CDCD_ACM_BCDDEVICE, \
- CONF_USB_CDCD_ACM_IMANUFACT, \
- CONF_USB_CDCD_ACM_IPRODUCT, \
- CONF_USB_CDCD_ACM_ISERIALNUM, \
- CONF_USB_CDCD_ACM_BNUMCONFIG)
-
-#define CDCD_ACM_DEV_QUAL_DESC \
- USB_DEV_QUAL_DESC_BYTES( \
- CONF_USB_CDCD_ACM_BCDUSB, 0x02, 0x00, 0x00, CONF_USB_CDCD_ACM_BMAXPKSZ0, CONF_USB_CDCD_ACM_BNUMCONFIG)
-
-#define CDCD_ACM_CFG_DESC \
- USB_CONFIG_DESC_BYTES(67, \
- 2, \
- CONF_USB_CDCD_ACM_BCONFIGVAL, \
- CONF_USB_CDCD_ACM_ICONFIG, \
- CONF_USB_CDCD_ACM_BMATTRI, \
- CONF_USB_CDCD_ACM_BMAXPOWER)
-
-#define CDCD_ACM_OTH_SPD_CFG_DESC \
- USB_OTH_SPD_CFG_DESC_BYTES(67, \
- 2, \
- CONF_USB_CDCD_ACM_BCONFIGVAL, \
- CONF_USB_CDCD_ACM_ICONFIG, \
- CONF_USB_CDCD_ACM_BMATTRI, \
- CONF_USB_CDCD_ACM_BMAXPOWER)
-
-#define CDCD_ACM_COMM_IFACE_DESCES \
- USB_IFACE_DESC_BYTES(CONF_USB_CDCD_ACM_COMM_BIFCNUM, \
- CONF_USB_CDCD_ACM_COMM_BALTSET, \
- 1, \
- 0x2, \
- 0x2, \
- 0x0, \
- CONF_USB_CDCD_ACM_COMM_IIFC), \
- USB_CDC_HDR_DESC_BYTES(0x1001), USB_CDC_CALL_MGMT_DESC_BYTES(0x01, 0x00), USB_CDC_ACM_DESC_BYTES(0x02), \
- USB_CDC_UNION_DESC_BYTES(CONF_USB_CDCD_ACM_COMM_BIFCNUM, 0x01), \
- USB_ENDP_DESC_BYTES(CONF_USB_CDCD_ACM_COMM_INT_EPADDR, \
- 3, \
- CONF_USB_CDCD_ACM_COMM_INT_MAXPKSZ, \
- CONF_USB_CDCD_ACM_COMM_INT_INTERVAL)
-
-#define CDCD_ACM_DATA_IFACE_DESCES \
- USB_IFACE_DESC_BYTES(CONF_USB_CDCD_ACM_DATA_BIFCNUM, \
- CONF_USB_CDCD_ACM_DATA_BALTSET, \
- 2, \
- 0x0A, \
- 0x0, \
- 0x0, \
- CONF_USB_CDCD_ACM_DATA_IIFC), \
- USB_ENDP_DESC_BYTES(CONF_USB_CDCD_ACM_DATA_BULKOUT_EPADDR, 2, CONF_USB_CDCD_ACM_DATA_BULKOUT_MAXPKSZ, 0), \
- USB_ENDP_DESC_BYTES(CONF_USB_CDCD_ACM_DATA_BULKIN_EPADDR, 2, CONF_USB_CDCD_ACM_DATA_BULKIN_MAXPKSZ, 0)
-
-#define CDCD_ACM_DATA_IFACE_DESCES_HS \
- USB_IFACE_DESC_BYTES(CONF_USB_CDCD_ACM_DATA_BIFCNUM, \
- CONF_USB_CDCD_ACM_DATA_BALTSET, \
- 2, \
- 0x0A, \
- 0x0, \
- 0x0, \
- CONF_USB_CDCD_ACM_DATA_IIFC), \
- USB_ENDP_DESC_BYTES(CONF_USB_CDCD_ACM_DATA_BULKOUT_EPADDR, 2, CONF_USB_CDCD_ACM_DATA_BULKOUT_MAXPKSZ_HS, 0), \
- USB_ENDP_DESC_BYTES(CONF_USB_CDCD_ACM_DATA_BULKIN_EPADDR, 2, CONF_USB_CDCD_ACM_DATA_BULKIN_MAXPKSZ_HS, 0)
-
-#define CDCD_ACM_STR_DESCES \
- CONF_USB_CDCD_ACM_LANGID_DESC \
- CONF_USB_CDCD_ACM_IMANUFACT_STR_DESC \
- CONF_USB_CDCD_ACM_IPRODUCT_STR_DESC \
- CONF_USB_CDCD_ACM_ISERIALNUM_STR_DESC \
- CONF_USB_CDCD_ACM_ICONFIG_STR_DESC
-
-/** USB Device descriptors and configuration descriptors */
-#define CDCD_ACM_DESCES_LS_FS \
- CDCD_ACM_DEV_DESC, CDCD_ACM_CFG_DESC, CDCD_ACM_COMM_IFACE_DESCES, CDCD_ACM_DATA_IFACE_DESCES, CDCD_ACM_STR_DESCES
-
-#define CDCD_ACM_HS_DESCES_LS_FS \
- CDCD_ACM_DEV_DESC, CDCD_ACM_DEV_QUAL_DESC, CDCD_ACM_CFG_DESC, CDCD_ACM_COMM_IFACE_DESCES, \
- CDCD_ACM_DATA_IFACE_DESCES, CDCD_ACM_OTH_SPD_CFG_DESC, CDCD_ACM_COMM_IFACE_DESCES, \
- CDCD_ACM_DATA_IFACE_DESCES_HS, CDCD_ACM_STR_DESCES
-
-#define CDCD_ACM_HS_DESCES_HS \
- CDCD_ACM_CFG_DESC, CDCD_ACM_COMM_IFACE_DESCES, CDCD_ACM_DATA_IFACE_DESCES_HS, CDCD_ACM_OTH_SPD_CFG_DESC, \
- CDCD_ACM_COMM_IFACE_DESCES, CDCD_ACM_DATA_IFACE_DESCES
-
-#endif /* USBDF_CDC_ACM_DESC_H_ */
diff --git a/usb/class/cdc/usb_protocol_cdc.h b/usb/class/cdc/usb_protocol_cdc.h
deleted file mode 100644
index 29d882a..0000000
--- a/usb/class/cdc/usb_protocol_cdc.h
+++ /dev/null
@@ -1,426 +0,0 @@
-/**
- * \file
- *
- * \brief USB Communication Device Class (CDC) protocol definitions
- *
- * Copyright (c) 2015-2018 Microchip Technology Inc. and its subsidiaries.
- *
- * \asf_license_start
- *
- * \page License
- *
- * Subject to your compliance with these terms, you may use Microchip
- * software and any derivatives exclusively with Microchip products.
- * It is your responsibility to comply with third party license terms applicable
- * to your use of third party software (including open source software) that
- * may accompany Microchip software.
- *
- * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES,
- * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE,
- * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY,
- * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE
- * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL
- * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE
- * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE
- * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT
- * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY
- * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
- * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
- *
- * \asf_license_stop
- *
- */
-/*
- * Support and FAQ: visit <a href="https://www.microchip.com/support/">Microchip Support</a>
- */
-#ifndef _USB_PROTOCOL_CDC_H_
-#define _USB_PROTOCOL_CDC_H_
-
-#include "usb_includes.h"
-
-/**
- * \ingroup usb_protocol_group
- * \defgroup cdc_protocol_group Communication Device Class Definitions
- * @{
- */
-
-/**
- * \name Possible values of class
- */
-//@{
-#define CDC_CLASS_DEVICE 0x02 //!< USB Communication Device Class
-#define CDC_CLASS_COMM 0x02 //!< CDC Communication Class Interface
-#define CDC_CLASS_DATA 0x0A //!< CDC Data Class Interface
-//@}
-
-//! \name USB CDC Subclass IDs
-//@{
-#define CDC_SUBCLASS_DLCM 0x01 //!< Direct Line Control Model
-#define CDC_SUBCLASS_ACM 0x02 //!< Abstract Control Model
-#define CDC_SUBCLASS_TCM 0x03 //!< Telephone Control Model
-#define CDC_SUBCLASS_MCCM 0x04 //!< Multi-Channel Control Model
-#define CDC_SUBCLASS_CCM 0x05 //!< CAPI Control Model
-#define CDC_SUBCLASS_ETH 0x06 //!< Ethernet Networking Control Model
-#define CDC_SUBCLASS_ATM 0x07 //!< ATM Networking Control Model
-//@}
-
-//! \name USB CDC Communication Interface Protocol IDs
-//@{
-#define CDC_PROTOCOL_V25TER 0x01 //!< Common AT commands
-//@}
-
-//! \name USB CDC Data Interface Protocol IDs
-//@{
-#define CDC_PROTOCOL_I430 0x30 //!< ISDN BRI
-#define CDC_PROTOCOL_HDLC 0x31 //!< HDLC
-#define CDC_PROTOCOL_TRANS 0x32 //!< Transparent
-#define CDC_PROTOCOL_Q921M 0x50 //!< Q.921 management protocol
-#define CDC_PROTOCOL_Q921 0x51 //!< Q.931 [sic] Data link protocol
-#define CDC_PROTOCOL_Q921TM 0x52 //!< Q.921 TEI-multiplexor
-#define CDC_PROTOCOL_V42BIS 0x90 //!< Data compression procedures
-#define CDC_PROTOCOL_Q931 0x91 //!< Euro-ISDN protocol control
-#define CDC_PROTOCOL_V120 0x92 //!< V.24 rate adaption to ISDN
-#define CDC_PROTOCOL_CAPI20 0x93 //!< CAPI Commands
-#define CDC_PROTOCOL_HOST 0xFD //!< Host based driver
-/**
- * \brief Describes the Protocol Unit Functional Descriptors [sic]
- * on Communication Class Interface
- */
-#define CDC_PROTOCOL_PUFD 0xFE
-//@}
-
-//! \name USB CDC Functional Descriptor Types
-//@{
-#define CDC_CS_INTERFACE 0x24 //!< Interface Functional Descriptor
-#define CDC_CS_ENDPOINT 0x25 //!< Endpoint Functional Descriptor
-//@}
-
-//! \name USB CDC Functional Descriptor Subtypes
-//@{
-#define CDC_SCS_HEADER 0x00 //!< Header Functional Descriptor
-#define CDC_SCS_CALL_MGMT 0x01 //!< Call Management
-#define CDC_SCS_ACM 0x02 //!< Abstract Control Management
-#define CDC_SCS_UNION 0x06 //!< Union Functional Descriptor
-//@}
-
-//! \name USB CDC Request IDs
-//@{
-#define USB_REQ_CDC_SEND_ENCAPSULATED_COMMAND 0x00
-#define USB_REQ_CDC_GET_ENCAPSULATED_RESPONSE 0x01
-#define USB_REQ_CDC_SET_COMM_FEATURE 0x02
-#define USB_REQ_CDC_GET_COMM_FEATURE 0x03
-#define USB_REQ_CDC_CLEAR_COMM_FEATURE 0x04
-#define USB_REQ_CDC_SET_AUX_LINE_STATE 0x10
-#define USB_REQ_CDC_SET_HOOK_STATE 0x11
-#define USB_REQ_CDC_PULSE_SETUP 0x12
-#define USB_REQ_CDC_SEND_PULSE 0x13
-#define USB_REQ_CDC_SET_PULSE_TIME 0x14
-#define USB_REQ_CDC_RING_AUX_JACK 0x15
-#define USB_REQ_CDC_SET_LINE_CODING 0x20
-#define USB_REQ_CDC_GET_LINE_CODING 0x21
-#define USB_REQ_CDC_SET_CONTROL_LINE_STATE 0x22
-#define USB_REQ_CDC_SEND_BREAK 0x23
-#define USB_REQ_CDC_SET_RINGER_PARMS 0x30
-#define USB_REQ_CDC_GET_RINGER_PARMS 0x31
-#define USB_REQ_CDC_SET_OPERATION_PARMS 0x32
-#define USB_REQ_CDC_GET_OPERATION_PARMS 0x33
-#define USB_REQ_CDC_SET_LINE_PARMS 0x34
-#define USB_REQ_CDC_GET_LINE_PARMS 0x35
-#define USB_REQ_CDC_DIAL_DIGITS 0x36
-#define USB_REQ_CDC_SET_UNIT_PARAMETER 0x37
-#define USB_REQ_CDC_GET_UNIT_PARAMETER 0x38
-#define USB_REQ_CDC_CLEAR_UNIT_PARAMETER 0x39
-#define USB_REQ_CDC_GET_PROFILE 0x3A
-#define USB_REQ_CDC_SET_ETHERNET_MULTICAST_FILTERS 0x40
-#define USB_REQ_CDC_SET_ETHERNET_POWER_MANAGEMENT_PATTERNFILTER 0x41
-#define USB_REQ_CDC_GET_ETHERNET_POWER_MANAGEMENT_PATTERNFILTER 0x42
-#define USB_REQ_CDC_SET_ETHERNET_PACKET_FILTER 0x43
-#define USB_REQ_CDC_GET_ETHERNET_STATISTIC 0x44
-#define USB_REQ_CDC_SET_ATM_DATA_FORMAT 0x50
-#define USB_REQ_CDC_GET_ATM_DEVICE_STATISTICS 0x51
-#define USB_REQ_CDC_SET_ATM_DEFAULT_VC 0x52
-#define USB_REQ_CDC_GET_ATM_VC_STATISTICS 0x53
-// Added bNotification codes according cdc spec 1.1 chapter 6.3
-#define USB_REQ_CDC_NOTIFY_RING_DETECT 0x09
-#define USB_REQ_CDC_NOTIFY_SERIAL_STATE 0x20
-#define USB_REQ_CDC_NOTIFY_CALL_STATE_CHANGE 0x28
-#define USB_REQ_CDC_NOTIFY_LINE_STATE_CHANGE 0x29
-//@}
-
-/*
- * Need to pack structures tightly, or the compiler might insert padding
- * and violate the spec-mandated layout.
- */
-COMPILER_PACK_SET(1)
-
-//! \name USB CDC Descriptors
-//@{
-
-//! CDC Header Functional Descriptor
-typedef struct usb_cdc_hdr_desc {
- uint8_t bFunctionLength;
- uint8_t bDescriptorType;
- uint8_t bDescriptorSubtype;
- le16_t bcdCDC;
-} usb_cdc_hdr_desc_t;
-
-#define USB_CDC_HDR_DESC_LEN 5
-#define USB_CDC_HDR_DESC_BYTES(bcdCDC) \
- USB_CDC_HDR_DESC_LEN, /* bFunctionLength */ \
- CDC_CS_INTERFACE, /* bDescriptorType */ \
- CDC_SCS_HEADER, /* bDescriptorSubtype */ \
- LE_BYTE0(bcdCDC), LE_BYTE1(bcdCDC) /* bcdCDC */
-
-//! CDC Call Management Functional Descriptor
-typedef struct usb_cdc_call_mgmt_desc {
- uint8_t bFunctionLength;
- uint8_t bDescriptorType;
- uint8_t bDescriptorSubtype;
- uint8_t bmCapabilities;
- uint8_t bDataInterface;
-} usb_cdc_call_mgmt_desc_t;
-
-#define USB_CDC_CALL_MGMT_DESC_LEN 5
-#define USB_CDC_CALL_MGMT_DESC_BYTES(bmCapabilities, bDataInterface) \
- USB_CDC_CALL_MGMT_DESC_LEN, /* bFunctionLength */ \
- CDC_CS_INTERFACE, /* bDescriptorType */ \
- CDC_SCS_CALL_MGMT, /* bDescriptorSubtype */ \
- bmCapabilities, bDataInterface
-
-//! CDC ACM Functional Descriptor
-typedef struct usb_cdc_acm_desc {
- uint8_t bFunctionLength;
- uint8_t bDescriptorType;
- uint8_t bDescriptorSubtype;
- uint8_t bmCapabilities;
-} usb_cdc_acm_desc_t;
-
-#define USB_CDC_ACM_DESC_LEN 4
-#define USB_CDC_ACM_DESC_BYTES(bmCapabilities) \
- USB_CDC_ACM_DESC_LEN, /* bFunctionLength */ \
- CDC_CS_INTERFACE, /* bDescriptorType */ \
- CDC_SCS_ACM, /* bDescriptorSubType */ \
- bmCapabilities
-
-//! CDC Union Functional Descriptor
-typedef struct usb_cdc_union_desc {
- uint8_t bFunctionLength;
- uint8_t bDescriptorType;
- uint8_t bDescriptorSubtype;
- uint8_t bMasterInterface;
- uint8_t bSlaveInterface0;
-} usb_cdc_union_desc_t;
-
-#define USB_CDC_UNION_DESC_LEN 5
-#define USB_CDC_UNION_DESC_BYTES(bMasterInterface, bSlaveInterface) \
- USB_CDC_UNION_DESC_LEN, CDC_CS_INTERFACE, CDC_SCS_UNION, bMasterInterface, bSlaveInterface
-
-//! \name USB CDC Call Management Capabilities
-//@{
-//! Device handles call management itself
-#define CDC_CALL_MGMT_SUPPORTED (1 << 0)
-//! Device can send/receive call management info over a Data Class interface
-#define CDC_CALL_MGMT_OVER_DCI (1 << 1)
-//@}
-
-//! \name USB CDC ACM Capabilities
-//@{
-//! Device supports the request combination of
-//! Set_Comm_Feature, Clear_Comm_Feature, and Get_Comm_Feature.
-#define CDC_ACM_SUPPORT_FEATURE_REQUESTS (1 << 0)
-//! Device supports the request combination of
-//! Set_Line_Coding, Set_Control_Line_State, Get_Line_Coding,
-//! and the notification Serial_State.
-#define CDC_ACM_SUPPORT_LINE_REQUESTS (1 << 1)
-//! Device supports the request Send_Break
-#define CDC_ACM_SUPPORT_SENDBREAK_REQUESTS (1 << 2)
-//! Device supports the notification Network_Connection.
-#define CDC_ACM_SUPPORT_NOTIFY_REQUESTS (1 << 3)
-//@}
-//@}
-
-//! \name USB CDC line control
-//@{
-
-//! \name USB CDC line coding
-//@{
-
-//! Line Coding structure
-typedef struct usb_cdc_line_coding {
- le32_t dwDTERate; //!< Data rate, bits per second
- uint8_t bCharFormat; //!< 0-1 Stop bit,1-1.5 Stop bits,2-2 Stop bits
- uint8_t bParityType; //!< 0-None,1-Odd,2-Even,3-Mark,4-Space
- uint8_t bDataBits; //!< 5,6,7,8 or 16
-} usb_cdc_line_coding_t;
-
-//! Possible values of bCharFormat
-enum cdc_char_format {
- CDC_STOP_BITS_1 = 0, //!< 1 stop bit
- CDC_STOP_BITS_1_5 = 1, //!< 1.5 stop bits
- CDC_STOP_BITS_2 = 2 //!< 2 stop bits
-};
-
-//! Possible values of bParityType
-enum cdc_parity {
- CDC_PAR_NONE = 0, //!< No parity
- CDC_PAR_ODD = 1, //!< Odd parity
- CDC_PAR_EVEN = 2, //!< Even parity
- CDC_PAR_MARK = 3, //!< Parity forced to 1 (mark)
- CDC_PAR_SPACE = 4 //!< Parity forced to 0 (space)
-};
-//@}
-
-//! \name USB CDC control signals
-//! spec 1.1 chapter 6.2.14
-//@{
-
-//! Control signal structure
-typedef struct usb_cdc_control_signal {
- union {
- le16_t value;
- struct {
- uint8_t dte_present;
- uint8_t carrier_ctrl;
- } modem;
- struct {
- uint8_t DTR : 1; //!< Data Terminal Ready
- uint8_t RTS : 1; //!< Request To Send
- } rs232;
- struct {
- uint8_t s108_2 : 1; //!< V.24 signal 108/2
- uint8_t s105 : 1; //!< V.24 signal 105
- } v24;
- };
-} usb_cdc_control_signal_t;
-
-//! \name Possible values in usb_cdc_control_signal_t
-//@{
-//! Carrier control for half duplex modems.
-//! This signal corresponds to V.24 signal 105 and RS-232 signal RTS.
-//! The device ignores the value of this bit
-//! when operating in full duplex mode.
-#define CDC_CTRL_SIGNAL_ACTIVATE_CARRIER (1 << 1)
-//! Indicates to DCE if DTE is present or not.
-//! This signal corresponds to V.24 signal 108/2 and RS-232 signal DTR.
-#define CDC_CTRL_SIGNAL_DTE_PRESENT (1 << 0)
-//@}
-//@}
-
-//! \name USB CDC notification message
-//@{
-
-typedef struct usb_cdc_notify_msg {
- uint8_t bmRequestType;
- uint8_t bNotification;
- union {
- le16_t wValue;
- struct {
- uint8_t low;
- uint8_t high;
- } wValueBytes;
- };
- union {
- le16_t wIndex;
- struct {
- uint8_t low;
- uint8_t high;
- } wIndexBytes;
- };
- union {
- le16_t wLength;
- struct {
- uint8_t low;
- uint8_t high;
- } wLengthBytes;
- };
-} usb_cdc_notify_msg_t;
-
-//! \name USB CDC serial state
-//@{*
-
-//! UART State Bitmap (cdc spec 1.1 chapter 6.3.5)
-typedef union usb_cdc_uart_state {
- le16_t value;
- struct {
- uint8_t bRxCarrier : 1;
- uint8_t bTxCarrier : 1;
- uint8_t bBreak : 1;
- uint8_t bRingSignal : 1;
- uint8_t bFraming : 1;
- uint8_t bParity : 1;
- uint8_t bOverRun;
- } bitmap;
- struct {
- uint8_t bDCD : 1;
- uint8_t bDSR : 1;
- uint8_t bBreak : 1;
- uint8_t bRingSignal : 1;
- uint8_t bFraming : 1;
- uint8_t bParity : 1;
- uint8_t bOverRun;
- } rs232;
- struct {
- uint8_t bS109 : 1; //!< V.24 signal 109
- uint8_t bS106 : 1; //!< V.24 signal 106
- uint8_t bBreak : 1;
- uint8_t bRingSignal : 1;
- uint8_t bFraming : 1;
- uint8_t bParity : 1;
- uint8_t bOverRun;
- } v24;
-} usb_cdc_uart_state_t;
-
-//! Hardware handshake support (cdc spec 1.1 chapter 6.3.5)
-typedef struct usb_cdc_notify_serial_state {
- usb_cdc_notify_msg_t header;
- union usb_cdc_uart_state state;
-} usb_cdc_notify_serial_state_t;
-
-//! \name Possible values in usb_cdc_notify_serial_state_t
-//@{
-#define CDC_SERIAL_STATE_DCD CPU_TO_LE16((1 << 0))
-#define CDC_SERIAL_STATE_DSR CPU_TO_LE16((1 << 1))
-#define CDC_SERIAL_STATE_BREAK CPU_TO_LE16((1 << 2))
-#define CDC_SERIAL_STATE_RING CPU_TO_LE16((1 << 3))
-#define CDC_SERIAL_STATE_FRAMING CPU_TO_LE16((1 << 4))
-#define CDC_SERIAL_STATE_PARITY CPU_TO_LE16((1 << 5))
-#define CDC_SERIAL_STATE_OVERRUN CPU_TO_LE16((1 << 6))
-//@}
-//! @}
-
-//! @}
-
-COMPILER_PACK_RESET()
-
-//! @}
-
-/**
- * \brief Fill a CDC SetLineCoding request
- * \param[out] req Pointer to the request to fill
- * \param[in] iface Interface Number
- */
-static inline void usb_fill_SetLineCoding_req(struct usb_req *req, uint8_t iface)
-{
- req->bmRequestType = 0x21;
- req->bRequest = USB_REQ_CDC_SET_LINE_CODING;
- req->wValue = 0;
- req->wIndex = iface;
- req->wLength = sizeof(usb_cdc_line_coding_t);
-}
-
-/**
- * \brief Fill a CDC SetControlLineState request
- * \param[out] req Pointer to the request to fill
- * \param[in] iface Interface Number
- * \param[in] ctrl Control Signal Bitmap
- */
-static inline void usb_fill_SetControlLineState_req(struct usb_req *req, uint8_t iface, uint16_t ctrl)
-{
- req->bmRequestType = 0x21;
- req->bRequest = USB_REQ_CDC_SET_CONTROL_LINE_STATE;
- req->wValue = ctrl;
- req->wIndex = iface;
- req->wLength = 0;
-}
-
-#endif // _USB_PROTOCOL_CDC_H_