@@ -168,59 +168,63 @@ void serial_irq_set(serial_t *obj, SerialIrq irq, uint32_t enable)
168
168
IRQn_Type irq_n = (IRQn_Type )0 ;
169
169
uint32_t vector = 0 ;
170
170
171
- switch (obj_s -> index ) {
172
- case 0 :
171
+ switch (obj_s -> uart ) {
172
+ #if defined(USART1_BASE )
173
+ case UART_1 :
173
174
irq_n = USART1_IRQn ;
174
175
vector = (uint32_t )& uart1_irq ;
175
176
break ;
176
- case 1 :
177
+ #endif
178
+ #if defined(USART2_BASE )
179
+ case UART_2 :
177
180
irq_n = USART2_IRQn ;
178
181
vector = (uint32_t )& uart2_irq ;
179
182
break ;
183
+ #endif
180
184
#if defined(USART3_BASE )
181
- case 2 :
185
+ case UART_3 :
182
186
irq_n = USART3_IRQn ;
183
187
vector = (uint32_t )& uart3_irq ;
184
188
break ;
185
189
#endif
186
190
#if defined(UART4_BASE )
187
- case 3 :
191
+ case UART_4 :
188
192
irq_n = UART4_IRQn ;
189
193
vector = (uint32_t )& uart4_irq ;
190
194
break ;
191
195
#endif
192
196
#if defined(UART5_BASE )
193
- case 4 :
197
+ case UART_5 :
194
198
irq_n = UART5_IRQn ;
195
199
vector = (uint32_t )& uart5_irq ;
196
200
break ;
197
201
#endif
198
202
#if defined(USART6_BASE )
199
- case 5 :
203
+ case UART_6 :
200
204
irq_n = USART6_IRQn ;
201
205
vector = (uint32_t )& uart6_irq ;
202
206
break ;
203
207
#endif
204
208
#if defined(UART7_BASE )
205
- case 6 :
209
+ case UART_7 :
206
210
irq_n = UART7_IRQn ;
207
211
vector = (uint32_t )& uart7_irq ;
208
212
break ;
209
213
#endif
210
214
#if defined(UART8_BASE )
211
- case 7 :
215
+ case UART_8 :
212
216
irq_n = UART8_IRQn ;
213
217
vector = (uint32_t )& uart8_irq ;
214
218
break ;
215
219
#endif
216
220
#if defined(UART9_BASE )
217
- case 8 :
221
+ case UART_9 :
218
222
irq_n = UART9_IRQn ;
219
223
vector = (uint32_t )& uart9_irq ;
220
224
break ;
221
225
#endif
222
226
#if defined(UART10_BASE )
223
- case 9 :
227
+ case UART_10 :
224
228
irq_n = UART10_IRQn ;
225
229
vector = (uint32_t )& uart10_irq ;
226
230
break ;
@@ -233,8 +237,8 @@ void serial_irq_set(serial_t *obj, SerialIrq irq, uint32_t enable)
233
237
} else { // TxIrq
234
238
__HAL_UART_ENABLE_IT (huart , UART_IT_TXE );
235
239
}
236
- NVIC_SetVector (irq_n , vector );
237
- NVIC_EnableIRQ (irq_n );
240
+ NVIC_SetVector (irq_n , vector );
241
+ NVIC_EnableIRQ (irq_n );
238
242
239
243
} else { // disable
240
244
int all_disabled = 0 ;
@@ -253,7 +257,7 @@ void serial_irq_set(serial_t *obj, SerialIrq irq, uint32_t enable)
253
257
}
254
258
255
259
if (all_disabled ) {
256
- NVIC_DisableIRQ (irq_n );
260
+ NVIC_DisableIRQ (irq_n );
257
261
}
258
262
}
259
263
}
@@ -284,7 +288,7 @@ void serial_clear(serial_t *obj)
284
288
{
285
289
struct serial_s * obj_s = SERIAL_S (obj );
286
290
UART_HandleTypeDef * huart = & uart_handlers [obj_s -> index ];
287
-
291
+
288
292
huart -> TxXferCount = 0 ;
289
293
huart -> RxXferCount = 0 ;
290
294
}
@@ -293,7 +297,7 @@ void serial_break_set(serial_t *obj)
293
297
{
294
298
struct serial_s * obj_s = SERIAL_S (obj );
295
299
UART_HandleTypeDef * huart = & uart_handlers [obj_s -> index ];
296
-
300
+
297
301
HAL_LIN_SendBreak (huart );
298
302
}
299
303
0 commit comments