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

📄 videoinedgedetection_system.c

📁 这个是balckfin533/561的视频输入和输出的源代码
💻 C
📖 第 1 页 / 共 2 页
字号:

*********************************************************************/	
section("sdram_bank1")
void InitButton (
	ADI_FLAG_ID	FlagID
){
    // open the flag    
    ezErrorCheck(adi_flag_Open (FlagID));
    // set flag direction as input
    ezErrorCheck(adi_flag_SetDirection(FlagID,ADI_FLAG_DIRECTION_INPUT));    
    // set flag trigger to sense button press & generate callback
    // senses on falling edge
    ezErrorCheck( adi_flag_InstallCallback	(	FlagID,							// Flag ID
#if defined(__ADSPBF561__)    
    											ADI_INT_PF0_15_A,				// peripheral ID
#elif defined(__ADSPBF533__)
												ADI_INT_PFA,					// peripheral ID
#endif												
    											ADI_FLAG_TRIGGER_RISING_EDGE,	// flag trigger mode
    											FALSE,							// not a wakeup flag
    											(void *)FlagID,					// Flag ID as client handle
    											DCBManagerHandle,				// Callback Manager
    											ButtonPressCallback				// callback function    						
    										));
    
	return;
}    

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

	Function:		TerminateSystem

	Description:	Closes all devices and terminates the application

*********************************************************************/
section("sdram_bank1")
void TerminateSystem (void)
{
	// Close MDMA streams
    CloseMDMA_Streams ();
    
#if defined(__ADSPBF561__)
	  
   	// Close ADV7183
	ezErrorCheck(adi_dev_Close(ADV7183DeviceHandle));
	// Close ADV717x
	ezErrorCheck(adi_dev_Close(ADV717xDeviceHandle));
	
#endif

	// Close the Device Manager
	ezErrorCheck(adi_dev_Terminate(DeviceManagerHandle));
	// Close down the DMA Manager
	ezErrorCheck(adi_dma_Terminate(DMAManagerHandle));		
	// Close Flag Manager
	ezErrorCheck(adi_flag_Terminate());	
	// Close Deferred Callback	
	ezErrorCheck(adi_dcb_Terminate());	
	// Close interrupt manager 
	ezErrorCheck(adi_int_Terminate());
		
	return;		
}

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

    Function:       InstallVideoDecoder
    Description:    Installs Video Decoder (ADV7183)

*********************************************************************/
section("sdram_bank1")
void InstallVideoDecoder()	
{
       
    // open the ADV7183 driver for video input
   	ezErrorCheck(adi_dev_Open(  DeviceManagerHandle,     		// Dev manager Handle
               		   			&ADIADV7183EntryPoint,          // Device Entry point
                          		0,                              // Device number
	                            NULL,                           // No client handle
   		                        &ADV7183DeviceHandle,           // Device manager handle address
       		                    ADI_DEV_DIRECTION_INBOUND,      // Data Direction (video in)
           		                DMAManagerHandle,               // Handle to DMA Manager
               		            DCBManagerHandle,				// Callback Manager
                   		        VideoInCallback));				// callback function

	// Configure the video decoder device driver
	ezErrorCheck(adi_dev_Control(ADV7183DeviceHandle, ADI_DEV_CMD_TABLE, VideoDecoderConfigTable));
	
#if defined(__ADSPBF561__)	
	// check if this is a cold start
	if (ADV717xDeviceHandle == NULL)
	{
#endif
		// if so, then Update Video Input Mode
		UpdateVideoMode ();
		// clear UpdateVideo flag	
		SystemFlag.UpdateVideoFlag = FALSE;
		// Format the Sobel video out frame buffers to specified video mode				
		FormatVideoOutFrames();
		// Configure and Install MDMA for Sobel Edge Detection
		ConfigureMDMA();
		
#if defined(__ADSPBF561__)			
	}
#endif

	// Check video mode
	if (SystemFlag.ITU656_Mode == ITU656_PAL)
	    // Config ADV7183 in PAL mode
		ezErrorCheck(adi_dev_Control(ADV7183DeviceHandle, ADI_AD7183_CMD_SET_VIDEO_FORMAT, (void *)1));
	else	// Video must be in NTSC
	    // Config ADV7183 in NTSC mode
		ezErrorCheck(adi_dev_Control(ADV7183DeviceHandle, ADI_AD7183_CMD_SET_VIDEO_FORMAT, (void *)0));
		
#if defined(__ADSPBF561__)
	// Set Dataflow method
	ezErrorCheck(adi_dev_Control(ADV7183DeviceHandle, ADI_DEV_CMD_SET_DATAFLOW_METHOD, (void *) ADI_DEV_MODE_CHAINED_LOOPBACK));
	// Enable streaming
	ezErrorCheck(adi_dev_Control(ADV7183DeviceHandle, ADI_DEV_CMD_SET_STREAMING, (void *) TRUE));
#else
	// Set Dataflow method
	ezErrorCheck(adi_dev_Control(ADV7183DeviceHandle, ADI_DEV_CMD_SET_DATAFLOW_METHOD, (void *) ADI_DEV_MODE_CHAINED));	
#endif
	
	// Prepare and submit video input buffer(s)
	SubmitVideoInBuffers();	
				
	return;
}

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

    Function:       EnableVideoIn
    Description:    Enable/Disable Video in dataflow (ADV7183)

