Skip to content

Conversation

bergzand
Copy link
Member

@bergzand bergzand commented Feb 27, 2019

Contribution description

This code provides a simple auto_init structure for USB peripherals and USBUS provided functions. The auto_init as contributed is designed as a simple solution for the common case. It is intentionally not designed to solve all use cases.

Testing procedure

The example should now provide a USB device without any usb specific handling in the main.c code.

Issues/PRs references

Depends on #10916

image

@bergzand
Copy link
Member Author

With the move to usbdev devices as part of periph, I have to think a bit on how to rework the device setup itself. suggestions are welcome of course (@dylad @kaspar030).
Main requirement from usbus is that it needs the usbdev context on initialization.

One option is to move the $usbdev_setup() to the periph_init() of the cpu and add a getter to retrieve the context, something like usbdev_get_context(unsigned num) where num selects the usb peripheral number (many mid and high end STM32's and Kinetis MCU's have 2 USB interfaces).

@bergzand
Copy link
Member Author

One option is to move the $usbdev_setup() to the periph_init() of the cpu and add a getter to retrieve the context, something like usbdev_get_context(unsigned num) where num selects the usb peripheral number (many mid and high end STM32's and Kinetis MCU's have 2 USB interfaces).

I can try to come up with something tomorrow, see if it works out the way I'd like

@bergzand
Copy link
Member Author

rebased

@bergzand
Copy link
Member Author

Reworked this to use periph_init for the low level peripheral initialization. The usbdev_init() function itself is still called by the USB stack.

The usb stack initialization only has to call usbdev_get_ctx(0) to get the context for the first device and pass it to the usbus initialization.

@@ -0,0 +1,3 @@
ifneq (,$(filter periph_usbdev,$(USEMODULE)))
FEATURES_REQUIRED += periph_gpio_irq
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it still needed ?

@MrKevinWeiss MrKevinWeiss added this to the Release 2019.07 milestone Jun 3, 2019
@bergzand bergzand force-pushed the pr/usb/auto_init branch from 1a43f4e to 6ef452a Compare June 5, 2019 13:24
@bergzand
Copy link
Member Author

bergzand commented Jun 5, 2019

Rebased (I think)

Copy link
Member

@dylad dylad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, I'll test it on hardware

#include "usb/usbus.h"

#define ENABLE_DEBUG (0)
#include "debug.h"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed!

@dylad dylad added Reviewed: 1-fundamentals The fundamentals of the PR were reviewed according to the maintainer guidelines Reviewed: 2-code-design The code design of the PR was reviewed according to the maintainer guidelines Reviewed: 3-testing The PR was tested according to the maintainer guidelines Reviewed: 4-code-style The adherence to coding conventions by the PR were reviewed according to the maintainer guidelines Reviewed: 5-documentation The documentation details of the PR were reviewed according to the maintainer guidelines labels Jun 5, 2019
Copy link
Member

@dylad dylad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works fine.
ACK !
Please squash

@bergzand bergzand force-pushed the pr/usb/auto_init branch from 1558fca to 8246b09 Compare June 5, 2019 14:17
@bergzand
Copy link
Member Author

bergzand commented Jun 5, 2019

Squashed!

@bergzand bergzand added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Jun 5, 2019
@dylad
Copy link
Member

dylad commented Jun 5, 2019

Here we go

@dylad dylad merged commit e1f6b08 into RIOT-OS:master Jun 5, 2019
@bergzand
Copy link
Member Author

bergzand commented Jun 5, 2019

Thanks again!

@bergzand bergzand deleted the pr/usb/auto_init branch June 5, 2019 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: USB Area: Universal Serial Bus CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Reviewed: 1-fundamentals The fundamentals of the PR were reviewed according to the maintainer guidelines Reviewed: 2-code-design The code design of the PR was reviewed according to the maintainer guidelines Reviewed: 3-testing The PR was tested according to the maintainer guidelines Reviewed: 4-code-style The adherence to coding conventions by the PR were reviewed according to the maintainer guidelines Reviewed: 5-documentation The documentation details of the PR were reviewed according to the maintainer guidelines Type: new feature The issue requests / The PR implemements a new feature for RIOT
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants