Beispiel #1
0
/** Abort the ongoing TX transaction. It disables the enabled interupt for TX and
 *  flushes the TX hardware buffer if TX FIFO is used
 *
 * @param obj The serial object
 */
void serial_tx_abort_asynch(serial_t *obj)
{
    struct serial_s *p_obj = GET_SERIAL_S(obj);

    usart_interrupt_disable(p_obj->uart, USART_INT_TC);
    usart_interrupt_disable(p_obj->uart, USART_INT_TBE);

    usart_flag_clear(p_obj->uart, USART_FLAG_TC);

    p_obj->tx_count = 0;
    p_obj->tx_state = OP_STATE_READY;
}
Beispiel #2
0
/**
 * Uart common interrupt process. This need add to uart ISR.
 *
 * @param serial serial device
 */
static void uart_isr(struct rt_serial_device *serial)
{
    struct gd32_uart *uart = (struct gd32_uart *) serial->parent.user_data;

    RT_ASSERT(uart != RT_NULL);

    /* UART in mode Receiver */
    if ((usart_interrupt_flag_get(uart->uart_periph, USART_INT_FLAG_RBNE) != RESET) &&
            (usart_flag_get(uart->uart_periph, USART_FLAG_RBNE) != RESET))
    {
        rt_hw_serial_isr(serial, RT_SERIAL_EVENT_RX_IND);
        /* Clear RXNE interrupt flag */
        usart_flag_clear(uart->uart_periph, USART_FLAG_RBNE);
    }
}
Beispiel #3
0
/** Abort the ongoing RX transaction. It disables the enabled interrupt for RX and
 *  flushes the RX hardware buffer if RX FIFO is used
 *
 * @param obj The serial object
 */
void serial_rx_abort_asynch(serial_t *obj)
{
    struct serial_s *p_obj = GET_SERIAL_S(obj);

    /* disable interrupts */
    usart_interrupt_disable(p_obj->uart, USART_INT_RBNE);
    usart_interrupt_disable(p_obj->uart, USART_INT_PERR);
    usart_interrupt_disable(p_obj->uart, USART_INT_ERR);

    /* clear USART_FLAG_RBNE flag */
    usart_flag_clear(p_obj->uart, USART_FLAG_RBNE);

    /* clear errors flag by reading USART STATx register and then USART DATA register */
    usart_flag_get(p_obj->uart, USART_FLAG_PERR);
    usart_flag_get(p_obj->uart, USART_FLAG_FERR);
    usart_flag_get(p_obj->uart, USART_FLAG_ORERR);
    USART_DATA(p_obj->uart);

    /* reset rx transfer count */
    p_obj->rx_count = 0;

    /* reset rx state */
    p_obj->rx_state = OP_STATE_READY;
}