mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
auto_init_usb: initial implementation
This commit is contained in:
parent
e98376c70d
commit
ef68827559
@ -18,4 +18,8 @@ ifneq (,$(filter auto_init_loramac,$(USEMODULE)))
|
||||
DIRS += loramac
|
||||
endif
|
||||
|
||||
ifneq (,$(filter auto_init_usbus,$(USEMODULE)))
|
||||
DIRS += usb
|
||||
endif
|
||||
|
||||
include $(RIOTBASE)/Makefile.base
|
||||
|
@ -182,6 +182,12 @@ void auto_init(void)
|
||||
auto_init_loramac();
|
||||
#endif
|
||||
|
||||
/* initialize USB devices */
|
||||
#ifdef MODULE_AUTO_INIT_USBUS
|
||||
extern void auto_init_usb(void);
|
||||
auto_init_usb();
|
||||
#endif
|
||||
|
||||
/* initialize network devices */
|
||||
#ifdef MODULE_AUTO_INIT_GNRC_NETIF
|
||||
|
||||
|
3
sys/auto_init/usb/Makefile
Normal file
3
sys/auto_init/usb/Makefile
Normal file
@ -0,0 +1,3 @@
|
||||
MODULE = auto_init_usbus
|
||||
|
||||
include $(RIOTBASE)/Makefile.base
|
42
sys/auto_init/usb/auto_init_usb.c
Normal file
42
sys/auto_init/usb/auto_init_usb.c
Normal file
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (C) 2018 Koen Zandberg
|
||||
*
|
||||
* This file is subject to the terms and conditions of the GNU Lesser
|
||||
* General Public License v2.1. See the file LICENSE in the top level
|
||||
* directory for more details.
|
||||
*/
|
||||
/**
|
||||
* @ingroup sys_auto_init
|
||||
* @{
|
||||
* @file
|
||||
* @brief initializes USBUS, usb devices and handlers
|
||||
*
|
||||
* This auto initialization for USBUS is designed to cover the common use case
|
||||
* of a single usb peripheral. An USBUS instance is started with USB function
|
||||
* handlers based on which module is compiled in.
|
||||
*
|
||||
* If this doesn't suit your use case, a different intialization function can
|
||||
* to be created based on this initialization sequence.
|
||||
*
|
||||
* @author Koen Zandberg <koen@bergzand.net>
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include "usb/usbus.h"
|
||||
|
||||
static char _stack[USBUS_STACKSIZE];
|
||||
static usbus_t usbus;
|
||||
|
||||
void auto_init_usb(void)
|
||||
{
|
||||
/* Get driver context */
|
||||
usbdev_t *usbdev = usbdev_get_ctx(0);
|
||||
assert(usbdev);
|
||||
|
||||
/* Initialize basic usbus struct, don't start the thread yet */
|
||||
usbus_init(&usbus, usbdev);
|
||||
|
||||
|
||||
/* Finally initialize USBUS thread */
|
||||
usbus_create(_stack, USBUS_STACKSIZE, USBUS_PRIO, USBUS_TNAME, &usbus);
|
||||
}
|
Loading…
Reference in New Issue
Block a user