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

📄 dsk6xtst.c

📁 使用在dsp TI DSK6711中 很多controller 的例子
💻 C
📖 第 1 页 / 共 3 页
字号:
/*-------------------------------------------------------------------------*/
/* FILENAME: dsk6xtst.c -- DSK Confidence    Test - HOST Code              */
/*                                                                         */
/*  Rev 2.01   11   May 2001  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.01   Mods -- Update for CCS2.0 Support                           */
/*                                                                         */
/*-------------------------------------------------------------------------*/

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

const ULONG DSPHS_BUFFER_ADDRESS = 0x200; /* Start Int Mem */
static FILE     *pLogFile = NULL;
static FILE     *pBoardFile = 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;  

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

  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;
  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"      */
  sBoardFile = DefaultBoard;

  /*-----------------------------------------------------------------------*/
  /* 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( "  -ffilename.ext : Specifies the board configuration file.\n");
          printf( "  -u     : Execute individual tests via menu.\n");
          printf( "  -d     : Debug mode.\n");
          printf("\nTMS320C6211/6711 DSK %s Test, ",TestType);
          printf("Version 2.01,  May 2001");
          printf("\nCopyright (c) 2001 ");
          printf("by Texas Instruments Incorporated. ");
          printf("\nAll rights reserved.\n\n");
          InfoOnly=TRUE;
          AllTests=FALSE;
          break;
        case 'f':
		sBoardFile = &argv1[i][2];
          break;
        case 'u':
          MenuTests=TRUE;
          AllTests=FALSE;
          break;
        case 'd':
          Debug=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.01,  May 2001", 0,0,0,0,1 );
        LogPrint("\nCopyright (c) 2001 ", 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 );
        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 );
      }
    }
  }
  else;

  pBoardFile = fopen( sBoardFile, "r" );
  if ( pBoardFile == NULL )
  {
	 printf( "ERROR: Please specify a valid board configuration file via the -f option.\n" );
	 exit(1);
  }
  else
  {
	 fclose(pBoardFile);
  }

  
  /*-----------------------------------------------------------------------*/
  /* Open a driver connection to a dsk6x board.                            */
  /*-----------------------------------------------------------------------*/
  if ( !dsk6x_open(sBoardFile,&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; 

⌨️ 快捷键说明

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