📄 programfpga.c
字号:
/*******************************************************************************/
/* */
/* (C) Copyright 2005 - Analog Devices, Inc. All rights reserved. */
/* */
/* FILE: M a i n ( ) */
/* */
/* CHANGES: 1.00.0 - initial release */
/* */
/* PURPOSE: VisualDSP++ "Flash Programmer" fpga driver for use with the */
/* ADSP-BF537 EZ-KIT Lite with the FPGA Extender board attached */
/* */
/*******************************************************************************/
#include <services/services.h> // system services includes
#include <drivers/adi_dev.h> // device manager includes
#include <stdlib.h> // malloc includes
#include "adi_spartan3.h"
#include "util.h" // EZ-Kit includes
section ("fpga")
#include "fpga_image.h"
//----- g l o b a l s -----//
void SetupDevice(void);
int WriteData( unsigned long ulStart, long lCount, long lStride, int *pnData );
//------------- m a i n ( ) ----------------//
int PROGRAM_FPGA()
{
int nOffset = 0;
int nCount = 0x625F8;
int nStride = 1;
int i = 0;
int index = 0;
unsigned int iResult;
// setup the fpga so the DSP can access it
SetupDevice();
iResult = WriteData( nOffset, sizeof(fpga_image), nStride, (int *)fpga_image );
return iResult;
}
//----------- S e t u p D e v i c e ( ) ----------//
//
// PURPOSE
// Perform necessary setup for the processor to talk to the
// device such as external memory interface registers, etc.
//
// RETURN VALUE
// ERROR_CODE - value if any error occurs during Opcode scan
// NO_ERR - otherwise
void SetupDevice(void)
{
*pEBIU_AMGCTL = 0xFF;
}
//----------- W r i t e D a t a ( ) ----------//
//
// PURPOSE
// Write a buffer to fpga.
//
// INPUTS
// unsigned long ulStart - offset to start the writes at
// long lCount - number of elements to write, in this case bytes
// long lStride - number of locations to skip between writes
// int *pnData - pointer to data buffer
//
// RETURN VALUE
// ERROR_CODE - value if any error occurs during writing
// NO_ERR - otherwise
//
// CHANGES
// 9-28-2005 Created
int WriteData( unsigned long ulStart, long lCount, long lStride, int *pnData )
{
int iResult = 0;
ADI_DEV_1D_BUFFER WriteBuff; // buffer pointer
WriteBuff.ElementCount = lCount;
WriteBuff.Data = (void *)pnData;
WriteBuff.pNext = NULL;
WriteBuff.pAdditionalInfo = (void *)&ulStart;
iResult = (int) adi_dev_Write( DevHandleSpartan3, ADI_DEV_1D, (ADI_DEV_BUFFER *)&WriteBuff);
// return the appropriate error code
return iResult;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -