lcd.h

来自「嵌入式系统」· C头文件 代码 · 共 241 行

H
241
字号
/*-----------------------------------------------------------------------------
@@ (Summary)    : LCD controller driver header file
@@ (Comment)    : User include file
@@ (Author)     :  
@@ (History)    : Date      Modifier    Comment
-----------------------------------------------------------------------------*/
#ifndef LCD
#define LCD
#include <stddef.h>
#include "type_def.h"

#define VIDEO_RAM	((unsigned int *)0x40700000)
#define VIDEO_PHY_RAM	((unsigned int)0x40700000)
/*-----------------------------------------------------------------------------
@@ {Name}       : APD_LCD_POINT
@@ {Summary}    : LCD coordinate data
@@ {Desc}       : The value of X and Y coordinates
@@ {History}    :
-----------------------------------------------------------------------------*/
typedef struct {
unsigned short x;        /* The value of X coordinate */
unsigned short y;        /* The value of Y coordinate */
} APD_LCD_POINT;

/*-----------------------------------------------------------------------------
@@ {Name}       : APD_LCD_DIM
@@ {Summary}    : LCD width and height data
@@ {Desc}       : The value of width and height
@@ {History}    :
-----------------------------------------------------------------------------*/
typedef struct {
unsigned short width;    /* The value of width */
unsigned short height;   /* The value of height */
} APD_LCD_DIM;

/* Type of image data */
typedef unsigned char   APD_LCD_IMAGE;

/* Type of color data */
typedef unsigned long   APD_LCD_COLOR;

/*-----------------------------------------------------------------------------
@@ {Name}     : APD_LCD_LINE_TYPE
@@ {Summary}  : Line type
@@ {Desc}     : definition of line type
@@ {End}      :
-----------------------------------------------------------------------------*/
typedef enum {
    APD_LCD_LINE_SOLID,     /* solid line */
    APD_LCD_LINE_DOT,       /* dot line */
    APD_LCD_LINE_DASH,      /* dash line */
    APD_LCD_LINE_DASH_DOT   /* dash and dot line */
} APD_LCD_LINE_TYPE;

/*-----------------------------------------------------------------------------
@@ {Name}     : APD_LCD_LINE_WIDTH
@@ {Summary}  : Line width
@@ {Desc}     : Definition of line width
@@ {End}      :
-----------------------------------------------------------------------------*/
typedef enum {
    APD_LCD_LINE_THIN = 1,  /* thin line */
    APD_LCD_LINE_MID,       /* middle width line */
    APD_LCD_LINE_THICK      /* thick line */
} APD_LCD_LINE_WIDTH;

/*-----------------------------------------------------------------------------
@@ {Name}     : APD_LCD_FILL_TYPE
@@ {Summary}  : Fill type
@@ {Desc}     : Definition of fill type
@@ {End}      :
-----------------------------------------------------------------------------*/
typedef enum {
    APD_LCD_FILL_SOLID,         /* solid fill */
    APD_LCD_FILL_DOT,           /* half-tone fill */
    APD_LCD_FILL_DIAGONAL,      /* diagonal (upward slant to the right) fill */
    APD_LCD_FILL_BDIAGONAL,     /* diagonal (upward slant to the left) fill */
    APD_LCD_FILL_DCROSS,        /* diagonal cross fill */
    APD_LCD_FILL_HORIZONTAL,    /* horizontal fill */
    APD_LCD_FILL_VERTICAL,      /* vertical fill */
    APD_LCD_FILL_CROSS          /* cross fill */
} APD_LCD_FILL_TYPE;

/*-----------------------------------------------------------------------------
@@ {Name}     : APD_LCD_ROP_TYPE
@@ {Summary}  : Raster operation type
@@ {Desc}  : Definition of raster operation type
@@           S : transfer data
@@           D : current data
@@           ~ : not operation
@@           | : or operation
@@           & : and operation
@@           ^ : exclusive or operation
@@ {End}      :
-----------------------------------------------------------------------------*/
typedef enum {
    APD_LCD_ROP_S,      /* S */
    APD_LCD_ROP_n_SoD,  /* ~(S|D) */
    APD_LCD_ROP_nS_aD,  /* ~S&D */
    APD_LCD_ROP_nS,     /* ~S */
    APD_LCD_ROP_Sa_nD,  /* S&~D */
    APD_LCD_ROP_nD,     /* ~D */
    APD_LCD_ROP_SeD,    /* S^D */
    APD_LCD_ROP_n_SaD,  /* ~(S&D) */
    APD_LCD_ROP_SaD,    /* S&D */
    APD_LCD_ROP_n_SeD,  /* ~(S^D) */
    APD_LCD_ROP_nS_oD,  /* ~S|D */
    APD_LCD_ROP_So_nD,  /* S|~D */
    APD_LCD_ROP_SoD     /* S|D */
} APD_LCD_ROP_TYPE;

