⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pros_edma3_drv_sample_app.c

📁 vicp做为dm6446上的硬件加速器
💻 C
📖 第 1 页 / 共 2 页
字号:
/*******************************************************************************
**+--------------------------------------------------------------------------+**
**|                            ****                                          |**
**|                            ****                                          |**
**|                            ******o***                                    |**
**|                      ********_///_****                                   |**
**|                      ***** /_//_/ ****                                   |**
**|                       ** ** (__/ ****                                    |**
**|                           *********                                      |**
**|                            ****                                          |**
**|                            ***                                           |**
**|                                                                          |**
**|         Copyright (c) 1998-2006 Texas Instruments Incorporated           |**
**|                        ALL RIGHTS RESERVED                               |**
**|                                                                          |**
**| Permission is hereby granted to licensees of Texas Instruments           |**
**| Incorporated (TI) products to use this computer program for the sole     |**
**| purpose of implementing a licensee product based on TI products.         |**
**| No other rights to reproduce, use, or disseminate this computer          |**
**| program, whether in part or in whole, are granted.                       |**
**|                                                                          |**
**| TI makes no representation or warranties with respect to the             |**
**| performance of this computer program, and specifically disclaims         |**
**| any responsibility for any damages, special or consequential,            |**
**| connected with the use of this program.                                  |**
**|                                                                          |**
**+--------------------------------------------------------------------------+**
*******************************************************************************/

/** \file   pros_edma3_drv_sample_app.c

    \brief  Demo sample application for the EDMA3 Driver.

    (C) Copyright 2006, Texas Instruments, Inc

    \version    1.0   Sukumar Ghorai         - Created

 */

#include <ti/sdo/edma3/drv/sample/pros_edma3_drv_sample.h>
extern void edma3OsWaitMsecs(unsigned int mSecs);
#define TSK_sleep(a) edma3OsWaitMsecs(10*a)


/* Flag variable to check transfer completion on channel 1 */
static volatile short irqRaised1 = 0;
/* Flag variable to check transfer completion on channel 2 */
static volatile short irqRaised2 = 0;


/* Cache line aligned source buffer 1. */
#ifdef EDMA3_ENABLE_DCACHE
/**
 * The DATA_ALIGN pragma aligns the symbol to an alignment boundary. The
 * alignment boundary is the maximum of the symbol抯 default alignment value
 * or the value of the constant in bytes. The constant must be a power of 2.
 * The syntax of the pragma in C is:
 * #pragma DATA_ALIGN (symbol, constant);
 */
#pragma DATA_ALIGN(_srcBuff1, EDMA3_CACHE_LINE_SIZE_IN_BYTES);
#endif  /* #ifdef EDMA3_ENABLE_DCACHE */
static signed char   _srcBuff1[MAX_BUFFER_SIZE];


/* Cache line aligned destination buffer 1. */
#ifdef EDMA3_ENABLE_DCACHE
/**
 * The DATA_ALIGN pragma aligns the symbol to an alignment boundary. The
 * alignment boundary is the maximum of the symbol抯 default alignment value
 * or the value of the constant in bytes. The constant must be a power of 2.
 * The syntax of the pragma in C is:
 * #pragma DATA_ALIGN (symbol, constant);
 */
#pragma DATA_ALIGN(_dstBuff1, EDMA3_CACHE_LINE_SIZE_IN_BYTES);
#endif  /* #ifdef EDMA3_ENABLE_DCACHE */
static signed char   _dstBuff1[MAX_BUFFER_SIZE];


static signed char *srcBuff1;
static signed char *dstBuff1;



/* Cache line aligned source buffer 2. */
#ifdef EDMA3_ENABLE_DCACHE
/**
 * The DATA_ALIGN pragma aligns the symbol to an alignment boundary. The
 * alignment boundary is the maximum of the symbol抯 default alignment value
 * or the value of the constant in bytes. The constant must be a power of 2.
 * The syntax of the pragma in C is:
 * #pragma DATA_ALIGN (symbol, constant);
 */
#pragma DATA_ALIGN(_srcBuff2, EDMA3_CACHE_LINE_SIZE_IN_BYTES);
#endif  /* #ifdef EDMA3_ENABLE_DCACHE */
static signed char   _srcBuff2[MAX_BUFFER_SIZE];


