|
@@ -53,42 +53,45 @@ void WifiSerial::init(PinName _rx, PinName _tx) {
|
53
|
53
|
WifiSerial::WifiSerial(void *peripheral) {
|
54
|
54
|
// If PIN_SERIALy_RX is not defined assume half-duplex
|
55
|
55
|
_serial.pin_rx = NC;
|
|
56
|
+ if (false) {
|
|
57
|
+ // for else if / else below...
|
|
58
|
+ }
|
56
|
59
|
// If Serial is defined in variant set
|
57
|
60
|
// the Rx/Tx pins for com port if defined
|
58
|
61
|
#if defined(Serial) && defined(PIN_SERIAL_TX)
|
59
|
|
- if ((void *)this == (void *)&Serial) {
|
|
62
|
+ else if ((void *)this == (void *)&Serial) {
|
60
|
63
|
#ifdef PIN_SERIAL_RX
|
61
|
64
|
setRx(PIN_SERIAL_RX);
|
62
|
65
|
#endif
|
63
|
66
|
setTx(PIN_SERIAL_TX);
|
64
|
|
- } else
|
|
67
|
+ }
|
65
|
68
|
#endif
|
66
|
69
|
#if defined(PIN_SERIAL1_TX) && defined(USART1_BASE)
|
67
|
|
- if (peripheral == USART1) {
|
|
70
|
+ else if (peripheral == USART1) {
|
68
|
71
|
#ifdef PIN_SERIAL1_RX
|
69
|
72
|
setRx(PIN_SERIAL1_RX);
|
70
|
73
|
#endif
|
71
|
74
|
setTx(PIN_SERIAL1_TX);
|
72
|
|
- } else
|
|
75
|
+ }
|
73
|
76
|
#endif
|
74
|
77
|
#if defined(PIN_SERIAL2_TX) && defined(USART2_BASE)
|
75
|
|
- if (peripheral == USART2) {
|
|
78
|
+ else if (peripheral == USART2) {
|
76
|
79
|
#ifdef PIN_SERIAL2_RX
|
77
|
80
|
setRx(PIN_SERIAL2_RX);
|
78
|
81
|
#endif
|
79
|
82
|
setTx(PIN_SERIAL2_TX);
|
80
|
|
- } else
|
|
83
|
+ }
|
81
|
84
|
#endif
|
82
|
85
|
#if defined(PIN_SERIAL3_TX) && defined(USART3_BASE)
|
83
|
|
- if (peripheral == USART3) {
|
|
86
|
+ else if (peripheral == USART3) {
|
84
|
87
|
#ifdef PIN_SERIAL3_RX
|
85
|
88
|
setRx(PIN_SERIAL3_RX);
|
86
|
89
|
#endif
|
87
|
90
|
setTx(PIN_SERIAL3_TX);
|
88
|
|
- } else
|
|
91
|
+ }
|
89
|
92
|
#endif
|
90
|
93
|
#ifdef PIN_SERIAL4_TX
|
91
|
|
- if (false
|
|
94
|
+ else if (false
|
92
|
95
|
#ifdef USART4_BASE
|
93
|
96
|
|| peripheral == USART4
|
94
|
97
|
#elif defined(UART4_BASE)
|
|
@@ -99,10 +102,10 @@ WifiSerial::WifiSerial(void *peripheral) {
|
99
|
102
|
setRx(PIN_SERIAL4_RX);
|
100
|
103
|
#endif
|
101
|
104
|
setTx(PIN_SERIAL4_TX);
|
102
|
|
- } else
|
|
105
|
+ }
|
103
|
106
|
#endif
|
104
|
107
|
#ifdef PIN_SERIAL5_TX
|
105
|
|
- if (false
|
|
108
|
+ else if (false
|
106
|
109
|
#ifdef USART5_BASE
|
107
|
110
|
|| peripheral == USART5
|
108
|
111
|
#elif defined(UART5_BASE)
|
|
@@ -113,18 +116,18 @@ WifiSerial::WifiSerial(void *peripheral) {
|
113
|
116
|
setRx(PIN_SERIAL5_RX);
|
114
|
117
|
#endif
|
115
|
118
|
setTx(PIN_SERIAL5_TX);
|
116
|
|
- } else
|
|
119
|
+ }
|
117
|
120
|
#endif
|
118
|
121
|
#if defined(PIN_SERIAL6_TX) && defined(USART6_BASE)
|
119
|
|
- if (peripheral == USART6) {
|
|
122
|
+ else if (peripheral == USART6) {
|
120
|
123
|
#ifdef PIN_SERIAL6_RX
|
121
|
124
|
setRx(PIN_SERIAL6_RX);
|
122
|
125
|
#endif
|
123
|
126
|
setTx(PIN_SERIAL6_TX);
|
124
|
|
- } else
|
|
127
|
+ }
|
125
|
128
|
#endif
|
126
|
129
|
#ifdef PIN_SERIAL7_TX
|
127
|
|
- if (false
|
|
130
|
+ else if (false
|
128
|
131
|
#ifdef USART7_BASE
|
129
|
132
|
|| peripheral == USART7
|
130
|
133
|
#elif defined(UART7_BASE)
|
|
@@ -135,10 +138,10 @@ WifiSerial::WifiSerial(void *peripheral) {
|
135
|
138
|
setRx(PIN_SERIAL7_RX);
|
136
|
139
|
#endif
|
137
|
140
|
setTx(PIN_SERIAL7_TX);
|
138
|
|
- } else
|
|
141
|
+ }
|
139
|
142
|
#endif
|
140
|
143
|
#ifdef PIN_SERIAL8_TX
|
141
|
|
- if (false
|
|
144
|
+ else if (false
|
142
|
145
|
#ifdef USART8_BASE
|
143
|
146
|
|| peripheral == USART8
|
144
|
147
|
#elif defined(UART8_BASE)
|
|
@@ -149,18 +152,18 @@ WifiSerial::WifiSerial(void *peripheral) {
|
149
|
152
|
setRx(PIN_SERIAL8_RX);
|
150
|
153
|
#endif
|
151
|
154
|
setTx(PIN_SERIAL8_TX);
|
152
|
|
- } else
|
|
155
|
+ }
|
153
|
156
|
#endif
|
154
|
157
|
#if defined(PIN_SERIAL9_TX) && defined(UART9_BASE)
|
155
|
|
- if (peripheral == UART9) {
|
|
158
|
+ else if (peripheral == UART9) {
|
156
|
159
|
#ifdef PIN_SERIAL9_RX
|
157
|
160
|
setRx(PIN_SERIAL9_RX);
|
158
|
161
|
#endif
|
159
|
162
|
setTx(PIN_SERIAL9_TX);
|
160
|
|
- } else
|
|
163
|
+ }
|
161
|
164
|
#endif
|
162
|
165
|
#ifdef PIN_SERIAL10_TX
|
163
|
|
- if (false
|
|
166
|
+ else if (false
|
164
|
167
|
#ifdef USART10_BASE
|
165
|
168
|
|| peripheral == USART10
|
166
|
169
|
#elif defined(UART10_BASE)
|
|
@@ -171,18 +174,18 @@ WifiSerial::WifiSerial(void *peripheral) {
|
171
|
174
|
setRx(PIN_SERIAL10_RX);
|
172
|
175
|
#endif
|
173
|
176
|
setTx(PIN_SERIAL10_TX);
|
174
|
|
- } else
|
|
177
|
+ }
|
175
|
178
|
#endif
|
176
|
179
|
#if defined(PIN_SERIALLP1_TX) && defined(LPUART1_BASE)
|
177
|
|
- if (peripheral == LPUART1) {
|
|
180
|
+ else if (peripheral == LPUART1) {
|
178
|
181
|
#ifdef PIN_SERIALLP1_RX
|
179
|
182
|
setRx(PIN_SERIALLP1_RX);
|
180
|
183
|
#endif
|
181
|
184
|
setTx(PIN_SERIALLP1_TX);
|
182
|
|
- } else
|
|
185
|
+ }
|
183
|
186
|
#endif
|
184
|
187
|
// else get the pins of the first peripheral occurrence in PinMap
|
185
|
|
- {
|
|
188
|
+ else {
|
186
|
189
|
_serial.pin_rx = pinmap_pin(peripheral, PinMap_UART_RX);
|
187
|
190
|
_serial.pin_tx = pinmap_pin(peripheral, PinMap_UART_TX);
|
188
|
191
|
}
|