⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.c

📁 DSP的一个范例
💻 C
字号:
/*****************************************************************************/
/*****************************************************************************/
/**                                                                         **/
/** (C) Copyright 2003 - Analog Devices, Inc.  All rights reserved.         **/
/**                                                                         **/
/*****************************************************************************/
/*****************************************************************************/

/*****************************************************************************/
/*               ADI DSP Division, EMP, Munich					             */
/*****************************************************************************/
/*
 *
 * FILE NAME	: main.c	
 *
 * DATE         : $Date: 2005/06/21 10:09:41 $
 *
 * AUTHOR(S)    : $Author: ANALOG\tlorenz $
 *
 * REVISION NO. : $Revision: 1.2 $
 *
 * HISTORY      : $Log: main.c,v $
 * HISTORY      : Revision 1.2  2005/06/21 10:09:41  ANALOG\tlorenz
 * HISTORY      : no message
 * HISTORY      :
 * HISTORY      : Revision 1.1.1.1  2005/04/12 06:59:32  ANALOG\tlorenz
 * HISTORY      : start point
 * HISTORY      :
 * HISTORY      :
 * 
 * DESCRIPTION  : Configuration via I2C and download images from the 
 *				  Micron image sensor "MT9V022"
 *
 * SOFTWARE		: VisualDSP++4.0
 *
 * HARDWARE		: ADSP-BF561 EZ-KIT REV 1.3
 *
 *  date        author          changes
 *  04-JAN-2005 T. Lorenzen       final release
 *
 *
 *****************************************************************************/
#include <cdefBF561.h>
#include <ccblkfn.h>
#include <stdio.h>
#include <sys\exception.h>
#include "main.h"


#define CFG_GP_Input_3Syncs 	0x0020
#define GP_Input_Mode			0x000C
//#define DMAbuffermode			0x0000 // stop mode
#define DMAbuffermode			0x1000 // autobuffer

/*************************************
Switches on:
	ADSP-BF561 EZ-KIT REV1.3:
	sw2: all off
	sw3: 1=off 2=off 3=on 4=off
	sw5: 1=off 2=off 3=on 4=on

*************************************/

/************************************************************/
/*********** Settings for the Micron sensor *****************/
/************************************************************/
/*	Image viewer settings:									*/
/*	Column:720, Rows:480, greyscale image  8bit				*/
/*	Blackfin AV EZ-Extender REV 1.1 settings:				*/
/*	JP1: do not populate	(DNP)							*/
/*  JP2: Pin 2-3											*/
/*  JP3: Pin 3-5, 4-6										*/
/*  JP4: Pin 1-2							 				*/
/*  JP5: Pin 1-2							 				*/
/*  JP6: Pin 3-5, 4-6						 				*/
/*  JP7: DNP								 				*/
/*  JP8: DNP								 				*/
/*  JP9: 3-5, 4-6							 				*/
/*  JP10:DNP								 				*/
/************************************************************/
#define POL_C 			0x0000
#define POL_S 			0x0000
#define PIXEL_PER_LINE	720
#define LINES_PER_FRAME	480

#define BUSWIDTH_16
#ifdef BUSWIDTH_16
	#define DMA_COUNT_DIV	1
	#define DATALEN			0x3800		// 16-bit bus 0x3800		
	#define	DataPacking		0x0000		// packing disabled=0x0000
#else
	#define DMA_COUNT_DIV	2
	#define DATALEN			0x0000		// 8-bit bus 0x0000		
	#define	DataPacking		0x0080		// packing enabled=0x0080
#endif 
	
#define PPICOUNT		719			// 719
/************************************************************/
/************************************************************/

/************************************************************/
/*********** Prototypes *************************************/
/************************************************************/
void VideoSensorFrameCapture ( unsigned short *usPTR );
void MI350_init(void);
/************************************************************/
/************************************************************/

/************************************************************/
/************* variable definition **************************/
/************************************************************/

section ("sdram_data") volatile unsigned short VideoInputFrame[LINES_PER_FRAME][PIXEL_PER_LINE/2];
volatile unsigned short *usDestAddr;

extern int result;
/************************************************************/
/************************************************************/


void main() {

	usDestAddr = &VideoInputFrame[0][0];				// init the pointer with the start addr of the array

	// initialise Micron Sensor
	MI350_init();


	VideoSensorFrameCapture ( (void*) usDestAddr );		// function call



	printf ("DMA done \n");


	while(1);

};




void VideoSensorFrameCapture ( unsigned short *usPTR ){

	// configure DMA for PPI0
	*pDMA1_0_X_COUNT = PIXEL_PER_LINE/DMA_COUNT_DIV;		// pixels per line	
	*pDMA1_0_Y_COUNT = LINES_PER_FRAME;		// lines per frame from the sensor
	*pDMA1_0_X_MODIFY = 2;					// Modifier 2 because of 16-bit DMA mode
	*pDMA1_0_Y_MODIFY = 2;					// Modifier 2 because of 16-bit DMA mode
	*pDMA1_0_START_ADDR = usPTR;			// Destination address of the image

	// Autobuffer mode DMA | Restart FIFO | 2-D DMA | Bus width 16 bit | write to memory 
	*pDMA1_0_CONFIG = DMAbuffermode	| RESTART | DMA2D | WDSIZE_16 | WNR;

	// PPI0 setup
	*pPPI0_FRAME = LINES_PER_FRAME;	//The PPI is set to receive X lines per frame
	*pPPI0_COUNT = PPICOUNT;		//The PPI is set to stop receiving after X number of samples for each liene

	// Fetching data at the falling(LM9618)/raising(OV6630/MT9V022) edge of PCLK| PPI 16-bit bus | PPI input with three frame syncs
	*pPPI0_CONTROL = POL_S | POL_C | DATALEN | DataPacking | CFG_GP_Input_3Syncs | GP_Input_Mode;

	*pDMA1_0_CONFIG |= DMAEN;	// | DMA enable
	ssync();

	*pPPI0_CONTROL |= PORT_EN;	// | Start PPI
	ssync();


}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -