From 7313525035f768c9e864fd296dbaffb8f3c96a57 Mon Sep 17 00:00:00 2001 From: Kaspar Schleiser Date: Fri, 27 Apr 2018 12:17:01 +0200 Subject: [PATCH] atmega_common: refactor avr-libc-extra into avr_libc_extra module --- boards/common/atmega/board.c | 5 +++++ boards/waspmote-pro/board.c | 3 +++ cpu/atmega_common/Makefile | 2 +- cpu/atmega_common/Makefile.include | 7 ++++++- cpu/atmega_common/avr_libc_extra/Makefile | 1 + cpu/atmega_common/{ => avr_libc_extra}/atmega_stdio.c | 0 .../{include/vendor => avr_libc_extra/include}/errno.h | 0 .../{include/vendor => avr_libc_extra/include}/inttypes.h | 0 cpu/atmega_common/{ => avr_libc_extra}/include/sys/time.h | 0 cpu/atmega_common/{ => avr_libc_extra}/include/sys/types.h | 0 .../{include/vendor => avr_libc_extra/include}/unistd.h | 0 .../{include => avr_libc_extra/include/vendor}/sys/stat.h | 0 .../{ => avr_libc_extra}/include/vendor/time.h | 0 cpu/atmega_common/{ => avr_libc_extra}/posix_unistd.c | 0 14 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 cpu/atmega_common/avr_libc_extra/Makefile rename cpu/atmega_common/{ => avr_libc_extra}/atmega_stdio.c (100%) rename cpu/atmega_common/{include/vendor => avr_libc_extra/include}/errno.h (100%) rename cpu/atmega_common/{include/vendor => avr_libc_extra/include}/inttypes.h (100%) rename cpu/atmega_common/{ => avr_libc_extra}/include/sys/time.h (100%) rename cpu/atmega_common/{ => avr_libc_extra}/include/sys/types.h (100%) rename cpu/atmega_common/{include/vendor => avr_libc_extra/include}/unistd.h (100%) rename cpu/atmega_common/{include => avr_libc_extra/include/vendor}/sys/stat.h (100%) rename cpu/atmega_common/{ => avr_libc_extra}/include/vendor/time.h (100%) rename cpu/atmega_common/{ => avr_libc_extra}/posix_unistd.c (100%) diff --git a/boards/common/atmega/board.c b/boards/common/atmega/board.c index 40605c4c2e..a85199b828 100644 --- a/boards/common/atmega/board.c +++ b/boards/common/atmega/board.c @@ -31,8 +31,13 @@ void led_init(void); void board_init(void) { + atmega_set_prescaler(CPU_ATMEGA_CLK_SCALE_INIT); + +#ifdef MODULE_AVR_LIBC_EXTRA atmega_stdio_init(); +#endif + cpu_init(); led_init(); irq_enable(); diff --git a/boards/waspmote-pro/board.c b/boards/waspmote-pro/board.c index 36b121046d..abedc5d67e 100644 --- a/boards/waspmote-pro/board.c +++ b/boards/waspmote-pro/board.c @@ -58,7 +58,10 @@ void board_init(void) #endif #endif +#ifdef MODULE_AVR_LIBC_EXTRA atmega_stdio_init(); +#endif + cpu_init(); led_init(); irq_enable(); diff --git a/cpu/atmega_common/Makefile b/cpu/atmega_common/Makefile index 8f1257b678..41d51c7b31 100644 --- a/cpu/atmega_common/Makefile +++ b/cpu/atmega_common/Makefile @@ -2,6 +2,6 @@ MODULE = atmega_common # add a list of subdirectories, that should also be build -DIRS = periph +DIRS = periph avr_libc_extra include $(RIOTBASE)/Makefile.base diff --git a/cpu/atmega_common/Makefile.include b/cpu/atmega_common/Makefile.include index 5624d68a07..3fe1fb6140 100644 --- a/cpu/atmega_common/Makefile.include +++ b/cpu/atmega_common/Makefile.include @@ -18,7 +18,9 @@ export USEMODULE += periph_common export USEMODULE += stdio_uart # include module specific includes -export INCLUDES += -I$(RIOTCPU)/atmega_common/include -isystem$(RIOTCPU)/atmega_common/include/vendor +export INCLUDES += -I$(RIOTCPU)/atmega_common/include \ + -isystem$(RIOTCPU)/atmega_common/avr_libc_extra/include \ + -isystem$(RIOTCPU)/atmega_common/avr_libc_extra/include/vendor ifeq ($(LTO),1) # avr-gcc <4.8.3 has a bug when using LTO which causes a warning to be printed always: @@ -37,3 +39,6 @@ LINKFLAGS += $(LINKFLAGPREFIX)--defsym=__DATA_REGION_LENGTH__=$(RAM_LEN) LDSCRIPT_COMPAT = $(if $(shell $(TARGET_ARCH)-ld --verbose | grep __TEXT_REGION_LENGTH__),,\ -T$(RIOTCPU)/$(CPU)/ldscripts_compat/avr_2.26.ld) LINKFLAGS += $(LDSCRIPT_COMPAT) + +# avr libc needs some RIOT-specific support code +USEMODULE += avr_libc_extra diff --git a/cpu/atmega_common/avr_libc_extra/Makefile b/cpu/atmega_common/avr_libc_extra/Makefile new file mode 100644 index 0000000000..48422e909a --- /dev/null +++ b/cpu/atmega_common/avr_libc_extra/Makefile @@ -0,0 +1 @@ +include $(RIOTBASE)/Makefile.base diff --git a/cpu/atmega_common/atmega_stdio.c b/cpu/atmega_common/avr_libc_extra/atmega_stdio.c similarity index 100% rename from cpu/atmega_common/atmega_stdio.c rename to cpu/atmega_common/avr_libc_extra/atmega_stdio.c diff --git a/cpu/atmega_common/include/vendor/errno.h b/cpu/atmega_common/avr_libc_extra/include/errno.h similarity index 100% rename from cpu/atmega_common/include/vendor/errno.h rename to cpu/atmega_common/avr_libc_extra/include/errno.h diff --git a/cpu/atmega_common/include/vendor/inttypes.h b/cpu/atmega_common/avr_libc_extra/include/inttypes.h similarity index 100% rename from cpu/atmega_common/include/vendor/inttypes.h rename to cpu/atmega_common/avr_libc_extra/include/inttypes.h diff --git a/cpu/atmega_common/include/sys/time.h b/cpu/atmega_common/avr_libc_extra/include/sys/time.h similarity index 100% rename from cpu/atmega_common/include/sys/time.h rename to cpu/atmega_common/avr_libc_extra/include/sys/time.h diff --git a/cpu/atmega_common/include/sys/types.h b/cpu/atmega_common/avr_libc_extra/include/sys/types.h similarity index 100% rename from cpu/atmega_common/include/sys/types.h rename to cpu/atmega_common/avr_libc_extra/include/sys/types.h diff --git a/cpu/atmega_common/include/vendor/unistd.h b/cpu/atmega_common/avr_libc_extra/include/unistd.h similarity index 100% rename from cpu/atmega_common/include/vendor/unistd.h rename to cpu/atmega_common/avr_libc_extra/include/unistd.h diff --git a/cpu/atmega_common/include/sys/stat.h b/cpu/atmega_common/avr_libc_extra/include/vendor/sys/stat.h similarity index 100% rename from cpu/atmega_common/include/sys/stat.h rename to cpu/atmega_common/avr_libc_extra/include/vendor/sys/stat.h diff --git a/cpu/atmega_common/include/vendor/time.h b/cpu/atmega_common/avr_libc_extra/include/vendor/time.h similarity index 100% rename from cpu/atmega_common/include/vendor/time.h rename to cpu/atmega_common/avr_libc_extra/include/vendor/time.h diff --git a/cpu/atmega_common/posix_unistd.c b/cpu/atmega_common/avr_libc_extra/posix_unistd.c similarity index 100% rename from cpu/atmega_common/posix_unistd.c rename to cpu/atmega_common/avr_libc_extra/posix_unistd.c