hal_regs.c
来自「一个图形显示芯片s1d13505的应用程序」· C语言 代码 · 共 171 行
C
171 行
/*
**===========================================================================
** HAL_REGS.C - Functions to access the registers.
**---------------------------------------------------------------------------
** Copyright (c) 1997, 1998, 2002 Epson Research and Development, Inc.
** All Rights Reserved.
**===========================================================================
*/
/*
** NOTES
**
** - At some point most every HAL function needs access to the internal
** register read/write routines. As a result the public functions will
** be linked into the executable regardless of whether they are needed.
**
** - Currently ReadRegister() and WriteRegister() perform the same as
** seGetReg() and seSetReg() however in the future (if multiple
** devices are supported) the Read and Write versions will execute
** faster as they won't do device validation in the release build.
*/
#ifdef INTEL
#include <stdio.h>
#endif
#include "hal.h"
#include "nonsefns.h"
#include "assert.h"
/*-----------------------------------------------------------------------*/
static const char Revision[] = "HAL_REGS.C=$Revision: 3 $";
extern LPHAL_STRUCT HalInfoArray[MAX_DEVICE];
/*-------------------------------------------------------------------------*/
/*
** seGetReg()
**
** Retrieves the value in the register specified by 'index'.
*/
int seGetReg( int seReserved1, int index, BYTE *pValue )
{
ASSERT( index <= MAX_REG );
ASSERT( 0 == seReserved1 );
*pValue = *((volatile LPBYTE)HalInfoArray[seReserved1]->dwRegAddr + index);
return ERR_OK;
}
/*-------------------------------------------------------------------------*/
/*
** seSetReg()
**
** Writes 'value' to the register specified by 'index'.
*/
int seSetReg( int seReserved1, int index, BYTE value )
{
ASSERT( index <= MAX_REG );
ASSERT( 0 == seReserved1 );
*((LPBYTE)HalInfoArray[seReserved1]->dwRegAddr + index) = value;
return ERR_OK;
}
/*-------------------------------------------------------------------------*/
/*
** seGetWordReg()
**
** Retrieves the WORD value in the register specified by 'index'.
*/
int seGetWordReg( int seReserved1, int index, WORD *pValue )
{
ASSERT( index <= MAX_REG );
ASSERT( 0 == seReserved1 );
*pValue = *((volatile LPWORD)HalInfoArray[seReserved1]->dwRegAddr + index);
return ERR_OK;
}
/*-------------------------------------------------------------------------*/
/*
** seSetWordReg()
**
** Writes WORD 'value' to the register specified by 'index'.
*/
int seSetWordReg( int seReserved1, int index, WORD value )
{
ASSERT( index <= MAX_REG );
ASSERT( 0 == seReserved1 );
*((LPWORD)HalInfoArray[seReserved1]->dwRegAddr + index) = value;
return ERR_OK;
}
/*-------------------------------------------------------------------------*/
/*
** seGetDwordReg()
**
** Retrieves the DWORD value in the register specified by 'index'.
*/
int seGetDwordReg( int seReserved1, int index, DWORD *pValue )
{
ASSERT( index <= MAX_REG );
ASSERT( 0 == seReserved1 );
*pValue = *((volatile LPDWORD)HalInfoArray[seReserved1]->dwRegAddr + index);
return ERR_OK;
}
/*-------------------------------------------------------------------------*/
/*
** seSetDwordReg()
**
** Writes DWORD 'value' to the register specified by 'index'.
*/
int seSetDwordReg( int seReserved1, int index, DWORD value )
{
ASSERT( index <= MAX_REG );
ASSERT( 0 == seReserved1 );
*((LPDWORD) HalInfoArray[seReserved1]->dwRegAddr + index) = value;
return ERR_OK;
}
/*-------------------------------------------------------------------------*/
/*
** ReadRegister() - internal function
**
** Returns the value of the register specified by 'index'.
**
** The question here is - Do we want to return a BYTE or an int?
*/
BYTE ReadRegister( int seReserved1, int index )
{
ASSERT( index <= MAX_REG );
ASSERT( 0 == seReserved1 );
return *(LPBYTE)(HalInfoArray[seReserved1]->dwRegAddr + index);
}
/*-----------------------------------------------------------------------*/
/*
** WriteRegister() - internal function
**
** Writes 'value' to the register specified by 'index'.
*/
void WriteRegister( int seReserved1, int index, BYTE value )
{
ASSERT( index <= MAX_REG );
ASSERT( 0 == seReserved1 );
*(LPBYTE)(HalInfoArray[seReserved1]->dwRegAddr + index) = value;
}
/*-------------------------------------------------------------------------*/
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?