#ifdef EDMA3_ENABLE_DCACHE
/* Cache line aligned destination buffer 2. */
/**
 * The DATA_ALIGN pragma aligns the symbol to an alignment boundary. The
 * alignment boundary is the maximum of the symbol抯 default alignment value
 * or the value of the constant in bytes. The constant must be a power of 2.
 * The syntax of the pragma in C is:
 * #pragma DATA_ALIGN (symbol, constant);
 */
#pragma DATA_ALIGN(_dstBuff2, EDMA3_CACHE_LINE_SIZE_IN_BYTES);
#endif  /* #ifdef EDMA3_ENABLE_DCACHE */
static signed char   _dstBuff2[MAX_BUFFER_SIZE];



static signed char *srcBuff2;
static signed char *dstBuff2;


#ifdef EDMA3_PING_PONG_TEST
/** Test Case Description **/
/**
 * There are two big buffers of size (PING_PONG_NUM_COLUMNS * PING_PONG_NUM_ROWS).
 * Both are present in DDR and are known as pingpongSrcBuf and pingpongDestBuf.
 * There are two small buffers of size (PING_PONG_L1D_BUFFER_SIZE). They are known as
 * ping buffer and pong buffer.
 * The pingpongSrcBuf is divided into chunks, each having size of
 * PING_PONG_L1D_BUFFER_SIZE. Data is being transferred from pingpongSrcBuf
 * to either ping or pong buffers, using EDMA3. Logic behind using two ping pong
 * buffers is that one can be processed by DSP while the other is used by EDMA3
 * for data movement. So ping and pong are alternately used by EDMA3 and DSP.
 * Also, to simulate the real world scenario, as a part of DSP processing,
 * I am copying data from ping/pong buffers to pingpongDestBuf.
 * In the end, I compare pingpongSrcBuf and pingpongDestBuf to check whether
 * the algorithm has worked fine.
 */
/**
 * Number of columns in the bigger source buffer.
 */
#define PING_PONG_NUM_COLUMNS           (720u)

/**
 * Number of columns in the bigger source buffer.
 */
#define PING_PONG_NUM_ROWS                (480u)

/* ACNT is equal to number of columns. */
#define PING_PONG_ACNT                          PING_PONG_NUM_COLUMNS
/* BCNT is equal to number of rows which will be transferred in one shot. */
#define PING_PONG_BCNT                          (8u)
/* CCNT is equal to 1. */
#define PING_PONG_CCNT                          (1u)

/* Number of times DMA will be triggered. */
#define PING_PONG_NUM_TRIGGERS           (PING_PONG_NUM_ROWS/PING_PONG_BCNT)

/* Size of bigger buffers in DDR. */
#define PING_PONG_DDR_BUFFER_SIZE     (PING_PONG_NUM_COLUMNS*PING_PONG_NUM_ROWS)
/* Size of smaller buffers in IRAM. */
#define PING_PONG_L1D_BUFFER_SIZE     (PING_PONG_ACNT*PING_PONG_BCNT)

/* Ping pong source buffer */
#ifdef EDMA3_ENABLE_DCACHE
/* Cache line aligned big source buffer. */
/**
 * The DATA_ALIGN pragma aligns the symbol to an alignment boundary. The
 * alignment boundary is the maximum of the symbol抯 default alignment value
 * or the value of the constant in bytes. The constant must be a power of 2.
 * The syntax of the pragma in C is:
 * #pragma DATA_ALIGN (symbol, constant);
 */
#pragma DATA_ALIGN(_pingpongSrcBuf, EDMA3_CACHE_LINE_SIZE_IN_BYTES);
#endif  /* #ifdef EDMA3_ENABLE_DCACHE */
static signed char _pingpongSrcBuf[PING_PONG_DDR_BUFFER_SIZE];


/**
 * Ping pong destination buffer.
 * It will be used to copy data from L1D ping/pong buffers to check the
 * validity.
 */
#ifdef EDMA3_ENABLE_DCACHE
/* Cache line aligned big destination buffer. */
/**
 * The DATA_ALIGN pragma aligns the symbol to an alignment boundary. The
 * alignment boundary is the maximum of the symbol抯 default alignment value
 * or the value of the constant in bytes. The constant must be a power of 2.
 * The syntax of the pragma in C is:
 * #pragma DATA_ALIGN (symbol, constant);
 */
