Skip to content

Commit 0ff1b53

Browse files
committed
Initial commit
0 parents  commit 0ff1b53

File tree

106 files changed

+113022
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+113022
-0
lines changed

App/Device/app_usbd.c

Lines changed: 468 additions & 0 deletions
Large diffs are not rendered by default.

App/Device/app_usbd.h

Lines changed: 491 additions & 0 deletions
Large diffs are not rendered by default.

App/Device/app_usbd_audio.c

Lines changed: 454 additions & 0 deletions
Large diffs are not rendered by default.

App/Device/app_usbd_cdc.c

Lines changed: 623 additions & 0 deletions
Large diffs are not rendered by default.

App/Device/app_usbd_cdc_eem.c

Lines changed: 194 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,194 @@
1+
/*
2+
*********************************************************************************************************
3+
* EXAMPLE CODE
4+
*
5+
* This file is provided as an example on how to use Micrium products.
6+
*
7+
* Please feel free to use any application code labeled as 'EXAMPLE CODE' in
8+
* your application products. Example code may be used as is, in whole or in
9+
* part, or may be used as a reference only. This file can be modified as
10+
* required to meet the end-product requirements.
11+
*
12+
*********************************************************************************************************
13+
*/
14+
15+
/*
16+
*********************************************************************************************************
17+
*
18+
* USB DEVICE CDC EEM CLASS APPLICATION INITIALIZATION
19+
*
20+
* TEMPLATE
21+
*
22+
* Filename : app_usbd_cdc_eem.c
23+
* Version : V4.06.00
24+
*********************************************************************************************************
25+
*/
26+
27+
/*
28+
*********************************************************************************************************
29+
* INCLUDE FILES
30+
*********************************************************************************************************
31+
*/
32+
33+
#include <app_usbd.h>
34+
35+
#if (APP_CFG_USBD_EN == DEF_ENABLED) && \
36+
(APP_CFG_USBD_CDC_EEM_EN == DEF_ENABLED)
37+
#include <Class/CDC-EEM/usbd_cdc_eem.h>
38+
39+
#include <Source/net.h>
40+
#include <Source/net_ascii.h>
41+
#include <Source/net_err.h>
42+
#include <IF/net_if.h>
43+
#include <IP/IPv4/net_ipv4.h>
44+
#include <net_dev_cfg.h>
45+
#include <Dev/Ether/USBD_CDCEEM/net_dev_usbd_cdceem.h>
46+
47+
48+
/*
49+
*********************************************************************************************************
50+
* LOCAL DEFINES
51+
*********************************************************************************************************
52+
*/
53+
54+
55+
/*
56+
*********************************************************************************************************
57+
* LOCAL GLOBAL VARIABLES
58+
*********************************************************************************************************
59+
*/
60+
61+
62+
/*
63+
*********************************************************************************************************
64+
* LOCAL FUNCTION PROTOTYPES
65+
*********************************************************************************************************
66+
*/
67+
68+
69+
/*
70+
*********************************************************************************************************
71+
* LOCAL CONFIGURATION ERRORS
72+
*********************************************************************************************************
73+
*/
74+
75+
76+
/*
77+
*********************************************************************************************************
78+
* App_USBD_CDC_EEM_Init()
79+
*
80+
* Description : Initialize USB device CDC EEM subclass.
81+
*
82+
* Argument(s) : dev_nbr Device number.
83+
*
84+
* cfg_hs Index of high-speed configuration to which this interface will be added to.
85+
*
86+
* cfg_fs Index of high-speed configuration to which this interface will be added to.
87+
*
88+
* Return(s) : DEF_OK, if successful.
89+
* DEF_FAIL, otherwise.
90+
*
91+
* Note(s) : (1) This function assumes that uC/TCP-IP with USBD_CDCEEM driver is part of the project
92+
* and that it has been initialized.
93+
*
94+
* (2) This example will set a static IPv4 address to the interface. For more examples that
95+
* uses IPv6 and/or assignation of address via DHCP, see uC/TCP-IPs application
96+
* examples.
97+
*********************************************************************************************************
98+
*/
99+
100+
CPU_BOOLEAN App_USBD_CDC_EEM_Init (CPU_INT08U dev_nbr,
101+
CPU_INT08U cfg_hs,
102+
CPU_INT08U cfg_fs)
103+
{
104+
CPU_BOOLEAN valid;
105+
CPU_INT08U cdc_eem_nbr;
106+
USBD_ERR err;
107+
NET_IF_NBR net_if_nbr;
108+
NET_IPv4_ADDR addr;
109+
NET_IPv4_ADDR subnet_mask;
110+
NET_IPv4_ADDR dflt_gateway;
111+
NET_ERR err_net;
112+
113+
114+
APP_TRACE_DBG((" Initializing CDC EEM class ... \r\n"));
115+
116+
USBD_CDC_EEM_Init(&err);
117+
if (err != USBD_ERR_NONE) {
118+
APP_TRACE_DBG((" ... could not initialize CDC EEM class w/err = %d\r\n\r\n", err));
119+
return (DEF_FAIL);
120+
}
121+
122+
cdc_eem_nbr = USBD_CDC_EEM_Add(&err);
123+
if (err != USBD_ERR_NONE) {
124+
APP_TRACE_DBG((" ... could not create CDC EEM class instance w/err = %d\r\n\r\n", err));
125+
return (DEF_FAIL);
126+
}
127+
128+
/* Add CDC EEM class instance to USB configuration(s). */
129+
if (cfg_hs != USBD_CFG_NBR_NONE) {
130+
USBD_CDC_EEM_CfgAdd(cdc_eem_nbr,
131+
dev_nbr,
132+
cfg_hs,
133+
"CDC EEM interface",
134+
&err);
135+
if (err != USBD_ERR_NONE) {
136+
APP_TRACE_DBG((" ... could not add CDC EEM instance #%d to HS configuration w/err = %d\r\n\r\n", cdc_eem_nbr, err));
137+
return (DEF_FAIL);
138+
}
139+
}
140+
141+
if (cfg_fs != USBD_CFG_NBR_NONE) {
142+
USBD_CDC_EEM_CfgAdd(cdc_eem_nbr,
143+
dev_nbr,
144+
cfg_fs,
145+
"CDC EEM interface",
146+
&err);
147+
if (err != USBD_ERR_NONE) {
148+
APP_TRACE_DBG((" ... could not add CDC EEM instance #%d to FS configuration w/err = %d\r\n\r\n", cdc_eem_nbr, err));
149+
return (DEF_FAIL);
150+
}
151+
}
152+
153+
/* Add uC/TCP-IP interface using CDC EEM. */
154+
NetDev_Cfg_Ether_USBD_CDCEEM.ClassNbr = cdc_eem_nbr; /* Set CDC EEM class instance number to drv cfg. */
155+
net_if_nbr = NetIF_Add((void *)&NetIF_API_Ether,
156+
(void *)&NetDev_API_USBD_CDCEEM,
157+
DEF_NULL,
158+
(void *)&NetDev_Cfg_Ether_USBD_CDCEEM,
159+
DEF_NULL,
160+
DEF_NULL,
161+
&err_net);
162+
if (err_net != NET_IF_ERR_NONE) {
163+
APP_TRACE_DBG((" ... could not add TCP IP IF w/err = %d\r\n\r\n", err_net));
164+
return (DEF_FAIL);
165+
}
166+
167+
168+
/* Set static address to device. */
169+
addr = NetASCII_Str_to_IPv4("192.168.0.10",
170+
&err_net);
171+
subnet_mask = NetASCII_Str_to_IPv4("255.255.255.0",
172+
&err_net);
173+
dflt_gateway = NetASCII_Str_to_IPv4("192.168.0.1",
174+
&err_net);
175+
176+
NetIPv4_CfgAddrAdd(net_if_nbr,
177+
addr,
178+
subnet_mask,
179+
dflt_gateway,
180+
&err_net);
181+
if (err_net != NET_IPv4_ERR_NONE) {
182+
APP_TRACE_DBG((" ... could not add static IPv4 address to TCP IP IF w/err = %d\r\n\r\n", err_net));
183+
return (DEF_FAIL);
184+
}
185+
186+
NetIF_Start(net_if_nbr, &err_net); /* Start uC/TCP-IP interface. */
187+
if (err_net != NET_IF_ERR_NONE) {
188+
APP_TRACE_DBG((" ... could not start TCP IP IF w/err = %d\r\n\r\n", err_net));
189+
return (DEF_FAIL);
190+
}
191+
192+
return (DEF_OK);
193+
}
194+
#endif

0 commit comments

Comments
 (0)