2017-07-04 08:44 AM
Hi,
I am writing a firmware for a USB device that uses the STM32L052K8 microcontroller.
Because my device must exhibit two USB interfaces, I have implemented a custom Composite Device class that acts like as broker: it dispatches the USB requests to the two standard USB classes on the basis of endpoint number or interface number present in the USB requests itself.
The first class is MSC- Bulk Only, therefore it has only two endpoints:
The second class is custom class that has three endpoints:
Except for 0x83, all of these endpoints have a maximum packet size of 64 bytes. The endpoint 0x83 has a maximum packet size of 8 bytes.
The problem is that the endpoints of the classes seems to interfere with each other, likely because I do something of wrong in the configuration of the USB peripheral PMA.
With the following configuration works only the MSC interface.
HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*) pdev->pData, 0x00, PCD_SNG_BUF, 0x18U + 0U * 0x40U);
HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*) pdev->pData, 0x80, PCD_SNG_BUF, 0x18U + 1U * 0x40U);
HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*) pdev->pData,
0x81
, PCD_SNG_BUF, 0x18U + 2U * 0x40U);
HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*) pdev->pData,
0x01
, PCD_SNG_BUF, 0x18U + 3U * 0x40U);
HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*) pdev->pData,
0x82
, PCD_SNG_BUF, 0x18U + 4U * 0x40U);
HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*) pdev->pData,
0x02
, PCD_SNG_BUF, 0x18U + 5U * 0x40U);
HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*) pdev->pData,
0x87
, PCD_SNG_BUF, 0x18U + 6U * 0x40U);
Instead, if I change the endpoint index from 0x83 to 0x87 (everywhere, also in the descriptor), the situation seems better, but randomically the device
exhibits a wrong behaviour (the OS enumerates it two times and than it wokrs good).
Why do the
behaviour change if I chage only the endpoint index and not the endpoint address?
Why the addresses in the PMA start from
0x18U?
What is the rule to evaluate the pma address?
Do I overwrite the BTABLE with the configuration above?
Is there something of wrong in the PMA configuration?
NB: When I changed the endpoint index, I also removed the device from Windows device manager. Furthermore this situation happened also on the NUCLEO-L053.
I'm sorry if my English is not perfect,
Thank you very much
#usb #stm32l0 #pma-usb-pmaconfig #pma #endpoint #usb-composite #stm32l052