mbed-os
Fork of mbed-os by
features/unsupported/tests/mbed/digitalinout/main.cpp@0:f269e3021894, 2016-10-23 (annotated)
- Committer:
- elessair
- Date:
- Sun Oct 23 15:10:02 2016 +0000
- Revision:
- 0:f269e3021894
Initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
elessair | 0:f269e3021894 | 1 | #include "test_env.h" |
elessair | 0:f269e3021894 | 2 | |
elessair | 0:f269e3021894 | 3 | #if defined(TARGET_LPC1114) |
elessair | 0:f269e3021894 | 4 | DigitalInOut d1(dp1); |
elessair | 0:f269e3021894 | 5 | DigitalInOut d2(dp2); |
elessair | 0:f269e3021894 | 6 | |
elessair | 0:f269e3021894 | 7 | #elif defined(TARGET_LPC1549) |
elessair | 0:f269e3021894 | 8 | // TARGET_FF_ARDUINO cannot be used, because D0 is used as USBRX (USB serial |
elessair | 0:f269e3021894 | 9 | // port pin), D1 is used as USBTX |
elessair | 0:f269e3021894 | 10 | DigitalInOut d1(D2); |
elessair | 0:f269e3021894 | 11 | DigitalInOut d2(D7); |
elessair | 0:f269e3021894 | 12 | |
elessair | 0:f269e3021894 | 13 | #elif defined(TARGET_STM) && defined(TARGET_FF_ARDUINO) |
elessair | 0:f269e3021894 | 14 | // TARGET_FF_ARDUINO cannot be used |
elessair | 0:f269e3021894 | 15 | // D0 is used as USBRX for some NUCLEO64 |
elessair | 0:f269e3021894 | 16 | // D7 is not used for some NUCLEO32 |
elessair | 0:f269e3021894 | 17 | DigitalInOut d1(D9); |
elessair | 0:f269e3021894 | 18 | DigitalInOut d2(D2); |
elessair | 0:f269e3021894 | 19 | |
elessair | 0:f269e3021894 | 20 | #elif defined(TARGET_DISCO_L053C8) || \ |
elessair | 0:f269e3021894 | 21 | defined(TARGET_DISCO_F334C8) |
elessair | 0:f269e3021894 | 22 | DigitalInOut d1(PA_15); |
elessair | 0:f269e3021894 | 23 | DigitalInOut d2(PA_8); |
elessair | 0:f269e3021894 | 24 | |
elessair | 0:f269e3021894 | 25 | #elif defined(TARGET_DISCO_L476VG) |
elessair | 0:f269e3021894 | 26 | DigitalInOut d1(PA_1); |
elessair | 0:f269e3021894 | 27 | DigitalInOut d2(PA_2); |
elessair | 0:f269e3021894 | 28 | |
elessair | 0:f269e3021894 | 29 | #elif defined(TARGET_ARCH_MAX) || \ |
elessair | 0:f269e3021894 | 30 | defined(TARGET_DISCO_F407VG) || \ |
elessair | 0:f269e3021894 | 31 | defined(TARGET_DISCO_F429ZI)|| \ |
elessair | 0:f269e3021894 | 32 | defined(TARGET_DISCO_F401VC) |
elessair | 0:f269e3021894 | 33 | DigitalInOut d1(PC_12); |
elessair | 0:f269e3021894 | 34 | DigitalInOut d2(PD_0); |
elessair | 0:f269e3021894 | 35 | |
elessair | 0:f269e3021894 | 36 | #elif defined(TARGET_FF_ARDUINO) |
elessair | 0:f269e3021894 | 37 | DigitalInOut d1(D0); |
elessair | 0:f269e3021894 | 38 | DigitalInOut d2(D7); |
elessair | 0:f269e3021894 | 39 | |
elessair | 0:f269e3021894 | 40 | #elif defined(TARGET_MAXWSNENV) |
elessair | 0:f269e3021894 | 41 | DigitalInOut d1(TP3); |
elessair | 0:f269e3021894 | 42 | DigitalInOut d2(TP4); |
elessair | 0:f269e3021894 | 43 | |
elessair | 0:f269e3021894 | 44 | #elif defined(TARGET_MAX32600MBED) |
elessair | 0:f269e3021894 | 45 | DigitalInOut d1(P1_0); |
elessair | 0:f269e3021894 | 46 | DigitalInOut d2(P4_7); |
elessair | 0:f269e3021894 | 47 | |
elessair | 0:f269e3021894 | 48 | #elif defined(TARGET_EFM32LG_STK3600) || defined(TARGET_EFM32GG_STK3700) || defined(TARGET_EFM32WG_STK3800) |
elessair | 0:f269e3021894 | 49 | DigitalInOut d1(PD0); |
elessair | 0:f269e3021894 | 50 | DigitalInOut d2(PC3); |
elessair | 0:f269e3021894 | 51 | |
elessair | 0:f269e3021894 | 52 | #elif defined(TARGET_EFM32ZG_STK3200) |
elessair | 0:f269e3021894 | 53 | DigitalInOut d1(PD7); |
elessair | 0:f269e3021894 | 54 | DigitalInOut d2(PC1); |
elessair | 0:f269e3021894 | 55 | |
elessair | 0:f269e3021894 | 56 | #elif defined(TARGET_EFM32HG_STK3400) |
elessair | 0:f269e3021894 | 57 | DigitalInOut d1(PE10); |
elessair | 0:f269e3021894 | 58 | DigitalInOut d2(PC1); |
elessair | 0:f269e3021894 | 59 | |
elessair | 0:f269e3021894 | 60 | #elif defined(TARGET_EFM32PG_STK3401) |
elessair | 0:f269e3021894 | 61 | DigitalInOut d1(PC6); |
elessair | 0:f269e3021894 | 62 | DigitalInOut d2(PA3); |
elessair | 0:f269e3021894 | 63 | |
elessair | 0:f269e3021894 | 64 | #elif defined(TARGET_SAMR21G18A) || defined(TARGET_SAMD21J18A) || defined(TARGET_SAMD21G18A) |
elessair | 0:f269e3021894 | 65 | DigitalInOut d1(PB02); |
elessair | 0:f269e3021894 | 66 | DigitalInOut d2(PB03); |
elessair | 0:f269e3021894 | 67 | |
elessair | 0:f269e3021894 | 68 | #elif defined(TARGET_SAML21J18A) |
elessair | 0:f269e3021894 | 69 | DigitalInOut d1(PA06); |
elessair | 0:f269e3021894 | 70 | DigitalInOut d2(PA07); |
elessair | 0:f269e3021894 | 71 | |
elessair | 0:f269e3021894 | 72 | #elif defined(TARGET_SAMG55J19) |
elessair | 0:f269e3021894 | 73 | DigitalInOut d1(PA18); |
elessair | 0:f269e3021894 | 74 | DigitalInOut d2(PA17); |
elessair | 0:f269e3021894 | 75 | |
elessair | 0:f269e3021894 | 76 | #elif defined(TARGET_VK_RZ_A1H) |
elessair | 0:f269e3021894 | 77 | DigitalInOut d1(P3_2); |
elessair | 0:f269e3021894 | 78 | DigitalInOut d2(P5_6); |
elessair | 0:f269e3021894 | 79 | |
elessair | 0:f269e3021894 | 80 | #else |
elessair | 0:f269e3021894 | 81 | DigitalInOut d1(p5); |
elessair | 0:f269e3021894 | 82 | DigitalInOut d2(p25); |
elessair | 0:f269e3021894 | 83 | |
elessair | 0:f269e3021894 | 84 | #endif |
elessair | 0:f269e3021894 | 85 | |
elessair | 0:f269e3021894 | 86 | |
elessair | 0:f269e3021894 | 87 | int main() |
elessair | 0:f269e3021894 | 88 | { |
elessair | 0:f269e3021894 | 89 | MBED_HOSTTEST_TIMEOUT(10); |
elessair | 0:f269e3021894 | 90 | MBED_HOSTTEST_SELECT(default_auto); |
elessair | 0:f269e3021894 | 91 | MBED_HOSTTEST_DESCRIPTION(DigitalInOut); |
elessair | 0:f269e3021894 | 92 | MBED_HOSTTEST_START("MBED_A6"); |
elessair | 0:f269e3021894 | 93 | |
elessair | 0:f269e3021894 | 94 | bool check = true; |
elessair | 0:f269e3021894 | 95 | |
elessair | 0:f269e3021894 | 96 | d1.output(); |
elessair | 0:f269e3021894 | 97 | d2.input(); |
elessair | 0:f269e3021894 | 98 | d1 = 1; |
elessair | 0:f269e3021894 | 99 | wait(0.1); |
elessair | 0:f269e3021894 | 100 | if (d2 != 1) { |
elessair | 0:f269e3021894 | 101 | printf("MBED: First check failed! d2 is %d\n", (int)d2); |
elessair | 0:f269e3021894 | 102 | check = false; |
elessair | 0:f269e3021894 | 103 | } |
elessair | 0:f269e3021894 | 104 | d1 = 0; |
elessair | 0:f269e3021894 | 105 | wait(0.1); |
elessair | 0:f269e3021894 | 106 | if (d2 != 0) { |
elessair | 0:f269e3021894 | 107 | printf("MBED: Second check failed! d2 is %d\n", (int)d2); |
elessair | 0:f269e3021894 | 108 | check = false; |
elessair | 0:f269e3021894 | 109 | } |
elessair | 0:f269e3021894 | 110 | |
elessair | 0:f269e3021894 | 111 | d1.input(); |
elessair | 0:f269e3021894 | 112 | d2.output(); |
elessair | 0:f269e3021894 | 113 | d2 = 1; |
elessair | 0:f269e3021894 | 114 | wait(0.1); |
elessair | 0:f269e3021894 | 115 | if (d1 != 1) { |
elessair | 0:f269e3021894 | 116 | printf("MBED: Third check failed! d1 is %d\n", (int)d1); |
elessair | 0:f269e3021894 | 117 | check = false; |
elessair | 0:f269e3021894 | 118 | } |
elessair | 0:f269e3021894 | 119 | d2 = 0; |
elessair | 0:f269e3021894 | 120 | wait(0.1); |
elessair | 0:f269e3021894 | 121 | if (d1 != 0) { |
elessair | 0:f269e3021894 | 122 | printf("MBED: Fourth check failed! d1 is %d\n", (int)d1); |
elessair | 0:f269e3021894 | 123 | check = false; |
elessair | 0:f269e3021894 | 124 | } |
elessair | 0:f269e3021894 | 125 | |
elessair | 0:f269e3021894 | 126 | MBED_HOSTTEST_RESULT(check); |
elessair | 0:f269e3021894 | 127 | } |