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

📄 dm642_cli.c

📁 dsp DM642 pci 详细的开发例程
💻 C
📖 第 1 页 / 共 3 页
字号:
// dm642_cli.c
//////////////////////////////////////////////////////////////////////////////
////
////  Copyright (c) 2003, Valley Technologies, Inc.
////  All rights reserved.
////
//////////////////////////////////////////////////////////////////////////////
////
////  $Header $
////
////  $ReleaseClass: src $
////
////  Original Author                 : ebersole
////  Most Recent Contributing $Author: ebersole $
////
//////////////////////////////////////////////////////////////////////////////
////
////  This file contains the CLI's entry point (main()), along with the
////  routines to manage its two highest-level menus.  It also contains
////  various menu-related routines that did not fit well anywhere else.
////  [ie, the file is a catch-all for CLI routines].
////  The low-level dirty work is done by the LED part of the DM642 Library.
////
//////////////////////////////////////////////////////////////////////////////


//############################################################################


// Includes
#include <stdio.h>
#include <dm642_lib.h>
#include "Dm642Cli.h"


//############################################################################


// Globals
int   gnBoardsFound = 2;
DWORD g_dwBoardNum  = -1;

// input command from user
static char line[256];


//############################################################################
//                            Start of Functions
//############################################################################


//////////////////////////////////////////////////////////////////////////////
////
////  Name: main
////
////  Purpose:  The entry point into the CLI program.
////            Initializes the DM642 library, device driver, etc.
////            Runs the top-level menu (the main CLI menu is a sub-menu
////            of this one).
////
////  Input Parameters:
////      argc - number of inputs to the program, plus 1.
////             <= 2
////      argv - the inputs to the program, in "string" form.
////
////  Output Parameters: none
////
////  Return Value(s)  :
////      0 - in ALL cases.
////
//////////////////////////////////////////////////////////////////////////////

int main(int argc, char *argv[])
{
    DM642_HANDLE hDM642           = NULL;
    DWORD        dwAction         = 0;
    BOOL         fRegisteredEvent = FALSE;


    printf ("DM642 diagnostic utility.\n");

    // Setup the debug values
    if ((2 == argc) && (0 == strcmp (argv [1], "off")))
    {
        DM642SetDebug (FALSE);
    }
    else
    {
        DM642SetDebug (TRUE);
    }

    // Check for active driver
    if(FALSE == DM642IsDeviceDriverPresent())
    {
        printf("Error no Device Driver present!\n");

        // Exit on Error
        return 0;
    }

    // Initialize all of the boards
    DM642Init();

    //-------------------------------------------------------------
    // Open one of the boards, defaulting to board #0 if only one
    // board is present
    //-------------------------------------------------------------
    ChangeBoard(&hDM642, DM642_DEFAULT_VENDOR_ID, DM642_DEFAULT_DEVICE_ID);

    //************************************************************************

    //=-=-=-=-=-=-=-=-=-=-=-=-=
    // Run the top-level menu
    //=-=-=-=-=-=-=-=-=-=-=-=-=

    DM642RunMainCLIMenu (&hDM642);


    if (hDM642)
    {
        DM642Close(hDM642);
    }

    return (0);

}       // END main()




//////////////////////////////////////////////////////////////////////////////
////
////  Name: DM642PrintCLIMenu
////
////  Purpose: Displays the main/primary CLI Menu to the screen.
////
////  Input Parameters:
////      hDM642 - Handle of the currently-open DM642 board/card
////
////  Output Parameters: none
////
////  Return Value(s)  : none
////
//////////////////////////////////////////////////////////////////////////////

