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

📄 lcd_hd44780.h

📁 freescale最新的16位单片机
💻 H
字号:
/******************************************************************************
*                                                                             *
* (c) Freescale Inc. 2003 All rights reserved                                 *
*                                                                             *
*******************************************************************************
*                                                                             *
* File Name      : LCD_HD44780.h                                              *
*                                                                             *
* Description    : Header file defining setup constants for HD44780 driven    *
*                  LCD display                                                *
*                                                                             *
* Compiler       : CW12 V3.1                                                  *
*                                                                             *
* $Version       : 1.0.6.0$                                                   *
*                                                                             *
* Author         : R62780                                                     *
*******************************************************************************
******************************************************************************/

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

#ifndef _LCD_HD44780_H
#define _LCD_HD44780_H


#define IIC_LCD_TRANSMIT    //I chose I2C comunication
   /**************************************************************************/
   /* AUXILIARY TYPES DEFINITIONS                                            */
   /**************************************************************************/
   #define     tUL		         unsigned long
   #define     tUI		         unsigned int  
   #define     tUC		         unsigned char
   #define     tSC		         signed char
   
   /**************************************************************************/
   /**************************************************************************/
   /*                                                                        */
   /*                     DISPLAY SETUP START                                */
   /*                                                                        */
   /**************************************************************************/
   /**************************************************************************/

   /**************************************************************************/
   /* LCD HARDWARE CONTROL PORTS                                             */
   /**************************************************************************/
   #define     LCD_E           PORTA_PA4  /* disp ENABLE pin                 */
   #define     LCD_RW          PORTA_PA5  /* disp R/W pin (write/read = 1/0) */
   #define     LCD_RS          PORTA_PA6  /* disp RS pin  (data/ctrl  = 1/0) */
   #define     LCD_DE          DDRA_DDRA4 /* disp ENABLE pin direction bit   */
   #define     LCD_DRW         DDRA_DDRA5 /* disp R/W pin direction bit      */
   #define     LCD_DRS         DDRA_DDRA6 /* disp RS pin direction bit       */   
   
    #ifdef IIC_LCD_TRANSMIT								/* IIC comunication                */
      #define  LCD_DPORTDIR    IIC0_IBCR_TX_RX  /* display data port direction re- */
    #else      
      #define  LCD_DPORTDIR    DDRA       /*gister address                   */
      #define  LCD_DPORT       PORTA      /* display data port               */    
    #endif
   
   #define     LCD_FBUS        24   /*24*/      /* uC bus frequency [MHz](necessary */
                                          /* to ensure software delays)       */
   
   /**************************************************************************/
   /*                       I2C Control                                      */
	 /**************************************************************************/
	 #ifdef IIC_LCD_TRANSMIT
	    #define IIC(U,V)                  U=(V)                                 
	    #define IIC_START                 1		            /* Start condition   */
	    #define IIC_STOP                  0		            /* Stop condition    */
	    #define IIC_CONDITION       		  IIC0_IBCR_MS_SL /* Start or Stop     */ 
	    #define IIC_SLAVE_ADRESS          114	            /* Slave adress      */
	    #define IIC_DATA_SEND							IIC0_IBDR				/*data to send/recive*/
	    #define IIC_STATUS                IIC0_IBSR_IBIF  /*data send flag     */
	    #define IIC_ACK                   IIC0_IBSR_RXAK  /*recieve ACK Flag   */
	    #define STATUS_CLEAR              1
	    
	    /***************************************************/
	    //tUI iic_delay_control;
	    //tUC data_send_iic;
	    
	           
	 #endif
	 
   /**************************************************************************/
   /* DATA PORT DIRECTIONS SETUP                                             */
   /**************************************************************************/
   #define     LCD_DIR_IN      0  /* def. input  direction value for DDR reg.*/
                                  /* to set port as input (see uP data sheet)*/ 
   #define     LCD_DIR_OUT     1  /* def. output direction value for DDR reg.*/
                                  /* to set port as output(see uP data sheet)*/
   /**************************************************************************/
   /* DISPLAY SETUP                                                          */
   /**************************************************************************/
   #define     LCD_LINES         2     /* number of physical display lines - 1,2,4           */
   #define     LCD_MLINES        2     /* number of display memory lines   - 1,2             */
   #define     LCD_COLUMNS       24    /* number of physical display columns - 8,16,24,32,40 */
   #define     LCD_LINE0ADDR     0x00  /* display line addresses - line 0                    */
   #define     LCD_LINE1ADDR     0x40  /* display line addresses - line 1                    */
   #define     LCD_LINE2ADDR     0x14  /* display line addresses - line 2                    */
   #define     LCD_LINE3ADDR     0x54  /* display line addresses - line 3                    */
   #define     LCD_DATAWIDTH     4     /* width of data communication - 4,8 bit interface    */

   #if LCD_DATAWIDTH==4                /* if 4 bits communication (#define LCD_DATAWIDTH 4)  */
                                       /* is selected define data port nibble                */
      #define     LCD_DPORTH           /* MSB port nibble                                    */
      //#define     LCD_DPORTL         /* LSB port nibble                                    */
   #endif
   
 #define LCD_NO_READ_FUNCTION        /* if defined then only LCD write functions are       */
                                       /* allowed. Display R/W\ pin is hold on 0             */
   
   #ifdef  LCD_NO_READ_FUNCTION        /* if LCD_NO_READ_FUNCTION is defined set HD44780     */
                                       /* oscillator frequency in kHz                        */
      #define HD44780_FOSC    220      /* HD44780 oscillator frequency in [kHz]              */
   #endif


   /**************************************************************************/
   /**************************************************************************/
   /*                                                                        */
   /*                     DISPLAY SETUP END                                  */
   /*                                                                        */
   /**************************************************************************/
   /**************************************************************************/


   /**************************************************************************/
   /*                    USER ACCESIBLE FUNCTIONS                            */
   /**************************************************************************/

   /*------------------------------------------------------------------------*/
   /*------------------- functions for display setup ------------------------*/
   /*------------------------------------------------------------------------*/   
   void SetupLCD                 (void);
   void LcdReset                 (void);
   void LcdSetUpIIC              (void);		 
   void LcdSetup                 (tUC setup);      /*((LCD_CURSORLEFT or  LCD_CURSORRIGHT) |
                                                      (LCD_SHIFTON    or  LCD_SHIFTOFF   ) |
                                                      (LCD_DISPLAYOFF or  LCD_DISPLAYON  ) |
                                                      (LCD_CURSORON   or  LCD_CURSOROFF  ) |
                                                      (LCD_BLINKON    or  LCD_BLINKOFF   ) |
                                                      (LCD_LARGEFONT  or  LCD_SMALLFONT  ))
                                                    */ 
   void LcdSetCursorDirection    (tUC direction);  /*LCD_CURSORLEFT LCD_CURSORRIGHT       */
   void LcdSetDisplayShiftEnable (tUC onoff);      /*LCD_SHIFTON    LCD_SHIFTOFF          */
   void LcdSetDisplayOnOff       (tUC onoff);      /*LCD_DISPLAYON  LCD_DISPLAYOFF        */  
   void LcdSetCursorOnOff        (tUC onoff);			 /*LCD_CURSORON   LCD_CURSOROFF         */
   void LcdSetBlinkOnOff         (tUC onoff);      /*LCD_BLINKON    LCD_BLINKOFF          */
   void LcdSetDisplayFont        (tUC font);       /*LCD_LARGEFONT  LCD_SMALLFONT         */  
   void LcdShiftDisplay          (tUC direction);  /*LCD_RIGHT,LCD_LEFT                   */  
   void LcdSetAddressCGRAM       (tUC address);		  
   /*------------------------------------------------------------------------*/
   /*------------------- functions for position read ------------------------*/
   /*------------------------------------------------------------------------*/
   #ifndef  LCD_NO_READ_FUNCTION
      tUC LcdGetLinePos          (void);
      tUC LcdGetColPos           (void);
      tUC LcdGetDDRAMPos         (void);
   #endif
   /*------------------------------------------------------------------------*/
   /*------------------- functions for position setup -----------------------*/
   /*------------------------------------------------------------------------*/
   void LcdReturnHome            (void);                 
   void LcdSetLine               (tUC line);
   void LcdSetPos                (tUC line, tUC col);
   void LcdSetAddressDDRAM       (tUC address);
   void LcdMoveCursor            (tUC direction); /*LCD_RIGHT,LCD_LEFT,LCD_UP,LCD_DOWN*/
   #ifndef  LCD_NO_READ_FUNCTION
      void LcdRollUp             (void);
      void LcdRollDown           (void);
      void LcdRollLeft           (void);
      void LcdRollRight          (void);
   #endif
   /*------------------------------------------------------------------------*/
   /*------------------- functions for display reading ----------------------*/
   /*------------------------------------------------------------------------*/
   #ifndef  LCD_NO_READ_FUNCTION
      tUC  LcdGetChar            (void);
      tUC  LcdGetCharLC          (tUC line, tUC col);
      void LcdGetLineL           (tUC line, char *str);
      void LcdGetLineLC          (tUC line,tUC col, char *str);
      void LcdGetLineLCn         (tUC line,tUC col,tUC n, char *str);
      void LcdGetWordLC          (tUC line,tUC col, char *str);
   #endif
   /*------------------------------------------------------------------------*/
   /*------------------- functions for clearing -----------------------------*/
   /*------------------------------------------------------------------------*/
   void LcdClear                 (void);
   void LcdClearLine             (tUC line);
   /*------------------------------------------------------------------------*/
   /*------------------- functions for display writing ----------------------*/
   /*------------------------------------------------------------------------*/
   void LcdWriteChar             (tUC chr);
   void LcdWriteCharLC           (tUC line,tUC col,tUC chr);
   void LcdOutText               (char *str);
   void LcdOutTextL              (tUC line, char *str);
   void LcdOutTextLC             (tUC line,tUC col, char *str);
   void LcdOutTextLCn            (tUC line,tUC col,tUC n,char *str);
	 void LcdShowFaultStatus       (tUC messageNumber);

   /**************************************************************************/
   /*                    CONTROL CONSTANTS DEFINITIONS                       */
   /**************************************************************************/
                                        /* USED IN FUNCTION                    */  
   #define     LCD_CURSORLEFT    0x80   /* void LcdSetCursorDirection    (tUC direction); */
   #define     LCD_CURSORRIGHT   0x00   /* void LcdSetCursorDirection    (tUC direction); */
   #define     LCD_SHIFTON       0x40   /* void LcdSetDisplayShiftEnable (tUC onoff);     */
   #define     LCD_SHIFTOFF      0x00   /* void LcdSetDisplayShiftEnable (tUC onoff);     */
   #define     LCD_DISPLAYOFF    0x20   /* void LcdSetDisplayOnOff       (tUC onoff);     */
   #define     LCD_DISPLAYON     0x00   /* void LcdSetDisplayOnOff       (tUC onoff);     */
   #define     LCD_CURSORON      0x10   /* void LcdSetCursorOnOff        (tUC onoff);     */ 
   #define     LCD_CURSOROFF     0x00   /* void LcdSetCursorOnOff        (tUC onoff);     */
   #define     LCD_BLINKON       0x08   /* void LcdSetBlinkOnOff         (tUC onoff);     */
   #define     LCD_BLINKOFF      0x00   /* void LcdSetBlinkOnOff         (tUC onoff);     */
   #define     LCD_LARGEFONT     0x01   /* void LcdSetDisplayFont        (tUC font);      */
   #define     LCD_SMALLFONT     0x00   /* void LcdSetDisplayFont        (tUC font);      */
   /*------------------------------------------------------------------------*/
   /* DEFINITIONS FOR DISPLAY CONTROL                                        */
   /*------------------------------------------------------------------------*/
   #define     LCD_RIGHT         1      /* void LcdMoveCursor (tUC direction);   */
                                        /* void LcdShiftDisplay (tUC direction); */
   #define     LCD_LEFT          0      /* void LcdMoveCursor (tUC direction);   */
                                        /* void LcdShiftDisplay (tUC direction); */
   #define     LCD_UP            3      /* void LcdMoveCursor (tUC direction);   */
   #define     LCD_DOWN          2      /* void LcdMoveCursor (tUC direction);   */
#endif

⌨️ 快捷键说明

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