📄 main.c
字号:
/*****************************************************************************
** **
** Name: main.c **
** **
******************************************************************************
(C) Copyright 2004 - Analog Devices, Inc. All rights reserved.
Pjoject Name: BF537 POST ATE
Date Modified: 01 Sept 2005
Software: VisualDSP++ 4.0
Hardware: ADSP-BF537 EZ-KIT Lite
Connections:
Purpose: Purpose: Perform a POST ATE on the BF537 EZ-Kit Lite
BF537 EZ-KIT and STAMP board test indicators (version 1.00.0 3 October 2005)
Enter BF537 EZ-KIT POST or STAMP board POST test by pressing PB1.
LED4 LED3 LED2 LED1
VERSION 0 0 0 1
PBLED 0 0 1 0
MAC 0 0 1 1 skip using PB1 & PB3
SDRAM 0 1 0 0
UART 0 1 0 1 needs jumper
ETHERNET 0 1 1 0 needs loop back connector
FLASH 0 1 1 1
AUDIO 1 0 0 0 not used on stamp
CAN_TX 1 0 0 1 test using PB1 & PB2
CAN_RX 1 0 1 0 test using PB2
The switch settings for the built in self test differ slightly from the default settings shipped.
See the users manual for default switch settings.
"Switch settings:
- SW2 CAN Enable, 1 = ON, 2 = ON, 3 = ON, 4 = ON.
- SW3 Ethernet, 1 = OFF, 2 = OFF, 3 = OFF, 4 = OFF.
- SW4 UART, 1 = ON, 2 = ON, 3 = ON, 4 = ON.
- SW5 Push Buttons, 1 = ON, 2 = ON, 3 = ON, 4 = ON.
- SW6 Flash enable, 1 = ON, 2 = ON, 3 = ON, 4 = ON.
- SW7 Audio enable, 1 = ON, 2 = ON, 3 = ON, 4 = ON, 5 = 0N, 6 = ON, 7 = ON, 8 = ON.
- SW16 Boot mode sel, 1
- JP5 Expansion Voltage ON
- JP9 UART loop, ON
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Enter FPGA EZ-Extender POST test by pressing PB4
Test indicators are as follows:
LED4 LED3 LED2 LED1
MEMORY 1 0 1 1
GPIO 1 1 0 0
SPORT 1 1 0 1
The switch settings for the built in self test for the FPGA EZ-Extender differ slightly from the default
settings shipped. See the users manual for default switch settings.
Switch settings for the BF537 EZ-KIT:
- SW2 CAN Enable, 1 = OFF, 2 = OFF, 3 = OFF, 4 = OFF.
- SW3 Ethernet, 1 = OFF, 2 = OFF, 3 = OFF, 4 = OFF.
- SW4 UART, 1 = OFF, 2 = OFF, 3 = OFF, 4 = OFF.
- SW5 Push Buttons, 1 = ON, 2 = ON, 3 = ON, 4 = ON.
- SW6 Flash enable, 1 = ON, 2 = ON, 3 = OFF, 4 = ON.
- SW7 Audio enable, 1 = OFF, 2 = OFF, 3 = OFF, 4 = OFF, 5 = OFF, 6 = OFF, 7 = OFF, 8 = OFF.
- SW16 Boot mode sel, 1
- JP5 Expansion Voltage ON
- JP9 UART loop, ON
Switch setting for the FPGA EZ-Extender:
- JP1: not installed
- JP2: installed
- JP3: installed
- JP4: none installed
- JP5: none installed
- P9: installed on pins 1 and 2
- P10: installed on pins 1 and 2
- P11: installed on pins 1 and 2
- P12: installed on pins 1 and 2
- P13: installed on pins 2 and 3
*****************************************************************************/
#include <string.h>
#include <services/services.h> // system service includes
#include <drivers/adi_dev.h> // device manager includes
#include "Timer_ISR.h"
#include "post_common.h"
#include "PBLED_test.h"
#include "Pll.h"
#include "adi_m29w320.h"
#ifdef _EZ_KIT_LITE_
#include "adi_spartan3.h"
#endif
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 DevHandleSpartan3;
ADI_DEV_DEVICE_HANDLE DevHandleM29W320;
//////////////////////////////////////////////////////////////////////////////
//
// 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_ETHERNET(void);
int TEST_CAN_TX(void);
int TEST_CAN_RX(void);
int TEST_AUDIO(void);
int TEST_FLASH(void);
int TEST_MAC(void);
int TEST_DUMMY(void) {return 1;}// a dummy test for targets which do not have a specific piece of hardware
// POST tests for the FPGA EZ_Extender board
int TEST_FPGA_MEMORY(void);
int TEST_FPGA_GPIO(void);
int TEST_FPGA_SPORTS(void);
int PROGRAM_FPGA(void);
// this controls the number of test run using g_pTestFunctions
typedef enum TEST_INDEX_tag{
VERSION, //0001
PBLED, //0010
MAC, //0011
SDRAM, //0100
UART, //0101
ETHERNET, //0110
FLASH, //0111
#ifdef _EZ_KIT_LITE_
AUDIO, //1000
#elif EZ_KIT_LITE_STAMP
DUMMY, //1000
#endif
NUM_TESTS_IMPLEMENTED, // this is the end of repeating tests
// these are one time tests they must be manually configured using push buttons
CAN_TX = NUM_TESTS_IMPLEMENTED, //1001
CAN_RX, //1010
#ifdef _EZ_KIT_LITE_
FIRST_FPGA_TEST,
FPGA_MEMORY = FIRST_FPGA_TEST, //1011
FPGA_GPIO, //1100
FPGA_SPORTS, //1101
#endif
LAST_FPGA_TEST,
NUM_TESTS = LAST_FPGA_TEST
}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_MAC},
{TEST_4, TEST_4_SET, TEST_SDRAM},
{TEST_5, TEST_5_SET, TEST_UART},
{TEST_6, TEST_6_SET, TEST_ETHERNET},
{TEST_7, TEST_7_SET, TEST_FLASH},
#ifdef _EZ_KIT_LITE_
{TEST_8, TEST_8_SET, TEST_AUDIO},
#else
{TEST_8, TEST_8_SET, TEST_DUMMY},
#endif
{TEST_9, TEST_9_SET, TEST_CAN_TX},
{TEST_10,TEST_10_SET,TEST_CAN_RX},
#ifdef _EZ_KIT_LITE_
// FPGA EZ-Extender tests follow
{TEST_11,TEST_11_SET,TEST_FPGA_MEMORY},
{TEST_12,TEST_12_SET,TEST_FPGA_GPIO},
{TEST_13,TEST_13_SET,TEST_FPGA_SPORTS},
#endif
};
//////////////////////////////////////////////////////////////////////////////
// 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; // result
u32 ResponseCount; // response count
u32 SecondaryCount; // secondary count
ADI_DEV_MANAGER_HANDLE DeviceManagerHandle; // DevMgr handle
strcpy(g_szBuildDate, __DATE__);
strcpy(g_szBuildTime, __TIME__);
// Set CCLK = 594 MHz, SCLK = 118 MHz
Init_PLL();
// 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_LEDs();
Init_PushButtons();
Init_Timers();
Init_Timer_Interrupts();
int temp = *pPORTFIO;
asm("nop;");
asm("nop;");
asm("nop;");
asm("nop;");
// if both the EZ-KIT POST and FPGA POST are selected at the same time this is an error
// only one can run at a given time because switch setting conflict between the two tests
if (0x24 == (temp & 0x24))
Blink_LED( LED6 | LED5 | LED4 | LED3 | LED2 | LED1, BLINK_FAST );
// If PB1 was pressed we will test the BF537 EZ-KIT Lite
if( 0x04 == (temp & 0x04) )
{
// open the M29W320
Result = adi_dev_Open( DeviceManagerHandle, // DevMgr handle
&ADIM29W320EntryPoint, // pdd entry point
0, // device instance
NULL, // client handle callback identifier
&DevHandleM29W320, // 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
// SILICON VERSION TEST //
PerformTest( g_Tests[VERSION], 0 );
// PUSH BUTTON & LED TEST //
PerformTest( g_Tests[PBLED], 0 );
// this is the CAN TX test, but it is only done once
// and only if both push buttons have been pressed at the
// same time
if( 0x08 == (temp & 0x08) )
{ // CAN TEST //
PerformTest( g_Tests[CAN_TX], 0 );
}
int nTestStartIndex = 2;
// this the MAC test, it tests to see if some ADI address
// is programmed into the MAC
// skip only if both push buttons have been pressed at the
// same time
if( 0x10 == (temp & 0x10) )
{ // MAC address test //
nTestStartIndex = 3;
}
while(1) // do the POST tests forever
{
int nTestIndex;
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(DevHandleM29W320);
}
#ifdef _EZ_KIT_LITE_
// If PB4 was pressed we will test the FPGA EZ-Extender board
else if ( 0x20 == (temp & 0x20) )
{
// open the Spartan 3
Result = adi_dev_Open( DeviceManagerHandle, // DevMgr handle
&ADISPARTAN3EntryPoint, // pdd entry point
0, // device instance
NULL, // client handle callback identifier
&DevHandleSpartan3, // 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
PROGRAM_FPGA();
while(1) // do the POST tests forever
{
int nTestIndex;
for( nTestIndex = FIRST_FPGA_TEST; nTestIndex < LAST_FPGA_TEST; 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(DevHandleSpartan3);
}
#endif
// Since the CAN test requires a receiver and a transmitter, this
// puts the ezkit into a CAN receiver for the CAN test
// and only if both push buttons have been pressed at the
// same time
else if( 0x08 == (temp & 0x08) )
{ // CAN RX TEST //
while( 1 )
{
PerformTest( g_Tests[CAN_RX], 1 );
ClearSet_LED_Bank( (-1), 0x0000);
for( nDelay = 0; nDelay < 8; nDelay++)
{
LED_Bar( BLINK_SLOW );
}
}
}
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 + -