in RISC-V_RV32_THEAD_SMART_CDS/csi_driver/smartl_rv32/ck_usart.c [385:456]
static void ck_usart_intr_recv_line(int32_t idx, ck_usart_priv_t *usart_priv)
{
ck_usart_reg_t *addr = (ck_usart_reg_t *)(usart_priv->base);
uint32_t lsr_stat = addr->LSR;
addr->IER &= (~IER_THRE_INT_ENABLE);
uint32_t timecount = 0;
while (addr->LSR & 0x1) {
addr->RBR;
timecount++;
if (timecount >= UART_BUSY_TIMEOUT) {
if (usart_priv->cb_event) {
usart_priv->cb_event(idx, USART_EVENT_RX_TIMEOUT);
}
return;
}
}
/** Break Interrupt bit. This is used to indicate the detection of a
* break sequence on the serial input data.
*/
if (lsr_stat & DW_LSR_BI) {
if (usart_priv->cb_event) {
usart_priv->cb_event(idx, USART_EVENT_RX_BREAK);
}
return;
}
/** Framing Error bit. This is used to indicate the occurrence of a
* framing error in the receiver. A framing error occurs when the receiver
* does not detect a valid STOP bit in the received data.
*/
if (lsr_stat & DW_LSR_FE) {
if (usart_priv->cb_event) {
usart_priv->cb_event(idx, USART_EVENT_RX_FRAMING_ERROR);
}
return;
}
/** Framing Error bit. This is used to indicate the occurrence of a
* framing error in the receiver. A framing error occurs when the
* receiver does not detect a valid STOP bit in the received data.
*/
if (lsr_stat & DW_LSR_PE) {
if (usart_priv->cb_event) {
usart_priv->cb_event(idx, USART_EVENT_RX_PARITY_ERROR);
}
return;
}
/** Overrun error bit. This is used to indicate the occurrence of an overrun error.
* This occurs if a new data character was received before the previous data was read.
*/
if (lsr_stat & DW_LSR_OE) {
if (usart_priv->cb_event) {
usart_priv->cb_event(idx, USART_EVENT_RX_OVERFLOW);
}
return;
}
}