usb_cdce.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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. /**\ingroup USB_CDC
  16. * \addtogroup USB_CDC_ECM USB CDC ECM subclass
  17. * \brief USB CDC ECM subclass definitions
  18. * \details This module based on "Universal Serial Bus Communications Class Subclass Specification for
  19. * Ethernet Control Model Devices Revision 1.2"
  20. * @{ */
  21. #ifndef _USB_CDC_ECM_H_
  22. #define _USB_CDC_ECM_H_
  23. #ifdef __cplusplus
  24. extern "C" {
  25. #endif
  26. /**\name Communications Class Subclass Codes
  27. * @{ */
  28. #define USB_CDC_SUBCLASS_ETH 0x06 /**<\brief Ethernet Networking Control Model */
  29. /* @} */
  30. /**\name CDC ECM subclass specific Functional Descriptors codes
  31. * @{ */
  32. #define USB_DTYPE_CDC_ETHERNET 0x0F /**<\brief Ethernet Networking Functional Descriptor*/
  33. /** @} */
  34. /**\name CDC ECM subclass specific requests
  35. * @{ */
  36. #define USB_CDC_SET_ETH_MULTICAST_FILTERS 0x40 /**<\brief */
  37. #define USB_CDC_SET_ETH_PM_PATTERN_FILTER 0x41 /**<\brief */
  38. #define USB_CDC_GET_ETH_PM_PATTERN_FILTER 0x42 /**<\brief */
  39. #define USB_CDC_SET_ETH_PACKET_FILTER 0x43 /**<\brief Sets device filter for running a network
  40. * analyzer application on the host machine.*/
  41. #define USB_CDC_GET_ETH_STATISTIC 0x44 /**<\brief Retrieves Ethernet device statistics such
  42. * as frames transmitted, frames received, and bad
  43. * frames received.*/
  44. /** @} */
  45. /**\name Ethernet Statistics Capabilities
  46. * @{ */
  47. #define USB_ETH_XMIT_OK (1<<0) /**<\brief Frames transmitted without errors.*/
  48. #define USB_ETH_RCV_OK (1<<1) /**<\brief Frames received without errors.*/
  49. #define USB_ETH_XMIT_ERROR (1<<2) /**<\brief Frames not transmitted, or transmitted
  50. * with errors.*/
  51. #define USB_ETH_RCV_ERROR (1<<3) /**<\brief Frames received with errors that are
  52. * not delivered to the USB host. */
  53. #define USB_ETH_RCV_NO_BUFFER (1<<4) /**<\brief Frame missed, no buffers */
  54. #define USB_ETH_DIRECTED_BYTES_XMIT (1<<5) /**<\brief Directed bytes transmitted without errors */
  55. #define USB_ETH_DIRECTED_FRAMES_XMIT (1<<6) /**<\brief Directed frames transmitted without errors */
  56. #define USB_ETH_MULTICAST_BYTES_XMIT (1<<7) /**<\brief Multicast bytes transmitted without errors */
  57. #define USB_ETH_MULTICAST_FRAMES_XMIT (1<<8) /**<\brief Multicast frames transmitted without errors */
  58. #define USB_ETH_BROADCAST_BYTES_XMIT (1<<9) /**<\brief Broadcast bytes transmitted without errors */
  59. #define USB_ETH_BROADCAST_FRAMES_XMIT (1<<10) /**<\brief Broadcast frames transmitted without errors */
  60. #define USB_ETH_DIRECTED_BYTES_RCV (1<<11) /**<\brief Directed bytes received without errors */
  61. #define USB_ETH_DIRECTED_FRAMES_RCV (1<<12) /**<\brief Directed frames received without errors */
  62. #define USB_ETH_MULTICAST_BYTES_RCV (1<<13) /**<\brief Multicast bytes received without errors */
  63. #define USB_ETH_MULTICAST_FRAMES_RCV (1<<14) /**<\brief Multicast frames received without errors */
  64. #define USB_ETH_BROADCAST_BYTES_RCV (1<<15) /**<\brief Broadcast bytes received without errors */
  65. #define USB_ETH_BROADCAST_FRAMES_RCV (1<<16) /**<\brief Broadcast frames received without errors */
  66. #define USB_ETH_RCV_CRC_ERROR (1<<17) /**<\brief Frames received with circular redundancy check
  67. * (CRC) or frame check sequence (FCS) error */
  68. #define USB_ETH_TRANSMIT_QUEUE_LENGTH (1<<18) /**<\brief Length of transmit queue */
  69. #define USB_ETH_RCV_ERROR_ALIGNMENT (1<<19) /**<\brief Frames received with alignment error */
  70. #define USB_ETH_XMIT_ONE_COLLISION (1<<20) /**<\brief Frames transmitted with one collision */
  71. #define USB_ETH_XMIT_MORE_COLLISIONS (1<<21) /**<\brief Frames transmitted with more than one collision */
  72. #define USB_ETH_XMIT_DEFERRED (1<<22) /**<\brief Frames transmitted after deferral */
  73. #define USB_ETH_XMIT_MAX_COLLISIONS (1<<23) /**<\brief Frames not transmitted due to collisions */
  74. #define USB_ETH_RCV_OVERRUN (1<<24) /**<\brief Frames not received due to overrun */
  75. #define USB_ETH_XMIT_UNDERRUN (1<<25) /**<\brief Frames not transmitted due to underrun */
  76. #define USB_ETH_XMIT_HEARTBEAT_FAILURE (1<<26) /**<\brief Frames transmitted with heartbeat failure */
  77. #define USB_ETH_XMIT_TIMES_CRS_LOST (1<<27) /**<\brief Times carrier sense signal lost during transmission */
  78. #define USB_ETH_XMIT_LATE_COLLISIONS (1<<28) /**<\brief Late collisions detected */
  79. /** @} */
  80. /**\brief Ethernet Networking Functional Descriptor
  81. * \details describes the operational modes supported by the
  82. * Communications Class interface, as defined in Section 3.4, with the SubClass code of Ethernet
  83. * Networking Control. It can only occur within the class-specific portion of an Interface descriptor.
  84. */
  85. struct usb_cdc_ether_desc {
  86. uint8_t bFunctionLength; /**<\brief Size of this functional descriptor, in bytes.*/
  87. uint8_t bDescriptorType; /**<\brief CS_INTERFACE descriptor type.*/
  88. uint8_t bDescriptorSubType; /**<\brief Ethernet Networking Functional Descriptor.*/
  89. uint8_t iMACAddress; /**<\brief Index of string descriptor that holds the
  90. * 48bit Ethernet MAC.*/
  91. uint32_t bmEthernetStatistics; /**<\brief Indicates which Ethernet statistics functions
  92. * the device collects. */
  93. uint16_t wMaxSegmentSize; /**<\brief The maximum segment size that the Ethernet
  94. * device is capable of supporting. */
  95. uint16_t wNumberMCFilters; /**<\brief Contains the number of multicast filters that
  96. * can be configured by the host. */
  97. uint8_t bNumberPowerFilters; /**<\brief Contains the number of pattern filters that
  98. * are available for causing wake-up of the host. */
  99. } __attribute__ ((packed));
  100. /** @} */
  101. #ifdef __cplusplus
  102. }
  103. #endif
  104. #endif /* _USB_CDC_ECM_H_ */