hal4hc.c

来自「此為philip 1362 USB DOS下的驅動程式包, 已經共測試並內含有說」· C语言 代码 · 共 160 行

C
160
字号
/*
   //*************************************************************************
   //
   //                  P H I L I P S   P R O P R I E T A R Y
   //
   //           COPYRIGHT (c)   2000 BY PHILIPS SINGAPORE.
   //                     --  ALL RIGHTS RESERVED  --
   //
   // File Name:        HAL4Hc.c
   // Author:           ZhenYu Zhang
   // Created:			Jun. 8, 2000
   // Modified:
   // Revision:         0.0
   //
   //*************************************************************************
   // Notes:
   //	Hal4Hc_xx 	: Hardware Abstraction Layer
   //
   //*************************************************************************
*/

#include <stdio.h>
#include <dos.h>

#include "BasicTyp.h"
#include "common.h"
#include "SysCnfg.h"

#include "hal4sys.h"
#include "hal4ISA.h"
#include "hal4Hc.h"

/*
//*************************************************************************
//  Public static data
//*************************************************************************
*/
extern UCHAR bVerbose;
extern UCHAR bIRQL;
/*
//*************************************************************************
//  Private static data
//*************************************************************************
*/

/*
//*************************************************************************
//  Subroutines - Hal4Hc_xx
//*************************************************************************
*/
void Hal4Hc_RegOutW(USHORT wCommand, USHORT wData)
{
	if(bIRQL ==0)
		RaiseIRQL();

	Hal4ISA_CommandOutW4HC(wCommand|0x80);
	Hal4Hc_Wait4DataPhase();
	Hal4ISA_DataOutW4HC(wData);

	if(bIRQL ==0)
		LowerIRQL();

#ifdef DBG_MODE
	if(bVerbose)
		printf("Write 0x%x to 0x%x;\n",wData,wCommand);
#endif
}

void Hal4Hc_RegOutDW(USHORT wCommand, ULONG dwData)
{
	USHORT wData;
	wData = (USHORT) dwData&0xffff;

	if(bIRQL ==0)
		RaiseIRQL();

	Hal4ISA_CommandOutW4HC(wCommand|0x80);
	Hal4Hc_Wait4DataPhase();
	Hal4ISA_DataOutW4HC( wData);
	wData = (USHORT) (dwData>>16)&0xffff;
	Hal4Hc_Wait4DataPhase();
	Hal4ISA_DataOutW4HC( wData);

	if(bIRQL ==0)
		LowerIRQL();

#ifdef DBG_MODE
	if(bVerbose)
		printf("Write 0x%lx to 0x%x;\n",dwData,wCommand);
#endif
}

USHORT Hal4Hc_RegInW(USHORT wCommand)
{
	USHORT wData;

	if(bIRQL ==0)
		RaiseIRQL();

	Hal4ISA_CommandOutW4HC(wCommand&0x7F);
	Hal4Hc_Wait4DataPhase();
	wData = Hal4ISA_DataInW4HC();

	if(bIRQL ==0)
		LowerIRQL();

#ifdef DBG_MODE
	if(bVerbose)
		printf("Read 0x%x from 0x%x;\n",wData,wCommand);
#endif
	return wData;
}

ULONG Hal4Hc_RegInDW(USHORT wCommand)
{
	USHORT wData;
	ULONG dwData;

	if(bIRQL ==0)
		RaiseIRQL();

	Hal4ISA_CommandOutW4HC(wCommand&0x7F);
	Hal4Hc_Wait4DataPhase();
	wData = Hal4ISA_DataInW4HC();
	dwData = (ULONG)wData;
	Hal4Hc_Wait4DataPhase();
	wData = Hal4ISA_DataInW4HC();
	dwData += ((ULONG)wData)<<16L;

	if(bIRQL ==0)
		LowerIRQL();

#ifdef DBG_MODE
	if(bVerbose)
		printf("Read 0x%lx from 0x%x;\n",dwData,wCommand);
#endif

	return dwData;
}
void Hal4Hc_Wait4DataPhase(void)
{
/*#ifdef	ISP1161_AT_48MHZ
	Hal4Sys_WaitinUS(1);
#endif

#ifdef	ISP1161_AT_24MHZ
	Hal4Sys_WaitinUS(1);
#endif

#ifdef	ISP1161_AT_12MHZ
	Hal4Sys_WaitinUS(2);
#endif

#ifdef	ISP1161_AT_6MHZ
	Hal4Sys_WaitinUS(4);
#endif*/
	Hal4Sys_WaitinUS(1);
}

⌨️ 快捷键说明

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