/*-----------------------------------------------------------------------------
@@ {Name}       : APD_LCD_GC
@@ {Summary}    : Graphic's context
@@ {Desc}       : Data of line type, line width, fill type and color
@@ {End}        :
-----------------------------------------------------------------------------*/
typedef struct {
APD_LCD_LINE_TYPE   lt;     /* line type */
APD_LCD_LINE_WIDTH  lw;     /* line width */
APD_LCD_FILL_TYPE   ft;     /* fill type */
APD_LCD_COLOR       c;      /* color */
APD_LCD_ROP_TYPE    rop;    /* raster operation type */
} APD_LCD_GC;

/*-----------------------------------------------------------------------------
@@ {Name}       : APD_LCD_RGB_COLOR
@@ {Summary}    : RGB color data
@@ {Desc}       : Express each color level of red, green and blue by 5 bits,
@@                and intensity by 1bit.
@@ {End}        :
-----------------------------------------------------------------------------*/
typedef struct {
unsigned char red;          /* red */
unsigned char green;        /* green */
unsigned char blue;         /* blue */
unsigned char intensity;    /* intensity */
} APD_LCD_RGB_COLOR;

/*-----------------------------------------------------------------------------
@@ {Name}       : APD_LCD_VCOMP_TYPE
@@ {Summary}    : Vertical compare interrupt type
@@ {Desc}       : Type of timing for Vertical Compare interrupt
@@ {End}        :
-----------------------------------------------------------------------------*/
typedef enum {
    APD_LCD_VCOMP_VSYNC     = (APD_USHORT)0x0000,   /* start of vertical synchronization */
    APD_LCD_VCOMP_BPORCH    = (APD_USHORT)0x1000,   /* start of back porch */
    APD_LCD_VCOMP_AVIDEO    = (APD_USHORT)0x2000,   /* start of active video */
    APD_LCD_VCOMP_FPORCH    = (APD_USHORT)0x3000    /* start of front porch */
} APD_LCD_VCOMP_TYPE;

/*-----------------------------------------------------------------------------
@@ {Name}       : APD_LCD_IPC_OUT_TYPE
@@ {Summary}    : LCD interface peripheral output control type
@@ {Desc}       : Type of output signals pertaining to the DMTN and HR-TFT
@@                format converters
@@ {End}        :
-----------------------------------------------------------------------------*/
typedef unsigned char APD_LCD_IPC_OUT_TYPE;
#define APD_LCD_IPC_SPS (APD_LCD_IPC_OUT_TYPE)0x01  /* SPS tristate output */
#define APD_LCD_IPC_CLS (APD_LCD_IPC_OUT_TYPE)0x02  /* CLS tristate output */
#define APD_LCD_IPC_UBL (APD_LCD_IPC_OUT_TYPE)0x04  /* LCD_UBL tristate output */
#define APD_LCD_IPC_DISP    (APD_LCD_IPC_OUT_TYPE)0x08  /* control DSPL_ENB output pin when in DMTN mode */
#define APD_LCD_IPC_EN0 (APD_LCD_IPC_OUT_TYPE)0x10  /* general-purpose output 0 */
#define APD_LCD_IPC_EN1 (APD_LCD_IPC_OUT_TYPE)0x20  /* general-purpose output 1 */
#define APD_LCD_IPC_EN2 (APD_LCD_IPC_OUT_TYPE)0x40  /* general-purpose output 2 */
#define APD_LCD_IPC_EN3 (APD_LCD_IPC_OUT_TYPE)0x80  /* general-purpose output 3 */

/* Type of interrupt flag for LCD controller */
/*-----------------------------------------------------------------------------
@@ {Name}       : APD_LCD_INTR_FLG
@@ {Summary}    : Type of interrupt flag for LCD controller
@@ {Desc}       :
@@ {End}        :
-----------------------------------------------------------------------------*/
typedef unsigned char APD_LCD_INTR_FLG;
#define APD_LCD_INTR_MBERR      0x10    /* AHB Master Error Interrupt */
#define APD_LCD_INTR_VCOMP      0x08    /* Vertical Compare Interrupt */
#define APD_LCD_INTR_LNBU       0x04    /* Next Base Update Interrupt */
#define APD_LCD_INTR_FUF        0x02    /* FIFO Underflow Interrupt */

