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

📄 lcd_twi.h

📁 基于RC500射频卡读写模块的程序设计
💻 H
字号:
/*H**************************************************************************
* NAME:         lcd_twi.h         
*----------------------------------------------------------------------------
* Copyright (c) 2003 Atmel.
*----------------------------------------------------------------------------
* RELEASE:      cc03-demo-adc-0_0_1      
* REVISION:     1.10     
*----------------------------------------------------------------------------
* PURPOSE: 
* This file contains LCD driver prototype functions and delarations.                                        
*****************************************************************************/
#ifndef _LCD_TWI_H
#define _LCD_TWI_H

/*_____ I N C L U D E S ____________________________________________________*/
#include FILE_BOARD_H
#include "modules/timer_soft/timer_soft.h"
#include "lib_mcu/twi/twi_lib.h"

/*_____ M A C R O S ________________________________________________________*/
/***********************/
/* LCD LM044L features */
/***********************/
#define ROW_LENGTH          20  // character 1 to 20
#define ROW_NUMBER          4   // row 1 to 4

#define BLANK_LINE          "                    "
extern char code sz_blank_line[];

#define LCD_LINE_1          0x00    // addr of 1st line
#define LCD_LINE_2          0x40    // addr of 2nd line
#define LCD_LINE_3          0x14    // addr of 3rd line
#define LCD_LINE_4          0x54    // addr of 4th line

/*******************************/
/*GENERIC DEMO BOARD PARAMETERS*/
/*******************************/
/*position of data on the IO expander*/
/* bit7 = E  */
/* bit6 = RW */
/* bit5 = RS */
/* bit4 NC */
/* bits 3-0 = DATA */
/*position of the bit on the IO expander*/
#define LCD_E_1             128
#define LCD_RW_1            64
#define LCD_RS_1            32
#define LCD_E_0             0
#define LCD_RW_0            0
#define LCD_RS_0            0

/***************************/
/* REGISTERS CONFIGURATION */
/***************************/
#define LCD_INIT            0x03    // Init
#define LCD_INIT_DL         0x02    // 4 bits data length

/* REG1: Clear Display */
#define LCD_CLR             0x01    // Clear entire display

/* REG2: Return Home */
#define LCD_HOME            0x02    // Cursor back to home position

/* REG3: Entry mode display */
#define LCD_DEC             0x04    // Specify cursor move
#define LCD_INC             0x06    // Specify cursor move
#define LCD_S_0             0x04    // Specify display shift
#define LCD_S_1             0x05    // Specify display shift

/* REG4: Display on/off control */
#define LCD_DISP_OFF        0x08
#define LCD_DISP_ON         0x0C
#define LCD_CURS_OFF        0x08
#define LCD_CURS_ON         0x0A
#define LCD_BLINK_OFF       0x08
#define LCD_BLINK_ON        0x09

/* REG5: Cursor or display shift */
#define LCD_CURS_MOV        0x10
#define LCD_DISP_SHIFT      0x18
#define LCD_RIGHT_SHIFT     0x14
#define LCD_LEFT_SHIFT      0x10

/* REG6: Function set */
#define LCD_4_DATA          0x20
#define LCD_8_DATA          0x30
#define LCD_1_LINE          0x20
#define LCD_2_LINE          0x28
#define LCD_FONT_5_8        0x20
#define LCD_FONT_5_10       0x24

#define LCD_SET_CGRAM       0x40 // REG7: Set CGRAM address
#define LCD_SET_DDRAM       0x80 // REG8: Set DDRAM address
#define LCD_BUSY_FLAG       0x80 // REG9: Read busy flag & address
         
/*****************/
/* MISCELLANEOUS */
/*****************/
#define LCD_TWI_WRITE       0x00
#define LCD_TWI_READ        0x01

#define LCD_SCROLL_INC      0
#define LCD_SCROLL_DEC      1


/***************************/
/* TABLE CHAR ROM Code A00 */
/***************************/
#define LCD_CHAR_DEGREE     223
#if 0
/***************************/
/* TABLE CHAR ROM Code A02 */
/***************************/
#define LCD_CHAR_DEGREE     176
#endif

/*F**************************************************************************
* NAME: lcd_clear_line 
*----------------------------------------------------------------------------
* PARAMS: 
* uc_line: line number
* return:   none
*----------------------------------------------------------------------------
* PURPOSE:
* This function clears a defined line of the display.
* This function doesn't use a controller command.
* The line is filled with blank characters. 
*----------------------------------------------------------------------------
* EXAMPLE:
*----------------------------------------------------------------------------
* NOTE: 
*----------------------------------------------------------------------------
* REQUIREMENTS: 
*****************************************************************************/
#define lcd_clear_line(uc_line) lcd_wr_str(uc_line,sz_blank_line)
#define lcd_wr_line             lcd_wr_str
/*F**************************************************************************
* NAME: lcd_set_ddram 
*----------------------------------------------------------------------------
* PARAMS:
* uc_address: DDRAM address 
* return:  none
*----------------------------------------------------------------------------
* PURPOSE:
* This function sets the DDRAM address.  
*----------------------------------------------------------------------------
* EXAMPLE:
*----------------------------------------------------------------------------
* NOTE: 
*----------------------------------------------------------------------------
* REQUIREMENTS: 
*****************************************************************************/
#define lcd_set_ddram(uc_address)   lcd_cmd_wr(uc_address | LCD_SET_DDRAM)
/*F**************************************************************************
* NAME: lcd_ddram_init 
*----------------------------------------------------------------------------
* PARAMS:
* uc_line: line number
* return: none
*----------------------------------------------------------------------------
* PURPOSE:
* This function initializes the cursor on the first character
* of the line
*----------------------------------------------------------------------------
* EXAMPLE:
*----------------------------------------------------------------------------
* NOTE: 
*----------------------------------------------------------------------------
* REQUIREMENTS: 
*****************************************************************************/
#define lcd_ddram_init(uc_line) lcd_set_ddram(lcd_ddram_addr[uc_line])
/*F**************************************************************************
* NAME: lcd_wr_ddram 
*----------------------------------------------------------------------------
* PARAMS:
* uc_address: DDRAM address
* uc_data:   data to write 
* return:   none
*----------------------------------------------------------------------------
* PURPOSE:
* Write a byte on the display
*----------------------------------------------------------------------------
* EXAMPLE:
*----------------------------------------------------------------------------
* NOTE: 
* void lcd_wr_ddram(Uchar uc_ddram_addr, Uchar uc_ddram_data)
* {
* lcd_set_ddram(uc_ddram_addr)
* lcd_putchar(uc_ddram_data);     
* }
*----------------------------------------------------------------------------
* REQUIREMENTS: 
*****************************************************************************/
#define lcd_wr_ddram(addr,ch)   (lcd_set_ddram(addr),lcd_putchar(ch))

extern Uchar code lcd_ddram_addr[];

/*_____ D E C L A R A T I O N S ____________________________________________*/
void    lcd_cmd_wr          (Uchar value);
void    lcd_cmd4_wr         (Uchar value);

#ifdef ENABLE_SPLASH_SCREEN
/*buffer for scrolling*/
extern  Uchar xdata uc_buffer_scroll[ROW_LENGTH + 1];

void    lcd_wr_str          (Uchar uc_line,Uchar *psz);
void    lcd_scrolling_line  (Uchar uc_line, Uchar * pt_string, Uchar uc_direction);
void    lcd_scrolling_inc   (Uchar uc_line);
void    lcd_scrolling_dec   (Uchar uc_line);
#endif

#ifdef ENABLE_OLD_LCD_FUNC
void	lcd_wr_byte_dec	    (Uchar uc_line, Uchar uc_byte, Uchar uc_offset);
void 	lcd_wr_byte_hex     (Uchar uc_line, Uchar uc_byte, Uchar uc_offset);
Uchar	lcd_hex_to_ASCII    (Uchar uc_data);
#endif

// Std functions for CUSTOM_IO support
bit     lcd_init            (void);
void    lcd_putchar         (Uchar uc_wr_byte);
void    lcd_gotoxy          (Byte x, Byte y);
void    lcd_clrscr          (void);
bit     lcd_splash          (void);

#endif  /* _LCD_TWI_H */

⌨️ 快捷键说明

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