1 /*
2  * Copyright (c) 2024, sakumisu
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 #ifndef USBH_CDC_ECM_H
7 #define USBH_CDC_ECM_H
8 
9 #include "usb_cdc.h"
10 
11 struct usbh_cdc_ecm {
12     struct usbh_hubport *hport;
13     struct usb_endpoint_descriptor *bulkin;  /* Bulk IN endpoint */
14     struct usb_endpoint_descriptor *bulkout; /* Bulk OUT endpoint */
15     struct usb_endpoint_descriptor *intin;   /* Interrupt IN endpoint */
16     struct usbh_urb bulkout_urb; /* Bulk out endpoint */
17     struct usbh_urb bulkin_urb; /* Bulk IN endpoint */
18     struct usbh_urb intin_urb; /* Interrupt IN endpoint */
19 
20     uint8_t ctrl_intf; /* Control interface number */
21     uint8_t data_intf; /* Data interface number */
22     uint8_t minor;
23 
24     uint8_t mac[6];
25     bool connect_status;
26     uint16_t max_segment_size;
27     uint32_t speed[2];
28 
29     void *user_data;
30 };
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 int usbh_cdc_ecm_get_connect_status(struct usbh_cdc_ecm *cdc_ecm_class);
37 
38 void usbh_cdc_ecm_run(struct usbh_cdc_ecm *cdc_ecm_class);
39 void usbh_cdc_ecm_stop(struct usbh_cdc_ecm *cdc_ecm_class);
40 
41 uint8_t *usbh_cdc_ecm_get_eth_txbuf(void);
42 int usbh_cdc_ecm_eth_output(uint32_t buflen);
43 void usbh_cdc_ecm_eth_input(uint8_t *buf, uint32_t buflen);
44 void usbh_cdc_ecm_rx_thread(CONFIG_USB_OSAL_THREAD_SET_ARGV);
45 
46 #ifdef __cplusplus
47 }
48 #endif
49 
50 #endif /* USBH_CDC_ECM_H */
51