]> git.gir.st - tmk_keyboard.git/blob - tmk_core/tool/mbed/mbed-sdk/libraries/tests/mbed/stdio/main.cpp
Merge commit '657d9f23fe47fb88cf221adb23095082f191ba6a'
[tmk_keyboard.git] / tmk_core / tool / mbed / mbed-sdk / libraries / tests / mbed / stdio / main.cpp
1 #include "mbed.h"
2 #include "test_env.h"
3
4 /* This test purpose is to verify the behaviour when the program does not link
5 * any symbol from the mbed library.
6 * In the past we had an issue where the stdio retargeting was not linked in.
7 */
8
9 int main() {
10 MBED_HOSTTEST_TIMEOUT(20);
11 MBED_HOSTTEST_SELECT(stdio_auto);
12 MBED_HOSTTEST_DESCRIPTION(stdio);
13 MBED_HOSTTEST_START("MBED_2");
14
15 DigitalOut led1(LED1);
16 DigitalOut led2(LED2);
17
18 int value_int;
19
20
21 notify_start(); // Just to sync with host test supervisor
22
23 const char* PRINT_PATTERN = "MBED: Your value was: %d\r\n";
24
25 while (true) {
26 // SCANF PRINTF family
27 value_int = 0;
28 led1 = 1;
29 scanf("%d", &value_int);
30 printf(PRINT_PATTERN, value_int);
31 led1 = 0;
32
33 // FSCANF, FPRINTF family
34 value_int = 0;
35 led2 = 1;
36 fscanf(stdin, "%d", &value_int);
37 fprintf(stdout, PRINT_PATTERN, value_int);
38 led2 = 0;
39 }
40 }
Imprint / Impressum