USB LLD of STM32 and Kinetis vs. AVR

Discussions and support about ChibiOS/HAL, the MCU Hardware Abstraction Layer.
lactide
Posts: 2
Joined: Tue Oct 17, 2017 8:24 pm

USB LLD of STM32 and Kinetis vs. AVR

Postby lactide » Sun Oct 22, 2017 6:10 pm

I've ported ChibiOS to the Nuvoton NUC122 and i've stumbled over the definition of the USBEndpointConfig:
What is the purpose of the following two fields in the USBEndpointConfig of the STM32 USB LLD?

Code: Select all

  /* End of the mandatory fields.*/
  /**
   * @brief   Reserved field, not currently used.
   * @note    Initialize this field to 1 in order to be forward compatible.
   */
  uint16_t                      ep_buffers;
  /**
   * @brief   Pointer to a buffer for setup packets.
   * @details Setup packets require a dedicated 8-bytes buffer, set this
   *          field to @p NULL for non-control endpoints.
   */
  uint8_t                       *setup_buf;

I couldn't find any use for them. ep_buffers seems to be set to either 1 or 2, depending on whether
it is only an IN/OUT endpoint or both. A buffer for the setup packet is included in the USBDriver structure anyway.

The STM32 USB LLD isn't the only one with those fields: the USB LLD of Kinetis has them as well.
I assume that it was done to make it easier for applications to create USBEndpointConfig structures that are valid
for both ChibiOS ports? The AVR USB LLD doesn't have those fields, so the application developer who wants
to run on those three ports will have to use #ifdefs when initializing his endpoint configs or provide
different modules depending on the port.

Now i'm asking myself whether i should add those two fields to my NUC122 port, because it might make the life
of the application developer easier who wants to support STM32/Kinetis/NUC122?
But since i don't see the purpose currently, i'm leaning towards the #ifdef for the application developer.

Maybe i'm just missing something here?

User avatar
Giovanni
Site Admin
Posts: 11019
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 354 times
Been thanked: 298 times
Contact:

Re: USB LLD of STM32 and Kinetis vs. AVR

Postby Giovanni » Sun Oct 22, 2017 6:53 pm

Hi,

Those fields are both non-mandatory, see the comment line just above them, those are required only by one of the two STM32 drivers, the other ones included those fields in order to have source compatibility with existing usbcfg.c/h files, it is a minor thing anyway.

Up to you to decide if to keep those or discard them.

I have a NUC140 board lying somewhere unused, is it similar?

Giovanni

lactide
Posts: 2
Joined: Tue Oct 17, 2017 8:24 pm

Re: USB LLD of STM32 and Kinetis vs. AVR

Postby lactide » Mon Oct 23, 2017 9:26 pm

ok, so i didn't missed something. Thanks for your response!

From skimming through the technical reference manual, the NUC140 is nearly identical.

I'll be able to prove that in a week when a batch of different devboards (including the 140) arrives here. Then i'll refine my port and create a pull request for the Contrib repository.


Return to “ChibiOS/HAL”

Who is online

Users browsing this forum: No registered users and 1 guest