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

📄 tft_nt39102.c

📁 LCD驱动代码
💻 C
📖 第 1 页 / 共 3 页
字号:
	0x2c,	//uint8	gram_write_cmd;		/*gram write command*/
	//@zhemin.lin, add 1 line, CR9590
	0x00,	//uint8	line_offset;		/*line offset for display on lcd*/
	0x00	//uint8 colum_offset        /*columoffset for display on lcd*/
};


/******************************************************************************/
//  Description:    get the important parameter for digital camera
//	Global resource dependence: 
//  Author:         Zhemin.lin
//	Note:           
/******************************************************************************/
LOCAL ERR_LCD_E  NT39102_GetMainLcdSpec(
	LCD_SPEC_T *spec_ptr 	//spec struct pointer
	)
{
	if (spec_ptr == PNULL)
	{
		return 1;
	}
	
	memcpy(spec_ptr, &g_NT39102_spec, sizeof(LCD_SPEC_T));
	
	return ERR_LCD_NONE;
}


/******************************************************************************/
//  Description:   Enter/Exit sleep mode .
//	Global resource dependence: 
//  Author:         Jim.zhang
//	Note:
/******************************************************************************/
LOCAL ERR_LCD_E  NT39102_EnterSleep(
	BOOLEAN is_sleep 	//SCI_TRUE: exter sleep mode;SCI_FALSE:exit sleep mode.
	)
{
	SCI_TRACE_LOW("NT39102_EnterSleep,%d", is_sleep);
	
	
	if ( is_sleep ) // enter sleep mode.
	{
	NT39102_SEND_COMMAND(0x28);              // 2007/02/07
	NT39102_SEND_COMMAND(0x10);
	NT39102_SEND_COMMAND(0xf0);
	NT39102_SEND_DATA(0x5a);
	NT39102_SEND_COMMAND(0xf2);
	NT39102_SEND_DATA(0x01);
	Delayms(100);
 
	}
	else 			// out sleep mode 
	{
	NT39102_reset();
	NT39102_Invalidate();
	}
	
	//if( !GetUdiskState())
	//	DC_EnterSleep(is_sleep);
	
	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 NT39102_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
	)
{
    NT39102_set_display_window(left, right, top, bottom);
    
    NT39102_sendcommand1(0x0037, OFFSET_X);		

    NT39102_SEND_COMMAND(0x002c); 				

    return ERR_LCD_NONE;
    
}

/*********************************************************************/
//  Description:   Initialize color LCD : NT39102
//  Input:
//      None.
//  Return:
//      None.
//	Note:           
/*********************************************************************/
LOCAL ERR_LCD_E NT39102_Init(void)
{
 
   	NT39102_reset();

	NT39102_Clear( 0xf25f );
	
	return ERR_LCD_NONE;
}


/******************************************************************************/
//  Description:  set the contrast value 
//	Global resource dependence: 
//  Author:         Jim.zhang
//	Note:
/******************************************************************************/
LOCAL ERR_LCD_E   NT39102_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   NT39102_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 NT39102_Close()
{
    GPIO_SetLcdBackLight( SCI_FALSE );
    NT39102_EnterSleep( SCI_TRUE );	
}


LOCAL LCD_OPERATIONS_T NT39102_operations = 
{
	NT39102_Init,
	NT39102_EnterSleep,
	NT39102_SetContrast,
	NT39102_SetBrightness,
	NT39102_SetDisplayWindow,
	NT39102_GetInfo,
	NT39102_InvalidateRect,
	NT39102_InvalidateRectImage,
	NT39102_Invalidate,
	NT39102_Clear,
	NT39102_Close,
	NT39102_GetMainLcdSpec
};

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

PUBLIC BOOLEAN NT39102_Probe(void)
{
	return SCI_TRUE;	
}

#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( 0x44 );
	mv3WriteDataToMainLcd( addr );

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

	mv3LcdCmdWrite( 0x45 );
	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


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

⌨️ 快捷键说明

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