Пример #1
0
int32_t serial_recv_stream_dma (serial_t *obj, char *prxbuf, uint32_t len)
{
    PHAL_RUART_OP      pHalRuartOp;
    PHAL_RUART_ADAPTER pHalRuartAdapter=(PHAL_RUART_ADAPTER)&(obj->hal_uart_adp);
    u8  uart_idx = pHalRuartAdapter->UartIndex;
    int32_t ret;

    pHalRuartOp = &(obj->hal_uart_op);
    if ((serial_dma_en[uart_idx] & SERIAL_RX_DMA_EN)==0) {
        PUART_DMA_CONFIG   pHalRuartDmaCfg;

        pHalRuartDmaCfg = &obj->uart_gdma_cfg;
#if 0        
        pHalRuartOp->HalRuartRxGdmaLoadDef (pHalRuartAdapter, pHalRuartDmaCfg);
        pHalRuartOp->HalRuartDmaInit (pHalRuartAdapter);
        InterruptRegister(&pHalRuartDmaCfg->RxGdmaIrqHandle);
        InterruptEn(&pHalRuartDmaCfg->RxGdmaIrqHandle);
        serial_dma_en[uart_idx] |= SERIAL_RX_DMA_EN;
#else
        if (HAL_OK == HalRuartRxGdmaInit(pHalRuartOp, pHalRuartAdapter, pHalRuartDmaCfg)) {
            serial_dma_en[uart_idx] |= SERIAL_RX_DMA_EN;
        }
        else {
            return HAL_BUSY;
        }
#endif
    }
    ret = pHalRuartOp->HalRuartDmaRecv(pHalRuartAdapter, (u8*)prxbuf, len);
    return (ret);
}
Пример #2
0
/**
 * Load UART HAL GDMA default setting
 *
 * Call this function to load the default setting for UART GDMA
 *
 *
 */
VOID
HalRuartRxGdmaInit(
    PRUART_ADAPTER pRuartAdapter
)
{
    PHAL_RUART_OP pHalRuartOp;
    PHAL_RUART_ADAPTER pHalRuartAdapter;
    PUART_DMA_CONFIG pUartGdmaConfig;
    PHAL_GDMA_ADAPTER pHalGdmaAdapter;
    
    if (NULL == pRuartAdapter) {
        return;
    }
    
    pHalRuartOp = pRuartAdapter->pHalRuartOp;
    pHalRuartAdapter = pRuartAdapter->pHalRuartAdapter;
    pUartGdmaConfig = pRuartAdapter->pHalRuartDmaCfg;

    if ((NULL == pHalRuartOp) || (NULL == pHalRuartAdapter) || (NULL == pUartGdmaConfig)) {
        return;
    }

    // Load default setting
    if (pHalRuartOp->HalRuartRxGdmaLoadDef != NULL) {
        HalGdmaOpInit((VOID*) (pUartGdmaConfig->pHalGdmaOp));
        pHalRuartOp->HalRuartRxGdmaLoadDef (pHalRuartAdapter, pUartGdmaConfig);
    }
    else {
        // Initial your GDMA setting here
    }

    // Start to patch the default setting
    pHalGdmaAdapter = (PHAL_GDMA_ADAPTER)pUartGdmaConfig->pRxHalGdmaAdapter;
    pHalGdmaAdapter->GdmaIndex   = 0;  // GDMA1
    pHalGdmaAdapter->ChNum       = 5;   // GDMA Channel
    pHalGdmaAdapter->ChEn        = GdmaCh5;     // GDMA Channel Enable

//    pUartGdmaConfig->RxGdmaIrqHandle.Data = pHalRuartAdapter;
    pUartGdmaConfig->RxGdmaIrqHandle.IrqNum = GDMA0_CHANNEL5_IRQ;
//    pUartGdmaConfig->RxGdmaIrqHandle.IrqFun = (IRQ_FUN)_UartTxDmaIrqHandle;
    pUartGdmaConfig->RxGdmaIrqHandle.Priority = 0x20;

    pHalRuartOp->HalRuartDmaInit (pHalRuartAdapter);
    InterruptRegister(&pUartGdmaConfig->RxGdmaIrqHandle);
    InterruptEn(&pUartGdmaConfig->RxGdmaIrqHandle);
}