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

📄 lcd12864.c

📁 瑞萨(Renesas)M16C系列芯片的函数库
💻 C
字号:
#include "sfr62p.h"	// SFR definition of M16C/62P#include "Lcd12864.h"	// LCD (128*64) utility header filevoid _lcd12864__initial(void);              /* initialize the LCD control port */void _lcd12864__wait(unsigned int t);       /* software wait for t*100us       */void _lcd12864__wr_creg(int command);/* write command to LCD            */void _lcd12864__wr_dreg(int data);   /* write data to LCD               */int _lcd12864__rd_creg(void);        /* read command from LCD           */int _lcd12864__rd_dreg(void);        /* read data from LCD              *//*""FUNC COMMENT""************************************************************** ID         		: ---* Function name     : void Lcd12864_init_lcd(void)* Function     		: initialize the LCD 128*64* Paramenter   		: none* Return 	 		: none* Function used		: _lcd12864__initial() : initialize the LCD control port*					: _lcd12864__wait(unsigned int) : software wait for t*100us*					: _lcd12864__wr_nibble_creg(int) : write command to LCD (8bit)*					: Lcd12864_write_creg(char) : write command to LCD (8bit)*					: Lcd12864_is_busy(void)	: wait for busy flag free* Notice	   		: none* History    		: ---*""FUNC COMMENT END""*********************************************************/void Lcd12864_init_lcd(void){	pd10	= pd10 | 0xf0;	// set the higher 4 bit of P10 as output, lower 4 bit as input	p10_6	= 0;	p10_7 	= 0;	pd0 	= 0x00;	// set P0 as input   _lcd12864__initial();                  /* initialize the LCD control port */    /*--- initial process after LCD reset ---*/    _lcd12864__wait(150);                   /* wait 15ms after VDD is steady       */    _lcd12864__wr_creg(0x01);        /* function set 8bit(0x03)   */    _lcd12864__wait(41);                    /* wait 4.1ms                        */    _lcd12864__wr_creg(0x03);        /* function set 8bit(0x03)   */    _lcd12864__wait(1);                     /* wait 0.1ms                        */    _lcd12864__wr_creg(0x0f);        /* function set 8bit(0x03)   */    _lcd12864__wait(1);                     /* wait 0.1ms                        */    _lcd12864__wr_creg(CMD_FUNC_D8_N2_F7);      /* set interface data length as 4 bit    */                                        /* 2 lines, 5*7 dots                */    _lcd12864__wait(1);                     /* wait 0.1ms                        */    _lcd12864__wr_creg(CMD_DISP_DS);            /* display off                         */    while(Lcd12864_is_busy());                   /* wait for busy flag free           */    _lcd12864__wr_creg(CMD_CLEAR);              /* clear display                       */    while(Lcd12864_is_busy());                   /* wait for busy flag free           */    _lcd12864__wr_creg(CMD_ENTRY_INC);         /* entry mode, increment  */    while(Lcd12864_is_busy());                   /* wait for busy flag free           */    _lcd12864__wr_creg(CMD_DISP_EN);            /* display on, cursol off          */                                        /* blink off                    */	}/*""FUNC COMMENT""************************************************************** ID         		: ---* Function name     : void Lcd12864_clear_lcd(void)* Function     		: clear display* Paramenter   		: none* Return 	 		: none* Function used		: Lcd12864_write_creg(char) : write command to LCD (8bit)*					: Lcd12864_is_busy(void)	: wait for busy flag free* Notice	   		: none* History    		: ---*""FUNC COMMENT END""*********************************************************/void Lcd12864_clear_lcd(void){	while(Lcd12864_is_busy());                   /* wait for busy flag free           */    _lcd12864__wr_creg(CMD_CLEAR);   			/* clear display                       */}/*""FUNC COMMENT""************************************************************** ID         		: ---* Function name     : void set_cursol(int x, int y)* Function     		: set cursol position* Paramenter   		: int x : X axis*					: int y : Y axis* Return 	 		: none* Function used		: Lcd12864_write_creg(char) : write command to LCD (8bit)*					: Lcd12864_is_busy(void)	: wait for busy flag free* Notice	   		: none* History    		: ---*""FUNC COMMENT END""*********************************************************/void Lcd12864_set_cursol(int x, int y){int a = Lcd12864_is_busy();    while(Lcd12864_is_busy());	// wait for busy flag free	switch(y)	// check the line number	{		case 3:			_lcd12864__wr_creg(0x80 | (0x18 + x));			break;		case 2:			_lcd12864__wr_creg(0x80 | (8 + x));			break;		case 1:			_lcd12864__wr_creg(0x80 | (0x10 + x));			break;		case 0:		default:			_lcd12864__wr_creg(0x80 | x);				}}/*""FUNC COMMENT""************************************************************** ID         		: ---* Function name     : void Lcd12864_write_lcd(const char* msg)* Function     		: write string to LCD* Paramenter   		: const char* : address of string to write to LCD* Return 	 		: none* Function used		: Lcd12864_write_dreg(char) : write data to LCD (8bit)*					: Lcd12864_is_busy(void)	: wait for busy flag free* Notice	   		: none* History    		: ---*""FUNC COMMENT END""*********************************************************/void Lcd12864_write_lcd(const char *msg){    for( ; '\0' != *msg; msg++){        while(Lcd12864_is_busy());        _lcd12864__wr_dreg(*msg);    }}/*""FUNC COMMENT""************************************************************** ID         		: ---* Function name     : void Lcd12864_write_lcd_char(const char msg)* Function     		: write a character to LCD* Paramenter   		: const char : character to write to LCD* Return 	 		: none* Function used		: Lcd12864_write_dreg(char) : write data to LCD (8bit)*					: Lcd12864_is_busy(void)	: wait for busy flag free* Notice	   		: none* History    		: ---*""FUNC COMMENT END""*********************************************************/void Lcd12864_write_lcd_char(const char msg){	while(Lcd12864_is_busy());	_lcd12864__wr_dreg(msg);}/*""FUNC COMMENT""************************************************************** ID         		: ---* Function name     : int Lcd12864_is_busy(void)* Function     		: check busy flag* Paramenter   		: none* Return 	 		: int : state of busy flag* Function used		: Lcd12864_read_creg() : read command from LCD* Notice	   		: none* History    		: ---*""FUNC COMMENT END""*********************************************************/int Lcd12864_is_busy(void){	int a = _lcd12864__rd_creg();    if(0x80 & _lcd12864__rd_creg()){                     /* if(BusyFlag)             */        return TRUE;    }    else{        return FALSE;    }}/*""FUNC COMMENT""************************************************************** ID         		: ---* Function name     : void Lcd12864_light_on(void)* Function     		: light background* Paramenter   		: none* Return 	 		: none* Function used		: none* Notice	   		: none* History    		: ---*""FUNC COMMENT END""*********************************************************/void Lcd12864_light_on(void){	p10_7 = 1;}/*""FUNC COMMENT""************************************************************** ID         		: ---* Function name     : void Lcd12864_light_off(void)* Function     		: unlight background* Paramenter   		: none* Return 	 		: none* Function used		: none* Notice	   		: none* History    		: ---*""FUNC COMMENT END""*********************************************************/void Lcd12864_light_off(void){	p10_7 = 0;}

⌨️ 快捷键说明

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