mbed-os

Fork of mbed-os by erkin yucel

Committer:
xuaner
Date:
Thu Jul 20 14:26:57 2017 +0000
Revision:
1:3deb71413561
Parent:
0:f269e3021894
mbed_os

Who changed what in which revision?

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