@@ -284,32 +284,29 @@ static void SerialRxDoneCallBack(VOID *pAdapter)
284
284
#ifdef CONFIG_MBED_ENABLED
285
285
static void serial_loguart_irq_handler (uint32_t id , LOG_UART_INT_ID event )
286
286
{
287
- if ( event == IIR_RX_RDY || event == IIR_CHAR_TIMEOUT )
288
- {
289
- if (log_irq_handler ) {
287
+ log_uart_irq_set ( & stdio_uart_log , event , 0 );
288
+ if ( log_irq_handler ) {
289
+ if (event == IIR_RX_RDY || event == IIR_CHAR_TIMEOUT ) {
290
290
log_irq_handler (serial_log_irq_ids , RxIrq );
291
- }
292
- } else if (event == IIR_THR_EMPTY ) {
293
- if (log_irq_handler ) {
294
- log_irq_handler (serial_log_irq_ids , TxIrq );
295
- }
291
+ } else if (event == IIR_THR_EMPTY ) {
292
+ log_irq_handler (serial_log_irq_ids , TxIrq );
293
+ }
296
294
}
297
295
return ;
298
296
}
299
297
#endif
300
298
301
299
302
-
303
300
void serial_irq_handler (serial_t * obj , uart_irq_handler handler , uint32_t id )
304
301
{
305
302
306
303
#ifdef CONFIG_MBED_ENABLED
307
- if (obj -> index == UART_3 ) {
308
- log_irq_handler = handler ;
309
- serial_log_irq_ids = id ;
310
- log_uart_irq_handler (& stdio_uart_log , serial_loguart_irq_handler , id );
311
- return ;
312
- }
304
+ if (obj -> index == UART_3 ) {
305
+ log_irq_handler = handler ;
306
+ serial_log_irq_ids = id ;
307
+ log_uart_irq_handler (& stdio_uart_log , serial_loguart_irq_handler , id );
308
+ return ;
309
+ }
313
310
#endif
314
311
PHAL_RUART_ADAPTER pHalRuartAdapter ;
315
312
u8 uart_idx ;
@@ -326,14 +323,33 @@ void serial_irq_handler(serial_t *obj, uart_irq_handler handler, uint32_t id)
326
323
void serial_irq_set (serial_t * obj , SerialIrq irq , uint32_t enable )
327
324
{
328
325
#ifdef CONFIG_MBED_ENABLED
329
- if (obj -> index == UART_3 ) {
326
+ if (obj -> index == UART_3 ) {
327
+ if (enable ) {
328
+ if (irq == RxIrq ) {
329
+ log_uart_irq_set (& stdio_uart_log , IIR_RX_RDY , enable );
330
+ serial_log_irq_en |= SERIAL_RX_IRQ_EN ;
331
+ } else {
332
+ log_uart_irq_set (& stdio_uart_log , IIR_THR_EMPTY , enable );
333
+ serial_log_irq_en |= SERIAL_TX_IRQ_EN ;
334
+ }
335
+ } else {
330
336
if (irq == RxIrq ) {
331
337
log_uart_irq_set (& stdio_uart_log , IIR_RX_RDY , enable );
338
+ serial_log_irq_en &= ~SERIAL_RX_IRQ_EN ;
332
339
} else {
333
340
log_uart_irq_set (& stdio_uart_log , IIR_THR_EMPTY , enable );
341
+ serial_log_irq_en &= ~SERIAL_TX_IRQ_EN ;
342
+ }
343
+
344
+ log_uart_t * log_obj = & stdio_uart_log ;
345
+ HAL_LOG_UART_ADAPTER * pUartAdapter = (PHAL_LOG_UART_ADAPTER )& (log_obj -> log_hal_uart );
346
+ if (pUartAdapter -> IntEnReg == 0 ) {
347
+ InterruptUnRegister (& pUartAdapter -> IrqHandle );
348
+ InterruptDis (& pUartAdapter -> IrqHandle );
334
349
}
335
- return ;
336
350
}
351
+ return ;
352
+ }
337
353
#endif
338
354
PHAL_RUART_ADAPTER pHalRuartAdapter ;
339
355
PHAL_RUART_OP pHalRuartOp ;
@@ -352,7 +368,6 @@ void serial_irq_set(serial_t *obj, SerialIrq irq, uint32_t enable)
352
368
}
353
369
354
370
pHalRuartOp -> HalRuartRegIrq (pHalRuartAdapter );
355
- //log_uart
356
371
pHalRuartOp -> HalRuartIntEnable (pHalRuartAdapter );
357
372
} else { // disable
358
373
if (irq == RxIrq ) {
@@ -394,6 +409,14 @@ void serial_putc(serial_t *obj, int c)
394
409
#ifdef CONFIG_MBED_ENABLED
395
410
if (obj -> index == UART_3 ) {
396
411
log_uart_putc (& stdio_uart_log , (char )c );
412
+
413
+ // UnMask LOG_UART TX FIFO empty IRQ
414
+ if (serial_log_irq_en & SERIAL_TX_IRQ_EN ) {
415
+ log_uart_t * log_obj = & stdio_uart_log ;
416
+ HAL_LOG_UART_ADAPTER * pUartAdapter = (PHAL_LOG_UART_ADAPTER )& (log_obj -> log_hal_uart );
417
+ pUartAdapter -> IntEnReg |= IER_ETBEI ;
418
+ HalLogUartSetIntEn (pUartAdapter );
419
+ }
397
420
return ;
398
421
}
399
422
#endif
0 commit comments