diff --git a/sys/auto_init/Makefile b/sys/auto_init/Makefile index f4594496decb632f1353608a47be8e1fad22d603..c91330387348be2039a85c66480b6accc8b6e222 100644 --- a/sys/auto_init/Makefile +++ b/sys/auto_init/Makefile @@ -12,4 +12,8 @@ ifneq (,$(filter auto_init_ng_netif,$(USEMODULE))) DIRS += netif endif +ifneq (,$(filter dev_eth_autoinit,$(USEMODULE))) +DIRS += $(RIOTBASE)/sys/auto_init/dev_eth +endif + include $(RIOTBASE)/Makefile.base diff --git a/sys/auto_init/auto_init.c b/sys/auto_init/auto_init.c index fc287e2e48b9e4cd8926ebd3aecadbb968333c03..2ff3c8b489441f401a26d885ee520fae874e7f82 100644 --- a/sys/auto_init/auto_init.c +++ b/sys/auto_init/auto_init.c @@ -103,6 +103,11 @@ #include "net/ng_udp.h" #endif +#ifdef MODULE_DEV_ETH_AUTOINIT +#include "net/dev_eth.h" +#include "dev_eth_autoinit.h" +#endif + #define ENABLE_DEBUG (0) #include "debug.h" diff --git a/sys/auto_init/dev_eth/Makefile b/sys/auto_init/dev_eth/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..347f229678e44021c7fc81b2c63a632cfa6cc89a --- /dev/null +++ b/sys/auto_init/dev_eth/Makefile @@ -0,0 +1,3 @@ +MODULE = dev_eth_autoinit + +include $(RIOTBASE)/Makefile.base diff --git a/sys/auto_init/dev_eth/dev_eth_autoinit.c b/sys/auto_init/dev_eth/dev_eth_autoinit.c new file mode 100644 index 0000000000000000000000000000000000000000..fc37fe7c815828da1069a4165c8ea9a7243249ce --- /dev/null +++ b/sys/auto_init/dev_eth/dev_eth_autoinit.c @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2015 Kaspar Schleiser <kaspar@schleiser.de> + * + * 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. + */ + +#include "net/dev_eth.h" +#include "dev_eth_autoinit.h" + +#ifdef MODULE_NG_NATIVENET +#include "dev_eth_tap.h" +#endif + +#ifdef MODULE_ENCX24J600 +#include "encx24j600.h" +encx24j600_t dev_eth_encx24j600; +#endif + +dev_eth_t * const dev_eth_devices[] = { +#ifdef MODULE_NG_NATIVENET + [DEV_ETH_TAP] = (dev_eth_t*)&dev_eth_tap, +#endif +#ifdef MODULE_ENCX24J600 + [DEV_ETH_ENCX24J600] = (dev_eth_t*)&dev_eth_encx24j600, +#endif +}; + +void dev_eth_autoinit(void) +{ +#ifdef MODULE_ENCX24J600 + /* TODO: use sensible defines */ + encx24j600_setup(&dev_eth_encx24j600, SPI_0, GPIO_1, GPIO_2); +#endif +} diff --git a/sys/include/dev_eth_autoinit.h b/sys/include/dev_eth_autoinit.h new file mode 100644 index 0000000000000000000000000000000000000000..58fe198f099b6ca60e447835299fa198f212c101 --- /dev/null +++ b/sys/include/dev_eth_autoinit.h @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2015 Kaspar Schleiser <kaspar@schleiser.de> + * + * 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. + */ + +/** + * @defgroup sys_net_dev_eth dev_eth auto setup + * @ingroup sys_net_eth + * @file + * @brief Automatically setup available ethernet devices + * @{ + * + * @brief header for dev_eth automatic initialization + * + * @author Kaspar Schleiser <kaspar@schleiser.de> + */ + +#ifndef DEV_ETH_AUTOINIT_H +#define DEV_ETH_AUTOINIT_H + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief enum for available ethernet devices + */ +enum { +#ifdef MODULE_NG_NATIVENET + DEV_ETH_TAP, +#endif +#ifdef MODULE_ENCX24J600 + DEV_ETH_ENCX24J600, +#endif + /* must be last: */ + NUM_DEV_ETH +}; + +/** + * @brief Array of const pointers to available ethernet devices + */ +extern dev_eth_t *const dev_eth_devices[]; + +/** + * @brief Automatically sets up available dev_eth ethernet devices + * + * ... by calling the respective *_setup() functions if available. + */ +void dev_eth_autoinit(void); + +#ifdef __cplusplus +} +#endif +/** @} */ +#endif /* DEV_ETH_AUTOINIT_H */