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

📄 pcutils.c

📁 rt采集卡dos下dm6430驱动源代码
💻 C
字号:
/***************************************************************************

	FILE NAME: PCUTIL.C

	FILE DESCRIPTION: 

	This file is a part of DM6430 driver. It contains functions that
	implement Interrupts service routines.

	PROJECT NAME: Part of DM6430 DOS Driver

	DRIVER VERSION: 1.1

	COMPILER: Borland C++ 3.1

	TARGET: Real-Mode DOS

	Copyright 2003 RTD Embedded Technologies

***************************************************************************/
#include <dos.h>
#include "drvr6430.h"

//=====================
// Interrupt handling.
//=====================


/****************************************************************************
 InitHostIT()

 The InitHostIT() function saves the old interrupt vector, sets the new
 interrupt vector and unmasks the IRQ channel in the mask register of the
 interrupt controller. InitHostIT() works differently for XT and AT interrupt
 channels.
****************************************************************************/
#ifdef __cplusplus
// Original interrupt storage C++ style
void interrupt (*OldINT) (...);

void InitHostIT(void interrupt (*IntVect) (...))
#else
// Original interrupt storage C style
void interrupt (*OldINT) (void);

void InitHostIT(void interrupt (*IntVect) (void),int IRQNum)
#endif
{
  unsigned char ITVector, IMR;

  disable();                           // Don't want int called during revector
  if (IRQNum < 8) {
	 ITVector = IRQNum + 8;             // XT interrupt channel
	 OldINT = getvect(ITVector);        // Save startup vector
	 setvect(ITVector, IntVect);        // Set the vector
	 IMR = inportb(0x21);               // Read in current IMR
	 IMR &= ~(1 << IRQNum);             // Clear desired bit
	 outportb(0x21, IMR);               // Out new IMR
  }
  else {
	 ITVector = IRQNum + 0x68;          // AT interrupt channel
	 OldINT = getvect(ITVector);        // Save startup vector
	 setvect(ITVector, IntVect);        // Set the vector
	 IMR = inportb(0xA1);               // Read in current IMR
	 IMR &= ~(1 << (IRQNum-8));         // Clear desired bit
	 outportb(0xA1, IMR);               // Out new IMR
  }
  enable();                            // Reenable interrupts
} //InitHostIT




/****************************************************************************
 RestoreHostIT()

 The RestoreHostIT() function masks the IRQ channel in the mask register of
 the interrupt controller and restores the old interrupt vector.
 RestoreHostIT() works differently for XT and AT interrupt channels.
****************************************************************************/
void RestoreHostIT(int IRQNum)
{
  unsigned char ITVector, IMR;

  disable();                           // Don't want int called during revector
  if (IRQNum < 8) {
	 ITVector = IRQNum + 8;             // XT interrupt channel
	 IMR = inportb(0x21);               // Read in current IMR
	 IMR |= 1 << IRQNum;                // Set desired bit
	 outportb(0x21, IMR);               // Out new IMR
  }
  else {
	 ITVector = IRQNum + 0x68;          // AT interrupt channel
	 IMR = inportb(0xA1);               // Read in current IMR
	 IMR |= 1 << (IRQNum-8);            // Set desired bit
	 outportb(0xA1, IMR);               // Out new IMR
  }
  setvect(ITVector, OldINT);           // Restore the old vector
  enable();                            // Reenable interrupts
} //RestoreHostIT




/****************************************************************************
 EndOfIT()

 The EndOfIT() function must be called at the end of all Interrupt Service
 Routines (ISR). It sends the "End of interrupt" command to the interrupt
 controller chip, to let the controller accept further interrupts.
****************************************************************************/
void EndOfIT(int IRQChannel)
{
  if ( IRQChannel >= 8 ) {
  outportb(0xA0, 0x20);      // End of interrupt command to the 2. controller
  }
  outportb(0x20, 0x20);      // End of interrupt command to the 1. controller
} //EndOfIT


⌨️ 快捷键说明

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