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

📄 tft_s1d19105.c

📁 LCD驱动代码
💻 C
📖 第 1 页 / 共 3 页
字号:
	*/
	return ERR_LCD_NONE;
}


/*****************************************************************************/
//  Description:    Enable lcd to partial display mode, so can save power.
//	Global resource dependence: 
//  Author:         Jim.zhang
//  Return:         SCI_TRUE:SUCCESS ,SCI_FALSE:failed.
//	Note:           If all input parameters are 0, exit partial display mode.
/*****************************************************************************/
LOCAL ERR_LCD_E S1D19105_SetDisplayWindow(
	uint16 left, 		//left of the window
	uint16 top,			//top of the window
	uint16 right,		//right of the window
	uint16 bottom		//bottom of the window
	)
{
    S1D19105_set_display_window(left, top, right, bottom);
    
	return ERR_LCD_NONE;
}

/*********************************************************************/
//  Description:   Initialize color LCD : S1D19105
//  Input:
//      None.
//  Author:         yinchun.li
//  Return:
//      None.
//	Note:
//  modify:  jim.cui  2005.0728 add dma init  
/*********************************************************************/
LOCAL ERR_LCD_E S1D19105_Init(void)
{
	SCI_TRACE_LOW("S1D19105_Init, time=%d", SCI_GetTickCount());
     //dma init
    dma_init ();

 	//S1D19105_HW_reset();
   	S1D19105_reset();

	S1D19105_Clear( 0xf25f );
	
	SCI_TRACE_LOW("end of S1D19105_Init, time=%d", SCI_GetTickCount());
	
	return ERR_LCD_NONE;
}


/******************************************************************************/
//  Description:  set the contrast value 
//	Global resource dependence: 
//  Author:         Jim.zhang
//	Note:
/******************************************************************************/
LOCAL ERR_LCD_E   S1D19105_SetContrast(
	uint16  contrast	//contrast value to set
	)
{
	return ERR_LCD_FUNC_NOT_SUPPORT;
} 


/*****************************************************************************/
//  Description:    Set the brightness of LCD.
//	Global resource dependence: 
//  Author:         Jim.zhang
//	Note:
/*****************************************************************************/
LOCAL ERR_LCD_E   S1D19105_SetBrightness(
	uint16 brightness	//birghtness to set
	)
{
	return ERR_LCD_FUNC_NOT_SUPPORT;
}

/******************************************************************************/
//  Description:   Close the lcd.(include sub lcd.)
//	Global resource dependence: 
//  Author:         Jim.zhang
//	Note:
/******************************************************************************/
LOCAL void S1D19105_Close(void)
{
	GPIO_SetLcdBackLight( SCI_FALSE );
    S1D19105_EnterSleep( SCI_TRUE );	
}


LOCAL LCD_OPERATIONS_T S1D19105_operations = 
{
	S1D19105_Init,
	S1D19105_EnterSleep,
	S1D19105_SetContrast,
	S1D19105_SetBrightness,
	S1D19105_SetDisplayWindow,
	S1D19105_GetInfo,
	S1D19105_InvalidateRect,
	S1D19105_InvalidateRectImage,
	S1D19105_Invalidate,
	S1D19105_Clear,
	S1D19105_Close,
	S1D19105_GetMainLcdSpec
};

/******************************************************************************/
//  Description:  return the S1D19105 lcd driver funtion pointer
//	Global resource dependence: 
//  Author:         Jim.zhang
//	Note:
/******************************************************************************/
PUBLIC LCD_OPERATIONS_T* S1D19105_GetOperations()
{
	return &S1D19105_operations;
}

#define ADC_NUM 10
PUBLIC BOOLEAN S1D19105_Probe(void)
{
    uint32 i, adc_val = 0, adc_sum = 0;
	
	/*Delayms(500);
		
	for(i=0; i<ADC_NUM; i++)
	{
	    adc_val = ADC_GetResultDirectly(ADIN_1, FALSE);
	    adc_sum += adc_val;
	    SCI_TRACE_LOW("adc_rlt[%d]: %d", i, adc_val);
	    Delayms(50);
	}
	
	adc_val = adc_sum / ADC_NUM;*/
	
	adc_val = LCD_GetADCValue(ADIN_1);//added by lipengyu.
	SCI_TRACE_LOW("average adc_val: %d", adc_val);
	
	if((adc_val >= ADC_S1D19105_LOW) && (adc_val <= ADC_S1D19105_HIGH))        //TRULY 3727
	{
	    return SCI_TRUE;	
	}
	
	return SCI_FALSE;
}

