diff --git a/boards/common/atmega/board.c b/boards/common/atmega/board.c index 40605c4c2e090ab08c1ecbd0db343b058da44bf4..a85199b828898964946931a715d26de7dc98d4b7 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 36b121046d86cfe8abb8de4d65a7d635581250ba..abedc5d67e5e8f83514ac69bf843aaf0a774e3c3 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 8f1257b6783d14f28e94fef1db46d4cf366daca3..41d51c7b311342d49081bbcde2bdcd80634e945c 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 5624d68a0799f8a2a1cf0f14cb9cf1b2b501ba79..3fe1fb61404b045b8d81dae58b731e2e82e7d412 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 0000000000000000000000000000000000000000..48422e909a47d7cd428d10fa73825060ccc8d8c2 --- /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