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

📄 main.c

📁 ADSP 地层驱动
💻 C
字号:
/*****************************************************************************
**																			**
**	 Name: 	main.c															**
**																			**
******************************************************************************

(C) Copyright 2006 - Analog Devices, Inc.  All rights reserved.

Pjoject Name:	ADSP-BF533 EZ-KIT LITE REV 1.7 POST ATE

Date Modified:	22 August 2006

Software:		VisualDSP++ 4.5

Hardware:		ADSP-BF533 EZ-KIT Lite

Connections:

Purpose:		Perform a POST on the BF533 EZ-Kit Lite


BF533 EZ-KIT  (version 2.1 22 August 2006)

Enter regular POST test using PF9 (SW5).
Enter AUDIO EZ-EXTENDER test2 using PF8 (SW4).
Enter Ethernet USBLAN EZ-EXTENDER test2 using PF10 (SW6) and PF11 (SW7).

				LED7	LED6	LED5	LED4
VERSION			0   	0   	0   	1
PBLED			0		0		1		0
SDRAM			0		0		1		1
UART			0		1		0		0	need jumper
AUDIO			0		1		0		1
FLASH			0		1		1		0
VIDEO			0		1		1		1
EZAUDIO_AD1938	1		0		0		0	test using PB4
EZAUDIO_ADAV801 1		0		0		1	test using PB4
ETHERNET		1		0		1		0	test using PB6 and PB7




-----------------------------------------------------
ADSP-BF533 EZ-KIT LITE SETTINGS:
-----------------------------------------------------
SW1 = ON, ON, ON, ON, ON, ON
SW2 = ON, ON, ON, OFF, OFF, OFF
SW3 = OFF, OFF, OFF, OFF, OFF, ON
SW9 = ON, ON, ON, ON, OFF, OFF
SW10 = ON, ON
SW11 = OFF, ON
SW12 =  ON, ON, ON, ON
JP4 = ON


-------------------------------------------------------
BLACKFIN USBLAN EZ-EXTENDER	board test jumpers
-------------------------------------------------------
SW1 = ON, ON, ON, OFF
SW2 = OFF, OFF, OFF, OFF
JP2 = ON
plug in Ethernet loop back connector
For Ethernet USBLAN EZ-EXTENDER test, ADSP-BF533 EZ-KIT LITE SETTINGS need be changed:
SW9 = ON, OFF, ON, ON, ON, ON

Reset the board and hold PF10 (sw6) and PF11 (sw7)to enter the test

-------------------------------------------------------
BLACKFIN AUDIO EZ-EXTENDER REV 1.0 board test jumpers
-------------------------------------------------------
	- JP1.3/4
	- JP1.5/6
	- JP2.5/6
	- J9 & J10 special male loop back connectors, see schematic
	- JP4 installed
	- Reset the board and hold PF8 (sw4) to enter the test

For AUDIO EZ-EXTENDER test, ADSP-BF533 EZ-KIT LITE SETTINGS need be changed:
SW9 = ON, OFF, OFF, OFF, OFF, OFF

*****************************************************************************/
#include <string.h>
#include <services/services.h>		// system service includes
#include <drivers/adi_dev.h>		// device manager includes

#include "post_common.h"
#include "PBLED_test.h"
#include "Pll.h"
#include "Timer_ISR.h"
#include "adi_psd4256g.h"		// flash-PSD4256G includes
#include "Video_test.h"


//////////////////////////////////////////////////////////////////////////////
//
// variables
//
//////////////////////////////////////////////////////////////////////////////
static int g_loops = 0;
char g_szVersion[64] = "1.00.0";
char g_szBuildDate[64];
char g_szBuildTime[64];


//////////////////////////////////////////////////////////////////////////////
//
// function prototypes
//
//////////////////////////////////////////////////////////////////////////////
int TEST_VERSION(void);
int TEST_PBLED(void);
int TEST_SDRAM(void);
int TEST_UART(void);
int TEST_AUDIO(void);
int TEST_FLASH(void);
int TEST_VIDEO(void);
int TEST_1938(void);
int TEST_ADAV801(void);
int TEST_ETHERNET(void);
int TEST_DUMMY(void) {return 1;} // a dummy test for targets which do not have a specific piece of hardware


// this controls the number of test run using g_pTestFunctions
typedef enum TEST_INDEX_tag
{
	VERSION,
	PBLED,
	SDRAM,
	UART,
	AUDIO,
	FLASH,
	VIDEO,
	NUM_TESTS_IMPLEMENTED,					// this is the end of repeating tests
	EZAUDIO_AD1938 = NUM_TESTS_IMPLEMENTED,
	EZAUDIO_ADAV801,
	EZUSBLAN_ETHERNET,
	NUM_TESTS,
}enTEST_INDEX;


typedef int (*pfnTests)(void);

typedef struct stTestParams_TAG
{
	enTESTS m_nTest;
	enTEST_STATES m_nTestState;
	pfnTests m_pTestFunctions;
}stTestParamaters;


stTestParamaters g_Tests[NUM_TESTS] = {
	{TEST_1, TEST_1_SET, TEST_VERSION},
 	{TEST_2, TEST_2_SET, TEST_PBLED},
 	{TEST_3, TEST_3_SET, TEST_SDRAM},
 	{TEST_4, TEST_4_SET, TEST_UART},
 	{TEST_5, TEST_5_SET, TEST_AUDIO},
 	{TEST_6, TEST_6_SET, TEST_FLASH},
 	{TEST_7, TEST_7_SET, TEST_VIDEO},
 	{TEST_8, TEST_8_SET, TEST_1938},
 	{TEST_9, TEST_9_SET, TEST_ADAV801},
 	{TEST_10, TEST_10_SET, TEST_ETHERNET} 	};

static u8 DevMgrData[ADI_DEV_BASE_MEMORY + (ADI_DEV_DEVICE_MEMORY * 2)];
static ADI_INT_CRITICAL_REGION_DATA	CriticalRegionData;						// storage for critical region
ADI_DEV_DEVICE_HANDLE DevHandlePSD4256G;
extern VIDEO_TEST video_test;


//////////////////////////////////////////////////////////////////////////////
// void PerformTest( const stTestParamaters Test, const int nIgnoreResult  )
//
// Purpose:  Wrap up the test paramaters and perform the test
//////////////////////////////////////////////////////////////////////////////
int PerformTest( const stTestParamaters Test, const int nIgnoreResult )
{
	int nResult = 0;

	Delay(BLINK_SLOW * 25);
	ClearSet_LED_Bank( (-1), 0x0000);
	ClearSet_LED_Bank( Test.m_nTest, Test.m_nTestState); // change the state of the led

	nResult = Test.m_pTestFunctions();
	if( 0 == nResult )
	{	// test failed
		if( 0 == nIgnoreResult )
		{
			Blink_LED( Test.m_nTest, BLINK_FAST );
		}
	}

	return nResult;
}



//--------------------------------------------------------------------------//
// Function:	main														//
//--------------------------------------------------------------------------//
void main(void)
{
	int bPassed;
	int nDelay;
	volatile int bTrue = 1;
	unsigned int Result;
	int temp =0;
	u32	ResponseCount;								// response count
	ADI_DEV_MANAGER_HANDLE DeviceManagerHandle;		// DevMgr handle


	*pEBIU_SDRRC = 0x01A0; 	
	*pEBIU_SDBCTL = 0x0025; // EZ-KIT rev 1.7 has 64 MB
//	*pEBIU_SDBCTL = 0x0013;	// EZ-KIT rev 1.6 and below has 32 MB
	*pEBIU_SDGCTL = 0x0091998d;
	
	strcpy(g_szBuildDate, __DATE__);
	strcpy(g_szBuildTime, __TIME__);

	// initialize device manager
	Result = adi_dev_Init(	DevMgrData,				// ptr to memory for use by DevMgr
							sizeof(DevMgrData),		// size of memory for use by DevMgr
							&ResponseCount,			// returns number of devices DevMgr can support
							&DeviceManagerHandle,	// ptr to DevMgr handle
							&CriticalRegionData);	// ptr to critical region info

	// init system
	Init_PLL();
	Init_LEDs();
	Init_PushButtons();
	Init_Timers();
	Init_Timer_Interrupts();

	temp = GetPushButtons();

	// SILICON VERSION TEST
	PerformTest( g_Tests[VERSION], 0 );

	// pushbutton SW4 is pressed, run one-time AUDIO test
	if( SW4_PF8 == (temp & SW4_PF8) )
	{
	    // SW4_PF8 is the only free pin when audio ez-extender is connected
	    // SW9: ON, OFF, OFF, OFF,OFF,OFF,

	    // this is the audio ez-extender board
		ClearSet_LED_Bank( (-1), 0x0000);


		// do this test as a one time test.
		PerformTest( g_Tests[EZAUDIO_ADAV801], 0 );

		while(1)
		{
			PerformTest( g_Tests[EZAUDIO_AD1938], 0 );

			/// done with all tests
			g_loops++;

			// WAIT A BIT, THEN RESET THE LED's
			Delay(BLINK_SLOW * 25);

			// indicate everything passed
			ClearSet_LED_Bank( (-1), 0x0000);
			for( nDelay = 0; nDelay < g_loops; nDelay++)
			{
				LED_Bar( BLINK_SLOW );
			}
		}
	}

	// pushbuttons SW6 and SW7 are both pressed, run one-time ETHERNET test
	if( (SW6_PF10 == (temp & SW6_PF10)) && (SW7_PF11 == (temp & SW7_PF11)))
	{
	    // SW4_PF8 cannot be used when USB-LAN ez-extender is connected
	    // SW9: ON, OFF, ON, ON, ON, ON

		ClearSet_LED_Bank( (-1), 0x0000);

		while(1)
		{
			PerformTest( g_Tests[EZUSBLAN_ETHERNET], 0 );

			/// done with all tests
			g_loops++;

			// WAIT A BIT, THEN RESET THE LED's
			Delay(BLINK_SLOW * 25);

			// indicate everything passed
			ClearSet_LED_Bank( (-1), 0x0000);
			for( nDelay = 0; nDelay < g_loops; nDelay++)
			{
				LED_Bar( BLINK_SLOW );
			}
		}
	}

	// pushbutton SW6 is pressed, run one-time VIDEO test, note that video
	// is still run in standard loop but this allows the user to just run video
	if(SW6_PF10 == (temp & SW6_PF10) )
	{
		ClearSet_LED_Bank( (-1), 0x0000);

		while(1)
		{
		    PerformTest( g_Tests[VIDEO], 0 );
		    
			// done with all tests
			g_loops++;

			// WAIT A BIT, THEN RESET THE LED's
			Delay(BLINK_SLOW * 25);

			// indicate everything passed
			ClearSet_LED_Bank( (-1), 0x0000);
			for( nDelay = 0; nDelay < g_loops; nDelay++)
			{
				LED_Bar( BLINK_SLOW );
			}
		}
	}

	// pushbutton SW5 is pressed, run all continuous POST
	if( SW5_PF9 == (temp & SW5_PF9) )
	{
		// open the PSD4256G
		Result = adi_dev_Open(	DeviceManagerHandle,			// DevMgr handle
								&ADIPSD4256GEntryPoint,			// pdd entry point
								0,								// device instance
								NULL,							// client handle callback identifier
								&DevHandlePSD4256G,				// DevMgr handle for this device
								ADI_DEV_DIRECTION_BIDIRECTIONAL,// data direction for this device
								NULL,							// handle to DmaMgr for this device
								NULL,							// handle to deferred callback service
								NULL);							// client's callback function

		// POST test has been entered, do the one time tests


		// PUSH BUTTON & LED tests
		PerformTest( g_Tests[PBLED], 0 );

		int nTestStartIndex = 2;

		while(1) // do the POST tests forever
		{
			int nTestIndex;
			int reg=0;

			for( nTestIndex = nTestStartIndex; nTestIndex < NUM_TESTS_IMPLEMENTED; nTestIndex++ )
			{
				PerformTest( g_Tests[nTestIndex], 0 );
			}

			// done with all tests
			g_loops++;

			// WAIT A BIT, THEN RESET THE LED's
			Delay(BLINK_SLOW * 25);

			// indicate everything passed
			ClearSet_LED_Bank( (-1), 0x0000);
			//for( nDelay = 0; nDelay < g_loops; nDelay++)
			{
				LED_Bar( BLINK_SLOW );
			}
		}// end while(1)

		// close the device, good programming practice would be to close the device
		// here but since the POST test runs in an infinite loop the device never needs
		// to be closed
		//Result = adi_dev_Close(DevHandlePSD4256G);

	}
	else
	{
		// this is just normal blink mode.
		ClearSet_LED_Bank( (-1), 0x0000);
		while(1)
		{
			LED_Bar(BLINK_SLOW);
		}
	}
}

⌨️ 快捷键说明

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