]> git.gir.st - tmk_keyboard.git/blob - tool/mbed/mbed-sdk/libraries/tests/mbed/portout_portin/main.cpp
Squashed 'tmk_core/' changes from 7967731..b9e0ea0
[tmk_keyboard.git] / tool / mbed / mbed-sdk / libraries / tests / mbed / portout_portin / main.cpp
1 #include "test_env.h"
2
3 #if defined(TARGET_K64F) || defined(TARGET_KL05Z)
4 #define P1_1 (1 << 16)
5 #define P1_2 (1 << 17)
6 #define PORT_1 PortC
7
8 #define P2_1 (1 << 2)
9 #define P2_2 (1 << 3)
10 #define PORT_2 PortC
11
12 #elif defined(TARGET_LPC11U24)
13 #define P1_1 (1 << 9) // p0.9
14 #define P1_2 (1 << 8) // p0.8
15 #define PORT_1 Port0
16
17 #define P2_1 (1 << 24) // p1.24
18 #define P2_2 (1 << 25) // p1.25
19 #define PORT_2 Port1
20
21 #elif defined(TARGET_LPC1768) || defined(TARGET_LPC2368)
22 #define P1_1 (1 << 9) // p0.9 -> p5
23 #define P1_2 (1 << 8) // p0.8 -> p6
24 #define PORT_1 Port0
25
26 #define P2_1 (1 << 1) // p2.1 -> p25
27 #define P2_2 (1 << 0) // p2.0 -> p26
28 #define PORT_2 Port2
29
30 #elif defined(TARGET_LPC4088)
31 #define P1_1 (1 << 7) // p0.7 -> p13
32 #define P1_2 (1 << 6) // p0.6 -> p14
33 #define PORT_1 Port0
34
35 #define P2_1 (1 << 2) // p1.2 -> p30
36 #define P2_2 (1 << 3) // p1.3 -> p29
37 #define PORT_2 Port1
38
39 #elif defined(TARGET_LPC1114)
40 #define P1_1 (1 << 9) // p0.9
41 #define P1_2 (1 << 8) // p0.8
42 #define PORT_1 Port0
43
44 #define P2_1 (1 << 1) // p1.1
45 #define P2_2 (1 << 0) // p1.0
46 #define PORT_2 Port1
47
48 #elif defined(TARGET_KL25Z)
49 #define P1_1 (1 << 4) // PTA4
50 #define P1_2 (1 << 5) // PTA5
51 #define PORT_1 PortA
52
53 #define P2_1 (1 << 5) // PTC5
54 #define P2_2 (1 << 6) // PTC6
55 #define PORT_2 PortC
56
57 #elif defined(TARGET_nRF51822)
58 #define P1_1 (1 << 4) // p4
59 #define P1_2 (1 << 5) // p5
60 #define PORT_1 Port0
61
62 #define P2_1 (1 << 24) // p24
63 #define P2_2 (1 << 25) // p25
64 #define PORT_2 Port0
65
66 #elif defined(TARGET_MAXWSNENV)
67 #define P1_1 (1 << 0)
68 #define P1_2 (1 << 1)
69 #define PORT_1 Port0
70
71 #define P2_1 (1 << 0)
72 #define P2_2 (1 << 1)
73 #define PORT_2 Port1
74
75 #elif defined(TARGET_MAX32600MBED)
76 #define P1_1 (1 << 0) // P1_0
77 #define P1_2 (1 << 1) // P1_1
78 #define PORT_1 Port1
79
80 #define P2_1 (1 << 7) // P4_7
81 #define P2_2 (1 << 6) // P4_6
82 #define PORT_2 Port4
83
84 #elif defined(TARGET_NUCLEO_F030R8) || \
85 defined(TARGET_NUCLEO_F070RB) || \
86 defined(TARGET_NUCLEO_F072RB) || \
87 defined(TARGET_NUCLEO_F091RC) || \
88 defined(TARGET_NUCLEO_F103RB) || \
89 defined(TARGET_NUCLEO_F302R8) || \
90 defined(TARGET_NUCLEO_F303RE) || \
91 defined(TARGET_NUCLEO_F334R8) || \
92 defined(TARGET_NUCLEO_F401RE) || \
93 defined(TARGET_NUCLEO_F411RE) || \
94 defined(TARGET_NUCLEO_L053R8) || \
95 defined(TARGET_NUCLEO_L073RZ) || \
96 defined(TARGET_NUCLEO_L152RE)
97 #define P1_1 (1 << 6) // PC_6
98 #define P1_2 (1 << 5) // PC_5
99 #define PORT_1 PortC
100
101 #define P2_1 (1 << 8) // PB_8
102 #define P2_2 (1 << 9) // PB_9
103 #define PORT_2 PortB
104 #endif
105
106 #define MASK_1 (P1_1 | P1_2)
107 #define MASK_2 (P2_1 | P2_2)
108
109 PortOut port_out(PORT_1, MASK_1);
110 PortIn port_in (PORT_2, MASK_2);
111
112 int main() {
113 MBED_HOSTTEST_TIMEOUT(20);
114 MBED_HOSTTEST_SELECT(default_auto);
115 MBED_HOSTTEST_DESCRIPTION(PortOut PortIn);
116 MBED_HOSTTEST_START("MBED_A10");
117
118 port_out = MASK_1;
119 wait(0.1);
120 int value = port_in.read();
121 if (value != MASK_2) {
122 printf("[Test high] expected (0x%x) received (0x%x)\n", MASK_2, value);
123 notify_completion(false);
124 }
125
126 port_out = 0;
127 wait(0.1);
128 value = port_in.read();
129 if (value != 0) {
130 printf("[Test low] expected (0x%x) received (0x%x)\n", 0, value);
131 notify_completion(false);
132 }
133
134 notify_completion(true);
135 }
Imprint / Impressum