📄 main.c
字号:
/*
* Copyright 2006
* Texas Instruments Incorporated
*
* All rights reserved. Property of Texas Instruments Incorporated
* Restricted rights to use, duplicate or disclose this code are
* granted through contract.
*
*/
/**
* @file main.c
*
* @brief Demonstrates how to use DAT APIs implemented using CSL DAT
* adapter with EDMA3 hardware
*
*
*/
#include <stdio.h>
/* Include the legacy csl 2.0 dat header */
#include <csl_dat.h>
/* Include EDMA3 low level driver specific implementation APIs for dat */
#include <csl2_dat_edma3lld.h>
#define SIZE 0x4000
#define NUM_TRANSFERS 0x100
/**
* EDMA3 Driver Handle, which is used to call all the Driver APIs.
* It gets initialized during EDMA3 Initialization.
*/
extern EDMA3_DRV_Handle hEdma;
extern EDMA3_DRV_Handle DAT_EDMA3LLD_hEdma;
/*
* Patterns to fill up in the source buffers
*/
unsigned long long fill1d = 0x1111111111111111;
unsigned long long fill1d2d = 0x1212121212121212;
unsigned long long fill2d1d = 0x8C0FFEE821212121;
unsigned long long fill2d2d = 0x2222222222222222;
unsigned long long fillzero = 0x0;
/*
* Destination buffer
*/
unsigned int dstBuff[SIZE];
/*
* Source buffers
*/
unsigned int srcBuff1[SIZE],srcBuff2[SIZE],srcBuff3[SIZE], srcBuff4[SIZE];
void main() {
/*
* Initialize Dat reference implementation module using EDMA3 Low level
* driver.
* - Creates and opens an EDMA3 Driver instance if passed a NULL handle
* - Optionally, can pass an existing EDMA3 driver instance handle
*/
if (!DAT_EDMA3LLD_init(NULL))
{
printf("Error initializing EDMA3 low level driver\n");
exit();
}
else
{
DAT_EDMA3LLD_hEdma = hEdma;
}
/*
* Using the DAT adapter with EDMA3 low level driver requires you to
* first register interrupts with the underlying OS, BIOS in this case
*/
// _bios_registerEdma3Interrupts();
}
/*
* DAT_main task that will perform the dat transfers
*/
void DAT_main() {
/*
* Holds the waitId(s) returned from the various transfers
*/
int waitId[NUM_TRANSFERS];
if (0 != DAT_open(0,0,0))
{
waitId[1] = DAT_fill(srcBuff1, SIZE, (Uint32 *)&fill1d);
waitId[2] = DAT_fill(srcBuff2, SIZE, (Uint32 *)&fill1d2d);
waitId[3] = DAT_fill(srcBuff3, SIZE, (Uint32 *)&fill2d1d);
waitId[4] = DAT_fill(srcBuff4, SIZE, (Uint32 *)&fill2d2d);
waitId[5] = DAT_fill(dstBuff, SIZE, (Uint32 *)&fillzero);
DAT_wait(waitId[1]);
if (DAT_busy(waitId[2])) {
/* srcBuff2 is busy, so copy Buff 1 first */
DAT_copy(srcBuff1, dstBuff, 16 * 4 * 8);
DAT_wait(waitId[1]);
DAT_copy2d(DAT_1D2D,srcBuff2, dstBuff + 16 * 8, 4 * 4, 16, 16 * 4);
}
else {
/*
* Copy out two rows of 64 bytes
*/
DAT_copy2d(DAT_1D2D,srcBuff2, dstBuff + 16 * 8, 4 * 4, 16, 16 * 4);
/*
* Copy out a row of data from srcBuff2 into a 2-d patter in dstBuff
*/
DAT_copy(srcBuff1, dstBuff, 16 * 4 * 8);
}
/*
* Wait for all transfers to finish
*/
DAT_wait(DAT_XFRID_WAITALL);
/*
* Demonstrate 2D copy mode
*/
waitId[6] = DAT_copy2d(DAT_2D1D, srcBuff3, dstBuff + 16 * 22 + 4 , 4, 12, 16 * 4);
waitId[7] = DAT_copy2d(DAT_2D1D, srcBuff3, dstBuff + 16 * 23 + 4 , 4, 12, 16 * 4);
waitId[8] = DAT_copy2d(DAT_2D2D, srcBuff4, dstBuff +16 * 8 + 4 , 4 * 12, 14, 16 * 4);
/*
* Wait for all transfers to complete
*/
DAT_wait(DAT_XFRID_WAITALL);
/*
* Clear up fill buffers
*/
waitId[0] = DAT_fill(srcBuff1, SIZE, (Uint32 *)&fillzero);
waitId[1] = DAT_fill(srcBuff2, SIZE, (Uint32 *)&fillzero);
waitId[2] = DAT_fill(srcBuff3, SIZE, (Uint32 *)&fillzero);
waitId[3] = DAT_fill(srcBuff4, SIZE, (Uint32 *)&fillzero);
/*
* Wait for all transfers to complete
*/
DAT_wait(DAT_XFRID_WAITALL);
/*
* Close DAT module
*/
DAT_close();
printf("DONE\n");
}
else
{
printf("Failed to open DAT\n");
}
/*
* Clean up and exit Dat reference implementation module using EDMA3 Low level
*/
DAT_EDMA3LLD_exit();
/*
* Un-register interrupts
*/
// _bios_unregisterEdma3Interrupts();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -