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

📄 main.c

📁 ADI Blackfin BF51X 範例程式
💻 C
📖 第 1 页 / 共 2 页
字号:
/*******************************************************************
Analog Devices, Inc. All Rights Reserved.

This software is proprietary and confidential.  By using this software
you agree to the terms of the associated Analog Devices License Agreement.

Project Name:  	Power_On_Self_Test

Hardware:		ADSP-BF518F EZ-Board

Description:	This example performs POST on the BF518F EZ-Board.

Please view the readme.txt file for detailed information related to
switch and jumper settings, LED indicators, etc.

Enter POST standard test loop by pressing PB1 at startup, or by entering
a sequence using PB1 and PB2 to choose a specific test.

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

#include <string.h>
#include "timer_ISR.h"
#include "post_common.h"
#include "pbled_test.h"
#include "pll.h"
#include "..\..\Landscape LCD EZ-EXTENDER\Power_On_Self_Test\ConfigFlash\m24c02.h"


/*******************************************************************
*  function prototypes
*******************************************************************/
int TEST_VERSION(void);
int TEST_PBLED(void);
int TEST_ROTARY(void);
int TEST_ETHERNET(void) {return 1;}	/* not yet implemented */

int TEST_EMMC(void) {return 1;}		/* not yet implemented */
int TEST_SPI_FLASH(void);
int TEST_PARALLEL_FLASH(void);
int TEST_SDRAM(void);

int TEST_UART(void);
int TEST_AUDIO(void);
int TEST_ADC(void) {return 1;}		/* not yet implemented */

int CHECK_PUBLIC_KEY(void);
int PROGRAM_PUBLIC_KEY(void);

int CHECK_CONFIGURATION_DATA(void);
int SET_RTC(void);
int CHECK_RTC(void);

int PROGRAM_DIGIPOT(void);
int CHECK_DIGIPOT(void);
int TEST_SD(void) {return 1;}		/* not yet implemented */

int TEST_LCD_TOUCH(void);
int TEST_LCD_CAPTOUCH(void);
int TEST_LCD_CONFIGFLASH(void);
void LCD_DISPLAY_PICS(void);

int BLINK_FW_VERSION( void );
bool IsLcdPresentAndConfigured(void);

int TEST_DUMMY(void) {return 1;}	/* a dummy test */

void Init_SDRAM(void);


/*******************************************************************
*  global variables and defines
*******************************************************************/
static int g_loops = 0;
char g_szBuildDate[64];
char g_szBuildTime[64];
bool g_bIsTestChosen = false;
int g_nInitialTest = 0;
int g_nPostState = STATE_START;
extern int g_nPORTHIO;

/* firmware version definitions */
#define FIRMWARE_MAJOR_REV 0
#define FIRMWARE_MINOR_REV 2

/* force user to specify the EZ-Board rev */
#ifdef _BF518F_EZBOARD_REV_0_1_
#else
#error *** EZ-Board rev not specified, please define a valid rev ***
#endif

/* test IDs */
												/* ================================ */
                                    			/*    |   PB   |  LEDS | blinks on  */
enum											/*  # |sequence| [3:1] |  failure   */
{												/* ================================ */
	TID_STANDARD_LOOP,							/*  0 |  11111 |  000  |  one time  */
	TID_VERSION,								/*  1 |  11112 |  001  |  one time  */
    TID_PBLED,									/*  2 |  11121 |  010  |  one time  */
	TID_ROTARY,		/* can't use LED2 and 3 */	/*  3 |  11122 |  011  |  one time  */
    TID_EMMC,  	    							/*  4 |  11211 |  100  |  one time  */
    TID_SPI_FLASH,      			 			/*  5 |  11212 |  101  |  one time  */
    TID_PARALLEL_FLASH,    						/*  6 |  11221 |  110  |  one time  */
    TID_SDRAM,  	    						/*  7 |  11222 |  111  |  one time  */
    											/* -------------------------------- */
    TID_UART,           						/*  8 |  12111 |  001  | two times  */
    TID_AUDIO,          						/*  9 |  12112 |  010  | two times  */
	TID_SET_RTC,								/* 10 |  12121 |  011  | two times  */
    TID_CHECK_DIGIPOT,		           			/* 11 |  12122 |  100  | two times  */
    TID_LAST_STD_LOOP_TEST = TID_CHECK_DIGIPOT,	/*    |        |       |            */
	TID_ADC,									/* 12 |  12211 |  101  | two times  */
	TID_CHECK_CONFIG_DATA,						/* 13 |  12212 |  110  | two times  */
	TID_CHECK_PUB_KEY,	  						/* 14 |  12221 |  111  | two times  */
												/* -------------------------------- */
	TID_CHECK_RTC,	  							/* 15 |  12222 |  001  |three times */
    TID_ETHERNET,								/* 16 |  21111 |  010  |three times */
    TID_PROG_DIGIPOT,							/* 17 |  21112 |  011  |three times */
    TID_PROG_PUB_KEY,							/* 18 |  21121 |  100  |three times */
    TID_SD,										/* 19 |  21122 |  101  |three times */
    TID_UNUSED1,								/* 20 |  21211 |  110  |three times */
    TID_UNUSED2,								/* 21 |  21212 |  111  |three times */
    											/* -------------------------------- */
	TID_UNUSED3,								/* 22 |  21221 |  001  |four times  */
    TID_LCD_TOUCH,	  	/* can't use LED0 */ 	/* 23 |  21222 |  010  |four times  */
    TID_LCD_CONFIG_FLASH,                   	/* 24 |  22111 |  011  |four times  */
    TID_LCD_CAPTOUCH, 	/* can't use LED0 */	/* 25 |  22112 |  100  |four times  */
    TID_BLINK_FW_VERSION,                   	/* 26 |  22121 |  101  |four times  */
    											/* -------------------------------- */
	NUM_TESTS,

};

