Preliminary main mbed library for nexpaq development
libraries/tests/mbed/stdio/main.cpp@1:d96dbedaebdb, 2016-11-04 (annotated)
- Committer:
- nexpaq
- Date:
- Fri Nov 04 20:54:50 2016 +0000
- Revision:
- 1:d96dbedaebdb
- Parent:
- 0:6c56fb4bc5f0
Removed extra directories for other platforms
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
nexpaq | 0:6c56fb4bc5f0 | 1 | #include "mbed.h" |
nexpaq | 0:6c56fb4bc5f0 | 2 | #include "test_env.h" |
nexpaq | 0:6c56fb4bc5f0 | 3 | |
nexpaq | 0:6c56fb4bc5f0 | 4 | /* This test purpose is to verify the behaviour when the program does not link |
nexpaq | 0:6c56fb4bc5f0 | 5 | * any symbol from the mbed library. |
nexpaq | 0:6c56fb4bc5f0 | 6 | * In the past we had an issue where the stdio retargeting was not linked in. |
nexpaq | 0:6c56fb4bc5f0 | 7 | */ |
nexpaq | 0:6c56fb4bc5f0 | 8 | |
nexpaq | 0:6c56fb4bc5f0 | 9 | int main() { |
nexpaq | 0:6c56fb4bc5f0 | 10 | MBED_HOSTTEST_TIMEOUT(20); |
nexpaq | 0:6c56fb4bc5f0 | 11 | MBED_HOSTTEST_SELECT(stdio_auto); |
nexpaq | 0:6c56fb4bc5f0 | 12 | MBED_HOSTTEST_DESCRIPTION(stdio); |
nexpaq | 0:6c56fb4bc5f0 | 13 | MBED_HOSTTEST_START("MBED_2"); |
nexpaq | 0:6c56fb4bc5f0 | 14 | |
nexpaq | 0:6c56fb4bc5f0 | 15 | DigitalOut led1(LED1); |
nexpaq | 0:6c56fb4bc5f0 | 16 | DigitalOut led2(LED2); |
nexpaq | 0:6c56fb4bc5f0 | 17 | |
nexpaq | 0:6c56fb4bc5f0 | 18 | int value_int; |
nexpaq | 0:6c56fb4bc5f0 | 19 | |
nexpaq | 0:6c56fb4bc5f0 | 20 | |
nexpaq | 0:6c56fb4bc5f0 | 21 | notify_start(); // Just to sync with host test supervisor |
nexpaq | 0:6c56fb4bc5f0 | 22 | |
nexpaq | 0:6c56fb4bc5f0 | 23 | const char* PRINT_PATTERN = "MBED: Your value was: %d\r\n"; |
nexpaq | 0:6c56fb4bc5f0 | 24 | |
nexpaq | 0:6c56fb4bc5f0 | 25 | while (true) { |
nexpaq | 0:6c56fb4bc5f0 | 26 | // SCANF PRINTF family |
nexpaq | 0:6c56fb4bc5f0 | 27 | value_int = 0; |
nexpaq | 0:6c56fb4bc5f0 | 28 | led1 = 1; |
nexpaq | 0:6c56fb4bc5f0 | 29 | scanf("%d", &value_int); |
nexpaq | 0:6c56fb4bc5f0 | 30 | printf(PRINT_PATTERN, value_int); |
nexpaq | 0:6c56fb4bc5f0 | 31 | led1 = 0; |
nexpaq | 0:6c56fb4bc5f0 | 32 | |
nexpaq | 0:6c56fb4bc5f0 | 33 | // FSCANF, FPRINTF family |
nexpaq | 0:6c56fb4bc5f0 | 34 | value_int = 0; |
nexpaq | 0:6c56fb4bc5f0 | 35 | led2 = 1; |
nexpaq | 0:6c56fb4bc5f0 | 36 | fscanf(stdin, "%d", &value_int); |
nexpaq | 0:6c56fb4bc5f0 | 37 | fprintf(stdout, PRINT_PATTERN, value_int); |
nexpaq | 0:6c56fb4bc5f0 | 38 | led2 = 0; |
nexpaq | 0:6c56fb4bc5f0 | 39 | } |
nexpaq | 0:6c56fb4bc5f0 | 40 | } |