亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? lcd.c

?? mp3量不要讓站長把時間都花費在為您修正說明上。壓縮包解壓時不能有密碼。系統會自動刪除debug和release目錄
?? C
字號:
/*****************************************************/
/*            File name : LCD.c                                                   */
/* Description : Code  for Nokia 3310LCD, display IC:PCD8544  */
/* Platform     : SourceInsight3.5 + WinARM20060606  for 7S256     */
/* Author       : Michael Zhang - 章其波                            */
/* Email         : sudazqb@163.com                                          */
/* MSN          : zhangqibo_1985@hotmail.com                          */
/* Date          : 2007-12-06                                                    */
/* NOT FOR COMMERCIAL USE,     ALL RIGHT RESERVED!         */
/*****************************************************/
/* Change Log:                                                                      */
/*  20080928: modify codes for ARM platform (NXP LPC2132)  */
/*                   20071222: modify for use another chip on board (mcuzone mp3) */
/*                   20071206: modify code for Atmel ARM AT91SAM7S256 */
/*                   20071122: fix a bug for some 3310lcd will not work with display function */
/*                   20071021: original version                                 */
/*****************************************************/


#include"LCD.h"


/*********** Display buffer in SRAM ************/
unsigned char disBuf[504];

#if HW_SPI
/*********************** Hardware SPI Speed Set **************/
void lcdSpiSpeedSet()
{
	S0PCCR = 12;										/* 設置SPI0時鐘分頻值為8  Set the value of dividing frequency to 8 */
	
	S0PCR  = (0 << 3) |									// CPHA = 0, 數據 在SCK 的第一個時鐘沿采樣
 	(1 << 4) |											// CPOL = 1, SCK 為低有效
 	(1 << 5) |											// MSTR = 1, SPI 處于主模式
 	(0 << 6) |											// LSBF = 0, SPI 數據傳輸MSB (位7)在先
 	(0 << 7);											// SPIE = 0, SPI 中斷被禁止

#if 0
	AT91PS_SPI pSPI      = AT91C_BASE_SPI;
	unsigned int reg;
	unsigned char speed = MCK/1000000/2;	/* 3310's max Fsclk is 4MHz, so 2MHz is ok! */

	reg = pSPI->SPI_CSR[0];	/* we control the CS but not SPI , so just use default SPI_CSR0 */
	reg = ( reg & ~(AT91C_SPI_SCBR) ) | ( (unsigned int)speed << 8 );	/* recaulate */
	pSPI->SPI_CSR[0] = reg;	/* set the value */
#endif
}
/************************ Hardware SPI Speed set End *********/
#endif


/************************ SPI write a byte *********************/
void lcdWriteByte(unsigned char val)
{
	/* we do not assert cs signal in each write cycle, cs is select in block data transfer */
	//AT91PS_SPI pSPI      = AT91C_BASE_SPI;	
	
#if HW_SPI				/* Use Hardware SPI */

	S0PDR = val;

	while(0 == (S0PSR & 0x80));						    /* wait for SPI0F being set, that is, wait for finishing of data being send */
	

//	return(S0PDR);

#if 0

	while( !( pSPI->SPI_SR & AT91C_SPI_TDRE ) );	/* transfer compl. wait */
	pSPI->SPI_TDR = val;

	while( !( pSPI->SPI_SR & AT91C_SPI_RDRF ) );	/* wait for char */
	return (unsigned char)( pSPI->SPI_RDR );			/* it's important to read RDR here! */
#endif
#else					/* Use common GPIO to simulate the timing*/
	unsigned char i = 8;
	while(i--)
	{
		LCD_SCK_L;
		if(val&0x80)LCD_MOSI_H;	/* MSB first */
		else LCD_MOSI_L;
		LCD_SCK_H;
		val <<= 1;				/* Data shift */
	}
#endif

}
/***************************************************************/

/************************ SPI write a command *********************/
void lcdWriteCmd(unsigned char val)
{
//	unsigned char temp;
	//AT91PS_SPI pSPI      = AT91C_BASE_SPI;
	
	LCD_RS_L;	/* command select */
	
#if HW_SPI				/* Use Hardware SPI */
	S0PDR = val;

	while(0 == (S0PSR & 0x80));						    /* wait for SPI0F being set, that is, wait for finishing of data being send */
	

	//return(S0PDR);

#if 0
	while( !( pSPI->SPI_SR & AT91C_SPI_TDRE ) );	/* transfer compl. wait */
	pSPI->SPI_TDR = val;

	while( !( pSPI->SPI_SR & AT91C_SPI_RDRF ) );	/* wait for char */
	temp =  (unsigned char)( pSPI->SPI_RDR );			/* it's important to read RDR here! */
#endif	
#else					/* Use common GPIO to simulate the timing*/
	unsigned char i = 8;
	while(i--)
	{
		LCD_SCK_L;
		if(val&0x80)LCD_MOSI_H;	/* MSB first */
		else LCD_MOSI_L;
		LCD_SCK_H;
		val <<= 1;				/* Data shift */
	}
#endif

	LCD_RS_H;	/* command deselect, data transfer now */

}
/***************************************************************/