void DM642PrintCLIMenu(DM642_HANDLE hDM642)
{
    char   sLine [80];
    int    nBoardType = 0;


    gnBoardsFound = DM642CountCards(DM642_DEFAULT_VENDOR_ID,
                                    DM642_DEFAULT_DEVICE_ID);

    gnBoardsFound = gnBoardsFound;

    sprintf(sLine, "                                     | %s\n",
            ((gnBoardsFound > 1) ? "c:  Change board #" : ""));

    printf ("\n");
    printf ("************************** Main Menu ************************\n");
    printf ("\n");
    printf ("Using board #%d (EVM-DM642)\n", g_dwBoardNum);
    printf ("\n");
    printf (" 1: Read  FPGA Version Reg           | 20: LED        Sub-Menu        \n");
    printf (" 2: Read  Flash Page Reg             | 21: SDRAM      Sub-Menu        \n");
    printf (" 3: Write Flash Page Reg             | 22: Flash      Sub-Menu        \n");
    printf ("                                     | 23: PCI-EEPROM Sub-Menu        \n");
    printf (" 4: Read  PCI config space           | 24: DMA        Sub-Menu        \n");
    printf (" 5: Write PCI config space           | 25: Interrupts Sub-Menu        \n");
    printf ("                                     |                                \n");
    printf (" 6: Read  memory                     |                                \n");
    printf (" 7: Write memory                     | 26: Execute (Program in Mem)   \n");
    printf (" 8: Fill  memory                     | 27: Warm Reset (DSP-chip only) \n");
    printf ("                                     | 28: Setup EMIF                 \n");
    printf (" 9: Read mem to ASC file             |                                \n");
    printf ("10: Read mem to BIN file             | 30. Scan PCI bus               \n");
    printf ("                                     |                                \n");
    printf ("11: Write mem from  ASC file         |                                \n");
    printf ("12: Write mem from  BIN file         |                                \n");
    printf ("13: Write mem from .hex file         |                                \n");
    printf ("14: Reset & Write mem from .hex file |                                \n");
    printf (sLine);
    printf ("                                     | q:  Quit                       \n");
    printf ("\n");
    printf (">> ");

}       // END DM642PrintCLIMenu()




//////////////////////////////////////////////////////////////////////////////
////
////  Name: DM642RunMainCLIMenu
////
////  Purpose:  Displays the Main CLI Menu.  Gets the user's choice
////            from said menu.  Processes that choice.
////
////  Input Parameters:
////      phDM642 -- POINTER to the handle of the currently-open DM642
////
////  Output Parameters:
////      phDM642 -- POINTER to the handle of the (recently opened) DM642
////
////  Return Value(s)  : none
////
//////////////////////////////////////////////////////////////////////////////

