diff --git a/drivers/periph_common/Makefile b/drivers/periph_common/Makefile index 48422e909a..ab69432bf6 100644 --- a/drivers/periph_common/Makefile +++ b/drivers/periph_common/Makefile @@ -1 +1,7 @@ +PERIPH_COMMON_MODULES_SRCS_ALL = $(filter-out init.c,$(wildcard *.c)) +PERIPH_COMMON_MODULES_NAMES = $(subst .c,,$(PERIPH_COMMON_MODULES_SRCS_ALL)) +PERIPH_COMMON_MODULES = $(addprefix periph_, $(PERIPH_COMMON_MODULES_NAMES)) +PERIPH_COMMON_MODULES_USED = $(filter $(PERIPH_COMMON_MODULES),$(USEMODULE)) +SRC = init.c $(subst periph_,,$(addsuffix .c,$(PERIPH_COMMON_MODULES_USED))) + include $(RIOTBASE)/Makefile.base diff --git a/drivers/periph_common/eeprom.c b/drivers/periph_common/eeprom.c index ccbcea7846..d666179836 100644 --- a/drivers/periph_common/eeprom.c +++ b/drivers/periph_common/eeprom.c @@ -23,9 +23,6 @@ #include "periph_cpu.h" #include "assert.h" -/* guard this file, must be done before including periph/eeprom.h */ -#if defined(EEPROM_SIZE) - #include "periph/eeprom.h" uint8_t eeprom_read_byte(uint32_t pos) @@ -60,4 +57,3 @@ size_t eeprom_erase(void) { return eeprom_clear(0, EEPROM_SIZE); } -#endif diff --git a/drivers/periph_common/flashpage.c b/drivers/periph_common/flashpage.c index 05252e1f6e..4ccb422972 100644 --- a/drivers/periph_common/flashpage.c +++ b/drivers/periph_common/flashpage.c @@ -22,13 +22,8 @@ #include "cpu.h" #include "assert.h" -/* guard this file, must be done before including periph/flashpage.h - * TODO: remove as soon as periph drivers can be build selectively */ -#if defined(FLASHPAGE_SIZE) || defined(PERIPH_FLASHPAGE_CUSTOM_PAGESIZES) #include "periph/flashpage.h" -#endif -#ifdef MODULE_PERIPH_FLASHPAGE_PAGEWISE void flashpage_read(unsigned page, void *data) { assert(page < FLASHPAGE_NUMOF); @@ -64,6 +59,7 @@ int flashpage_write_and_verify(unsigned page, const void *data) return flashpage_verify(page, data); } +#ifdef FLASHPAGE_SIZE void flashpage_write_page(unsigned page, const void *data) { assert((unsigned) page < FLASHPAGE_NUMOF); @@ -75,7 +71,7 @@ void flashpage_write_page(unsigned page, const void *data) flashpage_write(flashpage_addr(page), data, FLASHPAGE_SIZE); } } -#endif /* MODULE_PERIPH_FLASHPAGE_PAGEWISE */ +#endif #if defined(FLASHPAGE_RWWEE_NUMOF) void flashpage_rwwee_read(unsigned page, void *data) diff --git a/drivers/periph_common/gpio_util.c b/drivers/periph_common/gpio.c similarity index 90% rename from drivers/periph_common/gpio_util.c rename to drivers/periph_common/gpio.c index 54f960cf4b..5d2a172884 100644 --- a/drivers/periph_common/gpio_util.c +++ b/drivers/periph_common/gpio.c @@ -9,8 +9,6 @@ #include "periph/gpio.h" #include -#ifdef MODULE_PERIPH_GPIO - uint8_t gpio_util_shiftin(gpio_t data_pin, gpio_t clock_pin) { uint8_t byte = 0x00; @@ -25,5 +23,3 @@ uint8_t gpio_util_shiftin(gpio_t data_pin, gpio_t clock_pin) return byte; } - -#endif /* MODULE_PERIPH_GPIO */ diff --git a/drivers/periph_common/i2c.c b/drivers/periph_common/i2c.c index eb33e30937..b5e036bd6a 100644 --- a/drivers/periph_common/i2c.c +++ b/drivers/periph_common/i2c.c @@ -24,8 +24,6 @@ #include "periph/i2c.h" #include "byteorder.h" -#ifdef I2C_NUMOF - #ifdef PERIPH_I2C_NEED_READ_REG int i2c_read_reg(i2c_t dev, uint16_t addr, uint16_t reg, void *data, uint8_t flags) @@ -103,5 +101,3 @@ int i2c_write_regs(i2c_t dev, uint16_t addr, uint16_t reg, return i2c_write_bytes(dev, addr, data, len, flags | I2C_NOSTART); } #endif /* PERIPH_I2C_NEED_WRITE_REGS */ - -#endif /* I2C_NUMOF */ diff --git a/drivers/periph_common/ptp.c b/drivers/periph_common/ptp_timer.c similarity index 94% rename from drivers/periph_common/ptp.c rename to drivers/periph_common/ptp_timer.c index 4d0f2c8edc..a736e9758e 100644 --- a/drivers/periph_common/ptp.c +++ b/drivers/periph_common/ptp_timer.c @@ -18,7 +18,6 @@ * @} */ #include "kernel_defines.h" -#if IS_USED(MODULE_PERIPH_PTP_TIMER) #include "irq.h" #include "periph/ptp.h" @@ -45,6 +44,3 @@ void ptp_timer_set_u64(uint64_t target) irq_restore(irq_state); } #endif /* !defined(HAVE_PTP_TIMER_SET_U64) */ -#else -typedef int dont_be_pedantic; -#endif diff --git a/drivers/periph_common/spi.c b/drivers/periph_common/spi.c index 5cdb99612c..8b5edad7e8 100644 --- a/drivers/periph_common/spi.c +++ b/drivers/periph_common/spi.c @@ -25,8 +25,6 @@ #include "cpu.h" #include "periph/spi.h" -#ifdef SPI_NUMOF - #ifdef PERIPH_SPI_NEEDS_INIT_CS int spi_init_cs(spi_t bus, spi_cs_t cs) { @@ -69,5 +67,3 @@ void spi_transfer_regs(spi_t bus, spi_cs_t cs, spi_transfer_bytes(bus, cs, false, out, in, len); } #endif - -#endif /* SPI_NUMOF */