Skip to content

File usb_cdc.h

File List > fw > rbcx-coprocessor > lib > libusb_stm32 > include > usb_cdc.h

Go to the documentation of this file.

/* This file is the part of the Lightweight USB device Stack for STM32 microcontrollers
 *
 * Copyright ©2016 Dmitry Filimonchuk <dmitrystu[at]gmail[dot]com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *   http://www.apache.org/licenses/LICENSE-2.0
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef _USB_CDC_H_
#define _USB_CDC_H_

#ifdef __cplusplus
    extern "C" {
#endif

#define USB_CLASS_CDC                   0x02    
#define USB_CLASS_CDC_DATA              0x0A    
#define USB_CDC_SUBCLASS_ACM            0x02    
#define USB_CDC_PROTO_NONE              0x00    
#define USB_CDC_PROTO_V25TER            0x01    
#define USB_CDC_PROTO_NTB               0x01    
#define USB_CDC_PROTO_HOST              0xFD    
#define USB_CDC_PROTO_CDCSPEC           0xFE    
#define USB_DTYPE_CDC_HEADER            0x00    
#define USB_DTYPE_CDC_CALL_MANAGEMENT   0x01    
#define USB_DTYPE_CDC_ACM               0x02    
#define USB_DTYPE_CDC_UNION             0x06    
#define USB_DTYPE_CDC_COUNTRY           0x07    
#define USB_CDC_SEND_ENCAPSULATED_CMD   0x00    
#define USB_CDC_GET_ENCAPSULATED_RESP   0x01    
#define USB_CDC_SET_COMM_FEATURE        0x02    
#define USB_CDC_GET_COMM_FEATURE        0x03    
#define USB_CDC_CLEAR_COMM_FEATURE      0x04    
#define USB_CDC_SET_LINE_CODING         0x20    
#define USB_CDC_GET_LINE_CODING         0x21    
#define USB_CDC_SET_CONTROL_LINE_STATE  0x22    
#define USB_CDC_SEND_BREAK              0x23    
#define USB_CDC_NTF_NETWORK_CONNECTION  0x00    
#define USB_CDC_NTF_RESPONSE_AVAILABLE  0x01    
#define USB_CDC_NTF_SERIAL_STATE        0x20    
#define USB_CDC_NTF_SPEED_CHANGE        0x2A    
#define USB_CDC_COMM_FEATURE            0x01    
#define USB_CDC_CAP_LINE                0x02    
#define USB_CDC_CAP_BRK                 0x04    
#define USB_CDC_CAP_NOTIFY              0x08    
#define USB_CDC_CALL_MGMT_CAP_CALL_MGMT 0x01    
#define USB_CDC_CALL_MGMT_CAP_DATA_INTF 0x02    
#define USB_CDC_1_STOP_BITS             0x00    
#define USB_CDC_1_5_STOP_BITS           0x01    
#define USB_CDC_2_STOP_BITS             0x02    
#define USB_CDC_NO_PARITY               0x00    
#define USB_CDC_ODD_PARITY              0x01    
#define USB_CDC_EVEN_PARITY             0x02    
#define USB_CDC_MARK_PARITY             0x03    
#define USB_CDC_SPACE_PARITY            0x04    
#define USB_CDC_STATE_RX_CARRIER        0x0001 
#define USB_CDC_STATE_TX_CARRIER        0x0002 
#define USB_CDC_STATE_BREAK             0x0004 
#define USB_CDC_STATE_RING              0x0008 
#define USB_CDC_STATE_FRAMING           0x0010 
#define USB_CDC_STATE_PARITY            0x0020 
#define USB_CDC_STATE_OVERRUN           0x0040 
struct usb_cdc_header_desc {
    uint8_t     bFunctionLength;    
    uint8_t     bDescriptorType;    
    uint8_t     bDescriptorSubType; 
    uint16_t    bcdCDC;             
} __attribute__ ((packed));

struct usb_cdc_union_desc {
    uint8_t     bFunctionLength;    
    uint8_t     bDescriptorType;    
    uint8_t     bDescriptorSubType; 
    uint8_t     bMasterInterface0;  
    uint8_t     bSlaveInterface0;   
    /* ... and there could be other slave interfaces */
} __attribute__ ((packed));

struct usb_cdc_country_desc {
    uint8_t     bFunctionLength;     
    uint8_t     bDescriptorType;     
    uint8_t     bDescriptorSubType;  
    uint8_t     iCountryCodeRelDate; 
    uint8_t     wCountyCode0;        
    /* ... and there can be a lot of country codes */
} __attribute__ ((packed));

struct usb_cdc_call_mgmt_desc {
    uint8_t     bFunctionLength;    
    uint8_t     bDescriptorType;    
    uint8_t     bDescriptorSubType; 
    uint8_t     bmCapabilities;     
    uint8_t     bDataInterface;     
} __attribute__ ((packed));

struct usb_cdc_acm_desc {
    uint8_t     bFunctionLength;    
    uint8_t     bDescriptorType;    
    uint8_t     bDescriptorSubType; 
    uint8_t     bmCapabilities;     
} __attribute__ ((packed));

struct usb_cdc_notification {
    uint8_t     bmRequestType;      
    uint8_t     bNotificationType;  
    uint16_t    wValue;             
    uint16_t    wIndex;             
    uint16_t    wLength;            
    uint8_t     Data[];             
} __attribute__ ((packed));

struct usb_cdc_line_coding {
    uint32_t    dwDTERate;          
    uint8_t     bCharFormat;        
    uint8_t     bParityType;        
    uint8_t     bDataBits;          
} __attribute__ ((packed));

#ifdef __cplusplus
    }
#endif

#endif /* _USB_CDC_H_ */