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

📄 dsk6xtst.c

📁 This is Bsl.zip for DSP c6000
💻 C
📖 第 1 页 / 共 3 页
字号:
/*-------------------------------------------------------------------------*/
/* FILENAME: dsk6xtst.c -- DSK Confidence    Test - HOST Code              */
/*                                                                         */
/*  Rev 2.16   17   July 2000  T.J.Dillon                                  */
/*                                                                         */
/*-------------------------------------------------------------------------*/
/*  HISTORY                                                                */
/*  Rev 1.00   Created                                                     */
/*  Rev 1.10   Mods a) LEDS and CODEC parameter passing                    */
/*                  b) Removed FLASH checksum                              */
/*                  c) Changes for new Win32 DLL API for generic API       */
/*  Rev 1.20   Mods -- Added -pport options                                */
/*  Rev 1.21   Mods -- Reorganize to be consistent with Manufacturing Test */
/*  Rev 1.25   Mods -- Update with latest Win32 DLL API                    */
/*  Rev 1.26   Mods -- Added -pd option                                    */
/*  Rev 1.30   Mods -- Added board revision info                           */
/*  Rev 2.00   Mods -- Update for C6711 DSK                                */
/*  Rev 2.10   Mods -- Update for Larger SDRAMs                            */
/*  Rev 2.15   Mods -- Added -n option                                     */
/*  Rev 2.16   Mods -- Added newer memory test for SDRAM                   */
/*                                                                         */
/*-------------------------------------------------------------------------*/

#include <stdio.h>
#include <windows.h>
#include "dsk6211.h"
#include "dsk6xHSB.h"
#include "dsk6xtst.h"                                           

const ULONG DSPHS_BUFFER_ADDRESS = 0x200; /* Start Int Mem */
static FILE     *pLogFile = NULL;
#define STRING_BUFFER_SIZE  (80)
#define ULONG unsigned long

static void LogPrint( char *format, ULONG parm1, ULONG parm2,
                      ULONG parm3, ULONG parm4, int printflag );
static void PressAnyKey( void );
static void PrintMenu( void );
static int CheckResults( ULONG hSB[] );

BOOL  AllTests=TRUE;  
BOOL  InfoOnly=FALSE;  
BOOL  MenuTests=FALSE;
BOOL  Debug=FALSE;  
BOOL  NoDateOrTime=FALSE;  

/*-------------------------------------------------------------------------*/
/* main()                                                                  */
/*-------------------------------------------------------------------------*/

