Skip to content

Make usbd_interface_init() weak so that it can be redefined in sketch or external library #341

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

Closed
edogaldo opened this issue Sep 27, 2018 · 5 comments
Assignees

Comments

@edogaldo
Copy link
Contributor

edogaldo commented Sep 27, 2018

Hello @fpistm, as I can understand function usbd_interface_init() is a hook to initiate USB function (HID at the moment) if required, correct?

int main( void )
{
initVariant();
#if defined(USBCON)
usbd_interface_init();
#endif

If yes, what about making its definition

void usbd_interface_init(void)
{
#ifdef USBD_USE_HID_COMPOSITE
/* Init Device Library */
USBD_Init(&hUSBD_Device_HID, &HID_Desc, 0);
/* Add Supported Class */
USBD_RegisterClass(&hUSBD_Device_HID, USBD_COMPOSITE_HID_CLASS);
/* Start Device Process */
USBD_Start(&hUSBD_Device_HID);
#endif // USBD_USE_HID_COMPOSITE
}

as weak so that users can redefine it in order to implement USB features in sketches or external libraries?

Thanks in advance and best, E.

@fpistm
Copy link
Member

fpistm commented Sep 28, 2018

Yes (at this moment).
As mentioned in other Issuer/PR this will be removed as USB will be moved in builtin library.

@edogaldo
Copy link
Contributor Author

Thank you @fpistm.
Which are the planning for including UBS?
In my opinion it would anyway be better to embed it as an external library that can be included if needed in order to avoid useled code bloating if not needed.
Going back to my question and your answer, "Yes (at this moment)", does it mean you will change

void usbd_interface_init(void)
{
  ...
}

to

__attribute__((weak))
void usbd_interface_init(void)
{
  ...
}

in the meantime?

Thanks, E.

@fpistm
Copy link
Member

fpistm commented Sep 28, 2018

I've answered here to @hasenbanck
#222 (comment)
What I would mean by "at this moment" is this part will be reviewed.

@fpistm
Copy link
Member

fpistm commented Oct 12, 2018

I guess this issue will be deprecated with #344

@edogaldo
Copy link
Contributor Author

Well, the aim of this issue is to request the possibility for the user to be able to define his own USB initialization procedure, possibly also at sketch level (and not only at variant level).
Any solution which goes in that direction is fine for me.

Cheers, E.

@fpistm fpistm self-assigned this Dec 12, 2018
fpistm added a commit to fpistm/Arduino_Core_STM32 that referenced this issue Dec 12, 2018
fpistm added a commit to fpistm/Arduino_Core_STM32 that referenced this issue Dec 13, 2018
fpistm added a commit to fpistm/Arduino_Core_STM32 that referenced this issue Dec 20, 2018
fpistm added a commit to fpistm/Arduino_Core_STM32 that referenced this issue Jan 4, 2019
fpistm added a commit to fpistm/Arduino_Core_STM32 that referenced this issue Jan 7, 2019
fpistm added a commit to fpistm/Arduino_Core_STM32 that referenced this issue Jan 8, 2019
fpistm added a commit to fpistm/Arduino_Core_STM32 that referenced this issue Jan 10, 2019
@fpistm fpistm closed this as completed in 9c012ab Jan 11, 2019
benwaffle pushed a commit to benwaffle/Arduino_Core_STM32 that referenced this issue Apr 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants