Esempio n. 1
0
static int gd32_getc(struct rt_serial_device *serial)
{
    int ch;
    struct gd32_uart *uart;

    RT_ASSERT(serial != RT_NULL);
    uart = (struct gd32_uart *)serial->parent.user_data;

    ch = -1;
    if (usart_flag_get(uart->uart_periph, USART_FLAG_RBNE) != RESET)
        ch = usart_data_receive(uart->uart_periph);
    return ch;
}
Esempio n. 2
0
/*!
    \brief      this function handles USART RBNE interrupt request and TBE interrupt request
    \param[in]  none
    \param[out] none
    \retval     none
*/
void USART0_IRQHandler(void)
{
    if(RESET != usart_interrupt_flag_get(EVAL_COM1, USART_STAT_RBNE,USART_INT_RBNEIE)){
        /* receive data */
        receiver_buffer[rxcount++] = (usart_data_receive(EVAL_COM1) & 0x7F);
        if(rxcount == receivesize){
            usart_interrupt_disable(EVAL_COM1, USART_INT_RBNEIE);
        }
    }

    if(RESET != usart_interrupt_flag_get(EVAL_COM1, USART_STAT_TC,USART_INT_TBEIE)){
        /* transmit data */
        usart_data_transmit(EVAL_COM1, transmitter_buffer[txcount++]);
        if(txcount == transfersize){
            usart_interrupt_disable(EVAL_COM1, USART_INT_TBEIE);
        }
    }
}
Esempio n. 3
0
/*****************************************************************************
 Function    : Los_Uart1ReadByte
 Description : enable the device on the dev baord
 Input       : None
 Output      : None
 Return      : None
 *****************************************************************************/
void LOS_EvbUartReadByte(char* c)
{
    while (RESET == usart_flag_get(EVAL_COM1,USART_STAT_RBNE));
    *c = (usart_data_receive(EVAL_COM1));
    return;
}