📄 idma_channel1_example.c
字号:
/* ===========================================================================
* Copyright (c) Texas Instruments Inc 2002, 2003, 2004, 2005, 2006, 2007
*
* Use of this software is controlled by the terms and conditions found in the
* license agreement under which this software has been supplied.
* ==========================================================================
*/
/** ============================================================================
*
* @file idma_channel1_example.c
*
* @path $(CSLPATH)\example\DM648\idma\src
*
* @desc Example of IDMA Channel 1 CSL
*
* ============================================================================
* @n <b> Example Description </b>
* @n The example shows how to use the idma for data transfer from one memory
* area to another memory area
* This example test the following operations.
* - Initialize IDMA channel 1
* - Set channel 1 to have priority 7 and interrupt event generation on
* - Clear dst1 array
* - Perform copy of data from src to dst1
* - Wait until copying is completed
* - Comparing the source and destination buffers
*
* ============================================================================
* @n Target Platform: EVM
* ============================================================================
*
* <b> Example Procedure </b>
* @verbatim
* 1. Configure the CCS setup to work with the emulator being used
* 2. Please refer CCS manual for setup configuration and loading
* proper GEL file
* 3. Launch CCS window
* 4. Open project Idma_example.pjt
* 5. Build the project and load the .out file of the project.
* 6. The example can be executed from the main().
*
* @endverbatim
*
*/
/* ============================================================================
* Revision History
* ===============
* 27-Jul-2005 sd File Created.
* 12-01-2007 NS File Updated.
*
* ============================================================================
*/
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <cslr_idma.h>
#include <soc.h>
#define CSL_IDMA_DATA_ALIGN_MASK 0xFFFC
#define DATA_COUNT_BYTES 80
#define DATA_COUNT_WORDS (DATA_COUNT_BYTES/4)
/* Align various arrays to a double word address, in internal L2 */
#pragma DATA_SECTION(src, "ISRAM");
#pragma DATA_SECTION(dst1, "ISRAM1");
#pragma DATA_ALIGN(src, 8);
#pragma DATA_ALIGN(dst1, 8);
/* Static 80 byte array of data in "src" with known test pattern */
Uint32 src[20] =
{
0xDEADBEEF, 0xFADEBABE, 0x5AA51C3A, 0xD4536BA3,
0x5E69BA23, 0x4884A01F, 0x9265ACDA, 0xFFFF0123,
0xBEADDABE, 0x234A76B2, 0x9675ABCD, 0xABCDEF12,
0xEEEECDEA, 0x01234567, 0x00000000, 0xFEEDFADE,
0x0A1B2C3D, 0x4E5F6B7C, 0x5AA5ECCE, 0xFABEFACE
};
/* Forward declaration */
void idma_example (void);
/* Array in which results will be copied over */
Uint32 dst1[0x200];
/* Global variable to check fail status of example */
Uint32 idmaExampleFailed = 0;
void main(void)
{
/* Invoke a example */
idma_example ();
if (idmaExampleFailed > 0) {
printf ("<<Example Failed>>: Idma Channel 1 example failed. [Tests failed: %d]\n", \
idmaExampleFailed);
}
else {
printf ("<<Example Passed>>: Idma Channel 1 example passed.\n");
}
printf("===============================================================\n");
return;
}
/*
* =============================================================================
* @func idma_example
*
* @arg
* NONE
*
* @desc
* This example shows how idma csl performs the data transfer between
* source and destination buffers
*
* @return
* NONE
*
* =============================================================================
*/
void idma_example (void)
{
Uint32 count;
Uint32 cs;
/* Pointer to register overlay structure */
CSL_IdmaRegsOvly idmaRegs = (CSL_IdmaRegsOvly)CSL_IDMA_0_REGS;
cs = _disable_interrupts();
/* Initialize IDMA Channel 1
* Set Chan 1 to have Priority 7 and Interrupt Event Gen On
*/
idmaRegs->IDMA1_CNT = CSL_FMK (IDMA_IDMA1_CNT_PRI, CSL_IDMA_IDMA1_CNT_PRI_PRI7)
| CSL_FMKT (IDMA_IDMA1_CNT_INT, YES);
_restore_interrupts(cs);
/* Clear dst1 array */
memset(dst1, 0, sizeof(dst1));
/* Copy src to dst1 - 80 bytes - 20 words */
cs = _disable_interrupts();
/* Make sure that there are no pending transfers before using
* this channel. This is done by reading bit "1" of the status
* register.
*/
while (CSL_FEXT(idmaRegs->IDMA1_STAT, IDMA_IDMA1_STAT_PEND));
/* Poke in "src", "dst" and "count" with the correct
* priority and interrupt flags on.
*/
idmaRegs->IDMA1_SRC = (Uint32) src;
idmaRegs->IDMA1_DST = (Uint32) dst1;
((CSL_IdmaRegs*)CSL_IDMA_0_REGS)->IDMA1_CNT |= (DATA_COUNT_BYTES & CSL_IDMA_DATA_ALIGN_MASK);
_restore_interrupts(cs);
/* Wait until copying is completed */
cs = _disable_interrupts();
while (idmaRegs->IDMA1_STAT &
(CSL_IDMA_IDMA1_STAT_PEND_MASK | CSL_IDMA_IDMA1_STAT_ACTV_MASK));
_restore_interrupts(cs);
/* Comparing the source and destination buffers */
if (memcmp(src, dst1, sizeof(src))) {
printf("IDMA: data copy from source to destination using idma is ");
printf("failed\n");
idmaExampleFailed++;
return;
}
else {
for(count = 0; count < DATA_COUNT_WORDS; count++)
printf("value of src[%d]: 0x%x,value of dst[%d]: 0x%x\n", \
count, src[count], count, dst1[count]);
printf("IDMA: data copy from source to destination using idma is ");
printf("passed\n");
}
printf("===============================================================\n");
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -