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

📄 main.c

📁 adi black fin chip connect to cmos sensor
💻 C
字号:
/*****************************************************************************
*	main.c
*   
*	Copyright (c) 2007 Analog Devices, Inc.  All Rights Reserved.
*   This software is proprietary to Analog Devices, Inc. and its
*	licensors.
*  
* 	CHANGES:  	10/24/2007  1.00  - initial public release
*
*	SOFTWARE: 	VisualDSP++ 5.0 August 2007 Update
* 
* 	HARDWARE: 	BF561 EZ-Kit Lite Board Rev 1.4
*				Micron MTV9022 or MTV9032 Sensor
*
*
*	DESCRIPTION:
* 
*	Contains the main implementation of the Image Capture project.
*
* 
******************************************************************************/

#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 STOP_MODE				0x0000
#define AUTOBUFFER_MODE			0x1000

#define POL_C 			0x0000
#define POL_S 			0x0000
#define PIXEL_PER_LINE	720
#define LINES_PER_FRAME	480
#define X_MODIFY		2
#define Y_MODIFY		2

#define DMA_COUNT_DIV	1
#define DATALEN			0x0800		// 10-bit bus
#define	DataPacking		0x0000		// packing disabled=0x0000

#define PPICOUNT		719	


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

/*------------------------------------------------------------
 *           Variable Declarations                                   
 * -----------------------------------------------------------*/

section ("sdram_bank0") volatile unsigned short VideoInputFrame[LINES_PER_FRAME][PIXEL_PER_LINE];
volatile unsigned short *usDestAddr;
extern int result;




void main() 
{
	
 // Init the pointer with the start addr of the array
	usDestAddr = &VideoInputFrame[0][0];				

 // Initialize Micron Sensor
	micron_init();

 // Capture Image
	VideoSensorFrameCapture ( (void*) usDestAddr );

	printf ("DMA done \n");

	while(1);
};


void VideoSensorFrameCapture ( unsigned short *usPTR )
{
	    
    *pPLL_CTL = 0x1410;
	
    // configure DMA for PPI0
	
	*pDMA1_0_X_COUNT = PIXEL_PER_LINE/DMA_COUNT_DIV;	// MI350 pixels per line		
	*pDMA1_0_Y_COUNT = LINES_PER_FRAME;					// lines per frame from the sensor
	*pDMA1_0_X_MODIFY = X_MODIFY;						// Modifier 2 because of 16-bit DMA mode
	*pDMA1_0_Y_MODIFY = Y_MODIFY;						// 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 = AUTOBUFFER_MODE | 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 raising (MT9V022) edge of PCLK| PPI 10-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 + -