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

📄 interruptscli.c

📁 dsp DM642 pci 详细的开发例程
💻 C
字号:
// InterruptsCLI.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 necessary to test out the
////  interrupt functionality of DM642 (EVM) cards.
////
//////////////////////////////////////////////////////////////////////////////


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


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


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


void DM642IntHandlerRoutine(DM642_HANDLE  hDM642,
                            PVOID         pvInData);


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


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

void PrintInterruptsSubMenu(DM642_HANDLE hDM642)
{
    printf ("\n");
    printf ("***************** Interrupts Menu ******************\n");
    printf ("\n");
    printf ("Using board #%d (EVM-DM642)\n", g_dwBoardNum);
    printf ("\n");
    printf ("1: Enable  Interrupt Handling         \n");
    printf ("2: Disable Interrupt Handling         \n");
    printf ("                                      \n");
    printf ("3: Set PCI interrupt (EVM->Host)      \n");
    printf ("4: Clear PCI interrupt                \n");
    printf ("                                      \n");
    printf ("5: Set DSP interrupt (Host->EVM)      \n");
    printf ("6: Clear   DSP interrupt              \n");
    printf ("                                      \n");
    printf ("q: Quit (return to Main CLI Menu)     \n");
    printf ("                                      \n");
    printf (">> ");

}       // END PrintInterruptsSubMenu()

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


//////////////////////////////////////////////////////////////////////////////
////
////  Name: RunInterruptsSubMenu
////
////  Purpose:  Displays the Interrupts 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 RunInterruptsSubMenu(DM642_HANDLE hDM642)
{
    char  sChoice[80];
    int   nStatus = 0;


    while (TRUE)
    {
        //---------------------------------
        // Print the menu to the screen
        //---------------------------------
        PrintInterruptsSubMenu(hDM642);

        //------------------------
        // Get the user's choice
        //------------------------
        scanf ("%s", sChoice);
        printf ("\n");

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

        if (0 == strcmp (sChoice, "1"))
        {
            nStatus = DM642IntEnable(hDM642, DM642IntHandlerRoutine);
            printf("EVM-to-Host interrupt enable %s\n", 
                   (TRUE == nStatus) ? "passed" : "FAILED!");
        }

        if (0 == strcmp (sChoice, "2"))
        {
            DM642IntDisable(hDM642);
            printf("EVM-to-Host interrupt disabled\n");
        }

        if (0 == strcmp (sChoice, "3"))
        {
            // Set/Trigger interrupt from EVM->Host
            nStatus = DM642TriggerIntD2H(hDM642);
            printf("EVM-to-Host interrupt trigger D->H %s\n", 
                   (kNoError == nStatus) ? "passed" : "FAILED!");
        }

        if (0 == strcmp (sChoice, "4"))
        {
            // Clear interrupt from EVM->Host
            nStatus = DM642ClearIntD2H(hDM642);
            printf("EVM-to-Host interrupt clear D->H %s\n", 
                   (kNoError == nStatus) ? "passed" : "FAILED!");
        }

        if (0 == strcmp (sChoice, "5"))
        {
            // Set/Trigger interrupt from Host->EVM
            nStatus = DM642TriggerIntH2D(hDM642);
            printf("Host-to-EVM interrupt set H->D %s\n", 
                   (kNoError == nStatus) ? "passed" : "FAILED!");
        }

        if (0 == strcmp (sChoice, "6"))
        {
            // Clear interrupt from Host->EVM
            nStatus = DM642ClearIntH2D(hDM642);
            printf("Host-to-EVM interrupt clear D->H%s\n", 
                   (kNoError == nStatus) ? "passed" : "FAILED!");
        }

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

    }   // End while-loop

}       // END RunInterruptsSubMenu()

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


//////////////////////////////////////////////////////////////////////////////
////
////  Name: DM642IntHandlerRoutine
////
////  Purpose: Callback (deferred processing) routine attached to Host's
////           PCI interrupt (the interrupt from an EVM to the Host).
////           This routine is run (by the DM642 Library) at user-level
////           sometime _after_ the interrupt has occured.  
////           Lower level tasks (eg: clearing status registers) are
////           handled by the ISR and DM642 Library when the interrupt
////           actually occurs.
///
////           This routine must be passed into DM642IntEnable() before
////           it can be used.
////
////  Input Parameters:
////      hDM642   - Handle of the currently-open DM642 board/card
////      pvInData - Pointer to an int-status structure.
////
////  Output Parameters: none
////
////  Return Value(s)  : none
////
//////////////////////////////////////////////////////////////////////////////

void DM642IntHandlerRoutine(DM642_HANDLE  hDM642,
                            PVOID         pvInData)
{
    tDM642InterruptStatus *poStatus;

    poStatus = (tDM642InterruptStatus *)pvInData;

    //--------------------------------------------------------
    // Just print a message to let the user know that we
    //   got here.  If we do get here, that means that the
    //   interrupt HAS occurred.
    //--------------------------------------------------------
    printf ("Callback: Got Int number %u\n", (UINT)poStatus->dwCounter);

}       // END DM642IntHandlerRoutine


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

⌨️ 快捷键说明

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