1
0
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:
Koen Zandberg 2019-02-06 12:00:19 +01:00
parent e98376c70d
commit ef68827559
No known key found for this signature in database
GPG Key ID: 0895A893E6D2985B
4 changed files with 55 additions and 0 deletions

View File

@ -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

View File

@ -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

View File

@ -0,0 +1,3 @@
MODULE = auto_init_usbus
include $(RIOTBASE)/Makefile.base

View 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);
}