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

📄 main.c

📁 epsondriver 驱动源代码
💻 C
字号:
/**********************************************************************************************************
							Sincere Techonlogy
							 Shanghai.China
			(c) Copyright 2005,Sincere Technology,Shanghai China
							All Rights Reserved



File name         : main.c
Author            : Neil(dududu)
Description       : The main function of EpsonDriver 
Target            : C8051F023
Data              : 2005-3
**********************************************************************************************************/

#include "Include.h"

unsigned int xdata gammaRed[257]={32,72,72,72,71,70,68,67,65,76,111,208,211,213,215,217,219,243,247,251,254,272,283,290,293,
296,309,323,329,334,345,351,356,360,365,376,380,384,390,397,402,412,418,424,428,432,437,
444,451,457,463,468,472,475,480,484,488,493,498,504,509,514,519,523,528,532,535,539,543,
547,551,555,559,562,565,568,572,576,579,583,586,588,591,594,598,602,605,607,610,612,615,
617,620,622,625,629,632,636,639,641,644,646,649,651,654,656,659,661,664,666,670,674,677,
680,682,684,686,688,690,693,700,703,707,710,712,715,717,720,723,725,727,729,731,733,735,
738,740,742,744,746,749,752,755,757,759,760,762,763,765,767,770,772,775,777,779,782,785,
787,790,792,793,795,797,798,800,802,804,806,809,812,815,817,819,821,823,825,827,829,831,
833,835,837,839,841,843,845,847,849,851,854,856,858,860,862,864,867,869,871,873,876,878,
880,882,885,887,889,892,894,897,899,901,904,906,909,911,914,917,921,924,927,929,931,932,
934,936,938,941,944,947,951,953,956,958,960,962,965,967,971,975,977,980,983,985,988,990,
993,996,999,1001,1005,1009,1013,1017,1023,1024},
gammaGreen[257]={100,126,126,127,128,129,130,132,135,137,141,144,148,152,157,162,
168,174,180,187,195,202,210,217,221,234,240,245,252,261,266,270,275,279,285,291,299,305,310,320,326,330,333,336,340,345,351,356,361,366,370,375,381,386,391,396,402,407,411,416,421,426,432,435,438,441,444,448,451,454,457,461,465,469,472,476,479,482,484,487,489,493,498,502,505,509,512,516,519,521,524,526,528,531,534,537,540,543,546,549,553,556,559,561,564,566,569,572,574,577,579,582,584,586,589,591,594,597,599,602,605,607,610,614,619,624,627,629,632,634,636,639,642,646,648,650,653,655,658,660,662,664,667,669,671,673,675,678,680,682,684,685,687,689,692,695,698,702,704,706,709,713,716,719,721,723,726,728,730,732,734,737,739,741,744,746,748,751,753,756,759,763,766,768,770,773,776,780,783,785,788,790,793,795,797,800,802,804,807,809,811,814,816,819,821,824,826,829,831,834,837,841,845,848,850,853,856,858,861,864,867,869,872,875,878,880,883,888,892,896,899,903,906,909,913,916,919,923,928,933,937,941,945,950,954,959,966,971,977,981,985,989,996,1005,1013,1023,1024},
gammaBlue[257]={60,163,161,156,150,142,131,121,125,133,137,138,140,142,144,146,148,151,153,155,157,159,161,164,167,171,175,179,183,185,188,190,192,196,200,204,207,211,215,219,223,226,230,233,236,240,244,249,253,256,258,261,263,266,270,273,277,280,284,288,294,298,302,305,309,313,316,318,321,324,328,336,341,345,350,356,361,367,372,378,384,392,397,400,404,422,430,436,443,454,460,465,472,478,483,488,494,501,507,511,515,518,523,527,531,535,539,542,545,548,551,554,557,560,564,567,570,573,576,579,581,584,586,588,590,593,596,599,602,605,607,609,611,614,617,620,623,625,627,629,632,634,637,639,641,644,646,649,652,654,656,658,660,663,665,667,669,671,673,676,680,683,685,687,688,690,692,694,697,701,704,707,709,712,714,717,719,721,724,726,728,731,733,735,737,739,741,744,746,748,750,752,755,757,759,761,763,766,768,770,774,778,782,785,788,791,793,795,798,801,805,808,811,814,817,820,824,828,832,834,837,839,842,846,851,856,859,862,865,868,870,873,876,880,886,890,894,897,902,910,916,922,928,933,939,945,951,957,963,972,979,986,998,1006,1013,1023,1024};


