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

📄 test.c

📁 数字信号处理芯片的测试源文件
💻 C
字号:
/*--------------------------------------------------------*/
/*  WQ21ST SOFTWARE	STUDIO.			                  	  */
/*--------------------------------------------------------*/
/*  EVM Test Code Shell 				                  */
/*--------------------------------------------------------*/
/*  file name:	 test.c				                  */
/*  Started on:  08/11/2001    by: WQ 			          */
/*  Last update: 08/27/2001    by: WQ				      */
/*--------------------------------------------------------*/

/*--------------------------------------------------------*/
/* 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;


/*
  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 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+DSWSB1+PSWSB1; 	 /* 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 */
  test4_exec = TEST4;  /* dac test, run test if !=0, no if 0 */
  test5_exec = TEST5;  /* led test, run test if !=0, no if 0 */
  test6_exec = TEST6;  /* ti led test, run test if !=0, no if 0 */
  test7_exec = TEST7;  /* 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,i;
  unsigned int error_state, test_num;

  test_init();                           /* init variables & hardware */
  
  for (i=1 ; i<=4 ; i++)
   {
     ti_led_off(i);
   
   }   
  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 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 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 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 */
     



      if (test4_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 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 (test5_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 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 (test6_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 ti_led_fail;            /* force table exit */
          }                              /* end of halt on error */
        }                                /* end of error */
      }                                  /* end of test7_exec != 0 */
      wait_ms(500);
      test_num++;                        /* inc the test num */
      if (test7_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 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:  
  ti_led_on(1);
  ti_led_on(4);
  wait_ms(500);
  ti_led_off(4);
  ti_led_off(1);
  wait_ms(500);

  goto good_finish;  

data_ram_fail: 
  ti_led_on(1);
  wait_ms(500);
  ti_led_off(1);
  wait_ms(500);
  
  goto data_ram_fail;

prog_ram_fail:

  ti_led_on(2);
  wait_ms(500);
  ti_led_off(2);
  wait_ms(500);
  goto prog_ram_fail;

onchip_uart_fail: 
  ti_led_on(3);
  wait_ms(500);
  ti_led_off(3);
  wait_ms(500);
  goto onchip_uart_fail;

dac_fail:
  ti_led_on(4);
  wait_ms(500);
  ti_led_off(4);
  wait_ms(500);
  
  goto dac_fail;

led_fail:
  goto led_fail;

ti_led_fail:
  goto ti_led_fail;

ti_sw_fail:
  goto ti_sw_fail;



}

⌨️ 快捷键说明

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