*********************************************************************/
section("sdram_bank1")
void EnableVideoIn (bool dataflow)
{
	ezErrorCheck(adi_dev_Control(ADV7183DeviceHandle, ADI_DEV_CMD_SET_DATAFLOW, (void*)dataflow));
}

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

    Function:       InstallVideoEncoder
    Description:    Installs Video Encoder (ADV717x)

*********************************************************************/
section("sdram_bank1")
void InstallVideoEncoder()	
{

#if defined(__ADSPBF561__)

    // open the ADV7171 driver for video output
   	ezErrorCheck(adi_dev_Open(  DeviceManagerHandle,     		// Dev manager Handle
                		   		&ADIADV7179EntryPoint,          // Device Entry point
                            	0,                              // Device number
	                            NULL,                           // No client handle
    	                        &ADV717xDeviceHandle,           // Device manager handle address
        	                    ADI_DEV_DIRECTION_OUTBOUND,     // Data Direction (video out)
            	                DMAManagerHandle,               // Handle to DMA Manager
                	            DCBManagerHandle,				// Callback Manager
                    	        VideoOutCallback));				// callback function
                    	        
#elif defined(__ADSPBF533__)

    // open the AD7179 driver for video output
    ezErrorCheck(adi_dev_Open(  DeviceManagerHandle,            // Dev manager Handle
                 		   		&ADIADV7171EntryPoint,          // Device Entry point
                            	0,                              // Device number
	                            NULL,                           // No client handle
    	                        &ADV717xDeviceHandle,           // Device manager handle address
        	                    ADI_DEV_DIRECTION_OUTBOUND,     // Data Direction (video out)
            	                DMAManagerHandle,               // Handle to DMA Manager
                	            DCBManagerHandle,      			// Callback Manager
                    	        VideoOutCallback));				// callback function

#else
#error "*** ERROR: Processor not yet supported by the drivers ***"
#endif

	// Configure the video encoder device driver
	ezErrorCheck(adi_dev_Control(ADV717xDeviceHandle, ADI_DEV_CMD_TABLE, VideoEncoderConfigTable));	
	// Update ADV717x Operating video mode
	UpdateADV717xVideoMode ();	
	// Open PPI device for video out
	ezErrorCheck(adi_dev_Control(ADV717xDeviceHandle, ADI_ADV717x_CMD_SET_PPI_STATUS, (void *)ADI_ADV717x_PPI_OPEN));	
	// Set Dataflow method
	ezErrorCheck(adi_dev_Control(ADV717xDeviceHandle, ADI_DEV_CMD_SET_DATAFLOW_METHOD, (void *) ADI_DEV_MODE_CHAINED_LOOPBACK));

#if defined(__ADSPBF561__)	
	// Enable streaming
	ezErrorCheck(adi_dev_Control(ADV717xDeviceHandle, ADI_DEV_CMD_SET_STREAMING, (void *) TRUE));
#elif defined(__ADSPBF533__)
	// Prepare and submit video input buffer(s)
	SubmitVideoOutBuffers();			
#endif
		
	return;
}

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

    Function:       UpdateADV717xVideoMode
    Description:    Updates ADV717x operating video mode