void main(void)
{
	int i,n;
	unsigned char Selection;
	WDTCN = 0xde;                       
    WDTCN = 0xad;                       // Disable watchdog timer
	SYSCLK_Init ();                     // Initialize oscillator
	MEMORY_Init ();                     // Initialize memory
	PERIAL_Init ();						// Initialize digital peripherals
	PORT_Init ();
	INTERRUPT_Init ();
	SMBUS_Init ();
	UART0_Init ();
	NONE_READY();
	/*
	_0707READY();
	WRITE_0707(0x0c03,0x0009);
	NONE_READY();
	_0707READY();
	WRITE_0707(0x0c04,0x0020);
	NONE_READY();
	_R6100READY() ;                //Ready for red 6100
	WRITE_6100(0x0880);
	NONE_READY();
	_B6100READY() ;
	WRITE_6100(0x0880);
	NONE_READY();
	*/
	SetTG ();
/*
	n=0;
	for(i=0;i<=256;i++)
		{
	  		_0707READY();
			WRITE_0707(n,gammaRed[i]);
			n++;
			NONE_READY();
		}

	n=0;
	for(i=0;i<=256;i++)
		{
	  		_0707READY();
			WRITE_0707((1024+n),gammaGreen[i]);
			n++;
			NONE_READY();
		}

	n=0;
	for(i=0;i<=256;i++)
		{
	  		_0707READY();
			WRITE_0707((2048+n),gammaBlue[i]);
			n++;
			NONE_READY();
		}
*/
	/*SMBus communication*****************
	while(1)
	{
		SM_Send (_24LC256, 0x0011, 0x38);
		DELAY (100);
		rece_SMBus=SM_Receive (_24LC256, 0x0011);

	}*********************************/
	
	
	/*URAT0 communication*****************
	while(1)
	{
		pointer=sRecComBuf;
	 	Count_UART0=0;
		Count_UART0a=0;
		Tran_Flag=0;
		Rec_OK=0;
		Tran_OK=0;
		while(Rec_OK!=0x23)
	 		;
		pointer=sRecComBuf;
		while(Tran_OK!=0x45)
		{
			Tran_Flag=1;
			SBUF0=*pointer++;
			Count_UART0a++;
			DELAY(100);
			while(Tran_Flag)
			;
		}
	}***********************************/
	#if DEBUG
	while(1)
	{
		pointer=sRecComBuf;           //pointer->sRecComBuf[0]
	 	Count_UART0=0;
		Count_UART0a=0;
		Tran_Flag=0;
		Rec_OK=0;
		Tran_OK=0;
		while(Rec_OK!=0x23)
	 		;
		pointer=sRecComBuf;          //pointer->sRecComBuf[0]
		Selection		= *(pointer+6); 
		if (Selection==1)
		{
			pointer=sRecComBuf;          //pointer->sRecComBuf[0]
			Address0707=*pointer++<<8;
			Address0707+=*pointer++;;
			Data0707   =*pointer++<<8;
			Data0707   +=*pointer++;
			Address24LC256=*pointer++<<8; 
			Address24LC256  +=*pointer++;
			Selection		= *pointer;    
			pointer=sRecComBuf;          //pointer->sRecComBuf[0]
			_0707READY();
			WRITE_0707(Address0707,Data0707);
			NONE_READY();
			SM_Send (_24LC256,Address24LC256 , *pointer);
			SM_Send (_24LC256,Address24LC256+1 , *(pointer+1));
			SM_Send (_24LC256,Address24LC256+2 , *(pointer+2));
			SM_Send (_24LC256,Address24LC256+3 , *(pointer+3));
			sRecComBuf[0]=SM_Receive (_24LC256, Address24LC256);
			sRecComBuf[1]=SM_Receive (_24LC256, Address24LC256+1);
			sRecComBuf[2]=SM_Receive (_24LC256, Address24LC256+2);
			sRecComBuf[3]=SM_Receive (_24LC256, Address24LC256+3);
			pointer=sRecComBuf;           //pointer->sRecComBuf[0]
		}
		else if (Selection==2)
		{
			pointer=sRecComBuf;          //pointer->sRecComBuf[0]
			DataAddress6100=*pointer++<<8;
			DataAddress6100+=*pointer++;
			Address24LC256=*pointer++<<8; 
			Address24LC256  +=*pointer;
			pointer=sRecComBuf;          //pointer->sRecComBuf[0]
			_R6100READY() ;                //Ready for red 6100
			WRITE_6100(DataAddress6100);
			NONE_READY();
			SM_Send (_24LC256,Address24LC256 , *pointer);
			SM_Send (_24LC256,Address24LC256+1 , *(pointer+1));
			sRecComBuf[0]=SM_Receive (_24LC256, Address24LC256);
			sRecComBuf[1]=SM_Receive (_24LC256, Address24LC256+1);
			pointer=sRecComBuf;           //pointer->sRecComBuf[0]
		}
		else if (Selection==3)
		{
			pointer=sRecComBuf;          //pointer->sRecComBuf[0]
			DataAddress6100=*pointer++<<8;
			DataAddress6100+=*pointer++;
			Address24LC256=*pointer++<<8; 
			Address24LC256  +=*pointer;
			pointer=sRecComBuf;          //pointer->sRecComBuf[0]
			_G6100READY() ;                //Ready for red 6100
			WRITE_6100(DataAddress6100);
			NONE_READY();
			SM_Send (_24LC256,Address24LC256 , *pointer);
			SM_Send (_24LC256,Address24LC256+1 , *(pointer+1));
			sRecComBuf[0]=SM_Receive (_24LC256, Address24LC256);
			sRecComBuf[1]=SM_Receive (_24LC256, Address24LC256+1);
			pointer=sRecComBuf;           //pointer->sRecComBuf[0]
		}
		else if (Selection==4)
		{
			pointer=sRecComBuf;          //pointer->sRecComBuf[0]
			DataAddress6100=*pointer++<<8;
			DataAddress6100+=*pointer++;
			Address24LC256=*pointer++<<8; 
			Address24LC256  +=*pointer;
			pointer=sRecComBuf;          //pointer->sRecComBuf[0]
			_B6100READY() ;                //Ready for red 6100
			WRITE_6100(DataAddress6100);
			NONE_READY();
			SM_Send (_24LC256,Address24LC256 , *pointer);
			SM_Send (_24LC256,Address24LC256+1 , *(pointer+1));
			sRecComBuf[0]=SM_Receive (_24LC256, Address24LC256);
			sRecComBuf[1]=SM_Receive (_24LC256, Address24LC256+1);
			pointer=sRecComBuf;           //pointer->sRecComBuf[0]
		}
		while(Tran_OK!=0x45)
		{
			Tran_Flag=1;
			SBUF0=*pointer++;
			Count_UART0a++;
			DELAY(100);
			while(Tran_Flag)
			;
		}

	}
	#endif
SetTG ();
SetVSPCR ();
SetVSPRSR ();
SetVSPGSG ();
SetVSPBSB ();
SetGCRAMR ();
SetGCRAMG ();
SetGCRAMB ();
SetVSPPQICSR ();
SetVSPCUCSRa ();
SetVSPCUCSRb ();
Set6100R ();
Set6100G ();
Set6100B ();


}

⌨️ 快捷键说明

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