STMicroelectronics / STM32CubeL0

STM32Cube MCU Full Package for the STM32L0 series - (HAL + LL Drivers, CMSIS Core, CMSIS Device, MW libraries plus a set of Projects running on all boards provided by ST (Nucleo, Evaluation and Discovery Kits))
Other
103 stars 57 forks source link

Make maximum number of USB endpoints configurable to reduce memory footprint #24

Closed jelledevleeschouwer closed 1 year ago

jelledevleeschouwer commented 2 years ago
The STM32L082 USB peripheral support up to 8 configurable USB endpoints.
However, depending on the application one might only need a few of them.
For example, for a CDC class application, only 3 endpoints are used in
addition to endpoint 0 (bidirectional endpoint):

 - CDC IN  endpoint  (USB IN): USB device (MCU) -> USB host (PC)
 - CDC OUT endpoint (USB OUT): USB host (PC) -> USB device (MCU)
 - CDC CMD endpoint  (USB IN): CDC commands

But, since USB device library is used on various chipsets, it provides
memory structure for up to 16 (!) bidirectional USB endpoints, which is
not even possible on the STM32L082. So all these extra memory structures
are wasted RAM.

This commit makes the allocation of these endpoint memory structure
configurable. Since the USB device library *depends on* the HAL, the HAL
is modified such that a user can define 'HAL_PCD_NUM_ENDPOINTS_IN' and
'HAL_PCD_NUM_ENDPOINTS_OUT' to one's needs in stm32l0xx_hal_conf.h. For
CDC class device one can define these as follows:

 #define HAL_PCD_NUM_ENDPOINTS_IN      3U
 #define HAL_PCD_NUM_ENDPOINTS_OUT     2U

If those settings need to be propagated through to the ST USB Device
libray, one must define the following object-like macro's in the
application's usbd_conf.h to link the HAL configuration with the USB
device library:

 #define USBD_MAX_NUM_ENDPOINT_IN       (HAL_PCD_NUM_ENDPOINTS_IN)
 #define USBD_MAX_NUM_ENDPOINT_OUT      (HAL_PCD_NUM_ENDPOINTS_OUT)

IMPORTANT INFORMATION

Contributor License Agreement (CLA)

ALABSTM commented 2 years ago

Hi @jelledevleeschouwer,

Thank you for your interesting proposal. It will be submitted to our development teams. I will get back to you with their feedback.

With regards,

ALABSTM commented 2 years ago

ST Internal Reference: 123857

ALABSTM commented 2 years ago

Hi @jelledevleeschouwer,

Your proposal has been logged internally. Our development team will further analyze it. I will keep you updated.

With regards,

RJMSTM commented 1 year ago

Hi @jelledevleeschouwer

Unfortunately, our development teams could not reproduce the issue you reported as could be source of overflow.

Effort to protect all access to Ep IN and OUT table is considerable

Hence, they consider there is no issue to fix. Please allow me to close this thread in this case. Thank you for your comprehension.

With regards, Rania