typedef int (*pfnTests)(void);

/* test function pointers, these must match up to the
	test IDs above */
pfnTests g_TestPtrs[NUM_TESTS] =
{
    TEST_DUMMY,        /* standard loop placeholder, doesn't get called */
    TEST_VERSION,
    TEST_PBLED,
    TEST_ROTARY,
    TEST_EMMC,
    TEST_SPI_FLASH,
    TEST_DUMMY,				/* parallel flash doesn't work on rev 0.1 EZ-Board */
    TEST_SDRAM,

    TEST_UART,
    TEST_AUDIO,
    SET_RTC,
    CHECK_DIGIPOT,
    TEST_ADC,
    CHECK_CONFIGURATION_DATA,
    CHECK_PUBLIC_KEY,

    CHECK_RTC,
    TEST_ETHERNET,
    PROGRAM_DIGIPOT,
    PROGRAM_PUBLIC_KEY,
    TEST_SD,
    TEST_DUMMY,				/* for UNUSED1 */
    TEST_DUMMY,				/* for UNUSED2 */

    TEST_DUMMY,				/* for UNUSED3 */
    TEST_LCD_TOUCH,
    TEST_LCD_CONFIGFLASH,
    TEST_LCD_CAPTOUCH,
    BLINK_FW_VERSION,
};

/* only 8 different test patterns and states */
enTESTS patterns[] = {TEST_0, TEST_1, TEST_2, TEST_3,
					  TEST_4, TEST_5, TEST_6, TEST_7};
enTEST_STATES states[] = {TEST_0_SET, TEST_1_SET, TEST_2_SET, TEST_3_SET,
						  TEST_4_SET, TEST_5_SET, TEST_6_SET, TEST_7_SET};


/*******************************************************************
*   Function:    PerformTest
*   Description: This is where the test parameters are figured out
*				 and the test is performed
*******************************************************************/
int PerformTest( int nTestId, const int nIgnoreResult )
{
	int nResult = 0;		/* result */
	int	nRound = 0;			/* which round does this test run in */
	int n = 0, m = 0;		/* indexes */
	int test_indicator;		/* test indicator, with 3 LEDs only 0-7 */


	/* determine the test pattern */
	test_indicator = nTestId % 7;
	if (0 == test_indicator)
	{
		if (0 != nTestId)
		{
			test_indicator = 7;
		}
	}

	/* display test pattern */
	Delay(BLINK_SLOW * 25);
	ClearSet_LED_Bank( (-1), 0x0000);
	ClearSet_LED_Bank( patterns[test_indicator], states[test_indicator]);

	if (nTestId < NUM_TESTS)
		nResult = g_TestPtrs[nTestId]();	/* call test function */
	else
		nResult = 0; 						/* else fail, invalid test ID */

    /* if test failed */
    if( 0 == nResult )
	{
		/* determine which round this test runs in, for example
			with 3 LEDs tests 1 through 7 are in round 1,
			tests 8 through 14 are round 2 and so on */
		nRound = nTestId / 7;
		if ( nTestId % 7 )
			nRound += 1;

		/* blink forever or if we are to ignore failures we break out
			after a while */
		while (1)
		{
			/* we blink the test number once for each round so the user
				can determine which test failed since multiple tests use
				the same LED pattern such as tests 1, 8, 15, etc. */
			for ( n = 0; n < nRound; n++ )
			{
				ClearSet_LED_Bank( (-1), 0x0000);
				Delay(BLINK_SLOW * 3);
				ClearSet_LED_Bank( patterns[test_indicator], states[test_indicator]);
				Delay(BLINK_SLOW * 3);
			}

			/* long delay off after it blinks for each round */
			ClearSet_LED_Bank( (-1), 0x0000);
			Delay(BLINK_SLOW * 18);

			/* if we are to ignore failures only blink a handful
				times, then return */
			m++;
			if ( (10 == m) && (IGNORE_FAILURES == nIgnoreResult) )
				return nResult;
		}
	}

	return nResult;
}


/*******************************************************************
*   Function:    main
*   Description: This is the main entry point where everything starts.
*******************************************************************/
void main(void)
{
	int porth = 0x0;								/* PORTH status */
    int nTestIndex = 0x0;							/* test index */
	unsigned int Result;							/* result */
	int i = 0;										/* index */

	/* clear all interrupts */
	*pSIC_IMASK0 = 0x0;
	*pSIC_IMASK1 = 0x0;

⌨️ 快捷键说明

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