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

📄 sdramcli.c

📁 dsp DM642 pci 详细的开发例程
💻 C
字号:
// SdramCLI.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 routines needed for the SDRAM sub-menu.
////  These routines setup and perform various tests on the SDRAM memory.
////  The low-level dirty work is done by the DM642 Library.
////
//////////////////////////////////////////////////////////////////////////////


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


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


//############################################################################
//                           Function Prototypes
//############################################################################


static void doAddrWriteTest( DM642_HANDLE hDM642 );
static void doWalkingOnes  ( DM642_HANDLE hDM642 );


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


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

void PrintSdramSubMenu(DM642_HANDLE hDM642)
{
    printf ("\n");
    printf ("***************** SDRAM Menu *******************\n");
    printf ("\n");
    printf ("Using board #%d (EVM-DM642)\n", g_dwBoardNum);
    printf ("\n");
    printf ("1:  Run full      SDRAM test     \n");
    printf ("2:  Walk 1's      SDRAM test     \n");
    printf ("3:  Address write SDRAM test     \n");
    printf ("                                 \n");
    printf ("q:  Quit                         \n");
    printf ("                                 \n");
    printf (">> ");

}       // END PrintSdramSubMenu()

//////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////
////
////  Name: RunSdramSubMenu
////
////  Purpose:  Displays the SDRAM SubMenu.  Gets the user's choice
////            from said menu.  Processes that choice.
////
////  Input Parameters:
////      hDM642 - Handle of the currently-open DM642 board/card
////
////  Output Parameters: none
////
////  Return Value(s)  : none
////
//////////////////////////////////////////////////////////////////////////////

void RunSdramSubMenu(DM642_HANDLE hDM642)
{
    char    sChoice[80];
    int     nStatus = 0;


    while (TRUE)
    {
        PrintSdramSubMenu(hDM642);

        scanf ("%s", sChoice);
        printf ("\n");

        if (0 == strcmp(sChoice, "1"))
        {
            DM642RAMTest(hDM642);
        }

        if (0 == strcmp(sChoice, "2"))
        {
            doWalkingOnes(hDM642);
        }

        if (0 == strcmp(sChoice, "3"))
        {
            doAddrWriteTest(hDM642);
        }

        if (0 == strcmp (sChoice, "q"))
        {
            break;
        }

    }   // End infinite loop ...

}       // END RunSdramSubMenu()

////////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////
////
////  Name: doWalkingOnes
////
////  Purpose:  Setup and perform a walking-ones test across the data
////            lines for each bank of SDRAM.
////            The actual test is performed by the DM642 library.  The
///             library routine handles the printing of the results.
////
////  Input Parameters:
////      hDM642 - Handle of the currently-open DM642 board/card
////
////  Output Parameters: none
////
////  Return Value(s)  : none
////
//////////////////////////////////////////////////////////////////////////////

static void doWalkingOnes( DM642_HANDLE hDM642 )
{
    int          nStatus    = kNoError;
    int          nBank      = 0;
    int          nNumBanks  = 0;
    unsigned int nSize      = 0;
    unsigned int nStartAddr = 0;


    //--------------------------------------------------------
    // Determine the size and number of banks for the SDRAM
    //--------------------------------------------------------
    if (kNoError == nStatus)
    {
        nStatus = DM642GetSDRAMSize(hDM642, &nSize, &nNumBanks);
    }

    //--------------------------------------------------------------
    // If a valid size and number of banks were found, loop across
    //   the banks, walking a one across the data lines of each
    //   bank indiviually.
    //--------------------------------------------------------------
    if (kNoError == nStatus)
    {
        for (nBank = 0; nBank < nNumBanks; nBank++)
        {
            nStartAddr = (0 == nBank) ? kSDRAMBank0BaseAddress
                                      : kSDRAMBank1BaseAddress;

            if (kNoError == nStatus)
            {
                // Walk ones across the current bank's data lines
                nStatus = DM642WalkOnes(hDM642, nStartAddr);
            }
        }
    }

}       // END doWalkingOnes()

////////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////
////
////  Name: doAddrWriteTest
////
////
////  Purpose:  Setup and perform an address-to test for each bank of SDRAM
////            The actual test is performed by the DM642 library.  The
///             library routine handles the printing of the results.
////
////  Input Parameters:
////      hDM642 - Handle of the currently-open DM642 board/card
////
////  Output Parameters: none
////
////  Return Value(s)  : none
////
//////////////////////////////////////////////////////////////////////////////

static void doAddrWriteTest( DM642_HANDLE hDM642 )
{
    int          nStatus    = kNoError;
    int          nBank      = 0;
    int          nNumBanks  = 0;
    unsigned int nSize      = 0;
    unsigned int nStartAddr = 0;


    //--------------------------------------------------------
    // Determine the size and number of banks for the SDRAM
    //--------------------------------------------------------
    if (kNoError == nStatus)
    {
        nStatus = DM642GetSDRAMSize(hDM642, &nSize, &nNumBanks);
    }

    //-------------------------------------------------------------------
    // If a valid size and number of banks were found, loop across
    //   the banks, testing the address lines of each bank indiviually.
    //-------------------------------------------------------------------
    if (kNoError == nStatus)
    {
        for (nBank = 0; nBank < nNumBanks; nBank++)
        {
            nStartAddr = (0 == nBank) ? kSDRAMBank0BaseAddress
                                      : kSDRAMBank1BaseAddress;

            if (kNoError == nStatus)
            {
                // Test the current bank's address lines
                nStatus = DM642AddressWriteTest(hDM642, nStartAddr, nSize);
            }
        }
    }

}       // doAddrWriteTest()


//############################################################################
//                             End of Functions
//############################################################################

⌨️ 快捷键说明

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