Rtos API example
Embed:
(wiki syntax)
Show/hide line numbers
main.cpp
00001 #include "mbed.h" 00002 #include "test_env.h" 00003 00004 /* This test purpose is to verify the behaviour when the program does not link 00005 * any symbol from the mbed library. 00006 * In the past we had an issue where the stdio retargeting was not linked in. 00007 */ 00008 00009 int main() { 00010 MBED_HOSTTEST_TIMEOUT(20); 00011 MBED_HOSTTEST_SELECT(stdio_auto); 00012 MBED_HOSTTEST_DESCRIPTION(stdio); 00013 MBED_HOSTTEST_START("MBED_2"); 00014 00015 DigitalOut led1(LED1); 00016 DigitalOut led2(LED2); 00017 00018 int value_int; 00019 00020 00021 notify_start(); // Just to sync with host test supervisor 00022 00023 const char* PRINT_PATTERN = "MBED: Your value was: %d\r\n"; 00024 00025 while (true) { 00026 // SCANF PRINTF family 00027 value_int = 0; 00028 led1 = 1; 00029 scanf("%d", &value_int); 00030 printf(PRINT_PATTERN, value_int); 00031 led1 = 0; 00032 00033 // FSCANF, FPRINTF family 00034 value_int = 0; 00035 led2 = 1; 00036 fscanf(stdin, "%d", &value_int); 00037 fprintf(stdout, PRINT_PATTERN, value_int); 00038 led2 = 0; 00039 } 00040 }
Generated on Sun Jul 17 2022 08:25:26 by
1.7.2