1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

usbus_cdc_ecm: provide auto init integration

This commit is contained in:
Koen Zandberg 2019-02-27 22:23:14 +01:00
parent 9b68dec385
commit 3726bf62d3
No known key found for this signature in database
GPG Key ID: 0895A893E6D2985B
3 changed files with 73 additions and 0 deletions

View File

@ -261,6 +261,11 @@ void auto_init(void)
auto_init_kw2xrf();
#endif
#ifdef MODULE_USBUS_CDC_ECM
extern void auto_init_netdev_cdcecm(void);
auto_init_netdev_cdcecm();
#endif
#ifdef MODULE_NETDEV_TAP
extern void auto_init_netdev_tap(void);
auto_init_netdev_tap();

View File

@ -0,0 +1,59 @@
/*
* Copyright (C) 2019 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_gnrc_netif
* @{
*
* @file
* @brief Auto initialization for USB CDC ECM module
*
* @author Koen Zandberg <koen@bergzand.net>
*/
#ifdef MODULE_USBUS_CDC_ECM
#include "log.h"
#include "usb/usbus/cdc/ecm.h"
#include "net/gnrc/netif/ethernet.h"
/**
* @brief global cdc ecm object, declared in the usb auto init file
*/
extern usbus_cdcecm_device_t cdcecm;
/**
* @brief Define stack parameters for the MAC layer thread
* @{
*/
#define CDCECM_MAC_STACKSIZE (THREAD_STACKSIZE_DEFAULT)
#ifndef CDCECM_MAC_PRIO
#define CDCECM_MAC_PRIO (GNRC_NETIF_PRIO)
#endif
/**
* @brief Stacks for the MAC layer threads
*/
static char _netdev_eth_stack[CDCECM_MAC_STACKSIZE];
extern void cdcecm_netdev_setup(usbus_cdcecm_device_t *cdcecm);
void auto_init_netdev_cdcecm(void)
{
LOG_DEBUG("[auto_init_netif] initializing cdc ecm #0\n");
cdcecm_netdev_setup(&cdcecm);
/* initialize netdev<->gnrc adapter state */
gnrc_netif_ethernet_create(_netdev_eth_stack, CDCECM_MAC_STACKSIZE,
CDCECM_MAC_PRIO, "cdcecm", &cdcecm.netdev);
}
#else
typedef int dont_be_pedantic;
#endif /* MODULE_CDC_ECM */
/** @} */

View File

@ -24,6 +24,11 @@
#include "usb/usbus.h"
#ifdef MODULE_USBUS_CDC_ECM
#include "usb/usbus/cdc/ecm.h"
usbus_cdcecm_device_t cdcecm;
#endif
static char _stack[USBUS_STACKSIZE];
static usbus_t usbus;
@ -36,6 +41,10 @@ void auto_init_usb(void)
/* Initialize basic usbus struct, don't start the thread yet */
usbus_init(&usbus, usbdev);
/* USBUS function handlers initialization */
#ifdef MODULE_USBUS_CDC_ECM
usbus_cdcecm_init(&usbus, &cdcecm);
#endif
/* Finally initialize USBUS thread */
usbus_create(_stack, USBUS_STACKSIZE, USBUS_PRIO, USBUS_TNAME, &usbus);