/* Serial transmit data routines, This function will transmit data by using blocking_nbuf.  */
static rt_size_t _serial_fifo_tx_blocking_nbuf(struct rt_device *dev, rt_off_t pos, const void *buffer, rt_size_t size)
/* Serial transmit data routines, This function will transmit data by using blocking_nbuf.  */
static rt_size_t _serial_fifo_tx_blocking_nbuf(struct rt_device *dev, rt_off_t pos, const void *buffer, rt_size_t size)
{
    struct rt_serial_device *serial;
    struct rt_serial_tx_fifo *tx_fifo = RT_NULL;
    RT_ASSERT(dev != RT_NULL);
    if (size == 0) return 0;
    serial = (struct rt_serial_device *)dev;
    RT_ASSERT((serial != RT_NULL) && (buffer != RT_NULL));
    tx_fifo = (struct rt_serial_tx_fifo *) serial->serial_tx;
    RT_ASSERT(tx_fifo != RT_NULL);
    if (tx_fifo->activated == RT_TRUE)  return 0;
    tx_fifo->activated = RT_TRUE;
    serial->ops->transmit(serial,
                          (rt_uint8_t *)buffer,
                          size,
                          RT_SERIAL_TX_BLOCKING);
    rt_completion_wait(&(tx_fifo->tx_cpt), RT_WAITING_FOREVER);
    return size;
}