void main(int argc1, char *argv1[])
{
  unsigned int dip_settings;
  unsigned int bd_rev;

  dskHANDLE hBd;        /* Board device handle                             */
  short  iBd    = 0;    /* Board index                                     */
  BOOL   bExcl  = 1;    /* Exclusive open = TRUE                           */
  short  iMp    = 1;    /* Map selector = MAP1                             */
  char coffNam[20]= "CnfDSP.out";
                        /* COFF file name                                  */
  char *sLogFile;
  char stringBuffer[STRING_BUFFER_SIZE];
  BOOL bVerbose = 0;    /* COFF load verbose mode = FALSE                  */
  BOOL bClr     = 0;    /* Clear bss mode = FALSE                          */
  BOOL bDump    = 0;    /* Dump mode = FALSE                               */

  char YesOrNo[3]="\0";                                           
  ULONG handShakingBuffer[HS_BUFFER_LEN], readLength, writeLength;
  ULONG nPort=0xa;
  int handShakingFlag, dspProcFlag;                                
  int choice,i,error_count=0;
  int numblink,ledperiod;/* User params for LEDS test in menu+debug mode   */                                                      
  ULONG command;         /* Command variable to run each test on DSP       */
  ULONG writevalue,startaddr,sizemem;
                         /* User params for PGMEM test in menu+debug mode  */
  sLogFile = DefaultLog;  /* Default name for log file "dsk6xtst.log"      */

  /*-----------------------------------------------------------------------*/
  /* Parse Command Line                                                    */
  /*-----------------------------------------------------------------------*/
  for(i=1; argc1 > i; i++)
  {
    if( argv1[i][0] != '-' )
    {
      sLogFile = argv1[i];
    }
    else
    {
      switch(tolower(argv1[i][1]))
      {
        case 'h':
        case '?':
          printf( "Syntax: %s [-?] [-u] [-d] [logfilename]\n",TestName );
          printf( "\n");
          printf( "  -?,h   : Displays command line help info.\n");
          printf( "  -pport : Specifies board to test (a,b,c or d).\n");
          printf( "  -u     : Execute individual tests via menu.\n");
          printf( "  -d     : Debug mode.\n");
          printf( "  -n     : Turns off Date and Time.\n");
          printf("\nTMS320C6211/6711 DSK %s Test, ",TestType);
          printf("Version 2.16,  Jul 2000");
          printf("\nCopyright (c) 2000 ");
          printf("by Texas Instruments Incorporated. ");
          printf("\nAll rights reserved.\n\n");
          InfoOnly=TRUE;
          AllTests=FALSE;
          break;
        case 'p':
          switch(tolower(argv1[i][2]))
          {
            case 'a':
              nPort=0xa;
              break;
            case 'b':
              nPort=0xb;
              break;
            case 'c':
              nPort=0xc;
              break;
            case 'd':
              nPort=0xd;
              break;
            default:
              nPort=0xa;
              break;
          }
          break;
        case 'u':
          MenuTests=TRUE;
          AllTests=FALSE;
          break;
        case 'd':
          Debug=TRUE;
          break;
        case 'n':
          NoDateOrTime=TRUE;
          break;
        default:
          AllTests=TRUE;
          break;
      }
    }
  }

  if(InfoOnly)
    sLogFile = NULL;

  /*-----------------------------------------------------------------------*/
  /* Open Log File                                                         */
  /*-----------------------------------------------------------------------*/
  if ( sLogFile != NULL )
  {
    pLogFile = fopen( sLogFile, "w" );
    if ( pLogFile == NULL )
    {
      printf( "WARNING: Unable to open log file \"%s\".\n", sLogFile );
      PressAnyKey();
    }
    else
    { 
      if(InfoOnly)
      {  // do nothing  
      }  
      else
      {
        LogPrint("\nTMS320C6211/6711 DSK %s Test, ", (ULONG)TestType,0,0,0,1 );
        LogPrint("Version 2.16,  Jul 2000", 0,0,0,0,1 );
        LogPrint("\nCopyright (c) 2000 ", 0,0,0,0,1 );
        LogPrint("  by  Texas Instruments Incorporated. ", 0,0,0,0,1 );
        LogPrint("\nAll rights reserved.\n", 0,0,0,0,1 );
        if(!NoDateOrTime)
		{
          LogPrint("\nTest Run Time: ", 0,0,0,0,1 );
          GetTimeFormat( LOCALE_SYSTEM_DEFAULT, 0, NULL,
            "hh':'mm':'ss tt", stringBuffer, STRING_BUFFER_SIZE );
          LogPrint( stringBuffer, 0,0,0,0,1 );
          LogPrint( "   ", 0,0,0,0,1 );
          LogPrint("Test Run Date: ", 0,0,0,0,1 );
          GetDateFormat( LOCALE_SYSTEM_DEFAULT, 0, NULL,
            "MMM dd',' yyyy", stringBuffer, STRING_BUFFER_SIZE );
          LogPrint( stringBuffer, 0,0,0,0,1 );
		}
        LogPrint( "\n\n", 0,0,0,0,1 );
      }
    }
  }

  /*-----------------------------------------------------------------------*/
  /* Open a driver connection to a dsk6x board.                            */
  /*-----------------------------------------------------------------------*/
  if ( !dsk6x_open(nPort,&hBd) )
  {
    LogPrint("FAILED: dsk6x_open()!\n", 0,0,0,0,1);
    exit(1);
  }

  /*-----------------------------------------------------------------------*/
  /* Cause a DSP reset.                                                    */
  /*-----------------------------------------------------------------------*/
  if ( !dsk6x_reset_dsp(hBd,0,1) )
  {
    LogPrint("FAILED: dsk6x_reset_dsp()!\n", 0,0,0,0,1);
    exit(2);
  }

  /*-----------------------------------------------------------------------*/
  /* Establish a connection to the HPI of a target board.                  */
  /*-----------------------------------------------------------------------*/
  if ( !dsk6x_hpi_open(hBd))
  {
    LogPrint("FAILED: dsk6x_hpi_open()!\n", 0,0,0,0,1);
    exit(3);
  }

  /*-----------------------------------------------------------------------*/
  /* Read a COFF file and write the data to DSP memory.                    */
  /*-----------------------------------------------------------------------*/
  if (dsk6x_coff_load(hBd,coffNam,bVerbose,bClr,bDump))
  {
    LogPrint("FAILED: dsk6x_coff_load()!\n", 0,0,0,0,1);
    exit(4);
  }

  /*-----------------------------------------------------------------------*/
  /* Generate a DSPINT to start program                                    */
  /*-----------------------------------------------------------------------*/
  if (!dsk6x_hpi_generate_int(hBd))
  {
    LogPrint("FAILED: dsk6x_hpi_generate_int()!\n", 0,0,0,0,1);
    exit(5);
  }

  /*-----------------------------------------------------------------------*/
  /* If AllTests (default) or MenuTests then Handshake with DSP            */
  /*-----------------------------------------------------------------------*/
  if(AllTests || MenuTests)
  {

    /*---------------------------------------------------------------------*/
    /* Handshaking. Keep reading until hand shake is done.                 */
    /*---------------------------------------------------------------------*/
    do
    {
	    readLength = HS_BUFFER_LEN*4; /* 4 bytes for 1 word */

      /*-------------------------------------------------------------------*/
      /* Test if handShakingBuffer actually read (completely)              */
      /*-------------------------------------------------------------------*/
	    if (!dsk6x_hpi_read(hBd, handShakingBuffer, &readLength, 
        DSPHS_BUFFER_ADDRESS) || readLength != HS_BUFFER_LEN*4)
      { /* evm6x_hpi_read() failed */
		    continue; // try again
      }

      /*-------------------------------------------------------------------*/
      /* Test if handShakingBuffer contains correct ID                     */
      /*-------------------------------------------------------------------*/
	    handShakingFlag = 0;  // reset hand shaking flag
	    if(handShakingBuffer[0] != ID_0)
		    handShakingFlag = 1;
	    if(handShakingBuffer[1] != ID_1)
		    handShakingFlag = 1;
	    if(handShakingBuffer[2] != ID_2)
		    handShakingFlag = 1;
    } while (handShakingFlag == 1);

    /*---------------------------------------------------------------------*/
    /* Read dip settings                                                   */
    /*---------------------------------------------------------------------*/
    dip_settings=handShakingBuffer[5]&0x07000000;
    bd_rev=((handShakingBuffer[5])>>29)&0x7;
    LogPrint(" USER_SW3=%d ",((dip_settings&0x4000000)>>26),0,0,0,1);
    LogPrint(" USER_SW2=%d ",((dip_settings&0x2000000)>>25),0,0,0,1);
    LogPrint(" USER_SW1=%d ",((dip_settings&0x1000000)>>24),0,0,0,1);
    LogPrint(" Board Rev=%d\n\n",bd_rev,0,0,0,1);

    /*---------------------------------------------------------------------*/
    /* Send hand shaking ACK to Target(DSP)                                */
    /*---------------------------------------------------------------------*/
    writeLength = 4;
    handShakingBuffer[4] = HOST_RECEIVE_HAND_SHAKING_INFO;
    dsk6x_hpi_write(hBd, &handShakingBuffer[4], &writeLength, 
      DSPHS_BUFFER_ADDRESS+4*4);

  } // End of if(AllTests || MenuTests)

  /*-----------------------------------------------------------------------*/
  /* Choose AllTests or MenuTests                                          */
  /*-----------------------------------------------------------------------*/
  if(AllTests)
  {

    /*---------------------------------------------------------------------*/
    /* Send All commands to DSP (default mode for DSK Confidence Test)     */
    /*---------------------------------------------------------------------*/
    for(command=ISRAM;command<(CODEC+1);command+=0x1000)
    {
      LogPrint("Command=", 0,0,0,0,1);

      if(command == ISRAM)
        LogPrint("ISRAM",0,0,0,0,1);
		  else if(command == SDRAM)
        LogPrint("SDRAM",0,0,0,0,1);
		  else if(command == FLASH)
        LogPrint("FLASH",0,0,0,0,1);
		  else if(command == MCBSP)
        LogPrint("MCBSP",0,0,0,0,1);
		  else if(command == TIMER)
        LogPrint("TIMER",0,0,0,0,1);
		  else if(command == QDMA)
        LogPrint("QDMA.",0,0,0,0,1);
		  else if(command == LEDS)
        LogPrint("LEDS.",0,0,0,0,1);
		  else if(command == CODEC)
        LogPrint("CODEC",0,0,0,0,1);

      if(command == LEDS)
        LogPrint("..Are They Flashing?.......Result=>", 0,0,0,0,1);
      else if(command == CODEC)
        LogPrint("..Is Tone/Music Playing?...Result=>", 0,0,0,0,1);
      else
        LogPrint("...........................Result=>", 0,0,0,0,1);

      /*-------------------------------------------------------------------*/
      /* Send parameters to Target(DSP)                                    */
      /*-------------------------------------------------------------------*/
      if (command == LEDS)
      {
        handShakingBuffer[0]=LEDBlinks;
        handShakingBuffer[1]=LEDPeriod;
        handShakingBuffer[2]=0;
  	    writeLength = 3*4;
  	    dsk6x_hpi_write(hBd, handShakingBuffer, &writeLength, 
          DSPHS_BUFFER_ADDRESS);
      }
      else if (command == CODEC)
      {
        handShakingBuffer[0]=CodecTone;
        handShakingBuffer[1]=CodecCDPlay;
        handShakingBuffer[2]=0;
  	    writeLength = 3*4;
  	    dsk6x_hpi_write(hBd, handShakingBuffer, &writeLength, 
          DSPHS_BUFFER_ADDRESS);
      }

      /*-------------------------------------------------------------------*/
      /* Send command to Target(DSP)                                       */
      /*-------------------------------------------------------------------*/
      writeLength = 4;
      handShakingBuffer[3] = command; 
      dsk6x_hpi_write(hBd, &handShakingBuffer[3], &writeLength, 
        DSPHS_BUFFER_ADDRESS+3*4);

      /*-------------------------------------------------------------------*/
      /* Tell Target(DSP) that Host is ready                               */
      /*-------------------------------------------------------------------*/
      writeLength = 4;
      handShakingBuffer[4] = HOST_STATUS_INPUT_READY; 
      dsk6x_hpi_write(hBd, &handShakingBuffer[4], &writeLength, 
        DSPHS_BUFFER_ADDRESS+4*4);

      dspProcFlag = 1;

      /*-------------------------------------------------------------------*/
      /* Wait for Target(DSP) to tell you it is done!                      */
      /*-------------------------------------------------------------------*/
      do
      {
	      readLength = 4;
	      dsk6x_hpi_read(hBd, &handShakingBuffer[4], &readLength, 
          DSPHS_BUFFER_ADDRESS+4*4);

	      if(handShakingBuffer[4] == DSP_STATUS_OUTPUT_READY)
		    dspProcFlag = 0;  // DSP is done processing

      } while(dspProcFlag);

      /*-------------------------------------------------------------------*/

⌨️ 快捷键说明

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