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

📄 jpeg_mjpeg_main.c

📁 这个是balckfin533/561的MPEG和Mjpeg的源代码
💻 C
字号:
/*****************************************************************************
Copyright(c) 2005 Analog Devices, Inc.  All Rights Reserved. This software is 
proprietary and confidential to Analog Devices, Inc. and its licensors.
******************************************************************************

$RCSfile: jpeg_mjpeg_main.c,v $
$Revision: 1.2 $
$Date: 2006/11/10 07:18:58 $

Project:	BlackfinSDK (JPEG-MJPEG)
Title:		main program 
Author(s):	bmk
Revised by: 

Description:
			Main program for JPEG-MJPEG

References:
			None

******************************************************************************
Tab Setting:			4

Target Processor:		ADSP-BF5xx
Target Tools Revision:	ADSP VisualDSP++ v4.5
******************************************************************************

Modification History:
====================
$Log: jpeg_mjpeg_main.c,v $
Revision 1.2  2006/11/10 07:18:58  bmk
merged BF533 & BF561 apps
Fixed BF561 caches issue

Revision 1.1  2006/11/03 07:12:10  bmk
SDK 2.0  files - Initial Entry

******************************************************************************
Incudes
********************************/

#include <jpeg_mjpeg_system.h>					// JPEG-MJPEG System includes

// USB includes
#include <drivers\usb\net2272\plx\nccommon.h>	// Netchip common includes
#include <adi_usbcmd.h>							// supported USB commands
#include <adi_usbio_blackfin.h>					// USB I/O functions for Blackfin

/********************************
Firmware version string info
********************************/
#pragma align 4
char FwVersionInfo[NUM_VERSION_STRINGS][MAX_VERSION_STRING_LEN] = {
					"JPEG-MJPEG",				// Application name    
#if defined(__ADSPBF533__)
					"ADSP-BF533",				// target processor
#elif defined(__ADSPBF561__)
					"ADSP-BF561",				// target processor
#endif
					__DATE__,					// build date
					__TIME__,					// build time
					"02.00.00",					// version number
#if defined(__ADSPBF533__)
					"Uses Video Codecs on ADSP-BF533 EZ-KIT Lite"};		// Video Interface
#elif defined(__ADSPBF561__)
					"Uses Video Codecs on ADSP-BF561 EZ-KIT Lite"};		// Video Interface
#endif					


/********************************
USB data structures
********************************/
					
// USB data structures
// one-dimensional buffer to Tx/Rx Data to/from USB host
static ADI_DEV_1D_BUFFER HostBuffer;
static USBCB usbcb;				// USB command block
static USBCB *pusbcb = &usbcb;	// pointer to above USB Command Block

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

    Function:       main

    Description:    Main function

*********************************************************************/
// place this part of code in L1
section ("App_Code_L1")
void main(void)
{	

	u32 Result;			// result
	
	// USB device not configured yet
	Net2272Ready = FALSE;
	
	// Initialise Ez kit & system parameters
	InitSystem ();
	// init cache/heap
	InstallMemory();
	
	// Install system services
	InstallSystemServices();	
	
	// initialize the USB Host buffer to process usbcb		
	HostBuffer.Data = &usbcb;					// always point to usb command block as default
	HostBuffer.ElementCount = sizeof(usbcb);	// Transfer/Receive data of usb command block size
	HostBuffer.ElementWidth = 1;				// Tx/Rx 1 byte at a time 
	HostBuffer.CallbackParameter = NULL;		// Callback parameter
	HostBuffer.ProcessedFlag = FALSE;
	HostBuffer.ProcessedElementCount = 0;
	HostBuffer.pNext = NULL;
											
	// wait for commands over USB
	while(1)
	{
	    // wait until USB device is configured
	    while (!Net2272Ready);
	    	asm("nop;");
	    
		// wait for a USB command block from the host indicating what function we should perform
		Result = USB_Read(USBDeviceHandle, ADI_DEV_1D, (ADI_DEV_BUFFER *)&HostBuffer,TRUE);
		
		if ( ADI_DEV_RESULT_SUCCESS == Result )
		{
			// switch on the command we just received
			switch( pusbcb->ulCommand )
		    {
		    	// host is asking if we support a given command
		    	case QUERY_SUPPORT:
		    		Result = QueryUSBSupport( USBDeviceHandle, pusbcb->ulData );
		    		if (Result != ADI_DEV_RESULT_SUCCESS)	printf ("Query USB support Failed!\n");
		    			
		    		break;
	
		    	// get the firmware version
			    case GET_FW_VERSION:
			    	
			    	// Configure the 1D USB data buffer to send firmware version string info to Host
					HostBuffer.Data = (u8*)FwVersionInfo;	// point to Firmware version string
					HostBuffer.ElementCount = pusbcb->ulCount;	// size of Firmware version string
					
			    	// send the Firmware Version
			    	Result = USB_Write ( USBDeviceHandle, ADI_DEV_1D, (ADI_DEV_BUFFER *)&HostBuffer,TRUE);			    	
			    	if (Result != ADI_DEV_RESULT_SUCCESS)	printf ("Failed to send Firmware Version!\n");
			    	
			    	// Reset the USB Host buffer to point to USB command block
					HostBuffer.Data = &usbcb;					// always point to usb command block as default
					HostBuffer.ElementCount = sizeof(usbcb);	// Transfer/Receive data of usb command block size
					HostBuffer.ProcessedFlag = FALSE;			// clear processed flag
	
			        break;

		    	// get the Application ID
			    case GET_APP_ID:
			    	// load the application ID unique to JPEG-MJPEG app
			    	pusbcb->ulData	= ADI_JPEG_MJPEG;
			    	// send the application ID to PC Host
			    	Result = USB_Write(USBDeviceHandle, ADI_DEV_1D, (ADI_DEV_BUFFER *)&HostBuffer,TRUE);	    	
			    	if (Result != ADI_DEV_RESULT_SUCCESS)	printf ("Failed to send Application ID!\n");

			        break;
			        			        	
			    // perform USB IO
			    case USBIO_START:			    
					Result= PerformUSBIO();
			    	if (Result != ADI_DEV_RESULT_SUCCESS)	printf ("USB I/O operation failed!\n");
			    	
			        break;
	
				// set codec parameters corresponding to user selected option
			    case SET_PARAMS:
			    	// set codec parameters			    
			    	Result = SetCodecParameters((u32*) &pusbcb->ulParams[0]);
			    	// check the result
			    	if (Result != ADI_DEV_RESULT_SUCCESS)
			    	{
			    		// inform PC host as this operation has failed
			    		pusbcb->ulData	= OPERATION_FAILED;			    		
		    			printf ("Failed to set Codec Parameters!\n");
			    	}
		    		else
		    			// confirm Host as Device parameters were set successfully
						pusbcb->ulData	= OPERATION_PASSED;

			    	// pass the result to PC host
			    	Result = USB_Write(USBDeviceHandle, ADI_DEV_1D, (ADI_DEV_BUFFER *)&HostBuffer,TRUE);

				    break;
			        	
				// unsupported command
			    default:
			        break;
	    	}
		}
	}
}
/*****/

⌨️ 快捷键说明

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