#pragma DATA_ALIGN(_pingpongDestBuf, EDMA3_CACHE_LINE_SIZE_IN_BYTES);
#endif  /* #ifdef EDMA3_ENABLE_DCACHE */
static signed char _pingpongDestBuf[PING_PONG_DDR_BUFFER_SIZE];


/* These destination buffers are in IRAM. */
#ifdef EDMA3_ENABLE_DCACHE
/* Cache line aligned destination buffer 1 i.e. Ping buffer. */
/**
 * The DATA_ALIGN pragma aligns the symbol to an alignment boundary. The
 * alignment boundary is the maximum of the symbol抯 default alignment value
 * or the value of the constant in bytes. The constant must be a power of 2.
 * The syntax of the pragma in C is:
 * #pragma DATA_ALIGN (symbol, constant);
 */
#pragma DATA_ALIGN(_dstL1DBuff1, EDMA3_CACHE_LINE_SIZE_IN_BYTES);
#endif  /* #ifdef EDMA3_ENABLE_DCACHE */
#pragma DATA_SECTION(_dstL1DBuff1, "my_sect");
static signed char _dstL1DBuff1[PING_PONG_L1D_BUFFER_SIZE];

#ifdef EDMA3_ENABLE_DCACHE
/* Cache line aligned destination buffer 2 i.e. Pong buffer. */
/**
 * The DATA_ALIGN pragma aligns the symbol to an alignment boundary. The
 * alignment boundary is the maximum of the symbol抯 default alignment value
 * or the value of the constant in bytes. The constant must be a power of 2.
 * The syntax of the pragma in C is:
 * #pragma DATA_ALIGN (symbol, constant);
 */
#pragma DATA_ALIGN(_dstL1DBuff2, EDMA3_CACHE_LINE_SIZE_IN_BYTES);
#endif  /* #ifdef EDMA3_ENABLE_DCACHE */
#pragma DATA_SECTION(_dstL1DBuff2, "my_sect");
static signed char _dstL1DBuff2[PING_PONG_L1D_BUFFER_SIZE];

/* Pointers for all those buffers */
static signed char *pingpongSrcBuf;
static signed char *pingpongDestBuf;
static signed char *pingpongSrcBufCopy;
static signed char *pingpongDestBufCopy;

static signed char *dstL1DBuff1;
static signed char *dstL1DBuff2;

#endif  /* #ifdef EDMA3_PING_PONG_TEST */


/**
 * EDMA3 Driver Handle, which is used to call all the Driver APIs.
 * It gets initialized during EDMA3 Initialization.
 */
extern EDMA3_DRV_Handle hEdma;



/**
 *  \brief   EDMA3 mem-to-mem data copy test case, using a DMA channel.
 *
 *
 *  \param  acnt        [IN]      Number of bytes in an array
 *  \param  bcnt        [IN]      Number of arrays in a frame
 *  \param  ccnt        [IN]      Number of frames in a block
 *  \param  syncType    [IN]      Synchronization type (A/AB Sync)
 *
 *  \return  EDMA3_DRV_SOK or EDMA3_DRV Error Code
 */
static EDMA3_DRV_Result edma3_test(
                    unsigned int acnt,
                    unsigned int bcnt,
                    unsigned int ccnt,
                    EDMA3_DRV_SyncType syncType);



/**
 *  \brief   EDMA3 mem-to-mem data copy test case, using two DMA
 *              channels, linked to each other.
 *
 *  \param  acnt        [IN]      Number of bytes in an array
 *  \param  bcnt        [IN]      Number of arrays in a frame
 *  \param  ccnt        [IN]      Number of frames in a block
 *  \param  syncType    [IN]      Synchronization type (A/AB Sync)
 *
 *  \return  EDMA3_DRV_SOK or EDMA3_DRV Error Code
 */
static EDMA3_DRV_Result edma3_test_with_link(
                    unsigned int acnt,
                    unsigned int bcnt,
                    unsigned int ccnt,
                    EDMA3_DRV_SyncType syncType);



