Lightweight USB stack  1.0
usb_cdce.h
1 /* This file is the part of the Lightweight USB device Stack for STM32 microcontrollers
2  *
3  * Copyright ©2016 Dmitry Filimonchuk <dmitrystu[at]gmail[dot]com>
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  * http://www.apache.org/licenses/LICENSE-2.0
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
23 #ifndef _USB_CDC_ECM_H_
24 #define _USB_CDC_ECM_H_
25 
26 #ifdef __cplusplus
27  extern "C" {
28 #endif
29 
32 #define USB_CDC_SUBCLASS_ETH 0x06
33  /* @} */
34 
37 #define USB_DTYPE_CDC_ETHERNET 0x0F
42 #define USB_CDC_SET_ETH_MULTICAST_FILTERS 0x40
43 #define USB_CDC_SET_ETH_PM_PATTERN_FILTER 0x41
44 #define USB_CDC_GET_ETH_PM_PATTERN_FILTER 0x42
45 #define USB_CDC_SET_ETH_PACKET_FILTER 0x43
47 #define USB_CDC_GET_ETH_STATISTIC 0x44
54 #define USB_ETH_XMIT_OK (1<<0)
55 #define USB_ETH_RCV_OK (1<<1)
56 #define USB_ETH_XMIT_ERROR (1<<2)
58 #define USB_ETH_RCV_ERROR (1<<3)
60 #define USB_ETH_RCV_NO_BUFFER (1<<4)
61 #define USB_ETH_DIRECTED_BYTES_XMIT (1<<5)
62 #define USB_ETH_DIRECTED_FRAMES_XMIT (1<<6)
63 #define USB_ETH_MULTICAST_BYTES_XMIT (1<<7)
64 #define USB_ETH_MULTICAST_FRAMES_XMIT (1<<8)
65 #define USB_ETH_BROADCAST_BYTES_XMIT (1<<9)
66 #define USB_ETH_BROADCAST_FRAMES_XMIT (1<<10)
67 #define USB_ETH_DIRECTED_BYTES_RCV (1<<11)
68 #define USB_ETH_DIRECTED_FRAMES_RCV (1<<12)
69 #define USB_ETH_MULTICAST_BYTES_RCV (1<<13)
70 #define USB_ETH_MULTICAST_FRAMES_RCV (1<<14)
71 #define USB_ETH_BROADCAST_BYTES_RCV (1<<15)
72 #define USB_ETH_BROADCAST_FRAMES_RCV (1<<16)
73 #define USB_ETH_RCV_CRC_ERROR (1<<17)
75 #define USB_ETH_TRANSMIT_QUEUE_LENGTH (1<<18)
76 #define USB_ETH_RCV_ERROR_ALIGNMENT (1<<19)
77 #define USB_ETH_XMIT_ONE_COLLISION (1<<20)
78 #define USB_ETH_XMIT_MORE_COLLISIONS (1<<21)
79 #define USB_ETH_XMIT_DEFERRED (1<<22)
80 #define USB_ETH_XMIT_MAX_COLLISIONS (1<<23)
81 #define USB_ETH_RCV_OVERRUN (1<<24)
82 #define USB_ETH_XMIT_UNDERRUN (1<<25)
83 #define USB_ETH_XMIT_HEARTBEAT_FAILURE (1<<26)
84 #define USB_ETH_XMIT_TIMES_CRS_LOST (1<<27)
85 #define USB_ETH_XMIT_LATE_COLLISIONS (1<<28)
94 struct usb_cdc_ether_desc {
95  uint8_t bFunctionLength;
96  uint8_t bDescriptorType;
97  uint8_t bDescriptorSubType;
98  uint8_t iMACAddress;
100  uint32_t bmEthernetStatistics;
102  uint16_t wMaxSegmentSize;
104  uint16_t wNumberMCFilters;
106  uint8_t bNumberPowerFilters;
108 } __attribute__ ((packed));
109 
112 #ifdef __cplusplus
113  }
114 #endif
115 
116 #endif /* _USB_CDC_ECM_H_ */