-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added support for CDC ECM subclass driver and sample app #13
base: develop
Are you sure you want to change the base?
Conversation
} | ||
|
||
/* ----------- TASK FOR SENDING ARP MSG --------------- */ | ||
OSTaskCreate( &App_USBD_ECM_TaskTCB, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @wes-fflores. I notice there's no equivalent to USBH_OS_TaskCreate
for OS compatibility. Is there a good way to handle OS II and III compatibility here? Or is it okay to make it work only with uCOS-III?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets get the project to build without errors before doing changes for OS compatibility.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I created a project from scratch as a regular user to see if the project would build with the new class. I am getting the following warnings and errors during compilation
Warning[Pe223]: function "USBD_CDC_SetAltIFEn" declared implicitly
Warning[Pe223]: function "USBD_CDC_SetEndOfTx" declared implicitly
Warning[Pe223]: function "USBD_CDC_DataRxAsync" declared implicitly
Error[Pe020]: identifier "USBD_CDC_NOTIFICATION_NET_CONN" is undefined
Error[Pe020]: identifier "USBD_CDC_NOTIFICATION_CONN_SPEED_CHNG" is undefined
********************************************************************************************************* | ||
*/ | ||
|
||
#ifndef USBD_ECM_CFG_MAX_NBR_DEV |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I get a compiling error for USBD_ECM_CFG_MAX_NBR_DEV. This was not define in the configuration template in the "\Cfg\Template\usbd_cfg.h" file
* TEMPLATE | ||
* | ||
* Filename : app_usbd_cdc_ecm.c | ||
* Version : V3.42.01 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
version number is V4.06.01
@@ -196,6 +200,12 @@ CPU_BOOLEAN App_USBD_CDC_Init (CPU_INT08U dev_nbr, | |||
CPU_INT08U cfg_fs); | |||
#endif | |||
|
|||
#if (APP_CFG_USBD_CDC_ECM_EN == DEF_ENABLED) | |||
USBD_ERR App_USBD_CDC_ECM_Init (CPU_INT08U dev_nbr, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To keep the consistency with the other class application Init functions, change the return from USBD_ERR to CPU_BOOLEAN and remove 3 spaces before (CPU_INT08U
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In addition, You will need to add the call to App_USBD_CDC_ECM_Init()
in App_USBD_Init()
which is found in App\Device\app_usbd.c
#if (APP_CFG_USBD_CDC_ECM_EN == DEF_ENABLED)
ok = App_USBD_CDC_ECM_Init(dev_nbr, /* Initialize CDC ECM class. */
cfg_hs_nbr,
cfg_fs_nbr);
if (ok != DEF_OK) {
APP_TRACE_DBG((" ... could not initialize CDC ECM class w/err = %d\r\n\r\n", err));
return (DEF_FAIL);
}
#endif
********************************************************************************************************* | ||
*/ | ||
|
||
#define APP_USBD_CDC_ECM_MODULE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove lines 27 and 28
********************************************************************************************************* | ||
*/ | ||
|
||
#include <app_cfg.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replace this line with the following:
#include <app_usbd.h>
#if (APP_CFG_USBD_EN == DEF_ENABLED) && \
(APP_CFG_USBD_CDC_ECM_EN == DEF_ENABLED)
#include <Class/CDC/ECM/usbd_ecm.h>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line 885-912:
USBD_ECM_CTRL *p_ctrl;
CPU_INT08U request_code;
CPU_BOOLEAN valid;
p_ctrl = (USBD_ECM_CTRL *)p_subclass_arg;
request_code = p_setup_req->bRequest;
valid = DEF_FAIL;
if (p_ctrl->MgmtReq == DEF_NULL) {
return (valid);
}
switch (request_code) {
case USBD_CDC_REQ_SET_ETHER_MULTI_FILTER:
case USBD_CDC_REQ_SET_ETHER_PWR_MGT_FILTER:
case USBD_CDC_REQ_GET_ETHER_PWR_MGT_FILTER:
case USBD_CDC_REQ_SET_ETHER_PKT_FILTER:
case USBD_CDC_REQ_GET_ETHER_STAT:
valid = p_ctrl->MgmtReq(dev_nbr, p_setup_req, p_ctrl->MgmtReqArg);
break;
default:
break;
}
return (valid);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line 918: add 3 spaces before USBD_ECM_NotifyCmpl()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line 942: add 3 spaces before USBD_ECM_FnctDesc()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line 950: change if_nbr
to first_dci_if_nbr
and do the same for line 960 and 962
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line 980 : add 4 spaces before USBD_ECM_FnctDescSizeGet()
Overview
This change adds support for the CDC ECM subclass driver and sample app. This is similar to what was done with the USBH driver the sample app just exchange a couple ARP messages.
Validation
This driver has been used with several hosts like Linux, MacOS, Android and iOS. ECM is not natively supported on Windows.
This was tested on a full-speed interface and could get ~5Mbps IP transfers with iPerf on STM32.