/**
 *  \brief   EDMA3 mem-to-mem data copy test case, using a QDMA channel.
 *
 *
 *  \param  acnt        [IN]      Number of bytes in an array
 *  \param  bcnt        [IN]      Number of arrays in a frame
 *  \param  ccnt        [IN]      Number of frames in a block
 *  \param  syncType    [IN]      Synchronization type (A/AB Sync)
 *
 *  \return  EDMA3_DRV_SOK or EDMA3_DRV Error Code
 */
static EDMA3_DRV_Result qdma_test(
                    unsigned int acnt,
                    unsigned int bcnt,
                    unsigned int ccnt,
                    EDMA3_DRV_SyncType syncType);



/**
 *  \brief   EDMA3 misc test cases.
 *              This test case will read/write to some CC registers.
 *
 *  \return  EDMA3_DRV_SOK or EDMA3_DRV Error Code
 */
static EDMA3_DRV_Result edma3_misc_test();



#ifdef QDMA_TEST_WITH_LINKING
/**
 *  \brief   EDMA3 mem-to-mem data copy test case, using a QDMA channel,
 *              linked to another LINK channel.
 *
 *  \param  acnt        [IN]      Number of bytes in an array
 *  \param  bcnt        [IN]      Number of arrays in a frame
 *  \param  ccnt        [IN]      Number of frames in a block
 *  \param  syncType    [IN]      Synchronization type (A/AB Sync)
 *
 *  \return  EDMA3_DRV_SOK or EDMA3_DRV Error Code
 */
static EDMA3_DRV_Result qdma_test_with_link(
                    unsigned int acnt,
                    unsigned int bcnt,
                    unsigned int ccnt,
                    EDMA3_DRV_SyncType syncType);
#endif  /* #ifdef QDMA_TEST_WITH_LINKING */



#ifdef EDMA3_TEST_WITH_CHAINING
/**
 *  \brief   EDMA3 mem-to-mem data copy test case, using two DMA channels,
 *              chained to each other.
 *
 *  \param  acnt        [IN]      Number of bytes in an array
 *  \param  bcnt        [IN]      Number of arrays in a frame
 *  \param  ccnt        [IN]      Number of frames in a block
 *  \param  syncType    [IN]      Synchronization type (A/AB Sync)
 *
 *  \return  EDMA3_DRV_SOK or EDMA3_DRV Error Code
 */
static EDMA3_DRV_Result edma3_test_with_chaining(
                                unsigned int acnt,
                                unsigned int bcnt,
                                unsigned int ccnt,
                                EDMA3_DRV_SyncType syncType);
#endif  /* #ifdef EDMA3_TEST_WITH_CHAINING */



#ifdef EDMA3_POLL_MODE_TEST
/**
 *  \brief   EDMA3 mem-to-mem data copy test case, using a DMA channel.
 *              This test case doesnot rely on the callback mechanism.
 *              Instead, it Polls the IPR register to check the transfer
 *              completion status.
 *
 *  \param  acnt        [IN]      Number of bytes in an array
 *  \param  bcnt        [IN]      Number of arrays in a frame
 *  \param  ccnt        [IN]      Number of frames in a block
 *  \param  syncType    [IN]      Synchronization type (A/AB Sync)
 *
 *  \return  EDMA3_DRV_SOK or EDMA3_DRV Error Code
 */
static EDMA3_DRV_Result edma3_test_poll_mode(
                                unsigned int acnt,
                                unsigned int bcnt,
                                unsigned int ccnt,
                                EDMA3_DRV_SyncType syncType);
#endif  /* #ifdef EDMA3_POLL_MODE_TEST */



#ifdef EDMA3_PING_PONG_TEST

/**
 *  \brief   EDMA3 ping-pong based data copy test case, using a DMA and
 *              a link channel.
 *
 *  \return  EDMA3_DRV_SOK or EDMA3_DRV Error Code
 */
static EDMA3_DRV_Result edma3_test_ping_pong_mode();

#endif  /* #ifdef EDMA3_PING_PONG_TEST */



/* Callback function 1 */
static void callback1 (unsigned int tcc, EDMA3_RM_TccStatus status,
                        void *appData)
    {
    (void)tcc;
    (void)appData;

    switch (status)
        {
        case EDMA3_RM_XFER_COMPLETE:
            /* Transfer completed successfully */

⌨️ 快捷键说明

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