cancel
Showing results for 
Search instead for 
Did you mean: 

CP210x usb host class driver

christo
Associate III
Posted on September 19, 2015 at 00:10

Hi to All,

I make a step ahead with adding for testing purposes in usbh_cdc.c alternative staff in case of CP2102:

static USBH_StatusTypeDef USBH_CDC_InterfaceInit (USBH_HandleTypeDef *phost)
{ 
USBH_StatusTypeDef status = USBH_FAIL ;
uint8_t interface;
CDC_HandleTypeDef *CDC_Handle;
if (phost->pActiveClass->idVendor == 0x10c4 && phost->pActiveClass->idProduct == 0xea60) {
// CP2102
USBH_SelectInterface (phost, interface);
phost->pActiveClass->pData = (CDC_HandleTypeDef *)USBH_malloc (sizeof(CDC_HandleTypeDef));
CDC_Handle = (CDC_HandleTypeDef*) phost->pActiveClass->pData;
interface = USBH_FindInterface(phost,
0xff,
0x00,
0x00);
...
status = USBH_OK;
}
}
else {
 // CDC
 

interface = USBH_FindInterface(phost,
COMMUNICATION_INTERFACE_CLASS_CODE,
ABSTRACT_CONTROL_MODEL,
COMMON_AT_COMMAND);
...
status = USBH_OK;
}
}
}
return status;
}

Analogous alternative staff is added in

USBH_StatusTypeDef USBH_CDC_InterfaceDeInit (USBH_HandleTypeDef *phost)
{
CDC_HandleTypeDef *CDC_Handle = (CDC_HandleTypeDef*) phost->pActiveClass->pData;
if (phost->pActiveClass->idVendor == 0x10c4 && phost->pActiveClass->idProduct == 0xea60) {
// CP2102
...
}
else {
// CDC
...
}
return USBH_OK;
}

The result is:

// CP2102
USBH_UserProcess: HOST_USER_CONNECTION
USB Device Attached
PID: ea60h
VID: 10c4h
Address (#1) assigned.
Manufacturer : Silicon Labs
Product : CP2102 USB to UART Bridge Controller
Serial Number : 0001
Enumeration done.
This device has only 1 configuration.
Default configuration set.
Switching to Interface (#0)
Class : ffh
SubClass : 0h
Protocol : 0h
CDC class started.
USBH_UserProcess HOST_USER_CLASS_SELECTED: 255
USBH_UserProcess HOST_USER_DISCONNECTION: 255
USB Device disconnected
// CDC
USBH_UserProcess: HOST_USER_CONNECTION
USB Device Attached
PID: 5740h
VID: 483h
Address (#1) assigned.
Manufacturer : STMicroelectronics
Product : ChibiOS/RT Virtual COM Port
Serial Number : 301
Enumeration done.
This device has only 1 configuration.
Default configuration set.
Switching to Interface (#0)
Class : 2h
SubClass : 2h
Protocol : 1h
CDC class started.
USBH_UserProcess HOST_USER_CLASS_SELECTED: 2
USBH_UserProcess: HOST_CDC_CLASS_ACTIVATED
USBH_UserProcess HOST_USER_DISCONNECTION: 2
USB Device disconnected

The only stage did not present in case of CP2102 is:

HOST_CDC_CLASS_ACTIVATED

I try to follow the state machine logic and see that HOST_CHECK_CLASS passed successfully but next phase HOST_CLASS_REQUEST is not entered. I think that both cases have to follow the same logic so it is easier to test the things in a single file which will be split as CDC and CP210x host class drivers later on. Finally, some control functions have to be rewritten as well. The main difference for now between CDC and CP2102 cases is that CP2102 did not has control end point. Any ideas where to search the problem? Best regards Chris
10 REPLIES 10

I know this is 4 years old, but did anyone get past the HOST_CLASS_REQUEST state with the CP2102?

My H743 is stuck at that point, the request never gets answered.