Skip to content

Commit 9c6ab10

Browse files
committed
applications: only use uart0 for none-newlib boards
1 parent be95b87 commit 9c6ab10

File tree

8 files changed

+91
-25
lines changed

8 files changed

+91
-25
lines changed

examples/default/main.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,14 @@
2626
#include <string.h>
2727

2828
#include "thread.h"
29-
#include "posix_io.h"
29+
#ifdef MODULE_NEWLIB
30+
# include "uart_stdio.h"
31+
#else
32+
# include "posix_io.h"
33+
# include "board_uart0.h"
34+
#endif
3035
#include "shell.h"
3136
#include "shell_commands.h"
32-
#include "board_uart0.h"
3337

3438
#if FEATURE_PERIPH_RTC
3539
#include "periph/rtc.h"
@@ -42,7 +46,6 @@
4246
int main(void)
4347
{
4448
shell_t shell;
45-
(void) posix_open(uart0_handler_pid, 0);
4649

4750
#ifdef MODULE_LTC4150
4851
ltc4150_start();
@@ -54,7 +57,12 @@ int main(void)
5457

5558
(void) puts("Welcome to RIOT!");
5659

60+
#ifndef MODULE_NEWLIB
61+
(void) posix_open(uart0_handler_pid, 0);
5762
shell_init(&shell, NULL, UART0_BUFSIZE, uart0_readc, uart0_putc);
63+
#else
64+
shell_init(&shell, NULL, UART0_BUFSIZE, getchar, putchar);
65+
#endif
5866

5967
shell_run(&shell);
6068
return 0;

examples/gnrc_networking/main.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,14 @@
2020

2121
#include <stdio.h>
2222

23+
#include "kernel.h"
2324
#include "shell.h"
24-
#include "board_uart0.h"
25-
#include "posix_io.h"
25+
#ifdef MODULE_NEWLIB
26+
# include "uart_stdio.h"
27+
#else
28+
# include "posix_io.h"
29+
# include "board_uart0.h"
30+
#endif
2631

2732
extern int udp_cmd(int argc, char **argv);
2833

@@ -39,8 +44,12 @@ int main(void)
3944

4045
/* start shell */
4146
puts("All up, running the shell now");
42-
posix_open(uart0_handler_pid, 0);
43-
shell_init(&shell, shell_commands, UART0_BUFSIZE, uart0_readc, uart0_putc);
47+
#ifndef MODULE_NEWLIB
48+
(void) posix_open(uart0_handler_pid, 0);
49+
shell_init(&shell, NULL, UART0_BUFSIZE, uart0_readc, uart0_putc);
50+
#else
51+
shell_init(&shell, NULL, UART0_BUFSIZE, getchar, putchar);
52+
#endif
4453
shell_run(&shell);
4554

4655
/* should be never reached */

tests/driver_at86rf2xx/main.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,12 @@
2222

2323
#include "shell.h"
2424
#include "shell_commands.h"
25-
#include "posix_io.h"
26-
#include "board_uart0.h"
25+
#ifdef MODULE_NEWLIB
26+
# include "uart_stdio.h"
27+
#else
28+
# include "posix_io.h"
29+
# include "board_uart0.h"
30+
#endif
2731
#include "net/gnrc/pktdump.h"
2832
#include "net/gnrc.h"
2933

@@ -50,8 +54,12 @@ int main(void)
5054

5155
/* start the shell */
5256
puts("Initialization successful - starting the shell now");
57+
#ifndef MODULE_NEWLIB
5358
(void) posix_open(uart0_handler_pid, 0);
5459
shell_init(&shell, NULL, SHELL_BUFSIZE, uart0_readc, uart0_putc);
60+
#else
61+
shell_init(&shell, NULL, SHELL_BUFSIZE, getchar, putchar);
62+
#endif
5563
shell_run(&shell);
5664

5765
return 0;

tests/driver_kw2xrf/main.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,12 @@
2121

2222
#include "shell.h"
2323
#include "shell_commands.h"
24-
#include "posix_io.h"
25-
#include "board_uart0.h"
24+
#ifdef MODULE_NEWLIB
25+
# include "uart_stdio.h"
26+
#else
27+
# include "posix_io.h"
28+
# include "board_uart0.h"
29+
#endif
2630
#include "net/gnrc.h"
2731
#include "net/gnrc/pktdump.h"
2832

@@ -46,9 +50,13 @@ int main(void)
4650

4751
/* start the shell */
4852
puts("Initialization successful - starting the shell now");
53+
#ifndef MODULE_NEWLIB
4954
(void) posix_open(uart0_handler_pid, 0);
5055
shell_init(&shell, NULL, SHELL_BUFSIZE, uart0_readc, uart0_putc);
51-
shell_run(&shell);
56+
#else
57+
shell_init(&shell, NULL, SHELL_BUFSIZE, getchar, putchar);
58+
#endif
59+
shell_run(&shell);
5260

5361
return 0;
5462
}