#if 0
/*-----------------------------------------------------------------------------------------------
	Function name	: mv3LcdCmdWrite()
	Prototype		: void mv3LcdCmdWrite(mvUint16 addr, mvUint16 data);
	Return		: void
	Argument		: addr -> address
				  data -> data (This data is not pixel data but is register setting value)
	Comments	: command from MCU into LCD 
				  Sending a command to LCD, you should be change the RS pin by low value.
-----------------------------------------------------------------------------------------------*/
void mv3LcdCmdWrite(mvUint16 addr)
{
	mv3LcdClearRS();
	mv3LcdDataWrite(addr);
	mv3LcdSetRS();
}



/*-----------------------------------------------------------------------------------------------
	Function name	: mv3WriteDataToMainLcd()
	Prototype		: void mv3WriteDataToMainLcd(mvUint32 data);
	Return		: void
	Argument		: data -> data 
	Comments	: data from MCU into LCD 
-----------------------------------------------------------------------------------------------*/
void mv3WriteDataToMainLcd(mvUint32 data)
{
#ifdef COLOR18
	mv3LcdDataWrite(data >> 2);
	mv3LcdDataWrite(data << 14);
#else
	mv3LcdDataWrite(data);
#endif
}


/*-----------------------------------------------------------------------------------------------
	Function name	: mv3SetMainLcdWindow()
	Prototype		: void mv3SetMainLcdWindow();
	Return      	: void
	Argument      	: None
	Comments   	: set coordinates to display LCD
-----------------------------------------------------------------------------------------------*/
void mv3SetMainLcdWindow(mvUint16 sax, mvUint16 say, mvUint16 eax, mvUint16 eay)
{
	mvUint16 addr;

	mv3LcdBankSelect();
	
	addr = (( eax+2) << 8 );
	addr |= ( sax+2 );                                   //changed by wang 2005.01.21

	mv3LcdCmdWrite( 0x16 );
	mv3WriteDataToMainLcd( addr );

	addr = ( eay << 8 );
	addr |= ( say );

	mv3LcdCmdWrite( 0x17 );
	mv3WriteDataToMainLcd( addr );

	addr = ( say << 8 );
	addr |= ( sax );

	mv3LcdCmdWrite( 0x21 );
	mv3WriteDataToMainLcd( addr );
	
}



/*-----------------------------------------------------------------------------------------------
	Function name	: mv3SetMainLcdStart()
	Prototype   	: void mv3SetMainLcdStart();
	Return        	: void
	Argument     	: None
	Comments    	: set start position to display LCD
-----------------------------------------------------------------------------------------------*/
void mv3SetMainLcdStart(mvUint16 sax, mvUint16 say)
{
	mv3LcdBankSelect();
	mv3LcdCmdWrite(0x21);
	mv3WriteDataToMainLcd((say << 8) + sax );
	mv3LcdCmdWrite(0x22);
}



/*-----------------------------------------------------------------------------------------------
	Function name	: mv3MainLcdInit()
	Prototype   	: void mv3MainLcdInit(mvUint16 sax, mvUint16 say);
	Return       	: void
	Argument     	: None
	Comments     	: LCD Setting for MV3
-----------------------------------------------------------------------------------------------*/
void mv3MainLcdInit(mvUint16 sax, mvUint16 say)
{
	mvUint16 lcdCommand[10][3] = {
#if defined(FEATURE_MV3X7)
		// WE = write enable,  RS = register set
		// When RS is 0, command is excuted.
		// when RS is 1, data is transmitted.
		// {WE, RS, DATA}
		// before preview, LCD 4 word command
		{MV3_LCD_WRITE_ENABLE, MV3_LCD_RS_CLS, 0x21},
		{MV3_LCD_WRITE_ENABLE, MV3_LCD_RS_SET, 0},
		{MV3_LCD_WRITE_ENABLE, MV3_LCD_RS_CLS, 0x22},
		{0, 0, 0},
		// After preview, LCD 4 word command
		{0, 0, 0},
		{0, 0, 0},
		{0, 0, 0},
		{0, 0, 0},
		// reserved
		{0, 0, 0},
		{0, 0, 0}
#elif defined(FEATURE_MV3X9)
		//Before preview, LCD 5 word command
		{MV3_LCD_WRITE_ENABLE, MV3_LCD_RS_CLS, 0x21},
		{MV3_LCD_WRITE_ENABLE, MV3_LCD_RS_SET, 0},
		{MV3_LCD_WRITE_ENABLE, MV3_LCD_RS_CLS, 0x22},
		{0, 0, 0},
		{0, 0, 0},
		// After preview, LCD 5 word command
		{0, 0, 0},
		{0, 0, 0},
		{0, 0, 0},
		{0, 0, 0},
		{0, 0, 0}
#endif
    };
	lcdCommand[1][2] = (say << 8) + (sax+2);                //changed by wang 2005.01.21

	mv3LcdCmdControl((mvUint16 * )lcdCommand);
}



