From 9c6ab1007b68331f3caed6f75b68ddc087f0f7e0 Mon Sep 17 00:00:00 2001 From: Oleg Hahm Date: Tue, 4 Aug 2015 17:06:03 +0200 Subject: [PATCH] applications: only use uart0 for none-newlib boards --- examples/default/main.c | 14 +++++++++++--- examples/gnrc_networking/main.c | 17 +++++++++++++---- tests/driver_at86rf2xx/main.c | 12 ++++++++++-- tests/driver_kw2xrf/main.c | 14 +++++++++++--- tests/driver_nrfmin/main.c | 14 +++++++++++--- tests/driver_pcd8544/main.c | 14 +++++++++++--- tests/periph_gpio/main.c | 14 +++++++++++--- tests/periph_i2c/main.c | 17 +++++++++++++---- 8 files changed, 91 insertions(+), 25 deletions(-) diff --git a/examples/default/main.c b/examples/default/main.c index df24568dce..8fddc04f40 100644 --- a/examples/default/main.c +++ b/examples/default/main.c @@ -26,10 +26,14 @@ #include #include "thread.h" -#include "posix_io.h" +#ifdef MODULE_NEWLIB +# include "uart_stdio.h" +#else +# include "posix_io.h" +# include "board_uart0.h" +#endif #include "shell.h" #include "shell_commands.h" -#include "board_uart0.h" #if FEATURE_PERIPH_RTC #include "periph/rtc.h" @@ -42,7 +46,6 @@ int main(void) { shell_t shell; - (void) posix_open(uart0_handler_pid, 0); #ifdef MODULE_LTC4150 ltc4150_start(); @@ -54,7 +57,12 @@ int main(void) (void) puts("Welcome to RIOT!"); +#ifndef MODULE_NEWLIB + (void) posix_open(uart0_handler_pid, 0); shell_init(&shell, NULL, UART0_BUFSIZE, uart0_readc, uart0_putc); +#else + shell_init(&shell, NULL, UART0_BUFSIZE, getchar, putchar); +#endif shell_run(&shell); return 0; diff --git a/examples/gnrc_networking/main.c b/examples/gnrc_networking/main.c index b686ad97e2..36181304d1 100644 --- a/examples/gnrc_networking/main.c +++ b/examples/gnrc_networking/main.c @@ -20,9 +20,14 @@ #include +#include "kernel.h" #include "shell.h" -#include "board_uart0.h" -#include "posix_io.h" +#ifdef MODULE_NEWLIB +# include "uart_stdio.h" +#else +# include "posix_io.h" +# include "board_uart0.h" +#endif extern int udp_cmd(int argc, char **argv); @@ -39,8 +44,12 @@ int main(void) /* start shell */ puts("All up, running the shell now"); - posix_open(uart0_handler_pid, 0); - shell_init(&shell, shell_commands, UART0_BUFSIZE, uart0_readc, uart0_putc); +#ifndef MODULE_NEWLIB + (void) posix_open(uart0_handler_pid, 0); + shell_init(&shell, NULL, UART0_BUFSIZE, uart0_readc, uart0_putc); +#else + shell_init(&shell, NULL, UART0_BUFSIZE, getchar, putchar); +#endif shell_run(&shell); /* should be never reached */ diff --git a/tests/driver_at86rf2xx/main.c b/tests/driver_at86rf2xx/main.c index 40efb9bbd3..e15a4f0da8 100644 --- a/tests/driver_at86rf2xx/main.c +++ b/tests/driver_at86rf2xx/main.c @@ -22,8 +22,12 @@ #include "shell.h" #include "shell_commands.h" -#include "posix_io.h" -#include "board_uart0.h" +#ifdef MODULE_NEWLIB +# include "uart_stdio.h" +#else +# include "posix_io.h" +# include "board_uart0.h" +#endif #include "net/gnrc/pktdump.h" #include "net/gnrc.h" @@ -50,8 +54,12 @@ int main(void) /* start the shell */ puts("Initialization successful - starting the shell now"); +#ifndef MODULE_NEWLIB (void) posix_open(uart0_handler_pid, 0); shell_init(&shell, NULL, SHELL_BUFSIZE, uart0_readc, uart0_putc); +#else + shell_init(&shell, NULL, SHELL_BUFSIZE, getchar, putchar); +#endif shell_run(&shell); return 0; diff --git a/tests/driver_kw2xrf/main.c b/tests/driver_kw2xrf/main.c index f3047dfd2b..180c5c2d3b 100644 --- a/tests/driver_kw2xrf/main.c +++ b/tests/driver_kw2xrf/main.c @@ -21,8 +21,12 @@ #include "shell.h" #include "shell_commands.h" -#include "posix_io.h" -#include "board_uart0.h" +#ifdef MODULE_NEWLIB +# include "uart_stdio.h" +#else +# include "posix_io.h" +# include "board_uart0.h" +#endif #include "net/gnrc.h" #include "net/gnrc/pktdump.h" @@ -46,9 +50,13 @@ int main(void) /* start the shell */ puts("Initialization successful - starting the shell now"); +#ifndef MODULE_NEWLIB (void) posix_open(uart0_handler_pid, 0); shell_init(&shell, NULL, SHELL_BUFSIZE, uart0_readc, uart0_putc); - shell_run(&shell); +#else + shell_init(&shell, NULL, SHELL_BUFSIZE, getchar, putchar); +#endif + shell_run(&shell); return 0; } diff --git a/tests/driver_nrfmin/main.c b/tests/driver_nrfmin/main.c index 3ad26ecb69..33ae63c133 100644 --- a/tests/driver_nrfmin/main.c +++ b/tests/driver_nrfmin/main.c @@ -21,8 +21,12 @@ #include #include "shell.h" -#include "posix_io.h" -#include "board_uart0.h" +#ifdef MODULE_NEWLIB +# include "uart_stdio.h" +#else +# include "posix_io.h" +# include "board_uart0.h" +#endif #include "nrfmin.h" #include "net/gnrc.h" #include "net/gnrc/nomac.h" @@ -51,9 +55,13 @@ int main(void) gnrc_netreg_register(GNRC_NETTYPE_UNDEF, &netobj); /* initialize and run the shell */ +#ifndef MODULE_NEWLIB board_uart0_init(); - posix_open(uart0_handler_pid, 0); + (void) posix_open(uart0_handler_pid, 0); shell_init(&shell, NULL, SHELL_BUFSIZE, uart0_readc, uart0_putc); +#else + shell_init(&shell, NULL, SHELL_BUFSIZE, getchar, putchar); +#endif shell_run(&shell); return 0; diff --git a/tests/driver_pcd8544/main.c b/tests/driver_pcd8544/main.c index 56bbcf2ca6..a29519cde8 100644 --- a/tests/driver_pcd8544/main.c +++ b/tests/driver_pcd8544/main.c @@ -35,8 +35,12 @@ #include #include -#include "posix_io.h" -#include "board_uart0.h" +#ifdef MODULE_NEWLIB +# include "uart_stdio.h" +#else +# include "posix_io.h" +# include "board_uart0.h" +#endif #include "shell.h" #include "pcd8544.h" @@ -170,8 +174,12 @@ int main(void) /* run shell */ puts("All OK, running shell now"); +#ifndef MODULE_NEWLIB (void) posix_open(uart0_handler_pid, 0); - shell_init(&shell, shell_commands, SHELL_BUFSIZE, uart0_readc, uart0_putc); + shell_init(&shell, NULL, SHELL_BUFSIZE, uart0_readc, uart0_putc); +#else + shell_init(&shell, NULL, SHELL_BUFSIZE, getchar, putchar); +#endif shell_run(&shell); return 0; diff --git a/tests/periph_gpio/main.c b/tests/periph_gpio/main.c index b34f65d98f..1ea711c2a9 100644 --- a/tests/periph_gpio/main.c +++ b/tests/periph_gpio/main.c @@ -22,8 +22,12 @@ #include #include "shell.h" -#include "posix_io.h" -#include "board_uart0.h" +#ifdef MODULE_NEWLIB +# include "uart_stdio.h" +#else +# include "posix_io.h" +# include "board_uart0.h" +#endif #include "periph/gpio.h" #include "hwtimer.h" @@ -247,8 +251,12 @@ int main(void) " behavior for not existing ports/pins is not defined!"); /* start the shell */ +#ifndef MODULE_NEWLIB (void) posix_open(uart0_handler_pid, 0); - shell_init(&shell, shell_commands, SHELL_BUFSIZE, uart0_readc, uart0_putc); + shell_init(&shell, NULL, SHELL_BUFSIZE, uart0_readc, uart0_putc); +#else + shell_init(&shell, NULL, SHELL_BUFSIZE, getchar, putchar); +#endif shell_run(&shell); return 0; diff --git a/tests/periph_i2c/main.c b/tests/periph_i2c/main.c index 18a3406c61..8413d876f6 100644 --- a/tests/periph_i2c/main.c +++ b/tests/periph_i2c/main.c @@ -21,11 +21,16 @@ #include #include +#include "kernel.h" #include "periph_conf.h" #include "periph/i2c.h" #include "shell.h" -#include "posix_io.h" -#include "board_uart0.h" +#ifdef MODULE_NEWLIB +# include "uart_stdio.h" +#else +# include "posix_io.h" +# include "board_uart0.h" +#endif #define BUFSIZE (128U) @@ -310,12 +315,16 @@ int main(void) puts("Test for the low-level I2C driver"); +#ifndef MODULE_NEWLIB /* prepare I/O for shell */ board_uart0_init(); - posix_open(uart0_handler_pid, 0); + (void) posix_open(uart0_handler_pid, 0); + shell_init(&shell, NULL, UART0_BUFSIZE, uart0_readc, uart0_putc); +#else + shell_init(&shell, NULL, UART0_BUFSIZE, getchar, putchar); +#endif /* define own shell commands */ - shell_init(&shell, shell_commands, UART0_BUFSIZE, uart0_readc, uart0_putc); shell_run(&shell); return 0;