void DM642RunMainCLIMenu( DM642_HANDLE *phDM642 )
{
    char         sChoice [80];
    unsigned int nVal1  = 0;
    unsigned int nVal2  = 0;
    DM642_HANDLE hDM642 = *phDM642;


    //=-=-=-=-=-=-=-=-=
    // Run the CLI
    //=-=-=-=-=-=-=-=-=
    while (TRUE)
    {
        //--------------------------------------------------------
        // Each time thru the loop, print out the CLI Menu ...
        //--------------------------------------------------------
        DM642PrintCLIMenu(hDM642);

        //--------------------------------------------------------
        // ... then wait for the user to make his/her choice ...
        //--------------------------------------------------------
        scanf ("%s", sChoice);
        printf("\n");

        //---------------------------------------------
        // ... and finally process that choice ....
        //---------------------------------------------

        //------------------------------------------
        //  FPGA access routines
        //------------------------------------------

        if (0 == strcmp(sChoice, "1"))
        {
            // Read FPGA Version Register
            menuReadFpgaVersionReg(hDM642);
        }

        if (0 == strcmp(sChoice, "2"))
        {
            // Show/Display Flash Page Register
            showFlashPageReg(hDM642);
        }

        if (0 == strcmp(sChoice, "3"))
        {
            // Set Flash Page Register
            menuWriteFlashPageReg(hDM642);
        }

        //------------------------------------------------
        // DSP-Config-Space related routines/choices ...
        //------------------------------------------------

        if (0 == strcmp(sChoice, "4"))
        {
            // Read DSP config space
            menuReadDSPConfigSpace(hDM642);
        }

        if (0 == strcmp(sChoice, "5"))
        {
            // Write DSP config space
            menuWriteDSPConfigSpace(hDM642);
        }

        //--------------------------------------------
        // (Main) Memory-related routines/choices ...
        //--------------------------------------------

        if (0 == strcmp(sChoice, "6"))
        {
            // Read DSP Memory
            menuReadDSPMem(hDM642);
        }

        if (0 == strcmp(sChoice, "7"))
        {
            // Write DSP Memory
            menuWriteDSPMem(hDM642);
        }

        if (0 == strcmp(sChoice, "8"))
        {
            // Fill Memory
            fillMemory(hDM642);
        }

        //----------------------------------------
        // File I/O related routines/choices ...
        //----------------------------------------

        if (0 == strcmp(sChoice, "9"))
        {
            // Copy values from memory to an ASCII file
            // FALSE sets output file to ASCII
            readMemToFile(hDM642, FALSE);
        }

        if (0 == strcmp(sChoice, "10"))
        {
            // Copy values from memory to a Binary file
            // TRUE sets output file to Binary
            readMemToFile(hDM642, TRUE);
        }

        if (0 == strcmp(sChoice, "11"))
        {
            // Copy values from an ASCII file to memory
            // FALSE sets input file to ASCII
            writeMemFromFile(hDM642, FALSE);
        }

        if (0 == strcmp(sChoice, "12"))
        {
            // Copy values from an Binary file to memory
            // TRUE sets input file to Binary
            writeMemFromFile(hDM642, TRUE);
        }

        if (0 == strcmp(sChoice, "13"))
        {
            // Loads a .hex file to memory
            // Note: Does not write to Flash memory
            loadDotHexFile(hDM642);
        }

        if (0 == strcmp(sChoice, "14"))
        {
            // Resets the DSP, then loads a .hex file to memory
            // Note: Does not write to Flash memory
            resetAndLoadDotHexFile(hDM642);
        }

        //-------------------------------------
        // LED-related routines/choices ...
        //-------------------------------------

        if (0 == strcmp(sChoice, "20"))
        {
            // Display Led Menu
            RunLedSubMenu(hDM642);
        }

        //-------------------------------------
        // SDRAM-related routines/choices ...
        //-------------------------------------

        if (0 == strcmp(sChoice, "21"))
        {
            // Display SDRAM Menu
            RunSdramSubMenu(hDM642);
        }

        //-------------------------------------
        // FLASH-related routines/choices ...
        //-------------------------------------

        if (0 == strcmp(sChoice, "22"))
        {
            // Display Flash Menu
            RunFlashSubMenu(hDM642);
        }

        //-------------------------------------
        // PCI EEPROM-related routines/choices ...
        //-------------------------------------
        if (0 == strcmp(sChoice, "23"))
        {
            // Display PCI EEPROM Menu
            RunPciEEPROMSubMenu(hDM642);
        }

        //-------------------------------------
        // DMA-related routines/choices ...
        //-------------------------------------

        if (0 == strcmp (sChoice, "24"))
        {
            // Display DMA Menu
            RunDMASubMenu (hDM642);
        }

        //-----------------------------------------------
        // Board Interrupt-related routines/choices ...
        //-----------------------------------------------

        if (0 == strcmp (sChoice, "25"))
        {
            // Display Interrupt Menu
            RunInterruptsSubMenu(hDM642);
        }

        //---------------------------------------
        // Board Exec/Cntl routines/choices ...
        //---------------------------------------

        if (0 == strcmp(sChoice, "26"))
        {
            // Execute program
            DM642Execute(hDM642);
        }

        if (0 == strcmp(sChoice, "27"))
        {
            // Perform a DSP Warm Reset
            DM642WarmReset(hDM642);
        }

        if (0 == strcmp(sChoice, "28"))
        {

⌨️ 快捷键说明

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