edma.c

来自「使用於 TI dsk6711中的很多好用的例子可以看」· C语言 代码 · 共 81 行

C
81
字号
/*

 *  Copyright 2003 by Texas Instruments Incorporated.

 *  All rights reserved. Property of Texas Instruments Incorporated.

 *  Restricted rights to use, duplicate or disclose this code are

 *  granted through contract.

 *

 *  @(#) XDAS 2.51.00 11-29-2003 (xdas-2.50.00.9)

 */

/*

 *  ======== edma.c ========

 */



#include <std.h>



#include <dss.h>

#include <edma.h>



#include "c6711dsk.h"





/*

 *  ======== EDMA_init ========

 *  Initialise EDMA Controller

 */

Void EDMA_init(Void)

{

    /* General EDMA Initialisation */

    *(volatile Uns *) EER = 0x0000;     /* Disable all events */

    *(volatile Uns *) ECR = 0xffff;     /* Clear all pending events */

    *(volatile Uns *) CIER = 0x0000;    /* Disable all events to Interrupt */

    *(volatile Uns *) CIPR = 0xffff;    /* Clear all pending Queued EDMA ints */



    /*----------------------------------------------------------------------*/

    /* Initialise EDMA for Transfer from McBSP_0 on Receipt of New Sample   */

    *(volatile Uns *) EDMA_EVENTD_OPT   = 0x28710000;   // TCC = 1 for Receive

    *(volatile Uns *) EDMA_EVENTD_SRC   = McBSP0_DRR;   // Source = McBSP Rcv  

    *(volatile Uns *) EDMA_EVENTD_CNT   = 0x0;          // Count = not known yet

    *(volatile Uns *) EDMA_EVENTD_DST   = 0x0;          // Dst = not known yet

    *(volatile Uns *) EDMA_EVENTD_IDX   = 4;    // 4 byte offset (load low 16)

    *(volatile Uns *) EDMA_EVENTD_LNK   = 0;    // No auto reload parameters



    /*----------------------------------------------------------------------*/

    /* Initialise EDMA for Transfer Samples back to McBSP_0 when TXer Ready */

    *(volatile Uns *) EDMA_EVENTC_OPT   = 0x4B120000;   // TCC = 2 for Transmit

    *(volatile Uns *) EDMA_EVENTC_SRC   = 0x0;          // Src = not known yet

    *(volatile Uns *) EDMA_EVENTC_CNT   = 0x0;          // Cnt = not known yet

    *(volatile Uns *) EDMA_EVENTC_DST   = McBSP0_DXR;   // Dst = McBSP Transmit

    *(volatile Uns *) EDMA_EVENTC_IDX   = 4;    // 4 byte offset (load low 16)

    *(volatile Uns *) EDMA_EVENTC_LNK   = 0;    // No auto reload parameters

    

    /*----------------------------------------------------------------------*/

    /* Enable Events and Interrupts                                     */

    *(volatile Uns *) CIER = 0x0006;    /* Enable Rx/Tx Complete Interrupts */

}



/*

 *  ======= EDMA_rxStart ========

 */

Void EDMA_rxStart(Void *dst, Int nwords)

{

    /* Reconfig EDMA channel for next receive buffer */

    *(volatile Uns *) EDMA_EVENTD_CNT   = (Uns) DSS_rxCnt;

    *(volatile Uns *) EDMA_EVENTD_DST   = (Uns) DSS_rxPtr;



    *(volatile Uns *) EER = 0x3000;     /* Enable McBSP0 Rx/Tx Events */

    *(volatile Uns *) ESR = 0x2000;     /* Force Rx Event Start */

}



/*

 *  ======= EDMA_txStart ========

 */

Void EDMA_txStart(Void *src, Int nwords)

{

    /* Reconfig EDMA channel for next transmit buffer */

    *(volatile Uns *) EDMA_EVENTC_SRC   = (Uns) DSS_txPtr;

    *(volatile Uns *) EDMA_EVENTC_CNT   = (Uns) DSS_txCnt;



    *(volatile Uns *) EER = 0x3000;     /* Enable McBSP0 Rx/Tx Events */

    *(volatile Uns *) ESR = 0x1000;     /* Force Tx Event Start */

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?