mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
pkg/tinyusb: use auto_init for tinyusb stack and thread setup
This commit is contained in:
parent
bb883cdef3
commit
bb337cde8e
@ -42,6 +42,15 @@ menuconfig PACKAGE_TINYUSB
|
||||
|
||||
if PACKAGE_TINYUSB
|
||||
|
||||
config MODULE_AUTO_INIT_TINYUSB
|
||||
bool "Auto-initialize the tinyUSB package"
|
||||
default y
|
||||
depends on MODULE_AUTO_INIT
|
||||
help
|
||||
The tinyUSB stack including the used peripherals are initialized
|
||||
automatically at startup. Additionally, the auto-initialization
|
||||
starts the tinyUSB thread.
|
||||
|
||||
config MODULE_TINYUSB_COMMON
|
||||
bool
|
||||
help
|
||||
|
@ -6,6 +6,8 @@ USEMODULE += tinyusb_common
|
||||
USEMODULE += tinyusb_contrib
|
||||
USEMODULE += tinyusb_hw
|
||||
|
||||
DEFAULT_MODULE += auto_init_tinyusb
|
||||
|
||||
ifeq (,$(filter tinyusb_class_%,$(USEMODULE)))
|
||||
$(error At least one tinyusb_class_* module has to be enabled)
|
||||
endif
|
||||
|
@ -16,6 +16,10 @@
|
||||
#include "tinyusb.h"
|
||||
#include "tinyusb_hw.h"
|
||||
|
||||
#if IS_USED(MODULE_AUTO_INIT)
|
||||
#include "auto_init_utils.h"
|
||||
#endif
|
||||
|
||||
#define ENABLE_DEBUG 0
|
||||
#include "debug.h"
|
||||
|
||||
@ -79,3 +83,12 @@ int tinyusb_setup(void)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void tinyusb_auto_init(void)
|
||||
{
|
||||
tinyusb_setup();
|
||||
}
|
||||
|
||||
#if IS_USED(MODULE_AUTO_INIT_TINYUSB)
|
||||
AUTO_INIT(tinyusb_auto_init, AUTO_INIT_PRIO_MOD_TINYUSB);
|
||||
#endif
|
||||
|
@ -26,14 +26,17 @@
|
||||
* USEMODULE += tinyusb_class_cdc tinyusb_class_msc
|
||||
* ```
|
||||
*
|
||||
* Add `tinyusb_setup()` to your main function to initialize the tinyUSB stack
|
||||
* including used peripherals and to start the tinyUSB thread.
|
||||
* Either add `tinyusb_setup()` to your main function to explicitly initialize
|
||||
* the tinyUSB stack including the used peripherals and start the tinyUSB
|
||||
* thread, or use the `auto_init` module (**default**).
|
||||
*
|
||||
* ```c
|
||||
* int main(void)
|
||||
* {
|
||||
* ...
|
||||
* // If auto-initialization is not used (module `auto_init`),
|
||||
* // initialize the tinyUSB stack including used peripherals and
|
||||
* // start the tinyUSB thread
|
||||
* // start the tinyUSB thread. Auto-initialization is used by default.
|
||||
* tinyusb_setup();
|
||||
*
|
||||
* while (1) {
|
||||
|
@ -239,6 +239,12 @@ extern "C" {
|
||||
*/
|
||||
#define AUTO_INIT_PRIO_MOD_USBUS 1350
|
||||
#endif
|
||||
#ifndef AUTO_INIT_PRIO_MOD_TINYUSB
|
||||
/**
|
||||
* @brief tinyUSB priority
|
||||
*/
|
||||
#define AUTO_INIT_PRIO_MOD_TINYUSB 1350
|
||||
#endif
|
||||
#ifndef AUTO_INIT_PRIO_MOD_GNRC_NETIF
|
||||
/**
|
||||
* @brief GNRC netif priority
|
||||
|
@ -88,9 +88,12 @@ int main(void)
|
||||
THREAD_CREATE_WOUT_YIELD | THREAD_CREATE_STACKTEST,
|
||||
led_thread_impl, NULL, "led");
|
||||
|
||||
/* initialize the tinyUSB stack including used peripherals and
|
||||
* start the tinyUSB thread */
|
||||
tinyusb_setup();
|
||||
if (!IS_USED(MODULE_AUTO_INIT)) {
|
||||
/* If auto-initialization is not used (module `auto_init`),
|
||||
* initialize the tinyUSB stack including used peripherals and
|
||||
* start the tinyUSB thread. Auto-initialization is used by default. */
|
||||
tinyusb_setup();
|
||||
}
|
||||
|
||||
while (1) {
|
||||
ztimer_sleep(ZTIMER_MSEC, 10);
|
||||
|
Loading…
Reference in New Issue
Block a user