Пример #1
0
/*
****************************************************************************
*
*       LCD_X_Config
*
* Purpose:
*   Called during the initialization process in order to set up the
*   display driver configuration.
*
****************************************************************************   
*/
void LCD_X_Config(void) 
{
	/* 读取EEPROM中的参数 */	
	ee_ReadBytes((uint8_t *)&g_tTPSL, 1024, sizeof(g_tTPSL));
	
 	/* Set display driver and color conversion for 1st layer */
    GUI_DEVICE_CreateAndLink(DISPLAY_DRIVER, COLOR_CONVERSION, 0, 0);

     if (g_ChipID == IC_8875)
 	{
 		if (g_ucGPIX == 1)	/* 	GPIX = 1  4.3  480x272 */
 		{
			/* Display driver configuration */
			LCD_SetSizeEx    (0, 480, 272);
			LCD_SetVSizeEx   (0, 480, 272);
			
			/* Touch calibration */ 
			GUI_TOUCH_Calibrate(GUI_COORD_X, 0, 479, g_tTPSL.usAdcX1,  g_tTPSL.usAdcX2);
			GUI_TOUCH_Calibrate(GUI_COORD_Y, 0, 271, g_tTPSL.usAdcY1,  g_tTPSL.usAdcY2);
			
			/* 查看是否需要切换X,Y*/
			if(g_tTPSL.XYChange == 1)
			{
				GUI_TOUCH_SetOrientation(GUI_SWAP_XY);
			}
 		}
 		else 	/* 	GPIX = 0  7  800*480 */
 		{
 			/* Display driver configuration */
 			LCD_SetSizeEx    (0, XSIZE_PHYS, YSIZE_PHYS);
 			LCD_SetVSizeEx   (0, VXSIZE_PHYS, VYSIZE_PHYS);
 			
 			GUI_TOUCH_Calibrate(GUI_COORD_X, 0, XSIZE_PHYS - 1, g_tTPSL.usAdcX1,  g_tTPSL.usAdcX2);
 			GUI_TOUCH_Calibrate(GUI_COORD_Y, 0, YSIZE_PHYS - 1, g_tTPSL.usAdcY1,  g_tTPSL.usAdcY2);	
			
			/* 查看是否需要切换X,Y*/
			if(g_tTPSL.XYChange == 1)
			{
				GUI_TOUCH_SetOrientation(GUI_SWAP_XY);
			}
 		}
 	}
 	else
 	{
 		LCD_SetSizeEx    (0, 400, 240);
 		LCD_SetVSizeEx   (0, 400, 240);
 		
 		/* Touch calibration */ 
 		GUI_TOUCH_Calibrate(GUI_COORD_X, 0, 399, 300, 3600);
 		GUI_TOUCH_Calibrate(GUI_COORD_Y, 0, 239, 273,  3671);	
 	}

}
uint8_t EEPROM_AutoTest(void)
{
	uint16_t i;
	uint8_t write_buf[EE_SIZE];
  uint8_t read_buf[EE_SIZE];
  
/*-----------------------------------------------------------------------------------*/  
  if (ee_CheckOk() == 0)
	{		
		return 0;
	}
/*------------------------------------------------------------------------------------*/  
  /* 填充测试缓冲区 */
	for (i = 0; i < EE_SIZE; i++)
	{		
		write_buf[i] = i;
	}
/*------------------------------------------------------------------------------------*/  
  if (ee_WriteBytes(write_buf, 0, EE_SIZE) == 0)
	{
		
		return 0 ;
	}
	else //写成功
	{		

		
	}
  
  /*写完之后需要适当的延时再去读,不然会出错*/
  ee_Delay(0x0FFFFF);
/*-----------------------------------------------------------------------------------*/
  if (ee_ReadBytes(read_buf, 0, EE_SIZE) == 0)
	{		
		return 0;
	}
	else //读成功
	{		
		
	}
/*-----------------------------------------------------------------------------------*/  
  for (i = 0; i < EE_SIZE; i++)
	{
		if(read_buf[i] != read_buf[i])
		{
			return 0;
		}
	}
	
  return 1;


}
/* 
 * ISO 整板测试 
 */