/*****************************************************************************
 * Function prototypes
 *****************************************************************************/
extern  void apd_LCDInit(void);
extern  void apd_LCDDrawPixel(APD_LCD_POINT *);
extern  void apd_LCDDrawVline(APD_LCD_POINT *, APD_LCD_POINT *);
extern  void apd_LCDDrawHline(APD_LCD_POINT *, APD_LCD_POINT *);
extern  void apd_LCDDrawLine(APD_LCD_POINT *, APD_LCD_POINT *);
extern  void apd_LCDDrawRect(APD_LCD_POINT *, APD_LCD_DIM *);
extern  void apd_LCDFillRect(APD_LCD_POINT *, APD_LCD_DIM *);
extern  void apd_LCDDrawImage(APD_LCD_POINT *, APD_LCD_DIM *,APD_LCD_IMAGE *);
extern  void apd_LCDDrawBMP(APD_LCD_POINT *, APD_LCD_DIM *,APD_LCD_IMAGE *);
extern  APD_LCD_COLOR apd_LCDGetPixel(APD_LCD_POINT *);
extern  void apd_LCDGetImage(APD_LCD_POINT *, APD_LCD_DIM *,APD_LCD_IMAGE *);
extern  void apd_LCDSetLineStyle(APD_LCD_LINE_TYPE);
extern  void apd_LCDSetLineWidth(APD_LCD_LINE_WIDTH);
extern  void apd_LCDSetColor(APD_LCD_COLOR);
extern  void apd_LCDSetFillPattern(APD_LCD_FILL_TYPE);
extern  void apd_LCDSetRasterOperation(APD_LCD_ROP_TYPE);
extern  void apd_LCDSetGC(APD_LCD_GC *);
extern  void apd_LCDGetGC(APD_LCD_GC *);
extern  void apd_LCDSetDrawUpbase(unsigned long);
extern  void apd_LCDSetDrawLpbase(unsigned long);
extern  void apd_LCDEnableIntr(APD_LCD_INTR_FLG);
extern  void apd_LCDDisableIntr(APD_LCD_INTR_FLG);
extern  unsigned long apd_LCDGetEnableIntrState(void);
extern  void apd_LCDClearIntr(APD_LCD_INTR_FLG);
extern  unsigned long apd_LCDGetIntr(void);
extern  unsigned long apd_LCDGetStatus(void);
extern  void apd_LCDEnable(void);
extern  void apd_LCDDisable(void);
extern  void apd_LCDOn(void);
extern  void apd_LCDOff(void);
extern  void apd_LCDSetUpbase(unsigned long);
extern  void apd_LCDSetLpbase(unsigned long);
extern  unsigned long apd_LCDGetUpbase(void);
extern  unsigned long apd_LCDGetLpbase(void);
extern  unsigned long apd_LCDGetUpcurr(void);
extern  unsigned long apd_LCDGetLpcurr(void);
extern  void apd_LCDSetVcomp(APD_LCD_VCOMP_TYPE);
extern  APD_LCD_VCOMP_TYPE apd_LCDGetVcomp(void);
extern  void apd_LCDSetPalette(APD_LCD_RGB_COLOR *);
extern  void apd_LCDGetPalette(APD_LCD_RGB_COLOR *);
extern  void apd_LCDSetPaletteByID(APD_USHORT, APD_LCD_RGB_COLOR *);
extern  void apd_LCDGetPaletteByID(APD_USHORT, APD_LCD_RGB_COLOR *);



extern  void apd_LCDInit(void);
extern  void apd_ClearLcd(void);
extern  void apd_LCDFillScr(int color);
extern  void apd_LCDDrawChar(APD_LCD_POINT *point ,unsigned char value,APD_LCD_COLOR color);
extern  void apd_LCDDrawStr(APD_LCD_POINT *point,  char* str,APD_LCD_COLOR color);
extern  void apd_LCDShowTestcount(APD_LCD_POINT *point,unsigned int count,APD_LCD_COLOR color);


//extern	void apd_LCDDrawEllipse(APD_LCD_POINT *point,APD_LCD_DIM *dim)
#endif /* APD_LCD */

⌨️ 快捷键说明

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