M471M/R1/S BSP V3.01.000
The Board Support Package for M4521
usbh_cdc.h
Go to the documentation of this file.
1/**************************************************************************/
8#ifndef _USBH_CDC_H_
9#define _USBH_CDC_H_
10
11#include "NuMicro.h"
12#include "usb.h"
13
14#ifdef __cplusplus
15extern "C"
16{
17#endif
18
20
21#define CDC_DEBUG
22
23#define CDC_ERRMSG printf
24#ifdef CDC_DEBUG
25#define CDC_DBGMSG printf
26#else
27#define CDC_DBGMSG(...)
28#endif
29
30#define CDC_STATUS_BUFF_SIZE 64
31#define CDC_RX_BUFF_SIZE 64
32
33/* Interface Class Codes (defined in usbh.h) */
34//#define USB_CLASS_COMM 0x02
35//#define USB_CLASS_DATA 0x0A
36
37/* Communication Interface Class SubClass Codes */
38#define CDC_SC_RESERVED 0x00 /* RESERVED */
39#define CDC_SC_LINE_CTRL 0x01 /* Direct Line Control Model */
40#define CDC_SC_ABS_CTRL 0x02 /* Abstract Control Model */
41#define CDC_SC_TEL_CTRL 0x03 /* Telephone Control Model */
42#define CDC_SC_MULTI_CHN 0x04 /* Multi-Channel Control Model */
43#define CDC_SC_CAPI 0x05 /* CAPI Control Model */
44#define CDC_SC_ETHER 0x06 /* Ethernet Networking Control Model */
45#define CDC_SC_ATM 0x07 /* ATM Networking Control Model */
46
47/* Communication Interface Class Control Protocol Codes */
48#define CDC_PC_NONE 0x00 /* No class specific protocol required */
49#define CDC_PC_V25_TER 0x01 /* Common AT commands */
50#define CDC_PC_VENDOR 0xFF /* Vendor-specific */
51
52/* CDC Class-specific descritpor types */
53#define CDC_CS_INTERFACE 0x24
54#define CDC_CS_ENDPOINT 0x25
55
56/*
57 * CDC class specific descritpor types
58 */
59#define CDC_DT_HDR_FUNC 0x00 /* Header Functional Descriptor */
60#define CDC_DT_CALL_MANAGE 0x01 /* Call Management Functional Descriptor */
61#define CDC_DT_ABS_CTRL 0x02 /* Abstract Control Management Functional Descriptor */
62#define CDC_DT_LINE_MANAGE 0x03 /* Direct Line Management Functional Descriptor */
63#define CDC_DT_TEL_RINGER 0x04 /* Telephone Ringer Functional Descriptor */
64#define CDC_DT_CALL_LINE_CAP 0x05 /* Telephone Call and Line State Reporting Capabilities Descriptor */
65#define CDC_DT_UNION 0x06 /* Union Functional Descriptor */
66#define CDC_DT_COUNTRY_SEL 0x07 /* Country Selection Functional Descriptor */
67#define CDC_DT_TEL_OPER_MODES 0x08 /* Telephone Operational Modes Functional Descriptor */
68#define CDC_DT_USB_TERMINAL 0x09 /* USB Terminal Functional Descriptor */
69#define CDC_DT_NET_CHANNEL 0x0A /* Network Channel Terminal Functional Descriptor */
70#define CDC_DT_PROTO_UNIT 0x0B /* Protocol Unit Functional Descriptor */
71#define CDC_DT_EXTENT_UNIT 0x0C /* Extension Unit Functional Descriptor */
72#define CDC_DT_MULTI_CHANNEL 0x0D /* Multi-Channel Management Functional Descriptor */
73#define CDC_DT_CAPI_CTRL 0x0E /* CAPI Control Management Functional Descriptor */
74#define CDC_DT_ETHERNET_FUNC 0x0F /* Ethernet Networking Functional Descriptor */
75#define CDC_DT_ATM_FUNC 0x10 /* ATM Networking Functional Descriptor */
76
77
78/*
79 * CDC class requests
80 */
81#define CDC_SEND_ENCAPSULATED_COMMAND 0x00
82#define CDC_GET_ENCAPSULATED_RESPONSE 0x01
83#define CDC_SET_COMM_FEATURE 0x02
84#define CDC_GET_COMM_FEATURE 0x03
85#define CDC_CLEAR_COMM_FEATURE 0x04
86#define CDC_SET_AUX_LINE_STATE 0x10
87#define CDC_SET_HOOK_STATE 0x11
88#define CDC_PULSE_SETUP 0x12
89#define CDC_SEND_PULSE 0x13
90#define CDC_SET_PULSE_TIME 0x14
91#define CDC_RING_AUX_JACK 0x15
92#define CDC_SET_LINE_CODING 0x20
93#define CDC_GET_LINE_CODING 0x21
94#define CDC_SET_CONTROL_LINE_STATE 0x22
95#define CDC_SEND_BREAK 0x23
96#define CDC_SET_RINGER_PARMS 0x30
97#define CDC_GET_RINGER_PARMS 0x31
98#define CDC_SET_OPERATION_PARMS 0x32
99#define CDC_GET_OPERATION_PARMS 0x33
100#define CDC_SET_LINE_PARMS 0x34
101#define CDC_GET_LINE_PARMS 0x35
102#define CDC_DIAL_DIGITS 0x36
103#define CDC_SET_UNIT_PARAMETER 0x37
104#define CDC_GET_UNIT_PARAMETER 0x38
105#define CDC_CLEAR_UNIT_PARAMETER 0x39
106#define CDC_GET_PROFILE 0x3A
107#define CDC_SET_ETHERNET_MULTICAST_FILTERS 0x40
108#define CDC_SET_ETHERNET_PM_PATTERN_FILTER 0x41
109#define CDC_GET_ETHERNET_PM_PATTERN_FILTER 0x42
110#define CDC_SET_ETHERNET_PACKET_FILTER 0x43
111#define CDC_GET_ETHERNET_STATISTIC 0x44
112#define CDC_SET_ATM_DATA_FORMAT 0x50
113#define CDC_GET_ATM_DEVICE_STATISTICS 0x51
114#define CDC_SET_ATM_DEFAULT_VC 0x52
115#define CDC_GET_ATM_VC_STATISTICS 0x53
116
117#define CDC_CMD_TIMEOUT 100
118
119
120/*-----------------------------------------------------------------------------------
121 * CDC Class-specific interface descriptor header
122 */
123#ifdef __ICCARM__
124typedef struct cdc_if_header
125{
126 __packed uint8_t bLength;
127 __packed uint8_t bDescriptorType;
128 __packed uint8_t bDescriptorSubtype;
129 __packed uint8_t payload[16];
130} CDC_IF_HDR_T;
131#else
132typedef struct __attribute__((__packed__)) cdc_if_header
133{
134 uint8_t bLength;
135 uint8_t bDescriptorType;
136 uint8_t bDescriptorSubtype;
137 uint8_t payload[16];
138} CDC_IF_HDR_T;
139#endif
140
141struct cdc_dev_t;
142
144
145
150/*
151 * Line Coding
152 */
153#ifdef __ICCARM__
154typedef struct line_coding_t
155{
156 __packed uint32_t baud; /* Baud Rate */
157 __packed uint8_t stop_bits; /* 0 - 1 Stop bit; 1 - 1.5 Stop bits; 2 - 2 Stop bits */
158 __packed uint8_t parity; /* 0 - None; 1 - Odd; 2 - Even; 3 - Mark; 4 - Space */
159 __packed uint8_t data_bits; /* Data bits (5, 6, 7, 8 or 16) */
161#else
162typedef struct __attribute__((__packed__)) line_coding_t
163{
164 uint32_t baud; /* Baud Rate */
165 uint8_t stop_bits; /* 0 - 1 Stop bit; 1 - 1.5 Stop bits; 2 - 2 Stop bits */
166 uint8_t parity; /* 0 - None; 1 - Odd; 2 - Even; 3 - Mark; 4 - Space */
167 uint8_t data_bits; /* Data bits (5, 6, 7, 8 or 16) */
169#endif
170
171/*
172 * USB-specific CDC device struct
173 */
174typedef struct cdc_dev_t
175{
176 UDEV_T *udev;
177 IFACE_T *iface_cdc; /* CDC interface number */
178 IFACE_T *iface_data; /* CDC data interface number (can be NULL) */
180 EP_INFO_T *ep_sts;
181 EP_INFO_T *ep_rx;
182 EP_INFO_T *ep_tx;
183 UTR_T *utr_sts; /* Interrupt in URB */
184 UTR_T *utr_rx; /* Bulk in URB */
185 uint32_t sts_buff[CDC_STATUS_BUFF_SIZE/4];
186 uint32_t rx_buff[CDC_RX_BUFF_SIZE/4];
187 CDC_CB_FUNC *sts_func; /* Interrupt in data received callback */
188 CDC_CB_FUNC *rx_func; /* Bulk in data received callabck */
189 uint8_t rx_busy; /* Bulk in transfer is on going */
192 /* end of group USBH_EXPORTED_STRUCTURES */
194 /* end of group USBH_Library */
196 /* end of group Library */
198
199#ifdef __cplusplus
200}
201#endif
202
203#endif /* _USBH_CDC_H_ */
204
NuMicro peripheral access layer header file.
LINE_CODING_T
Definition: usbh_cdc.h:168
uint8_t rx_busy
Definition: usbh_cdc.h:189
int ifnum_data
Definition: usbh_cdc.h:179
IFACE_T * iface_data
Definition: usbh_cdc.h:178
uint32_t sts_buff[CDC_STATUS_BUFF_SIZE/4]
Definition: usbh_cdc.h:185
CDC_CB_FUNC * sts_func
Definition: usbh_cdc.h:187
UDEV_T * udev
Definition: usbh_cdc.h:176
IFACE_T * iface_cdc
Definition: usbh_cdc.h:177
UTR_T * utr_sts
Definition: usbh_cdc.h:183
struct __attribute__((__packed__)) line_coding_t
Definition: usbh_cdc.h:162
EP_INFO_T * ep_rx
Definition: usbh_cdc.h:181
EP_INFO_T * ep_tx
Definition: usbh_cdc.h:182
uint32_t rx_buff[CDC_RX_BUFF_SIZE/4]
Definition: usbh_cdc.h:186
struct cdc_dev_t * next
Definition: usbh_cdc.h:190
UTR_T * utr_rx
Definition: usbh_cdc.h:184
CDC_CB_FUNC * rx_func
Definition: usbh_cdc.h:188
EP_INFO_T * ep_sts
Definition: usbh_cdc.h:180
struct cdc_dev_t CDC_DEV_T
void() CDC_CB_FUNC(struct cdc_dev_t *cdev, uint8_t *rdata, int data_len)
Definition: usbh_lib.h:119
USB Host library header file.