Exemplo n.º 1
0
static int gd32_putc(struct rt_serial_device *serial, char ch)
{
    struct gd32_uart *uart;

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

    usart_data_transmit(uart->uart_periph, ch);
    while((usart_flag_get(uart->uart_periph, USART_FLAG_TC) == RESET));
    
    return 1;
}
Exemplo n.º 2
0
/*****************************************************************************
 Function    : LOS_EvbUartInit
 Description : enable the device on the dev baord
 Input       : None
 Output      : None
 Return      : None
 *****************************************************************************/
void LOS_EvbUartWriteStr(const char* str)
{
#ifdef GD32F150R8
    while (*str)
    {
        usart_data_transmit(EVAL_COM1, * str++);
        while (RESET == usart_flag_get(EVAL_COM1,USART_STAT_TBE));
    }
    
    while(RESET == usart_flag_get(EVAL_COM1, USART_STAT_TC)){
    }
#endif
    return;
}
Exemplo n.º 3
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);
        }
    }
}
Exemplo n.º 4
0
/* retarget the C library printf function to the usart */
int fputc(int ch, FILE *f)
{
    usart_data_transmit(EVAL_COM2, (uint8_t) ch);
    while (RESET == usart_flag_get(EVAL_COM2,USART_STAT_TC));
    return ch;
}
Exemplo n.º 5
0
/*****************************************************************************
 Function    : LOS_EvbUartInit
 Description : enable the device on the dev baord
 Input       : None
 Output      : None
 Return      : None
 *****************************************************************************/
void LOS_EvbUartWriteByte(char c)
{
    usart_data_transmit(EVAL_COM1, c);
    while (RESET == usart_flag_get(EVAL_COM1, USART_STAT_TBE));
    return;
}