/*-----------------------------------------------------------------------------------------------
	Function name	: mv3MainLcdDisplayRegion()
	Prototype    	: void mv3MainLcdDisplayRegion();
	Return       	: void
	Argument     	: none
	Comments     	: write gamma table
-----------------------------------------------------------------------------------------------*/
void mv3MainLcdDisplayRegion(mvUint32 sax, mvUint32 say, mvUint32 eax, mvUint32 eay,
                             mvUint16 *pFullImage)
{
	mvUint16 i, j;

	// set window 
	mv3SetMainLcdWindow(sax, say, eax, eay);
	mv3SetMainLcdStart(sax, say);

	pFullImage += say * MAX_M_LCD_X + sax;
	for(i = 0; i < (eay - say + 1); i++)
	{
		for(j = 0; j < (eax - sax + 1); j++)
		{
			mv3WriteDataToMainLcd((mvUint32)*(pFullImage + j));
		}
		pFullImage += MAX_M_LCD_X;
	}

}
#endif
LOCAL void S1D19105_DisplayOn()
{
	S1D19105_sendcommand1(0x0007, 0x0001);	
	Delayms(30); 
	S1D19105_sendcommand1(0x0007, 0x0025);	
	S1D19105_sendcommand1(0x0007, 0x0027);
	Delayms(30); 
	S1D19105_sendcommand1(0x0007, 0x0037);
}
LOCAL void S1D19105_DisplayOff()
{
	S1D19105_sendcommand1(0x0007, 0x0036);	
	Delayms(30); 
	S1D19105_sendcommand1(0x0007, 0x0026);
	Delayms(30); 
	S1D19105_sendcommand1(0x0007, 0x0004);

	//power off
	S1D19105_sendcommand1(0x0010, 0x0000);	
	S1D19105_sendcommand1(0x0012, 0x0000);
	S1D19105_sendcommand1(0x0013, 0x0000);
}

LOCAL void S1D19105_GoSleep(void)
{
	S1D19105_DisplayOff();
	S1D19105_sendcommand1(0x0010, 0x0002);
}

LOCAL void S1D19105_ExitSleep(void)
{
	S1D19105_sendcommand1(0x0010, 0x0000);
	// power setting
	  S1D19105_sendcommand1(0x0012,0x0000);
	   Delayms(40);   
	  S1D19105_sendcommand1(0x0013,0x0000);
	  Delayms(40);   //delay
	  // initfun 2
	  S1D19105_sendcommand1(0x0011,0x0003);
	  Delayms(40);   //delay
	   
	  S1D19105_sendcommand1(0x0012,0x0000);
	   Delayms(40); 

	  S1D19105_sendcommand1(0x0013,0x0000);
	  Delayms(40);
	  S1D19105_sendcommand1(0x0010,0x0000);
	  Delayms(40);
	  S1D19105_sendcommand1(0x0010,0x0044);
	  Delayms(40);
	  //S1D19105_sendcommand1(0x000b,0x0400);
	  //Delayms(40);
	  S1D19105_sendcommand1(0x0012,0x001e);
	  Delayms(40);
	  S1D19105_sendcommand1(0x0013,0x351e);
	  Delayms(40);
	  S1D19105_sendcommand1(0x0010,0x0040);
	  Delayms(40);
	  S1D19105_sendcommand1(0x0010,0x6360);

	S1D19105_DisplayOn();
	  
}

/**---------------------------------------------------------------------------*
 **                         Compiler Flag                                     *
 **---------------------------------------------------------------------------*/
#ifdef   __cplusplus
    }
#endif 

⌨️ 快捷键说明

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