void platform_uart_irq( platform_uart_driver_t* driver ) { platform_uart_port_t* uart = (platform_uart_port_t*) driver->interface->uart_base; uint8_t data=0; while (Chip_UART_GetLineStatus(uart) & UART_LSR_RDR) { Chip_UART_ReceiveByte(uart,&data); ring_buffer_write( driver->rx_buffer,&data, 1 ); } // Notify thread if sufficient data are available if ( ( driver->rx_size > 0 ) && ( ring_buffer_used_space( driver->rx_buffer ) >= driver->rx_size ) ) { host_rtos_set_semaphore( &driver->rx_complete, WICED_TRUE ); driver->rx_size = 0; } }
/* Get Interrupt Stream Status */ UART_INT_STATUS_Type Chip_UART_GetIntStatus(LPC_USART_Type *UARTx) { uint32_t intsrc, tmp, tmp1; UART_INT_STATUS_Type ret = UART_INTSTS_ERROR; /* Determine the interrupt source */ intsrc = Chip_UART_IntGetStatus(UARTx); tmp = intsrc & UART_IIR_INTID_MASK; /* Receive Line Status */ if (tmp == UART_IIR_INTID_RLS) { /* Check line status */ tmp1 = (uint32_t) Chip_UART_GetLineStatus(UARTx); /* Mask out the Receive Ready and Transmit Holding empty status */ tmp1 &= (UART_LSR_OE | UART_LSR_PE | UART_LSR_FE \ | UART_LSR_BI | UART_LSR_RXFE); /* If any error exist */ if (tmp1) { return UART_INTSTS_ERROR; } } /* Receive Data Available or Character time-out */ if ((tmp == UART_IIR_INTID_RDA) || (tmp == UART_IIR_INTID_CTI)) { ret |= UART_INTSTS_RTR; } /* Transmit Holding Empty */ if (tmp == UART_IIR_INTID_THRE) { ret |= UART_INTSTS_RTS; } if (intsrc & UART_IIR_ABEO_INT){ ret |= UART_INTSTS_ABEO; } else if (intsrc & UART_IIR_ABTO_INT){ ret |= UART_INTSTS_ABTO; } return ret; }