mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
drivers/periph_common: add periph_init% module
This commit is contained in:
parent
0b1dce36ac
commit
6b6479e6e9
16
Makefile.dep
16
Makefile.dep
@ -1047,6 +1047,11 @@ FEATURES_REQUIRED += $(filter arch_%,$(FEATURES_PROVIDED))
|
||||
# FEATURES_USED is defined in Makefile.features
|
||||
USEMODULE += $(filter periph_%,$(FEATURES_USED))
|
||||
|
||||
# set all USED periph_% init modules as DEFAULT_MODULE
|
||||
ifneq (,$(filter periph_init, $(USEMODULE)))
|
||||
DEFAULT_MODULE += $(subst periph_,periph_init_,$(filter periph_%,$(FEATURES_USED)))
|
||||
endif
|
||||
|
||||
# select cpu_check_address pseudomodule if the corresponding feature is used
|
||||
USEMODULE += $(filter cpu_check_address, $(FEATURES_USED))
|
||||
|
||||
@ -1067,9 +1072,16 @@ ifneq ($(OLD_USEMODULE) $(OLD_USEPKG),$(USEMODULE) $(USEPKG))
|
||||
else
|
||||
# Add auto_init_% DEFAULT_MODULES. This is done after the recursive cach since
|
||||
# none of these modules can trigger dependency resolution.
|
||||
DEFAULT_MODULE := $(sort $(DEFAULT_MODULE))
|
||||
ifneq (,$(filter auto_init,$(USEMODULE)))
|
||||
DEFAULT_MODULE := $(sort $(DEFAULT_MODULE))
|
||||
USEMODULE += $(filter auto_init_%,$(filter-out $(DISABLE_MODULE),$(DEFAULT_MODULE)))
|
||||
USEMODULE := $(sort $(USEMODULE))
|
||||
endif
|
||||
|
||||
# Add auto_init_periph_% to DEFAULT_MODULES. This is done after the recursive
|
||||
# cach since none of these modules can trigger dependency resolution.
|
||||
ifneq (,$(filter periph_init,$(USEMODULE)))
|
||||
USEMODULE += $(filter periph_init_%,$(filter-out $(DISABLE_MODULE),$(DEFAULT_MODULE)))
|
||||
endif
|
||||
|
||||
USEMODULE := $(sort $(USEMODULE))
|
||||
endif
|
||||
|
@ -22,63 +22,68 @@
|
||||
|
||||
#define USB_H_USER_IS_RIOT_INTERNAL
|
||||
|
||||
#ifdef MODULE_PERIPH_I2C
|
||||
#ifdef MODULE_PERIPH_INIT
|
||||
#ifdef MODULE_PERIPH_INIT_I2C
|
||||
#include "periph/i2c.h"
|
||||
#endif
|
||||
#ifdef MODULE_PERIPH_SPI
|
||||
#ifdef MODULE_PERIPH_INIT_SPI
|
||||
#include "periph/spi.h"
|
||||
#endif
|
||||
#ifdef MODULE_PERIPH_RTC
|
||||
#ifdef MODULE_PERIPH_INIT_RTC
|
||||
#include "periph/rtc.h"
|
||||
#endif
|
||||
#ifdef MODULE_PERIPH_RTT
|
||||
#ifdef MODULE_PERIPH_INIT_RTT
|
||||
#include "periph/rtt.h"
|
||||
#endif
|
||||
#ifdef MODULE_PERIPH_HWRNG
|
||||
#ifdef MODULE_PERIPH_INIT_HWRNG
|
||||
#include "periph/hwrng.h"
|
||||
#endif
|
||||
#ifdef MODULE_PERIPH_USBDEV
|
||||
#ifdef MODULE_PERIPH_INIT_USBDEV
|
||||
#include "periph/usbdev.h"
|
||||
#endif
|
||||
#ifdef MODULE_PERIPH_WDT
|
||||
#ifdef MODULE_PERIPH_INIT_WDT
|
||||
#include "periph/wdt.h"
|
||||
#endif
|
||||
#endif /* MODULE_PERIPH_INIT */
|
||||
|
||||
void periph_init(void)
|
||||
{
|
||||
#ifdef MODULE_PERIPH_INIT
|
||||
/* initialize configured I2C devices */
|
||||
#ifdef MODULE_PERIPH_I2C
|
||||
#ifdef MODULE_PERIPH_INIT_I2C
|
||||
for (unsigned i = 0; i < I2C_NUMOF; i++) {
|
||||
i2c_init(I2C_DEV(i));
|
||||
}
|
||||
#endif
|
||||
|
||||
/* initialize configured SPI devices */
|
||||
#ifdef MODULE_PERIPH_SPI
|
||||
#ifdef MODULE_PERIPH_INIT_SPI
|
||||
for (unsigned i = 0; i < SPI_NUMOF; i++) {
|
||||
spi_init(SPI_DEV(i));
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Initialize RTC */
|
||||
#ifdef MODULE_PERIPH_RTC
|
||||
#ifdef MODULE_PERIPH_INIT_RTC
|
||||
rtc_init();
|
||||
#endif
|
||||
|
||||
/* Initialize RTT */
|
||||
#ifdef MODULE_PERIPH_RTT
|
||||
#ifdef MODULE_PERIPH_INIT_RTT
|
||||
rtt_init();
|
||||
#endif
|
||||
|
||||
#ifdef MODULE_PERIPH_HWRNG
|
||||
#ifdef MODULE_PERIPH_INIT_HWRNG
|
||||
hwrng_init();
|
||||
#endif
|
||||
|
||||
#ifdef MODULE_PERIPH_USBDEV
|
||||
#ifdef MODULE_PERIPH_INIT_USBDEV
|
||||
usbdev_init_lowlevel();
|
||||
#endif
|
||||
|
||||
#if defined(MODULE_PERIPH_WDT) && WDT_HAS_INIT
|
||||
#if defined(MODULE_PERIPH_INIT_WDT) && WDT_HAS_INIT
|
||||
wdt_init();
|
||||
#endif
|
||||
|
||||
#endif /* MODULE_PERIPH_INIT */
|
||||
}
|
||||
|
@ -1,3 +1,6 @@
|
||||
DEFAULT_MODULE += board cpu core core_init core_msg core_panic sys
|
||||
|
||||
DEFAULT_MODULE += auto_init
|
||||
|
||||
# Initialize all used peripherals by default
|
||||
DEFAULT_MODULE += periph_init
|
||||
|
Loading…
Reference in New Issue
Block a user