📄 main.c
字号:
/*****************************************************************************
Copyright(c) 2005 Analog Devices, Inc. All Rights Reserved. This software is
proprietary and confidential to Analog Devices, Inc. and its licensors.
******************************************************************************
$RCSfile: main.c,v $
$Revision: 1.2 $
$Date: 2005/10/28 02:49:13 $
Project: Developer Kit
Title: Set up ezkit
Author(s): dwu
Revised by:
Description:
Main program
References:
None
******************************************************************************
Tab Setting: 4
Target Processor: ADSP-BF5xx
Target Tools Revision: ADSP VisualDSP++ v4.0
******************************************************************************
Modification History:
====================
$Log: main.c,v $
Revision 1.2 2005/10/28 02:49:13 dwu
Added error checking code for JPEG/MJPEG routines, and added ADI
legal headers.
*****************************************************************************/
#pragma default_section(CODE, "sdram0_bank1")
#include "system.h"
#include "heap_services.h"
#include "cache_services.h"
#include "ez_kit_setup.h"
#include "system_services_install.h"
#include "cplb_tables.h"
#include "usbio.h"
#include "nccommon.h" // Netchip common includes
#include "usbcmd.h" // USB commands
// firmware version string info
#pragma align 4
char FwVersionInfo[NUM_VERSION_STRINGS][MAX_VERSION_STRING_LEN] = {
__DATE__, // build date
__TIME__, // build time
"01.00.00", // version number
"ADSP-BF561", // target processor
"BF561 (M)JPEG Codec"}; // application name
int Coding_Algorithm = JPEG; // global parameters holding current coding algorithm
int Coding_Action = DECODE; // global parameters holding current coding direction (encode/decode)
// USB data structures
static ADI_DEV_1D_BUFFER UsbcbBuffer; // one-dimensional buffer for processing usbcb
static USBCB usbcb; // USB command block
static USBCB *pusbcb = &usbcb; // pointer to USBCB
static ADI_DEV_DEVICE_HANDLE USB_DevHandle; // USB driver device handle
void main(void)
{
int temp;
char *ptr;
bool bKeepRunning = TRUE; // keep running flag
unsigned int Result; // result
init_memory();
init_buttons_and_LEDs();
// Configure cache
disable_data_cache();
configure_data_cache_cplbs(codec_dcplbs_table);
enable_data_cache();
disable_instruction_cache();
configure_instruction_cache_cplbs(codec_icplbs_table);
enable_instruction_cache();
// Configure interrupts and PLL
*pSICA_IWR0 = 0xFFFFFFFF;
*pPLL_CTL = 0x2800;
idle();
// Install heaps
temp = install_codec_heaps();
// Install system services
install_system_services();
*pDMA1_TC_PER |= 0x7f0;
*pDMA2_TC_PER |= 0x7f0;
// initialize the USB data buffer
UsbcbBuffer.Data = &usbcb;
UsbcbBuffer.ElementCount = sizeof(usbcb);
UsbcbBuffer.ElementWidth = 1;
UsbcbBuffer.CallbackParameter = NULL;
UsbcbBuffer.ProcessedFlag = FALSE;
UsbcbBuffer.ProcessedElementCount = 0;
UsbcbBuffer.pNext = NULL;
// Install the USB driver
install_USB_driver(&USB_DevHandle);
// main loop
// wait for commands over USB
while( bKeepRunning )
{
// wait for a USB command block from the host indicating what function we should perform
Result = adi_dev_Read(USB_DevHandle, ADI_DEV_1D, (ADI_DEV_BUFFER *)&UsbcbBuffer);
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 = QuerySupport( USB_DevHandle, pusbcb->ulData );
break;
// get the firmware version
case GET_FW_VERSION:
Result = ReadMemory( USB_DevHandle, (u8*)FwVersionInfo, pusbcb->ulCount );
break;
// perform IO over USB
case USBIO_START:
Result = PerformIo( USB_DevHandle );
break;
// read memory
case MEMORY_READ:
Result = ReadMemory( USB_DevHandle, (u8*)pusbcb->ulData, pusbcb->ulCount );
break;
// write memory
case MEMORY_WRITE:
Result = WriteMemory( USB_DevHandle, (u8*)pusbcb->ulData, pusbcb->ulCount );
break;
// start codec according to input parameters
case SET_PARAMS:
Coding_Algorithm = (int)pusbcb->ulCount;
Coding_Action = (int)pusbcb->ulData;
PRINT_DEBUG(("Parameters set to "));
if(Coding_Algorithm == MJPEG)
{PRINT_DEBUG(("Motion JPEG "));}
else
{PRINT_DEBUG(("JPEG "));}
if(Coding_Action == DECODE)
{PRINT_DEBUG(("decoding\n"));}
else
{PRINT_DEBUG(("encoding\n"));}
break;
// unsupported command
default:
exit(1);
break;
}
}
}
return;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -