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

📄 hal.h

📁 一个图形显示芯片s1d13505的应用程序
💻 H
字号:
/*
**===========================================================================
** HAL.H
**---------------------------------------------------------------------------
** Copyright (c) 1997, 2001 Epson Research and Development, Inc.
** All Rights Reserved.
**===========================================================================
*/

#ifndef _HAL_H_
#define _HAL_H_

#pragma warning(disable:4001)   // Disable the 'single line comment' warning.


#include "hal_regs.h"

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

typedef unsigned char  BYTE;
typedef unsigned short WORD;
typedef unsigned long  DWORD;
typedef unsigned int   UINT;
typedef          int   BOOL;

typedef BYTE      *LPBYTE;
typedef WORD      *LPWORD;
typedef DWORD     *LPDWORD;

#ifndef LOBYTE
#define LOBYTE(w)    ((BYTE)(w))
#endif

#ifndef HIBYTE
#define HIBYTE(w)    ((BYTE)(((UINT)(w) >> 8) & 0xFF))
#endif

#ifndef LOWORD
#define LOWORD(l)    ((WORD)(DWORD)(l))
#endif

#ifndef HIWORD
#define HIWORD(l)    ((WORD)((((DWORD)(l)) >> 16) & 0xFFFF))
#endif

#ifndef MAKEWORD
#define MAKEWORD(lo, hi) ((WORD)(((WORD)(lo)) | (((WORD)(hi)) << 8)) )
#endif

#ifndef MAKELONG
#define MAKELONG(lo, hi) ((long)(((WORD)(lo)) | (((DWORD)((WORD)(hi))) << 16)))
#endif

#ifndef TRUE
#define TRUE   1
#endif

#ifndef FALSE
#define FALSE  0
#endif

#define OFF 0
#define ON  1

#ifndef NULL
#ifdef __cplusplus
#define NULL    0
#else 
#define NULL    ((void *)0)
#endif 
#endif 

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

/*
** SIZE_VERSION  is the size of the version string (eg. "1.00")
** SIZE_STATUS   is the size of the status string (eg. "b" for beta)
** SIZE_REVISION is the size of the status revision string (eg. "00")
*/
#define SIZE_VERSION    5
#define SIZE_STATUS     2
#define SIZE_REVISION   3


#ifdef ENABLE_DPF       /* Debug_printf() */

#define DPF(exp)  printf(#exp "\n")
#define DPF1(exp) printf(#exp " = %d\n", exp)
#define DPF2(exp1, exp2) printf(#exp1 "=%d  " #exp2 "=%d\n", exp1, exp2)
#define DPFL(exp) printf(#exp " = %x\n", exp)

#else 

#define DPF(exp) ((void)0)
#define DPF1(exp) ((void)0)
#define DPFL(exp) ((void)0)

#endif 


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

/*
** Definitions for HAL_STRUCT.dwFlags
*/
#define fDEFAULT_LCD       0x00000001
#define fDEFAULT_CRT       0x00000002
#define fDEFAULT_LCDCRT    0x00000004
#define fVALID_LCD         0x00000008
#define fVALID_CRT         0x00000010
#define fVALID_LCDCRT      0x00000020   /* Simultaneous display */
#define fFIXED_LCD_CLKI    0x00000040
#define fFIXED_CRT_CLKI    0x00000080
#define fFIXED_DIVLCDPCLK  0x00000100
#define fFIXED_DIVCRTPCLK  0x00000200
#define fMEMORY_512K       0x00000400
#define fMEMORY_1M         0x00000800

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

enum
{
   ERR_OK = 0,                      /* No error, call was successful. */
   ERR_FAILED,                      /* General purpose failure.       */

   ERR_UNKNOWN_DEVICE,           /* */
   ERR_INVALID_PARAMETER,     /* Function was called with invalid parameter. */
   ERR_HAL_BAD_ARG,
   ERR_TOOMANY_DEVS,

/*
// ERR_HAL_DOES_NOT_SUPPORT_CHIP,
// ERR_NOT_AVAILABLE,
// ERR_COULD_NOT_GET_VALUE,
// ERR_INVALID_REG_DEVICE,
*/

   ERR_INVALID_STD_DEVICE
};

/*******************************************
 * Definitions for seGetId()
 *******************************************/
enum
{
   ID_UNKNOWN,
   ID_S1D13505,
   ID_S1D13505F0A
};

#define MAX_DEVICE      10

/*
** SE_RESERVED is for reserved device
*/
#define  SE_RESERVED    0

/*
** DetectEndian is used to determine whether the most significant
** and least significant bytes are reversed by the given compiler.
*/
#define ENDIAN       0x1234
#define REV_ENDIAN   0x3412


/*******************************************
 * Definitions for Internal calculations.
 *******************************************/

#define MIN_NON_DISP_X     32
#define MAX_NON_DISP_X     256

#define MIN_NON_DISP_Y     2
#define MAX_NON_DISP_Y     64


/*******************************************
 * Definitions for seSetFont
 *******************************************/

