1 /*
2  * Copyright (c) 2022, sakumisu
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 #ifndef USBH_CDC_ACM_H
7 #define USBH_CDC_ACM_H
8 
9 #include "usb_cdc.h"
10 
11 struct usbh_cdc_acm {
12     struct usbh_hubport *hport;
13     struct usb_endpoint_descriptor *bulkin;  /* Bulk IN endpoint */
14     struct usb_endpoint_descriptor *bulkout; /* Bulk OUT endpoint */
15 #ifdef CONFIG_USBHOST_CDC_ACM_NOTIFY
16     struct usb_endpoint_descriptor *intin;   /* INTR IN endpoint (optional) */
17 #endif
18     struct usbh_urb bulkout_urb;
19     struct usbh_urb bulkin_urb;
20 #ifdef CONFIG_USBHOST_CDC_ACM_NOTIFY
21     struct usbh_urb intin_urb;
22 #endif
23 
24     struct cdc_line_coding linecoding;
25 
26     uint8_t intf;
27     uint8_t minor;
28 
29     void *user_data;
30 };
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 int usbh_cdc_acm_set_line_coding(struct usbh_cdc_acm *cdc_acm_class, struct cdc_line_coding *line_coding);
37 int usbh_cdc_acm_get_line_coding(struct usbh_cdc_acm *cdc_acm_class, struct cdc_line_coding *line_coding);
38 int usbh_cdc_acm_set_line_state(struct usbh_cdc_acm *cdc_acm_class, bool dtr, bool rts);
39 
40 int usbh_cdc_acm_bulk_in_transfer(struct usbh_cdc_acm *cdc_acm_class, uint8_t *buffer, uint32_t buflen, uint32_t timeout);
41 int usbh_cdc_acm_bulk_out_transfer(struct usbh_cdc_acm *cdc_acm_class, uint8_t *buffer, uint32_t buflen, uint32_t timeout);
42 
43 void usbh_cdc_acm_run(struct usbh_cdc_acm *cdc_acm_class);
44 void usbh_cdc_acm_stop(struct usbh_cdc_acm *cdc_acm_class);
45 
46 #ifdef __cplusplus
47 }
48 #endif
49 
50 #endif /* USBH_CDC_ACM_H */
51