tests/driver_nrfmin/main.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,12 @@
2121
#include <stdio.h>
2222

2323
#include "shell.h"
24-
#include "posix_io.h"
25-
#include "board_uart0.h"
24+
#ifdef MODULE_NEWLIB
25+
# include "uart_stdio.h"
26+
#else
27+
# include "posix_io.h"
28+
# include "board_uart0.h"
29+
#endif
2630
#include "nrfmin.h"
2731
#include "net/gnrc.h"
2832
#include "net/gnrc/nomac.h"
@@ -51,9 +55,13 @@ int main(void)
5155
gnrc_netreg_register(GNRC_NETTYPE_UNDEF, &netobj);
5256

5357
/* initialize and run the shell */
58+
#ifndef MODULE_NEWLIB
5459
board_uart0_init();
55-
posix_open(uart0_handler_pid, 0);
60+
(void) posix_open(uart0_handler_pid, 0);
5661
shell_init(&shell, NULL, SHELL_BUFSIZE, uart0_readc, uart0_putc);
62+
#else
63+
shell_init(&shell, NULL, SHELL_BUFSIZE, getchar, putchar);
64+
#endif
5765
shell_run(&shell);
5866

5967
return 0;

tests/driver_pcd8544/main.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,12 @@
3535
#include <string.h>
3636
#include <stdlib.h>
3737

38-
#include "posix_io.h"
39-
#include "board_uart0.h"
38+
#ifdef MODULE_NEWLIB
39+
# include "uart_stdio.h"
40+
#else
41+
# include "posix_io.h"
42+
# include "board_uart0.h"
43+
#endif
4044
#include "shell.h"
4145
#include "pcd8544.h"
4246

@@ -170,8 +174,12 @@ int main(void)
170174

171175
/* run shell */
172176
puts("All OK, running shell now");
177+
#ifndef MODULE_NEWLIB
173178
(void) posix_open(uart0_handler_pid, 0);
174-
shell_init(&shell, shell_commands, SHELL_BUFSIZE, uart0_readc, uart0_putc);
179+
shell_init(&shell, NULL, SHELL_BUFSIZE, uart0_readc, uart0_putc);
180+
#else
181+
shell_init(&shell, NULL, SHELL_BUFSIZE, getchar, putchar);
182+
#endif
175183
shell_run(&shell);
176184

177185
return 0;

tests/periph_gpio/main.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,12 @@
2222
#include <stdlib.h>
2323

2424
#include "shell.h"
25-
#include "posix_io.h"
26-
#include "board_uart0.h"
25+
#ifdef MODULE_NEWLIB
26+
# include "uart_stdio.h"
27+
#else
28+
# include "posix_io.h"
29+
# include "board_uart0.h"
30+
#endif
2731
#include "periph/gpio.h"
2832
#include "hwtimer.h"
2933

@@ -247,8 +251,12 @@ int main(void)
247251
" behavior for not existing ports/pins is not defined!");
248252

249253
/* start the shell */
254+
#ifndef MODULE_NEWLIB
250255
(void) posix_open(uart0_handler_pid, 0);
251-
shell_init(&shell, shell_commands, SHELL_BUFSIZE, uart0_readc, uart0_putc);
256+
shell_init(&shell, NULL, SHELL_BUFSIZE, uart0_readc, uart0_putc);
257+
#else
258+
shell_init(&shell, NULL, SHELL_BUFSIZE, getchar, putchar);
259+
#endif
252260
shell_run(&shell);
253261

254262
return 0;

tests/periph_i2c/main.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,16 @@
2121
#include <stdio.h>
2222
#include <stdlib.h>
2323

24+
#include "kernel.h"
2425
#include "periph_conf.h"
2526
#include "periph/i2c.h"
2627
#include "shell.h"
27-
#include "posix_io.h"
28-
#include "board_uart0.h"
28+
#ifdef MODULE_NEWLIB
29+
# include "uart_stdio.h"
30+
#else
31+
# include "posix_io.h"
32+
# include "board_uart0.h"
33+
#endif
2934

3035
#define BUFSIZE (128U)
3136

@@ -310,12 +315,16 @@ int main(void)
310315

311316
puts("Test for the low-level I2C driver");
312317

318+
#ifndef MODULE_NEWLIB
313319
/* prepare I/O for shell */
314320
board_uart0_init();
315-
posix_open(uart0_handler_pid, 0);
321+
(void) posix_open(uart0_handler_pid, 0);
322+
shell_init(&shell, NULL, UART0_BUFSIZE, uart0_readc, uart0_putc);
323+
#else
324+
shell_init(&shell, NULL, UART0_BUFSIZE, getchar, putchar);
325+
#endif
316326

317327
/* define own shell commands */
318-
shell_init(&shell, shell_commands, UART0_BUFSIZE, uart0_readc, uart0_putc);
319328
shell_run(&shell);
320329

321330
return 0;

0 commit comments

Comments
 (0)