/* Receives an amount of data in non blocking mode.  */
ald_status_t ald_uart_recv_by_it(ald_uart_handle_t *hperh, uint8_t *buf, uint16_t size)
/* Receives an amount of data in non blocking mode.  */
ald_status_t ald_uart_recv_by_it(ald_uart_handle_t *hperh, uint8_t *buf, uint16_t size)
{
    assert_param(IS_UART_ALL(hperh->perh));
    if ((hperh->state != ALD_UART_STATE_READY) && (hperh->state != ALD_UART_STATE_BUSY_TX))
        return ALD_BUSY;
    if ((buf == NULL ) || (size == 0))
        return ALD_ERROR;
    __LOCK(hperh);
    hperh->rx_buf   = buf;
    hperh->rx_size  = size;
    hperh->rx_count = 0;
    hperh->err_code = ALD_UART_ERROR_NONE;
    SET_BIT(hperh->state, ALD_UART_STATE_RX_MASK);
    __UNLOCK(hperh);
    SET_BIT(hperh->perh->ICR, UART_ICR_RFNEMPTY_MSK);
    ald_uart_interrupt_config(hperh, ALD_UART_IT_RFNEMPTY, ENABLE);
    return ALD_OK;
}