www.pudn.com > ADSP-BF561_MicronSensorExample_I2C_ASM_in_C.zip > main.c
/*****************************************************************************/ /*****************************************************************************/ /** **/ /** (C) Copyright 2003 - Analog Devices, Inc. All rights reserved. **/ /** **/ /*****************************************************************************/ /*****************************************************************************/ /*****************************************************************************/ /* ADI DSP Division, EMP, Munich */ /*****************************************************************************/ /* * * FILE NAME : main.c * * DATE : $Date: 2006/02/22 10:09:41 $ * * AUTHOR(S) : $Author: ANALOG\tlorenz $ * * REVISION NO. : $Revision: 1.3 $ * * 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.5 * * HARDWARE : ADSP-BF561 EZ-KIT * * date author changes * 22-JAN-2006 T. Lorenzen final release * * *****************************************************************************/ #include#include #include #include #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 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 Definitions *************************/ /************************************************************/ section ("sdram_data") volatile unsigned short VideoInputFrame[LINES_PER_FRAME][PIXEL_PER_LINE]; 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 = 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(); }