enum
{
   HAL_STDOUT,
   HAL_STDIN,
   HAL_DEVICE_ERR
};


#define FONT_NORMAL          0x00
#define FONT_DOUBLE_WIDTH    0x01
#define FONT_DOUBLE_HEIGHT   0x02

enum
{
   RED,
   GREEN,
   BLUE
};


/*******************************************
 * Definitions for seSplitScreen()
 *******************************************/

enum
{
SCREEN1 = 1,
SCREEN2
};

/*************************************************************************/

enum
{
DISP_MODE_LCD = 0,
DISP_MODE_CRT,
DISP_MODE_LCDCRT,

MAX_DISP_MODE
};

#pragma pack(1)

typedef struct tagHalStruct
{
   char  szIdString[16];
   WORD  wDetectEndian;
   WORD  wSize;
   DWORD dwFlags;
   BYTE Regs[MAX_DISP_MODE][MAX_REG+1];
   WORD  wHostBusWidth;    /* Host CPU bus width in bits */ 
   DWORD dwClkI;           /* Input Clock Frequency (in kHz) */
   DWORD dwBusClk;         /* Bus Clock Frequency (in kHz) */
   DWORD dwRegAddr;        /* Starting address of registers */
   DWORD dwDispMemAddr;    /* Starting address of display buffer memory */

   WORD  wPanelFrameRate;  /* Desired panel frame rate */
   WORD  wCrtFrameRate;    /* Desired CRT rate */
   WORD  wMemSpeed;        /* Memory speed in ns */
   WORD  wRefreshTime;     /* DRAM refresh time in us */
   WORD  wTrc;             /* Ras to Cas Delay in ns */
   WORD  wTrp;             /* Ras Precharge time in ns */
   WORD  wTras;            /* Ras Pulse Width time in ns */
   WORD  wTrac;            /* Ras Access Charge time in ns */
   
   /* WORD  lastMember;*/  /* Last member of a structure */  
} HAL_STRUCT;

#pragma pack()

#define HAL_OFFSET(x)  ( (unsigned long)&(((HAL_STRUCT*)NULL)->x))

typedef HAL_STRUCT * PHAL_STRUCT;

typedef HAL_STRUCT     * LPHAL_STRUCT;


/*=========================================================================*/
/*                         FUNCTION  PROTO-TYPES                           */
/*=========================================================================*/


/*---------------------------- HAL Support --------------------------------*/

int seInitHal( void );
int seGetHostBusWidth(int seReserved1, int *bits);
int seRegisterDevice( const LPHAL_STRUCT lpHalInfo, int *Device );
int seGetMemSize( int seReserved1, DWORD *val );


/*
** Definitions for seSetDisplayMode
*/
#define DONT_CLEAR_MEM   0x0000
#define CLEAR_MEM        0x0001
#define DISP_FIFO_OFF    0x0002
#define DISP_FIFO_ON     0x0004

int seSetDisplayMode(int device, int DisplayMode, int flags);

int seSetInit(int device);

int  seGetId( int seReserved1, int *pId );
void seGetHalVersion( const char **pVersion, const char **pStatus, const char **pStatusRevision );
int seGetLibseVersion(int *ver);

/*---------------------------- Chip Access --------------------------------*/

int seGetReg( int seReserved1, int index, BYTE *pValue );
int seSetReg( int seReserved1, int index, BYTE value );
int seGetWordReg( int seReserved1, int index, WORD *pValue );
int seSetWordReg( int seReserved1, int index, WORD value );
int seGetDwordReg( int seReserved1, int index, DWORD *pValue );
int seSetDwordReg( int seReserved1, int index, DWORD value );

/*------------------------------- Misc ------------------------------------*/

int seSetBitsPerPixel( int seReserved1, UINT nBitsPerPixel );
int seGetBitsPerPixel( int seReserved1, UINT *pBitsPerPixel );

int seGetBytesPerScanline( int seReserved1, UINT *pBytes );
int seGetScreenSize( int seReserved1, UINT *width, UINT *height );
int seSWSuspend(int seReserved1, BOOL val);
int seHWSuspend(int seReserved1, BOOL val);
int seSelectBusWidth(int seReserved1, int width);

int seDelay( int seReserved1, DWORD Seconds );

int seGetLastUsableByte( int seReserved1, DWORD *LastByte );
int seDisplayEnable(int seReserved1, BYTE NewState);
int seDisplayFifo(int seReserved1, BYTE NewState);

int seSplitInit( int seReserved1, DWORD wScrn1Addr, DWORD wScrn2Addr );
int seSplitScreen( int nReserved1, int WhichScreen, long VisibleScanlines );
int seVirtInit( int seReserved1, DWORD xVirt, DWORD *yVirt );
int seVirtMove( int seReserved1, int nWhichScreen, DWORD x, DWORD y );

/*------------------------- Memory Access ---------------------------------*/

int seReadDisplayByte( int seReserved1, DWORD offset, BYTE *pByte );
int seReadDisplayWord( int seReserved1, DWORD offset, WORD *pWord );
int seReadDisplayDword( int seReserved1, DWORD offset, DWORD *pDword );

int seWriteDisplayBytes( int seReserved1, DWORD addr, BYTE val, DWORD count );
int seWriteDisplayWords( int seReserved1, DWORD addr, WORD val, DWORD count );
int seWriteDisplayDwords( int seReserved1, DWORD addr, DWORD val, DWORD count );

/*------------------------------- Drawing ---------------------------------*/

int seGetInkStartAddr(int seReserved1, DWORD *addr);

int seSetPixel( int seReserved1, long x, long y, DWORD color );
int seGetPixel( int seReserved1, long x, long y, DWORD *pColor );
int seDrawLine( int seReserved1, long x1, long y1, long x2, long y2, DWORD color );
int seDrawRect( int seReserved1, long x1, long y1, long x2, long y2, DWORD color, BOOL SolidFill );
int seDrawEllipse(int seReserved1, long xc, long yc, long xr, long yr, DWORD color, BOOL SolidFill);
int seDrawCircle( int seReserved1, long xCenter, long yCenter, long radius, DWORD color, BOOL SolidFill );

// int seMoveBlt( int seReserved1, long SrcX, long SrcY, long DestX, long DestY, long Width, long Height );
// int seReadBlt( int seReserved1, LPBYTE pSystemMemory, long SrcX, long SrcY, long DestX, long DestY, long Width, long Height );
// int seWriteBlt( int seReserved1, LPBYTE pSystemMemory, long SrcX, long SrcY, long DestX, long DestY, long Width, long Height );

/*------------------------------- Hardware Cursor ---------------------------------*/

int seInitCursor(int seReserved1);
int seCursorOn(int seReserved1);
int seCursorOff(int seReserved1);
int seGetCursorStartAddr(int seReserved1, DWORD *addr);
int seMoveCursor(int seReserved1, long x, long y);
int seSetCursorColor(int seReserved1, int index, DWORD color);
int seSetCursorPixel( int seReserved1, long x, long y, DWORD color );
int seDrawCursorLine( int seReserved1, long x1, long y1, long x2, long y2, DWORD color );
int seDrawCursorRect( int seReserved1, long x1, long y1, long x2, long y2, DWORD color, BOOL SolidFill );
int seDrawCursorEllipse(int seReserved1, long xc, long yc, long xr, long yr, DWORD color, BOOL SolidFill);
int seDrawCursorCircle( int seReserved1, long xCenter, long yCenter, long radius, DWORD color, BOOL SolidFill );

/*------------------------------- Hardware Ink Layer ---------------------------------*/

int seInitInk(int seReserved1);
int seInkOn(int seReserved1);
int seInkOff(int seReserved1);
int seGetInkStartAddr(int seReserved1, DWORD *addr);
int seSetInkColor(int seReserved1, int index, DWORD color);
int seSetInkPixel( int seReserved1, long x, long y, DWORD color );
int seDrawInkLine( int seReserved1, long x1, long y1, long x2, long y2, DWORD color );
int seDrawInkRect( int seReserved1, long x1, long y1, long x2, long y2, DWORD color, BOOL SolidFill );
int seDrawInkEllipse(int seReserved1, long xc, long yc, long xr, long yr, DWORD color, BOOL SolidFill);
int seDrawInkCircle( int seReserved1, long xCenter, long yCenter, long radius, DWORD color, BOOL SolidFill );

/*------------------------------ Text -------------------------------------*/

// int seSetColor( DWORD foreground, DWORD background);
// int seSetCursor( int row, int col);
// int seSetFont( BYTE FontSize, BYTE FontAttr);
// int seDrawText( int seReserved1, char *fmt, ... );

/*------------------------------ Color ------------------------------------*/

int seSetLut( int seReserved1, BYTE *pLut, int count );
int seGetLut( int seReserved1, BYTE *pLut, int count );
int seSetLutEntry( int seReserved1, int index, BYTE *pLut );
int seGetLutEntry( int seReserved1, int index, BYTE *pLutEntry );

/*--------------------------- C Like Support ------------------------------*/

int seDrawText( int seReserved1, char *fmt, ... );
int sePutChar( int seReserved1, int ch );
int seGetChar( void );

// extern int sePutc( int seReserved1, int ch );

/*--------------------------- XLIB Support --------------------------------*/

//int seGetLinearDispAddr(int seReserved1, DWORD *pDispLogicalAddr);
//int InitLinear(int seReserved1);

int halpFreeLinearAddress( void );
int halpGetLinearAddress( DWORD ulPhysAddr, DWORD * pulLinearAddr );

//	HAL error condition codes.

enum
{
	ERR_NONE = 0,				// No error, call was successful.
	ERR_PCI_DRIVER_NOT_FOUND,	// The file SED13xx.VxD was not found/loaded.
	ERR_PCI_ADAPTER_NOT_FOUND	// The VxD was unable to locate the LCD controller.
};



#endif      /* _HAL_H_ */

⌨️ 快捷键说明

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