📄 tst_2407.c
字号:
/*--------------------------------------------------------*/
/* SPECTRUM DIGITAL INC. */
/*--------------------------------------------------------*/
/* EVM Test Code Shell */
/*--------------------------------------------------------*/
/* file name: tst_main.c */
/* Started on: 02/11/1997 by mls */
/* Last update: 02/18/2000 by rrp for 2407 */
/*--------------------------------------------------------*/
/*--------------------------------------------------------*/
/* test run flags */
/*--------------------------------------------------------*/
#include "tst_main.h"
#include "run_test.h"
#include "sys2407.h"
#include "prot2407.h"
#include "ioreg.h"
#define LOOP_CNT 1 /* 1-n, or -1 = forever */
unsigned int test1_exec; /* you need one for each test,!=0=run, 0=no */
unsigned int test2_exec;
unsigned int test3_exec;
unsigned int test4_exec;
unsigned int test5_exec;
unsigned int test6_exec;
unsigned int test7_exec;
unsigned int test8_exec;
/*
declarations for external test routines
*/
/*unsigned int memtest1(void); */ /* data space test */
/*unsigned int memtest2(void); */ /* code space test */
/*unsigned int uart1test(void); */ /* onchip uart test */
/*unsigned int uart2test(void); */ /* off chip uart test */
/*unsigned int led2test(void); */ /* led test */
/*unsigned int ti_led_test(void);*/ /* led test */
/*unsigned int dactest(void); */ /* dac test */
unsigned int error_code; /* ms byte = main test #, ls byte = error code */
unsigned int halt_on_error;
unsigned int print_on_error;
unsigned int led_error_code;
unsigned int print_header;
volatile unsigned int configdata;
void set_wait(void);
void set_wait(void)
{
configdata = IOWSB1; /* 2 waits for off chip I/O */
OUTMAC( _WSGR, configdata);
}
void set_system(void)
{
unsigned int SCSR1_Data;
SCSR1_Data = *(volatile unsigned int*)SCSR1;
SCSR1_Data |= (ADC_CLKEN | SCI_CLKEN | SPI_CLKEN | CAN_CLKEN | EVB_CLKEN | EVA_CLKEN);
*(volatile unsigned int*)SCSR1 = SCSR1_Data;
}
void bad_trap(void);
void bad_trap(void)
{
while(1); /* a place to hang if illegal trap */
}
void test_init(void);
void test_init(void)
{
test1_exec = TEST1; /* data space ram test,run test if !=0, no if 0 */
test2_exec = TEST2; /* code space ram test,run test if !=0, no if 0 */
test3_exec = TEST3; /* onchip uart test,run test if !=0, no if 0 */
test5_exec = TEST5; /* dac test, run test if !=0, no if 0 */
test6_exec = TEST6; /* led test, run test if !=0, no if 0 */
test7_exec = TEST7; /* ti led test, run test if !=0, no if 0 */
test8_exec = TEST8; /* ti switch, run test if !=0, no if 0 */
error_code = 0; /* show no error */
halt_on_error = 1; /* stop if error occurred */
print_on_error = 0; /* do not print error info to uart */
led_error_code = 0; /* don't put on leds */
print_header = 0; /* do not print header info to uart */
set_wait(); /* set up wait states for I/O */
set_system();
set_pll();
}
void error_process(unsigned int);
void error_process(unsigned int bad_code)
{
error_code = bad_code; /* put in global location */
if (print_on_error) /* print msg to uart ? */
{
}
if (led_error_code) /* put error code on leds ? */
{
}
}
void main(void)
{
int loop_var;
unsigned int error_state, test_num;
test_init(); /* init variables & hardware */
if (LOOP_CNT)
{
loop_var = LOOP_CNT;
while (loop_var--)
{
test_num = 1; /* init the test num */
/* start of a test1 section */
if (test1_exec)
{
error_state = 0; /* clear the error */
error_state = memtest1(); /* execute the test */
if (error_state) /* did we get an error */
{
error_state |= (test_num * 256); /* fold in the test # */
error_process(error_state); /* go process the error */
if (halt_on_error)
{
/* goto error_finish; */ /* force table exit */
goto data_ram_fail; /* force table exit */
} /* end of halt on error */
} /* end of error */
} /* end of test1_exec != 0 */
test_num++; /* inc the test num */
if (test2_exec)
{
error_state = 0; /* clear the error */
error_state = memtest2(); /* execute the test */
if (error_state) /* did we get an error */
{
error_state |= (test_num * 256); /* fold in the test # */
error_process(error_state); /* go process the error */
if (halt_on_error)
{
/* goto error_finish; */ /* force table exit */
goto prog_ram_fail; /* force table exit */
} /* end of halt on error */
} /* end of error */
} /* end of test2_exec != 0 */
test_num++; /* inc the test num */
if (test3_exec)
{
error_state = 0; /* clear the error */
error_state = uart1test(); /* execute the test */
if (error_state) /* did we get an error */
{
error_state |= (test_num * 256); /* fold in the test # */
error_process(error_state); /* go process the error */
if (halt_on_error)
{
/* goto error_finish; */ /* force table exit */
goto onchip_uart_fail; /* force table exit */
} /* end of halt on error */
} /* end of error */
} /* end of test3_exec != 0 */
test_num++; /* inc the test num */
test_num++; /* inc the test num */
if (test5_exec)
{
error_state = 0; /* clear the error */
error_state = dactest(); /* execute the test */
if (error_state) /* did we get an error */
{
error_state |= (test_num * 256); /* fold in the test # */
error_process(error_state); /* go process the error */
if (halt_on_error)
{
/* goto error_finish; */ /* force table exit */
goto dac_fail; /* force table exit */
} /* end of halt on error */
} /* end of error */
} /* end of test5_exec != 0 */
test_num++; /* inc the test num */
if (test6_exec)
{
error_state = 0; /* clear the error */
error_state = led2test(); /* execute the test */
if (error_state) /* did we get an error */
{
error_state |= (test_num * 256); /* fold in the test # */
error_process(error_state); /* go process the error */
if (halt_on_error)
{
/* goto error_finish; */ /* force table exit */
goto led_fail; /* force table exit */
} /* end of halt on error */
} /* end of error */
} /* end of test6_exec != 0 */
test_num++; /* inc the test num */
if (test7_exec)
{
error_state = 0; /* clear the error */
error_state = ti_led_test(); /* execute the test */
if (error_state) /* did we get an error */
{
error_state |= (test_num * 256); /* fold in the test # */
error_process(error_state); /* go process the error */
if (halt_on_error)
{
/* goto error_finish; */ /* force table exit */
goto ti_led_fail; /* force table exit */
} /* end of halt on error */
} /* end of error */
} /* end of test7_exec != 0 */
test_num++; /* inc the test num */
if (test8_exec)
{
error_state = 0; /* clear the error */
error_state = ti_sw_test(); /* execute the test */
if (error_state) /* did we get an error */
{
error_state |= (test_num * 256); /* fold in the test # */
error_process(error_state); /* go process the error */
if (halt_on_error)
{
/* goto error_finish; */ /* force table exit */
goto ti_sw_fail; /* force table exit */
} /* end of halt on error */
} /* end of error */
} /* end of test8_exec != 0 */
} /* end of loop */
} /* end of loop cnt >= 0 */
else
{
while (1)
{
/* start of a test section */
} /* end of forever */
}
good_finish:
goto good_finish; /* a place to hang if ok */
data_ram_fail:
goto data_ram_fail;
prog_ram_fail:
goto prog_ram_fail;
onchip_uart_fail:
goto onchip_uart_fail;
offchip_uart_fail:
goto offchip_uart_fail;
dac_fail:
goto dac_fail;
led_fail:
goto led_fail;
ti_led_fail:
goto ti_led_fail;
ti_sw_fail:
goto ti_sw_fail;
error_finish:
goto error_finish; /* a place to break if error */
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -