📄 main.c
字号:
/*
* Copyright 2002 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.
*
*/
/* "@(#) DSP/BIOS 4.80.208 12-06-02 (barracuda-l19)" */
/******************************************************************************\
* Copyright (C) 2000 Texas Instruments Incorporated.
* All Rights Reserved
*------------------------------------------------------------------------------
* FILENAME...... main.c
* DATE CREATED.. 01/11/2000
* LAST MODIFIED. 10/12/2000
\******************************************************************************/
#include <std.h>
#include <swi.h>
#include <log.h>
#include <csl.h>
#include <csl_dma.h>
#include <csl_irq.h>
#include "dma1cfg.h"
/*----------------------------------------------------------------------------*/
extern far SWI_Obj SwiMain;
extern far LOG_Obj LogMain;
void SwiMainFunc();
void DmaIsr();
static int Example3();
static int Example4();
#define BUFFSZ 1024
static Uint32 BuffA[BUFFSZ/sizeof(Uint32)];
static Uint32 BuffB[BUFFSZ/sizeof(Uint32)];
static volatile int Complete;
/*----------------------------------------------------------------------------*/
void main() {
/******************************************************************************\
* Before using DSP/BIOS configuration tool -
* run the manual_config version to check BuffA and BuffB start addresses
* - Create Dma config.structures
* dmaCfg1 : Prictl = 0x10000050 ( PRI=DMA START_STOP DST/SRC= Inc )
* Src = 0x00000000 (BuffA will be set separatly)
* Dst = 0x00000000 (BuffB will be set separatly )
* Cnt = 0x00000100 ( 256 byte elements)
* dmaCfg2 : Prictl = 0x12000050 ( PRI=DMA TCINT=Enable -
* START_STOP - DST/SRC=Inc )
* Src = 0x00000000 (BuffA will be set separatly)
* Dst = 0x00000000 (BuffB will be set separatly )
* Cnt = 0x00000100 ( 256 byte elements)
* dmaCfg2 will be used by Example4()
* - Open DMA handlers Channel 1 and Channel 3
* hDma1 for Example3()
* hDma3 for Example4()
*
\******************************************************************************/
LOG_printf(&LogMain,"<DMA1>");
SWI_post(&SwiMain);
}
/*----------------------------------------------------------------------------*/
void SwiMainFunc() {
int success = 1;
/* Call the various examples */
if (1) success = success && Example3();
if (1) success = success && Example4();
LOG_printf(&LogMain,"success=%d",success);
LOG_printf(&LogMain,"<DONE>");
}
/*----------------------------------------------------------------------------*/
int Example3() {
int success = TRUE;
int x;
LOG_printf(&LogMain,"Example3");
/* Initialize the buffers */
for (x=0; x<BUFFSZ/sizeof(Uint32); x++) {
BuffA[x] = x;
BuffB[x] = 0x00000000;
}
/* Let's use the DMA to perform a simple data copy from */
/* one buffer to another using the DMA_channel 1 */
/* Update the SRC/DST addresses of the config*/
DMA_FSETA(&dmaCfg1.src,SRC,SRC,(Uint32)BuffA);
DMA_FSETA(&dmaCfg1.dst,DST,DST,(Uint32)BuffB);
/* update the new config. parameter - Start transfer */
DMA_config(hDma1,&dmaCfg1);
/* Start DMA channel for transfer */
DMA_start(hDma1);
/* Wait until the DMA completes */
DMA_wait(hDma1);
/* close the DMA channels which was opened under the CSL_cfgInit() */
DMA_close(hDma1);
/* Verify the results */
for (x=0; x<BUFFSZ/sizeof(Uint32); x++) {
if (BuffA[x] != BuffB[x]) {success = FALSE; break;}
}
return success;
}
/*----------------------------------------------------------------------------*/
int Example4() {
int success = TRUE;
int x;
LOG_printf(&LogMain,"Example4");
/* Initialize the buffers */
for (x=0; x<BUFFSZ/sizeof(Uint32); x++) {
BuffA[x] = x;
BuffB[x] = 0x00000000;
}
/* Let's use the DMA to perform a simple data copy from */
/* one buffer to another with an Interrupt function call */
/* Enable the DMA completion interrupt */
IRQ_enable(DMA_getEventId(hDma3));
/* Update the SRC/DST addresses of the config*/
DMA_FSETA(&dmaCfg2.src,SRC,SRC,(Uint32)BuffA);
DMA_FSETA(&dmaCfg2.dst,DST,DST,(Uint32)BuffB);
/*Update config */
DMA_config(hDma3,&dmaCfg2);
/* Clear completion flag */
Complete = FALSE;
/* Start the DMA operation */
DMA_start(hDma3);
/* Wait until the DMA completes */
while (!Complete);
/* close DMA channel which was opened under the CSL_cfgInit() */
DMA_close(hDma3);
/* Verify the results */
for (x=0; x<BUFFSZ/sizeof(Uint32); x++) {
if (BuffA[x] != BuffB[x]) {success = FALSE; break;}
}
return success;
}
/*----------------------------------------------------------------------------*/
void DmaIsr() {
DMA_CLEAR_CONDITION(hDma3, DMA_SECCTL_FRAMECOND);
Complete = TRUE;
}
/*----------------------------------------------------------------------------*/
/******************************************************************************\
* End of main.c
\******************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -