/* Start sending data to UART transmitter,(received data is ignored). The function is non-blocking,UART_EVENT_TRANSFER_COMPLETE is signaled when transfer completes. csi_usart_get_status can indicates if transmission is still in progress or pending.  */
int32_t csi_usart_send(usart_handle_t handle, const void *data, uint32_t num)
/* Start sending data to UART transmitter,(received data is ignored). The function is non-blocking,UART_EVENT_TRANSFER_COMPLETE is signaled when transfer completes. csi_usart_get_status can indicates if transmission is still in progress or pending.  */
int32_t csi_usart_send(usart_handle_t handle, const void *data, uint32_t num)
{
    USART_NULL_PARAM_CHK(handle);
    USART_NULL_PARAM_CHK(data);
    if (num == 0)
    {
        return ERR_USART(DRV_ERROR_PARAMETER);
    }
    ck_usart_priv_t *usart_priv = handle;
    usart_priv->tx_buf = (uint8_t *)data;
    usart_priv->tx_total_num = num;
    usart_priv->tx_cnt = 0;
    usart_priv->tx_busy = 1;
    usart_priv->last_tx_num = 0;
    ck_usart_reg_t *addr = (ck_usart_reg_t *)(usart_priv->base);
    ck_usart_intr_threshold_empty(usart_priv->idx, usart_priv);
    addr->IER |= IER_THRE_INT_ENABLE;
    return 0;
}