📄 c62x.cpp
字号:
#include "stdafx.h"
#include "C62x.h"
/*-------------------------------------------------------------------------*/
/* Write one word (32 bits) to DSP memory */
/*-------------------------------------------------------------------------*/
void WriteWord2Mem( LPVOID hHpi, ULONG ulDataAddr, ULONG ulDataWord )
{
ULONG ulLength;
ULONG ulReturnedLength;
ulLength = 4;
ulReturnedLength = ulLength;
if ( !evm6x_hpi_write( hHpi, &ulDataWord,
&ulReturnedLength, ulDataAddr) ) exit(6);
if ( ulLength != ulReturnedLength ) exit(7);
}
/*-------------------------------------------------------------------------*/
/* Read one word (32 bits) from DSP memory */
/*-------------------------------------------------------------------------*/
void ReadWord2Mem( LPVOID hHpi, ULONG ulDataAddr, ULONG *ulDataWord )
{
ULONG ulLength;
ULONG ulReturnedLength;
ulLength = 4;
ulReturnedLength = ulLength;
if ( !evm6x_hpi_read( hHpi, ulDataWord,
&ulReturnedLength, ulDataAddr) ) exit(6);
if ( ulLength != ulReturnedLength ) exit(7);
}
void InitDSP(HANDLE &hBd, LPVOID &hHpi)
{
// Board index
short iBd = 0;
// Exclusive open = TRUE
BOOL bExcl = 1;
// Map selector = MAP1
short iMp = 1;
// DSP boot mode
EVM6XDLL_BOOT_MODE mode = HPI_BOOT_MAP0;
// COFF load verbose mode = FALSE
BOOL bVerbose = 0;
// Clear bss mode = FALSE
BOOL bClr = 0;
// Dump mode = FALSE
BOOL bDump = 0;
// COFF file name
static char CoffNam[] = "..\\dsp\\gather.out";
hBd = NULL;
hHpi = NULL;
/*-----------------------------------------------------------------------*/
/* Open a driver connection to a specific [Mc]EVM6x board. */
/*-----------------------------------------------------------------------*/
hBd = evm6x_open( iBd, bExcl );
if ( hBd == INVALID_HANDLE_VALUE ) exit(1);
/*-----------------------------------------------------------------------*/
/* Cause a hardware reset on the target board. */
/*-----------------------------------------------------------------------*/
if ( !evm6x_reset_board(hBd) ) exit(2);
/*-----------------------------------------------------------------------*/
/* Set board configuration. */
/*-----------------------------------------------------------------------*/
if ( !evm6x_set_board_config(hBd, DSP_CLOCK_NORMAL,
LITTLE_ENDIAN_MODE, 0XFF) )
exit(0);
/*-----------------------------------------------------------------------*/
/* Set the boot mode and cause a DSP reset. */
/*-----------------------------------------------------------------------*/
mode = iMp ? HPI_BOOT : HPI_BOOT_MAP0;
if ( !evm6x_reset_dsp(hBd,mode) ) exit(3);
/*-----------------------------------------------------------------------*/
/* Establish a connection to the HPI of a target board. */
/*-----------------------------------------------------------------------*/
hHpi = evm6x_hpi_open(hBd);
if ( hHpi == NULL ) exit(4);
/*-----------------------------------------------------------------------*/
/* Initialize EMIF registers */
/*-----------------------------------------------------------------------*/
if ( !evm6x_init_emif(hBd, hHpi) ) exit(5);
/*-----------------------------------------------------------------------*/
/* set Aux DMA priority higher than CPU */
/*-----------------------------------------------------------------------*/
/* Due to the default priority of the auxiliary DMA channel used for */
/* HPI accesses, the CPU can prevent HPI accesses from completing for */
/* an indeterminate amount of time. This can occur when the CPU is */
/* very active on the external memory interface, such as while executing*/
/* code from external memory. This condition manifests itself as a */
/* hung PCI bus. To prevent this condition, the value 0x10 can be */
/* written to the DMA Auxiliary Control Register of the 6201 (at */
/* address 0x01840070). This elevates the priority of the auxiliary */
/* DMA channel above all other DMA channels and above the CPU. */
/*-----------------------------------------------------------------------*/
WriteWord2Mem( hHpi, 0x01840070 /*Addr*/, 0x00000010 /*Data*/ );
/*-----------------------------------------------------------------------*/
/* Read a COFF file and write the data to DSP memory. */
/*-----------------------------------------------------------------------*/
if (!evm6x_coff_load(hBd,hHpi,CoffNam,bVerbose,bClr,bDump)) exit(8);
/*-----------------------------------------------------------------------*/
/* Release the DSP from the halted state */
/*-----------------------------------------------------------------------*/
if (!evm6x_unreset_dsp(hBd)) exit(10);
}
void CloseDSP(HANDLE hBd, LPVOID hHpi)
{
/*-----------------------------------------------------------------------*/
/* Close the HPI session started with evm6x_hpi_open() */
/*-----------------------------------------------------------------------*/
if (!evm6x_hpi_close(hHpi)) exit(9);
/*-----------------------------------------------------------------------*/
/* Close a previously opened driver connection to a board. */
/*-----------------------------------------------------------------------*/
if (!evm6x_close(hBd)) exit(16);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -