📄 idma_channel0_example.c
字号:
/* ===========================================================================
* Copyright (c) Texas Instruments Inc 2002, 2003, 2004, 2005, 2006
*
* 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_channel0_example.c
*
* @path $(CSLPATH)\example\c6486\idma\src
*
* @desc Example of IDMA Channel 0 CSL
*
* ============================================================================
* @n Target Platform: TCI6486 VDB
* ============================================================================
* @n <b> Example Description </b>
* @n The example shows how to use the idma
* to transfer data between the peripheral configuration space (CFG)
* and any local memories (L1P, L1D, and L2). Two possible ways have
* been presented as to how to populate the CFG memory with the data
* using IDMA Channel 0.
* This example test the following operations.
* - Initialize IDMA channel 0
* - Set channel 0 to have interrupt event generation on
* - Perform copy of data from src to CFG space of Timer0
* - Wait until copying is completed
* - Comparing the data from source and destination addresses
*
* ============================================================================
* @n Target Platform: VDB
* ============================================================================
*
* <b> Procedure to run the example </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_channel0_example.pjt
* 5. Build the project and load the .out file of the project.
*
* @endverbatim
*
* =============================================================================
*/
/* ============================================================================
* Revision History
* ===============
* 02-02-2007 NS File Created.
*
* ============================================================================
*/
#include <stdio.h>
#include <stdlib.h>
#include <csl_idma.h>
#define MASK 0xFFFFFF0F
#define MASK2 0xFFFFFF0F
/* Align various arrays to a word address, in internal L2 */
#pragma DATA_SECTION(src, "ISRAM");
#pragma DATA_ALIGN(src, 32);
#pragma DATA_ALIGN(dst2, 32);
/* Static 80 byte array of data in "src" with known test pattern. */
unsigned int src[32] = {
0xDEADBEEF, 0xFADE0003, 0x5AA51C3A, 0x03036BA3,
0x00000FFF, 0x0000ABCD, 0x00001234, 0x00005678,
0x000003BE, 0x0000760F, 0x9675A800, 0xABCDEF12,
0xEEEECDEA, 0x01234567, 0x00000000, 0xFEEDFADE,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0
};
unsigned int *dst2 = (unsigned int *)0x025E0000;
void main(void)
{
Uint32 i, mask, cnt0;
Uint32 idmaChan0TestFailed = 0;
IDMA0_Config config;
/* Set Chan 0 to have Interrupt Event Gen On */
printf("Runnning IDMA Channel0 Example \n");
/* Initialize IDMA Channel 0 */
/* Set Chan 0 to have Interrupt Event Gen On */
cnt0 = IDMA0_init(IDMA_INT_EN);
if (cnt0 != 0x10000000){
printf("IDMA: Set the channel 0 to have Interrupt Event \
generation enable Failed.\n");
idmaChan0TestFailed++;
return;
}
else {
printf("IDMA: Set the channel 0 to have Interrupt Event \
generation enable Passed.\n");
printf("Channel 0 initialization passed.\n");
}
printf("===============================================================\n");
mask = MASK;
IDMA0_configArgs(mask, src, dst2, 0);
IDMA0_wait();
for (i = 0; i < 32; i++) {
if(!(mask & 0x1)){
if (src[i] != dst2[i]) {
printf("IDMA: configuring the MMRs Failed.\n");
idmaChan0TestFailed++;
return;
}
else {
printf("IDMA: src[%d] is: 0x%X dst2[%d] is: 0x%X\n", \
i,src[i],i,dst2[i]);
}
}
else {
printf("\tIDMA: Performing transfer of this data src[%d]: \
0x%X is blocked.\n",i,src[i]);
}
mask = mask >> 1;
}
mask = MASK2;
config.mask = mask;
config.src = src;
config.dst = dst2;
config.cnt = 0x0;
IDMA0_config(&config);
IDMA0_wait();
/* Check that what transferred to config bus MMRs is correct and */
/* with correct masking */
for (i = 0; i < 32; i++) {
if(!(mask & 0x1)) {
if (src[i] != dst2[i]) {
printf("IDMA: configuring the MMRs Failed.\n");
idmaChan0TestFailed++;
return;
}
else {
printf("IDMA: src[%d] is: 0x%X dst2[%d] is: 0x%X\n", \
i,src[i],i,dst2[i]);
}
}
else {
printf("\tIDMA: Performing transfer of this data src[%d]: \
0x%X is blocked.\n",i,src[i]);
}
mask = mask >> 1;
}
if (idmaChan0TestFailed > 0) {
printf ("\nIDMA: Channel 0 tests Failed. \
[Tests failed: %d]\n", idmaChan0TestFailed);
}
else {
printf ("\nIDMA: Channel 0 tests Passed.\n");
}
printf("===============================================================\n");
return;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -