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

📄 s6b0724.c

📁 ATmega64+12864液晶
💻 C
字号:
/*
file name:s6b0724.c 
function: the lcm use the s6b0724 controller
author :Einsn
date:2006-12-23

*/
#include "s6b0724.h"
#include <avr/delay.h>

#define DelayN10ms(x)  do{\
	for(uint16 i=0;i<x;i++)_delay_ms(10);\
}while(0)

/*
#define RS_COM    PORTC&=~(1<<PC0)
#define RS_DAT    PORTC|=(1<<PC0)

#define CS_LOW   PORTC&=~(1<<PC1)
#define CS_HIG    PORTC|=(1<<PC1)

#define RD_LOW   PORTG&=~(1<<PG1)
#define RD_HIG    PORTG|=(1<<PG1)

#define WR_LOW   PORTG&=~(1<<PG0)
#define WR_HIG    PORTG|=(1<<PG0)

#define nop()  asm("nop;")


void portinitial(void){
DDRA=0xff;
DDRC=0xff;
DDRG=0xff;
PORTA=0xff;
PORTC=0xff;
PORTG=0xff;
}


void wcom(uint8  cmd)
{
CS_LOW;
RS_COM;
PORTA=cmd;
WR_LOW;
nop();
nop();
nop();
nop();
WR_HIG;
CS_HIG;
nop();
nop();
nop();
}


void wdat(uint8 dat)
{
CS_LOW;
RS_DAT;
PORTA=dat;
WR_LOW;
nop();
nop();
nop();
nop();
WR_HIG;
CS_HIG;
nop();
nop();
nop();
}

*/

/*
name:S6B0724Initial()
function: the lcm use the s6b0724 controller
author :Einsn
date:2006-12-23

*/


void S6B0724Initial(void){
//portinitial();	
HardResetOff();
_delay_ms(1);
SetLCDBias(0);//default:1/9
ADCSelect(0);//Normal
SHLSelect(1);//reverse
InitialDisplayLine(0);
PowerControlSet((1<<PCVC));
DelayN10ms(5);
PowerControlSet(((1<<PCVC)|(1<<PCVR)));
DelayN10ms(5);
PowerControlSet(((1<<PCVC)|(1<<PCVR)|(1<<PCVF)));
DelayN10ms(5);
RegulatorResistorSelect(5); //101 default
SetReferenceVoltage(32);//default
DisplayOn(1);
}


#define SetBit(dat,bit,val)   (dat=(dat&(~(1<<bit)))|(val<<bit))

/*
name:LcmGetRowData()
function:
author:einsn
date :2006-12-24

*/

int8 S6B0724GetRowData(uint8 row,uint8 col,uint8 *pbyte,uint8 n){
if(row > ROWSIZE-1 || col+n> COLSIZE)
	return -1;
SetPosition(row, col);
rdat();//Dummy Read
while(n--){
	*pbyte++=rdat();
	}
return 0;
}

/*
name:LcmPutRowData()
function:
author:einsn
date :2006-12-24

*/

int8 S6B0724PutRowData(uint8 row,uint8 col,uint8 *pbyte,uint8 n){
if(row > ROWSIZE-1 || col+n> COLSIZE)
	return -1;
SetPosition(row, col);
while(n--){
	wdat(*pbyte++);
	}
return 0;
}


/*
name:LcmGetColData()
function:
author:einsn
date :2006-12-24

*/

int8 S6B0724GetColData(uint8 row,uint8 col,uint8 *pbyte,uint8 n){
if(row+n> ROWSIZE || col > COLSIZE-1)
	return -1;
while(n--){
	SetPosition(row, col);
	rdat();//dummy read
	*pbyte++=rdat();
	row++;
	}
return 0;
}

/*
name:LcmPutColData()
function:
author:einsn
date :2006-12-24

*/

int8 S6B0724PutColData(uint8 row,uint8 col,uint8 *pbyte,uint8 n){
if(row+n> ROWSIZE || col > COLSIZE-1)
	return -1;
while(n--){
	SetPosition(row, col);
	wdat(*pbyte++);
	}
return 0;
}





/*
name:LcmDot
function:
author:einsn
date :2006-12-24


*/
int8 S6B0724WDot(uint8 xrow,uint8 col,uint8 bt){
uint8 temp;
if(xrow > ROWSIZE*8-1 || col > COLSIZE-1)
	return -1;
SetPosition(xrow/8, col);
SetReadModifyWrite();
rdat();//Dummy Read
temp=rdat();
SetBit(temp,xrow%8,bt);
wdat(temp);
ResetSetReadModifyWrite();
return 0;
}





⌨️ 快捷键说明

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