/***************** LCD initialization *****************************/
void lcdInit(void)
{
#if 0
	AT91PS_SPI pSPI      = AT91C_BASE_SPI;
	AT91PS_PMC pPMC      = AT91C_BASE_PMC;
#endif
	LCD_PORT_INI;		/* IO port initialization*/

#if 0
#if HW_SPI			/* If hardware SPI is used, Initialize SPI & adjust the SPI speed */

	/* disable PIO from controlling MOSI, MISO, SCK (=hand over to SPI) */
	pPIO->PIO_PDR = AT91C_PA12_MISO | AT91C_PA13_MOSI | AT91C_PA14_SPCK;
	/* set pin-functions in PIO Controller */
	pPIO->PIO_ASR = AT91C_PA12_MISO | AT91C_PA13_MOSI | AT91C_PA14_SPCK;

	/* enable peripheral clock for SPI ( PID Bit 5 ) */
	pPMC->PMC_PCER = ( 1 << AT91C_ID_SPI ); /* n.b. IDs are just bit-numbers */

	/* SPI enable and reset */
	pSPI->SPI_CR = AT91C_SPI_SPIEN | AT91C_SPI_SWRST;

	/* SPI mode: master, fixed periph. sel., FDIV=0, fault detection disabled */
	pSPI->SPI_MR  = AT91C_SPI_MSTR | AT91C_SPI_PS_FIXED | AT91C_SPI_MODFDIS;

	/* set PCS for fixed select, in this program we do not use select of the SPI */
	/* We control the select ourself, so the default cs is 0, but we never use it */
	pSPI->SPI_MR &= 0xFFF0FFFF; /* clear old PCS - redundant (AT91lib) */
	pSPI->SPI_MR |= ( (0<<16) & AT91C_SPI_PCS ); /* set PCS */
	pSPI->SPI_CSR[0] = AT91C_SPI_NCPHA | AT91C_SPI_BITS_8;

	/* set SPI clock speed */
	lcdSpiSpeedSet();

	/* Enable SPI interface */
	pSPI->SPI_CR = AT91C_SPI_SPIEN;
	
#endif	
#endif

	lcdSpiSpeedSet();

	lcdClrDisBuf();	/* clear display buffer: not the lcd internal buffer */

	_delay_ms(15);	/*MAX F_CPU should below than 16MHz*/
	_delay_ms(15);

	LCD_RST_L;		/* Reset LCD */
	_delay_ms(1);
	LCD_RST_H;

	_delay_ms(1);	/* Short Delay */

	LCD_E_L;		/* Enable LCD: CS = 0 */

	lcdWriteCmd(0x21);	/* Expanted Instuction, Set H = 1 */
	lcdWriteCmd(0xc8);	/* Set bias voltage */
	lcdWriteCmd(0x06);	/* Set temperature */
	lcdWriteCmd(0x13);	/* Set 1/48 cycle*/
	lcdWriteCmd(0x20);	/* Normal Insturction, Set H = 0 */
	lcdWriteCmd(0x0c);	/* Display control, Normal mode*/

	lcdUpdateDisplay();	/* Update display */

	LCD_E_H;		/* Disable LCD: CS =1 */
}


/******** Clear the display buffer, external buffer in mico's SRAM ***************/
void lcdClrDisBuf(void)
{
	unsigned int n = 504;	/* 84*48/8 = 504*/
	unsigned char * p = disBuf;	
	while(n--)*p++ = 0x00;	/* clear the content */
}

/** Update the display, actually transfer the data of the SRAM to LCD through SPI ****/
void lcdUpdateDisplay(void)
{
	//unsigned int n = 504;
	unsigned char * p = disBuf;
	unsigned int i,j;

#if HW_SPI			/* If hardware SPI is used, adjust the SPI speed*/
	lcdSpiSpeedSet();	/* Other SPI device may share the SPI & they may change the speed */
#endif

	LCD_E_L;		/* Chip select, we then do not need to assert and dessert it in each spi cycle */

/***************************************************************************/
/*** It seems that some 3310lcd do not support the following code  ****/

 	//lcdWriteCmd(0x0c);
	//lcdWriteCmd(0x40 | 0);	/* Set row to 0 */
  	//lcdWriteCmd(0x80 | 0);	/* Set column to 0*/
							/* To make sure the data always start at codinate(0,0) */
	//while(n--)
	//	lcdWriteByte(*p++);
/***************************************************************************/

/* so we use this, set the address at each row */	
	for(i=0;i<6;i++)
	{
		lcdWriteCmd(0x40 | i);	/* Set row to 0 */
 	 	lcdWriteCmd(0x80 | 0);	/* Set column to 0*/
		for(j=0;j<84;j++)
		{
			lcdWriteByte(*p++);	/* send one byte data */
		}
	}
	LCD_E_H;		/* chip deselect */
}



/*********** Set a pixel bit with value val *************************/
void OnePixel(unsigned char x,unsigned char y,unsigned char val)
{
	unsigned char *p = &disBuf[ (unsigned int)y/8*84 + x ];/* find out which byte it is in */
	if(val)*p |= (1<<(y%8));		/* then modify the right bit according the value of "val" */
	else *p &= ~(1<<(y%8));
}
/**********  Read the pixel value withe the given codination ************/
unsigned char ReadPixel(unsigned char x,unsigned char y)
{
	unsigned char *p = &disBuf[ (unsigned int)y/8*84 + x ];/* find out which byte it is in */
	if(*p & (1<<(y%8)))return 1;	/* return the value of that bit */
	else return 0;
}

/* Lcd test utility, if the connection & lcd is ok, you'll see the screen is filling dots */
void lcdTest(void)
{
	unsigned int i,j;
	unsigned char val = 0;
	lcdClrDisBuf();	/* clear the buffer first */
	while(1)
	{
		if (val)val = 0;
		else val = 1;
		for(i=0;i<48;i++)
		{
			for(j=0;j<84;j++)
			{
				OnePixel(j,i,val);	/* write data, and the display is lines, you can image what it is like */
				lcdUpdateDisplay();	/* update the display contents */
				_delay_ms(1);	/* a delay, otherwise the transfer is too fast */
			}
		}
	}
}

/*  demo program
int main()
{
	lcdInit();
	lcdTest();
	while(1);
}*/

/*  This is the end of LCD.c   */

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲sss视频在线视频| 国产专区综合网| 免费成人av资源网| 国产精品原创巨作av| 99国内精品久久| 欧美福利视频一区| 欧美日韩在线精品一区二区三区激情| 日韩一级二级三级精品视频| 国产精品亲子伦对白| 日日夜夜免费精品| 成人国产电影网| 91精品国产全国免费观看| 2021国产精品久久精品| 亚洲女爱视频在线| 国产剧情一区二区| 欧美一级久久久久久久大片| 日韩理论片中文av| 精品一区二区av| 欧美体内she精视频| 欧美国产日韩在线观看| 石原莉奈一区二区三区在线观看| 国产一区二区伦理| 欧美丰满一区二区免费视频| 国产女同性恋一区二区| 日韩电影一区二区三区四区| 色综合夜色一区| 国产亚洲欧美日韩在线一区| 五月综合激情网| 一本色道久久综合狠狠躁的推荐| 久久亚洲二区三区| 麻豆一区二区三区| 欧美日韩www| 亚洲婷婷综合色高清在线| 国产美女一区二区三区| 日韩亚洲国产中文字幕欧美| 午夜在线成人av| 欧美色涩在线第一页| 国产精品天美传媒| 国产福利一区在线| 日韩精品一区二区三区蜜臀 | 一区二区三区精品视频在线| 日韩 欧美一区二区三区| 欧美在线综合视频| 亚洲国产日韩精品| 欧美色偷偷大香| 亚洲成人中文在线| 777欧美精品| 丝瓜av网站精品一区二区| 欧美性猛片aaaaaaa做受| 1024成人网| 在线中文字幕不卡| 亚洲综合网站在线观看| 欧洲视频一区二区| 亚洲香蕉伊在人在线观| 成人动漫av在线| 国产日韩欧美麻豆| 99久久久久久| 亚洲欧洲综合另类在线| 色婷婷综合视频在线观看| 一区二区三区日韩| 欧美日韩激情一区二区三区| 亚洲成在线观看| 日韩欧美一区在线观看| 国产在线不卡一卡二卡三卡四卡| 91精品国产手机| 久久精品国产网站| 久久久久99精品一区| 国产成人无遮挡在线视频| 2020日本不卡一区二区视频| 丰满少妇在线播放bd日韩电影| 国产精品久久久99| 色丁香久综合在线久综合在线观看| 一区二区三区中文字幕精品精品| 色妹子一区二区| 午夜亚洲国产au精品一区二区| 欧美日本一区二区三区四区| 老司机午夜精品99久久| 欧美极品少妇xxxxⅹ高跟鞋| 91视频免费看| 免费欧美日韩国产三级电影| 久久亚洲免费视频| 欧洲一区在线电影| 视频一区二区中文字幕| 91精品福利在线一区二区三区| 国产一区二区三区最好精华液| 最新不卡av在线| 欧美精品日韩一本| 国产剧情一区二区| 亚洲国产wwwccc36天堂| 久久综合久久综合亚洲| 91女神在线视频| 免费高清成人在线| 亚洲婷婷在线视频| 精品福利一二区| 日本精品视频一区二区| 一区二区激情视频| 久久美女高清视频| 欧美日韩久久一区| caoporen国产精品视频| 午夜不卡在线视频| 亚洲免费观看高清完整| 精品国产乱码久久久久久蜜臀| 91国在线观看| 国产成人精品亚洲777人妖| 秋霞av亚洲一区二区三| 亚洲欧洲精品成人久久奇米网| 欧美成人三级在线| 欧美日韩综合在线| 91丨porny丨国产| 91小视频在线免费看| 麻豆成人免费电影| 亚洲美女屁股眼交3| 久久久久久久久岛国免费| 欧美日韩激情在线| 在线观看欧美精品| av网站一区二区三区| 国产高清在线观看免费不卡| 久色婷婷小香蕉久久| 亚洲午夜国产一区99re久久| 欧美国产视频在线| 久久久亚洲精品一区二区三区| 日韩欧美综合一区| 欧美一区二区性放荡片| 精品视频在线免费看| 色菇凉天天综合网| 国产高清久久久久| 久久99久久99精品免视看婷婷| 亚洲v中文字幕| 亚洲电影第三页| 午夜精品国产更新| 香蕉成人啪国产精品视频综合网| 亚洲自拍都市欧美小说| 亚洲黄色小视频| 亚洲另类在线制服丝袜| 亚洲欧洲日产国码二区| 亚洲欧美一区二区久久 | 婷婷综合在线观看| 久久99国产乱子伦精品免费| 一区二区三区四区精品在线视频| 欧美性大战久久久久久久蜜臀| 成人av在线影院| 91一区二区在线| 51精品久久久久久久蜜臀| 久久只精品国产| 亚洲婷婷综合色高清在线| 天堂av在线一区| 91精品国产综合久久香蕉的特点 | 国内精品视频一区二区三区八戒| 欧美在线制服丝袜| **欧美大码日韩| 不卡的av电影在线观看| 久久精品无码一区二区三区| 日本va欧美va欧美va精品| 欧美午夜一区二区三区 | 亚洲一卡二卡三卡四卡| 91亚洲精品久久久蜜桃网站 | 欧洲激情一区二区| 亚洲精品写真福利| 色香蕉成人二区免费| 国产精品人妖ts系列视频| 国产suv精品一区二区883| 久久久久久一二三区| 国产自产视频一区二区三区| 久久综合狠狠综合久久激情| 国内精品视频一区二区三区八戒| 欧美大片一区二区三区| 久久 天天综合| 久久一夜天堂av一区二区三区 | 中文字幕第一区二区| 国产真实乱子伦精品视频| 欧美成人综合网站| 精品影院一区二区久久久| 日韩精品一区国产麻豆| 国产一二精品视频| 国产精品无人区| 91免费看`日韩一区二区| 亚洲精品v日韩精品| 欧美少妇一区二区| 首页国产欧美日韩丝袜| 日韩欧美在线观看一区二区三区| 久久99久久精品欧美| 2020国产成人综合网| 成人av网站在线观看| 日av在线不卡| 欧美va亚洲va国产综合| 国产乱人伦精品一区二区在线观看 | 亚洲一区二区三区自拍| 色悠悠久久综合| 日韩电影在线一区| 国产亚洲va综合人人澡精品| 97se亚洲国产综合自在线不卡| 一区二区欧美国产| 日韩欧美国产wwwww| 国产成人99久久亚洲综合精品| 亚洲天堂a在线| 91精品国产综合久久国产大片| 国产美女视频一区| 亚洲精品第一国产综合野| 91精品欧美一区二区三区综合在 | 亚洲私人黄色宅男|