*********************************************************************/
section("sdram_bank1")
void	UpdateADV717xVideoMode (void)	
{
    // Check present ITU video mode
	if (SystemFlag.ITU656_Mode == ITU656_PAL)
	{
	    // Config ADV717x in PAL mode
	    // SCFR with PAL config values
		ezErrorCheck(adi_dev_Control(ADV717xDeviceHandle, ADI_ADV717x_CMD_SET_SCF_REG, (void *)ADV717x_SCF_VALUE_PAL_BI));
		// Config other internal regs of ADV717x to PAL
		ezErrorCheck(adi_dev_Control(ADV717xDeviceHandle, ADI_DEV_CMD_REGISTER_TABLE_WRITE, (void *)ADV717x_PAL_Cfg));
	}	
	else	// Video must be in NTSC
	{
	    // Config ADV717x in NTSC mode
	    // SCFR with NTSC config values
		ezErrorCheck(adi_dev_Control(ADV717xDeviceHandle, ADI_ADV717x_CMD_SET_SCF_REG, (void *)ADV717x_SCF_VALUE_NTSC));
		// Config other internal regs of ADV717x to NTSC
		ezErrorCheck(adi_dev_Control(ADV717xDeviceHandle, ADI_DEV_CMD_REGISTER_TABLE_WRITE, (void *)ADV717x_NTSC_Cfg));
	}

	return;
}	
	
/*********************************************************************

    Function:       EnableVideoOut
    Description:    Enable/Disable Video out dataflow (ADV717x)

*********************************************************************/
section("sdram_bank1")
void EnableVideoOut (bool dataflow)
{
	ezErrorCheck(adi_dev_Control(ADV717xDeviceHandle, ADI_DEV_CMD_SET_DATAFLOW, (void*)dataflow));
}

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

	Function:		ExceptionHandler
					HWErrorHandler

	Description:	We should never get an exception or hardware error,
					but just in case we'll catch them and simply turn
					on all the LEDS should one ever occur.

*********************************************************************/
section("sdram_bank1")
static ADI_INT_HANDLER(ExceptionHandler)	// exception handler
{
		ezErrorCheck(1);
		return(ADI_INT_RESULT_PROCESSED);
}

section("sdram_bank1")
static ADI_INT_HANDLER(HWErrorHandler)		// hardware error handler
{
		ezErrorCheck(1);
		return(ADI_INT_RESULT_PROCESSED);
}

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

    Function:       VideoOutCallback

    Description:    Video Out callback function (ADV717x)

*********************************************************************/
section ("Callback_Code_L1")
static void VideoOutCallback(
	void *AppHandle,
	u32  Event,
	void *pArg
){         
	// Call corresponding service routine   
	VideoOut(AppHandle,Event,pArg);
	return;
}

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

    Function:       VideoInCallback

    Description:    Video In callback function (ADV7183)

*********************************************************************/
section ("Callback_Code_L1")
static void VideoInCallback(
	void *AppHandle,
	u32  Event,
	void *pArg
){
	// Call corresponding service routine   
	VideoIn(AppHandle,Event,pArg);
}

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

    Function:       ButtonPressCallback

    Description:    Ez-Kit button press callback function
    				Corresponding push button related operations
    				will start only after the button is released

*********************************************************************/
section ("Callback_Code_L1")
static void ButtonPressCallback	(	
	void *AppHandle,
	u32  Event,
	void *pArg
){
	// Call corresponding service routine   
	ButtonPressed(AppHandle,Event,pArg);
}

/*****/

⌨️ 快捷键说明

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