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

📄 inttest.c

📁 用于TM1300/PNX1300系列DSP(主要用于视频处理)的外部设备的源码
💻 C
字号:
/*
 * Copyright (c) 1995-2000 by TriMedia Technologies. 
 *
 * +------------------------------------------------------------------+
 * | This software is furnished under a license and may only be used  |
 * | and copied in accordance with the terms and conditions of  such  |
 * | a license and with the inclusion of this copyright notice. This  |
 * | software or any other copies of this software may not be provided|
 * | or otherwise made available to any other person.  The ownership  |
 * | and title of this software is not transferred.                   |
 * |                                                                  |
 * | The information in this software is subject  to change without   |
 * | any  prior notice and should not be construed as a commitment by |
 * | TriMedia Technologies.                                           |
 * |                                                                  |
 * | this code and information is provided "as is" without any        |
 * | warranty of any kind, either expressed or implied, including but |
 * | not limited to the implied warranties of merchantability and/or  |
 * | fitness for any particular purpose.                              |
 * +------------------------------------------------------------------+
 *
 *  Module name              : inttest.c    1.8
 *
 *  Last update              : 17:25:08 - 00/11/09
 *
 *  Description              :
 *
 *      A test and demonstration for the TriMedia Interrupts library.
 *      This test installs two interrupt handlers at different priorities,
 *      and checks if the priority changing mechanism works: The lower
 *      level priority should not interrupt execution of the higher
 *      level one.
 *
 *  Revision                 :
 *      Built for the TCS 1.1f release
 *
 *
 */


#include <stdio.h>
#include <tm1/tmInterrupts.h>
#include <assert.h>
#include <tm1/tmHelp.h>


 /*
  * Here are two interrupt handlers; they will be installed in main(); and be
  * made simultaneously pending.
  * 
  * Because the second one will be installed at a lower priority, and the first
  * one uppers the global interrupt priority to its own level (with the
  * intention of locking lower priority interrupts out during its execution),
  * the second one will be serviced strictly after the first one has
  * completed.
  */



static UInt vout_activated = 0;

static void 
VINHandler()
{
#pragma TCS_handler
    intPriority_t saved_prio;

    saved_prio = intSetPriority(intPRIO_6);

    intSetIEN();

    /************************************/
    /* give opportunity for VOUTHandler */
    /************************************/

    intClearIEN();

    assert(vout_activated == 0);    /* shouldn't have come */

    intSetPriority(saved_prio);
}



static void 
VOUTHandler()
{
#pragma TCS_handler
    vout_activated++;
}






 /*
  * Macro to do compact error checking on device library calls:
  */
#define E(x)   if ((x) != 0) { fprintf(stderr, "Error\n"); exit(-1); }






main()
{
    intInstanceSetup_t setup;

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

    setup.enabled          = True;
    setup.handler          = VINHandler;
    setup.level_triggered  = False;
    setup.priority         = intPRIO_6;

    E( intOpen(intVIDEOIN) );
    E( intInstanceSetup(intVIDEOIN, &setup) );

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

    setup.enabled          = True;
    setup.handler          = VOUTHandler;
    setup.level_triggered  = False;
    setup.priority         = intPRIO_0;

    E( intOpen(intVIDEOOUT) );
    E( intInstanceSetup(intVIDEOOUT, &setup) );

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

    intClearIEN();        /* simultanuous interrupt raise */
    intRaise(intVIDEOOUT);
    intRaise(intVIDEOIN);
    intSetIEN();

    assert(vout_activated == 1);    /* should have come once */

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

    E( intClose(intVIDEOIN) );
    E( intClose(intVIDEOOUT) );

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

    printf("Finished\n");
    exit(0);
}

⌨️ 快捷键说明

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