These are the examples provided for [[/users/frank26080115/libraries/LPC1700CMSIS_Lib/]] Note, the entire "program" is not compilable!

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers drv_glcd.h Source File

drv_glcd.h

00001 /*************************************************************************
00002  *
00003  *
00004  *    (c) Copyright IAR Systems 2006
00005  *
00006  *    File name   : drv_glcd.h
00007  *    Description : Graphic LCD driver include file
00008  *
00009  *    History :
00010  *    1. Date        : December 2, 2006
00011  *       Author      : Stanimir Bonev
00012  *       Description : Create
00013  *
00014  *    $Revision: 28532 $
00015  **************************************************************************/
00016 #include "drv_glcd_cnfg.h"
00017 #include "lpc_types.h"
00018 
00019 #ifndef  __DRV_GLCD_H
00020 #define  __DRV_GLCD_H
00021 
00022 #define DEF_X_LEFT          0
00023 #define DEF_Y_UP            0
00024 #define DEF_X_RIGHT         GLCD_HORIZONTAL_SIZE
00025 #define DEF_Y_DOWN          GLCD_VERTICAL_SIZE
00026 #define DEF_FONT_COLOUR     0x000000
00027 #define DEF_BACKGND_COLOUR  0x00FF0
00028 #define TEXT_DEF_TAB_SIZE   4
00029 
00030 #define MAX_GLCD_STR_SIZE   256
00031 // External function
00032 #define TEXT_BEL1_FUNC()         // generate BEL signal
00033 
00034 // Set window
00035 #define LCD_SET_WINDOW(xl,xr,yu,yd) \
00036 {\
00037 uint32_t Temp;\
00038   Temp = xl | (xr<<8);\
00039   GLCD_SendCmd(CASET,(unsigned char*)&Temp,0);\
00040   Temp = (yu+2) | ((yd+2)<<8);\
00041   GLCD_SendCmd(RASET,(unsigned char*)&Temp,0);\
00042 }
00043 
00044 // Send pixel
00045 #define LCD_WRITE_PIXEL(c) GLCD_SendCmd(RAMWR,(unsigned char*)&c,2)
00046 
00047 // Flush pixels
00048 #define LCD_FLUSH_PIXELS() GLCD_SendCmd(NOP,NULL,0)
00049 
00050 #define GLCD_MANF_ID 0x45
00051 #define GLCD_MOD_ID  0x03
00052 
00053 #define WAITED_PIXEL 0x80000000
00054 
00055 #define PIXEL_CONV(Pixel,Order) (!Order)?(((Pixel >> 4) & 0xFF) | ((Pixel << 12) & 0xF000)):(((Pixel << 16) & 0xFF0000) | ((Pixel) & 0xF00))
00056 // PCF8833 status register
00057 #define PCF8833_ST_BOOSTER_ON     (1UL <<  7)
00058 #define PCF8833_ST_Y_ADDR_ODR     (1UL <<  6)
00059 #define PCF8833_ST_X_ADDR_ODR     (1UL <<  5)
00060 #define PCF8833_ST_ADDR_MODE      (1UL <<  4)
00061 #define PCF8833_ST_LINE_ADDR_ORD  (1UL <<  3)
00062 #define PCF8833_ST_RGB_ORD        (1UL <<  2)
00063 #define PCF8833_ST_PIXEL_FORM     (7UL << 12)
00064 #define PCF8833_ST_IDLE_MODE      (1UL << 11)
00065 #define PCF8833_ST_PARTIAL_MODE   (1UL << 10)
00066 #define PCF8833_ST_SLEEP_MODE     (1UL <<  9)
00067 #define PCF8833_ST_NORM_MODE      (1UL <<  8)
00068 #define PCF8833_ST_V_SCROLL_MODE  (1UL << 23)
00069 #define PCF8833_ST_INV_MODE       (1UL << 21)
00070 #define PCF8833_ST_ALL_PIXELS_ON  (1UL << 20)
00071 #define PCF8833_ST_ALL_PIXELS_OFF (1UL << 19)
00072 #define PCF8833_ST_DISPLAY_MODE   (1UL << 18)
00073 #define PCF8833_ST_TEARING_MODE   (1UL << 17)
00074 
00075 // GLCD command interpreter type
00076 typedef enum _GLCD_ISS_t {
00077     GLCD_ISS_0 = 0, GLCD_ISS_1
00078 } GLCD_ISS_t;
00079 
00080 // execution status
00081 typedef enum _GLCD_Status_t {
00082     GLCD_OK = 0, GLCD_ID_ERROR, GLCD_UNSUPPORTED, GLCD_ERROR
00083 } GLCD_Status_t;
00084 
00085 // GCLD command set
00086 typedef enum _GLCD_Cmd_t {
00087     // Equal commands
00088     NOP, SLPIN, SLPOUT, PTLOUT, INVOFF, INVON,
00089     DISPOFF, DISPON, CASET, RASET, RAMWR, RGBSET, VSCSAD,
00090     IDMOFF, IDMON, RDID1, RDID2, RDID3, FRMSEL, FRM8SEL, TMPRNG,
00091     TMPHIS, TMPREAD, EPWRIN, EPWROUT, RDEV, RDRR,
00092   // Adapted commands
00093   PTIN,     // ISS=0 equal on PTLAR + PTIN
00094   SCRLAR,   // ISS=1 ASCSET mode 0
00095   DATCTR,   // ISS=0 equal on MADCTR + COLMOD
00096   SETCON, //
00097   // Commands applicable only when ISS=1
00098   OSCON, OSCOFF, RMWIN, RMWOUT, VOLUP, VOLDOWN, ASCSET, DISCTR,
00099   PWRCTR, VOLCTR,
00100   // Commands applicable only when ISS=0
00101   CLKINT, CLKEXT, RDDST, SWRESET, RDDID, PTLAR, PTLON, MADCTR,
00102   COLMOD, APOFF, APON, BSTROFF, BSTRON,
00103     GLCD_CMD_NUMB
00104 } GLCD_Cmd_t;
00105 
00106 // Command direction
00107 typedef enum _GLCD_CmdDir_t {
00108     GLCD_WRITE = 0, GLCD_READ
00109 } GLCD_CmdDir_t;
00110 
00111 // Data flag
00112 #define GLCD_DATA                     0x100
00113 
00114 // Invalid command (some commands don't have analog in other
00115 // command mode interpreter)
00116 #define GLCD_INV_CMD                    ((uint32_t)(-1))
00117 
00118 #define GLCD_MAX_COTRAST   63
00119 #define GLCD_MIN_COTRAST  -64
00120 
00121 typedef struct _GLCD_CmdCtrl_t {
00122     uint32_t        Cmd;
00123     GLCD_CmdDir_t   Dir;
00124     Bool        Pulse;
00125     uint32_t        Param;
00126 } GLCD_CmdCtrl_t, *pGLCD_CmdCtrl_t;
00127 
00128 #pragma pack(1)
00129 typedef struct _ASCSET_Data_t {
00130     uint8_t Ssl;
00131     uint8_t Sel;
00132     uint8_t Sfl;
00133     uint8_t Smd;
00134 } ASCSET_Data_t, *pASCSET_Data_t;
00135 
00136 #if defined ( __CC_ARM   )
00137 #pragma anon_unions
00138 #endif
00139 
00140 typedef struct _DATCTR_Data_t {
00141     union 
00142     {
00143         uint8_t RC_AddMode;
00144         struct 
00145         {
00146             uint8_t MY : 1;
00147             uint8_t MX : 1;
00148             uint8_t MV : 1;
00149             uint8_t ML : 1;
00150             uint8_t : 4;
00151         };
00152     };
00153     union  
00154     {
00155         uint8_t RGB_Mode;
00156         struct 
00157         {
00158             uint8_t RGB : 1;
00159             uint8_t : 7;
00160         };
00161     };
00162     union 
00163     {
00164         uint8_t GrayScale;
00165         struct  
00166         {
00167             uint8_t GS  : 3;
00168             uint8_t Reversed: 5;
00169         };
00170     };
00171 } DATCTR_Data_t, *pDATCTR_Data_t;
00172 
00173 typedef struct _MADCTR_Data_t {
00174     union
00175     {
00176         uint8_t MemDataAccCtrl;
00177         struct 
00178         {
00179             uint8_t Reversed: 3;
00180             uint8_t RGB : 1;
00181             uint8_t ML  : 1;
00182             uint8_t MV  : 1;
00183             uint8_t MX  : 1;
00184             uint8_t MY  : 1;
00185         };
00186     };
00187 } MADCTR_Data_t, *pMADCTR_Data_t;
00188 
00189 
00190 typedef struct _COLMOD_Data_t {
00191     union
00192     {
00193         uint8_t ColourMode;
00194         struct
00195         {
00196             uint8_t Mode    : 3;
00197             uint8_t Reversed : 5;
00198         };
00199     };
00200 } COLMOD_Data_t, *pCOLMOD_Data_t;
00201 #pragma pack()
00202 
00203 typedef uint32_t LdcPixel_t, *pLdcPixel_t;
00204 
00205 typedef struct _FontType_t {
00206   uint32_t H_Size;
00207   uint32_t V_Size;
00208   uint32_t CharacterOffset;
00209   uint32_t CharactersNuber;
00210   unsigned char *pFontStream;
00211   unsigned char *pFontDesc;
00212 } FontType_t, *pFontType_t;
00213 
00214 typedef struct _Bmp_t {
00215   uint32_t  H_Size;
00216   uint32_t  V_Size;
00217   uint32_t  BitsPP;
00218   uint32_t  BytesPP;
00219   unsigned int *pPalette;
00220   unsigned int *pPicStream;
00221   unsigned char *pPicDesc;
00222 } Bmp_t, *pBmp_t;
00223 
00224 extern void Dly100us(void *arg);
00225 
00226 /*************************************************************************
00227  * Function Name: GLCD_SendCmd
00228  * Parameters: GLCD_Cmd_t Cmd, unsigned char* pData, uint32_t Size
00229  * Return: GLCD_Status_t
00230  *
00231  * Description: Send command to the Graphic LCD
00232  *
00233  *************************************************************************/
00234 GLCD_Status_t GLCD_SendCmd (GLCD_Cmd_t Cmd, unsigned char *pData, uint32_t Size);
00235 
00236 /*************************************************************************
00237  * Function Name: GLCD_PowerUpInit
00238  * Parameters: unsigned char* pInitData
00239  * Return: GLCD_Status_t
00240  *         GLCD_OK - init pass
00241  *               GLCD_ID_ERROR - unsupported driver type
00242  * Description: Power-up initialization of Graphic LCD
00243  *
00244  *************************************************************************/
00245 //GLCD_Status_t GLCD_PowerUpInit (unsigned char *pInitData);
00246 GLCD_Status_t GLCD_PowerUpInit (unsigned char *pInitData);
00247 
00248 /*************************************************************************
00249  * Function Name: GLCD_SetFont
00250  * Parameters: pFontType_t pFont, LdcPixel_t Color
00251  *              LdcPixel_t BackgndColor
00252  *
00253  * Return: none
00254  *
00255  * Description: Set current font, font color and background color
00256  *
00257  *************************************************************************/
00258 void GLCD_SetFont(pFontType_t pFont,
00259                   LdcPixel_t Color, LdcPixel_t BackgndColor);
00260 
00261 /*************************************************************************
00262  * Function Name: GLCD_SetWindow
00263  * Parameters: uint32_t X_Left, uint32_t Y_Up,
00264  *             uint32_t X_Right, uint32_t Y_Down
00265  *
00266  * Return: none
00267  *
00268  * Description: Set draw window XY coordinate in pixels
00269  *
00270  *************************************************************************/
00271 void GLCD_SetWindow(uint32_t X_Left, uint32_t Y_Up,
00272                     uint32_t X_Right, uint32_t Y_Down);
00273 
00274 /*************************************************************************
00275  * Function Name: GLCD_TextSetPos
00276  * Parameters: uint32_t X_UpLeft, uint32_t Y_UpLeft,
00277  *             uint32_t X_DownLeft, uint32_t Y_DownLeft
00278  *
00279  * Return: none
00280  *
00281  * Description: Set text X,Y coordinate in characters
00282  *
00283  *************************************************************************/
00284 void GLCD_TextSetPos(uint32_t X, uint32_t Y);
00285 
00286 /*************************************************************************
00287  * Function Name: GLCD_TextSetTabSize
00288  * Parameters: uint32_t Size
00289  *
00290  * Return: none
00291  *
00292  * Description: Set text tab size in characters
00293  *
00294  *************************************************************************/
00295 void GLCD_TextSetTabSize(uint32_t Size);
00296 
00297 /*************************************************************************
00298  * Function Name: GLCD_TextCalcWindow
00299  * Parameters: pInt32U pXL, pInt32U pXR,
00300  *             pInt32U pYU, pInt32U pYD,
00301  *             pInt32U pH_Size, pInt32U pV_Size
00302  *
00303  * Return: Boolean
00304  *          FALSE - out of window coordinate aren't valid
00305  *          TRUE  - the returned coordinate are valid
00306  *
00307  * Description: Calculate character window
00308  *
00309  *************************************************************************/
00310 static Bool GLCD_TextCalcWindow (unsigned int *pXL, unsigned int *pXR,
00311         unsigned int *pYU, unsigned int *pYD,
00312         unsigned int *pH_Size, unsigned int *pV_Size);
00313 
00314 /*************************************************************************
00315  * Function Name: GLCD_putchar
00316  * Parameters: int c
00317  *
00318  * Return: none
00319  *
00320  * Description: Put char function
00321  *
00322  *************************************************************************/
00323 int GLCD_putchar (int c);
00324 
00325 /*************************************************************************
00326  * Function Name: GLCD_print
00327  * Parameters: int c
00328  *
00329  * Return: none
00330  *
00331  * Description: Put char function
00332  *
00333  *************************************************************************/
00334 void GLCD_print (const char *fmt);
00335 
00336 #endif  /* __DRV_GLCD_H */