void ISO_Test(void)
{
	uint8_t board_test=0;

	i2c_CheckDevice();
	delay(0xff); 
	ee_ReadBytes(&board_test, 0, 1);
	
	if(board_test != 0x55) //自检未通过 
	{
		ISO_AutoTest();		
	}
	else
	{
		ISO_Init();	
		Test_Menu();
		Board_Test();
	}

	while( 1 ){}
}
/*
 * eeprom AT24C02 读写测试
 */
void Eeprom_Test(void)
{
  uint16_t i;
	uint8_t write_buf[EE_SIZE];
  uint8_t read_buf[EE_SIZE];
  
/*-----------------------------------------------------------------------------------*/  
  if (ee_CheckOk() == 0)
	{
		/* 没有检测到EEPROM */
		printf("没有检测到串行EEPROM!\r\n");
		
		#ifdef LCD_DISPLAY
		//	LCD_Clear(20,128,206,16,BACKGROUND);			//清除屏幕
			LCD_DispEnCh(20,128,"没有检测到串行EEPROM!",RED);			
		#endif 	
		
			
		while (1);	/* 停机 */
	}
/*------------------------------------------------------------------------------------*/  
  /* 填充测试缓冲区 */
	for (i = 0; i < EE_SIZE; i++)
	{		
		write_buf[i] = i;
	}
/*------------------------------------------------------------------------------------*/  
  if (ee_WriteBytes(write_buf, 0, EE_SIZE) == 0)
	{
		printf("写eeprom出错!\r\n");
		#ifdef LCD_DISPLAY
		//	LCD_Clear(20,128,206,16,BACKGROUND);			//清除屏幕
			LCD_DispEnCh(20,128,"写EEPROM出错!",RED);			
		#endif 	
		
		return;
	}
	else
	{		
		printf("写eeprom成功!\r\n");
		#ifdef LCD_DISPLAY
		//	LCD_Clear(20,128,206,16,BACKGROUND);			//清除屏幕
			LCD_DispEnCh(20,128,"写EEPROM成功!",BLUE);			
		#endif 	
		
	}
  
  /*写完之后需要适当的延时再去读,不然会出错*/
  ee_Delay(0x0FFFFF);
/*-----------------------------------------------------------------------------------*/
  if (ee_ReadBytes(read_buf, 0, EE_SIZE) == 0)
	{
		printf("读eeprom出错!\r\n");
		#ifdef LCD_DISPLAY
		//	LCD_Clear(20,146,206,16,BACKGROUND);			//清除屏幕
			LCD_DispEnCh(20,146,"读EEPROM出错!",RED);			
		#endif 
		
		return;
	}
	else
	{		
		printf("读eeprom成功,数据如下:\r\n");
		#ifdef LCD_DISPLAY
		//	LCD_Clear(20,146,206,16,BACKGROUND);			//清除屏幕
			LCD_DispEnCh(20,146,"读EEPROM成功!",BLUE);			
		#endif 
		
	}
/*-----------------------------------------------------------------------------------*/  
  for (i = 0; i < EE_SIZE; i++)
	{
		if(read_buf[i] != read_buf[i])
		{
			printf("0x%02X ", read_buf[i]);
			printf("错误:EEPROM读出与写入的数据不一致");
		#ifdef LCD_DISPLAY
		//	LCD_Clear(20,165,206,16,BACKGROUND);			//清除屏幕
			LCD_DispEnCh(20,165,"错误:EEPROM读出与写入的数据不一致!",RED);			
		#endif 
			return;
		}
    printf(" %02X", read_buf[i]);
		
		if ((i & 15) == 15)
		{
			printf("\r\n");	
		}		
	}
  printf("eeprom读写测试成功\r\n");
		#ifdef LCD_DISPLAY
		//	LCD_Clear(20,165,206,16,BACKGROUND);			//清除屏幕
			LCD_DispEnCh(20,165,"EEPROM读写测试成功!",BLUE);			
		#endif 
  while(1);
}