[Components][Drivers][USB] Add CDC-ECM class (LWIP on USB)

Windows下没驱动 linux和mac下免驱
This commit is contained in:
uestczyh222
2017-11-21 22:37:22 +08:00
parent 334da974c3
commit bd566e6a37
5 changed files with 686 additions and 2 deletions
+8
View File
@@ -132,6 +132,10 @@ menu "Using USB"
config _RT_USB_DEVICE_HID
bool "Enable to use device as HID device"
select RT_USB_DEVICE_HID
config _RT_USB_DEVICE_ECM
bool "Enable to use device as ecm device"
select RT_USB_DEVICE_ECM
depends on RT_USING_LWIP
endchoice
if RT_USB_DEVICE_COMPOSITE
config RT_USB_DEVICE_CDC
@@ -143,6 +147,10 @@ menu "Using USB"
config RT_USB_DEVICE_HID
bool "Enable to use device as HID device"
default n
config RT_USB_DEVICE_ECM
bool "Enable to use device as ecm device"
default n
depends on RT_USING_LWIP
endif
if RT_USB_DEVICE_HID
@@ -16,6 +16,9 @@ if GetDepend('RT_USB_DEVICE_HID'):
if GetDepend('RT_USB_DEVICE_MSTORAGE'):
src += Glob('class/mstorage.c')
if GetDepend('RT_USB_DEVICE_ECM'):
src += Glob('class/ecm.c')
CPPPATH = [cwd]
group = DefineGroup('rt_usbd', src, depend = ['RT_USING_USB_DEVICE'], CPPPATH = CPPPATH)
+62 -2
View File
@@ -31,6 +31,7 @@
#define USB_CDC_CLASS_COMM 0x02
#define USB_CDC_CLASS_DATA 0x0A
#define USB_CDC_SUBCLASS_NONE 0x00
#define USB_CDC_SUBCLASS_DLCM 0x01
#define USB_CDC_SUBCLASS_ACM 0x02
#define USB_CDC_SUBCLASS_TCM 0x03
@@ -38,9 +39,10 @@
#define USB_CDC_SUBCLASS_CCM 0x05
#define USB_CDC_SUBCLASS_ETH 0x06
#define USB_CDC_SUBCLASS_ATM 0x07
#define USB_CDC_SUBCLASS_EEM 0x0C
#define USB_CDC_PROTOCOL_NONE 0x00
#define USB_CDC_PROTOCOL_V25TER 0x01
#define USB_CDC_PROTOCOL_I430 0x30
#define USB_CDC_PROTOCOL_HDLC 0x31
#define USB_CDC_PROTOCOL_TRANS 0x32
@@ -54,6 +56,7 @@
#define USB_CDC_PROTOCOL_HOST 0xFD
#define USB_CDC_PROTOCOL_PUFD 0xFE
#define USB_CDC_PROTOCOL_VENDOR 0xFF
#define USB_CDC_PROTOCOL_EEM 0x07
#define USB_CDC_CS_INTERFACE 0x24
#define USB_CDC_CS_ENDPOINT 0x25
@@ -62,6 +65,7 @@
#define USB_CDC_SCS_CALL_MGMT 0x01
#define USB_CDC_SCS_ACM 0x02
#define USB_CDC_SCS_UNION 0x06
#define USB_CDC_SCS_ETH 0x0F
#define CDC_SEND_ENCAPSULATED_COMMAND 0x00
#define CDC_GET_ENCAPSULATED_RESPONSE 0x01
@@ -153,6 +157,30 @@ struct ucdc_comm_descriptor
};
typedef struct ucdc_comm_descriptor* ucdc_comm_desc_t;
struct ucdc_enet_descriptor
{
rt_uint8_t bFunctionLength;
rt_uint8_t bDescriptorType;
rt_uint8_t bDescriptorSubtype;
rt_uint8_t iMACAddress;
rt_uint8_t bmEthernetStatistics[4];
rt_uint16_t wMaxSegmentSize;
rt_uint16_t wMCFilters;
rt_uint8_t bNumberPowerFilters;
};
struct ucdc_eth_descriptor
{
#ifdef RT_USB_DEVICE_COMPOSITE
struct uiad_descriptor iad_desc;
#endif
struct uinterface_descriptor intf_desc;
struct ucdc_header_descriptor hdr_desc;
struct ucdc_union_descriptor union_desc;
struct ucdc_enet_descriptor enet_desc;
struct uendpoint_descriptor ep_desc;
};
typedef struct ucdc_eth_descriptor* ucdc_eth_desc_t;
struct ucdc_data_descriptor
{
struct uinterface_descriptor intf_desc;
@@ -177,7 +205,39 @@ struct cdc_eps
uep_t ep_cmd;
};
typedef struct cdc_eps* cdc_eps_t;
struct ucdc_management_element_notifications
{
rt_uint8_t bmRequestType;
rt_uint8_t bNotificatinCode;
rt_uint16_t wValue;
rt_uint16_t wIndex;
rt_uint16_t wLength;
};
typedef struct ucdc_management_element_notifications * ucdc_mg_notifications_t;
struct ucdc_connection_speed_change_data
{
rt_uint32_t down_bit_rate;
rt_uint32_t up_bit_rate;
};
typedef struct connection_speed_change_data * connect_speed_data_t;
enum ucdc_notification_code
{
UCDC_NOTIFI_NETWORK_CONNECTION = 0x00,
UCDC_NOTIFI_RESPONSE_AVAILABLE = 0x01,
UCDC_NOTIFI_AUX_JACK_HOOK_STATE = 0x08,
UCDC_NOTIFI_RING_DETECT = 0x09,
UCDC_NOTIFI_SERIAL_STATE = 0x20,
UCDC_NOTIFI_CALL_STATE_CHANGE = 0x28,
UCDC_NOTIFI_LINE_STATE_CHANGE = 0x29,
UCDC_NOTIFI_CONNECTION_SPEED_CHANGE = 0x2A,
};
typedef enum ucdc_notification_code ucdc_notification_code_t;
#pragma pack()
#endif
File diff suppressed because it is too large Load Diff
@@ -132,6 +132,17 @@ rt_err_t rt_usb_device_init(void)
}
#endif
#ifdef RT_USB_DEVICE_ECM
{
extern ufunction_t rt_usbd_function_ecm_create(udevice_t device);
/* create a rndis function object */
func = rt_usbd_function_ecm_create(udevice);
/* add the function to the configuration */
rt_usbd_config_add_function(cfg, func);
}
#endif
/* set device descriptor to the device */
#ifdef RT_USB_DEVICE_COMPOSITE
rt_usbd_device_set_descriptor(udevice, &compsit_desc);