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

📄 at91_uart.c

📁 at91rm9200 linux 下t6963的驱动
💻 C
字号:
/* can_sja1000funcs** can4linux -- LINUX CAN device driver source*  * This file is subject to the terms and conditions of the GNU General Public * License.  See the file "COPYING" in the main directory of this archive * for more details. * * * Copyright (c) 2002 port GmbH Halle/Saale* (c) 2001 Heinz-J黵gen Oertel (oe@port.de)*------------------------------------------------------------------* $Header: /z2/cvsroot/products/0530/software/can4linux/src/can_sja1000funcs.c,v 1.13 2005/08/29 08:51:27 oe Exp $**--------------------------------------------------------------------------*** modification history* --------------------* $Log: can_sja1000funcs.c,v $* Revision 1.13  2005/08/29 08:51:27  oe* - added support for SJA1000 ListenOnlyMode, thanks to Steven Scholz*   <steven.scholz@imc-berlin.de>* - added support for frame self reception mode**/#include "at91_uart_defs.h"/* can_GetStat - read back as many status information as possible ** Because the CAN protocol itself describes different kind of information* already, and the driver has some generic information* (e.g about it's buffers)* we can define a more or less hardware independent format.*** exception:* ERROR WARNING LIMIT REGISTER (EWLR)* The SJA1000 defines a EWLR, reaching this Error Warning Level* an Error Warning interrupt can be generated.* The default value (after hardware reset) is 96. In reset* mode this register appears to the CPU as a read/write* memory. In operating mode it is read only.* Note, that a content change of the EWLR is only possible,* if the reset mode was entered previously. An error status* change (see status register; Table 14) and an error* warning interrupt forced by the new register content will not* occur until the reset mode is cancelled again.*/static void configure_t6963c0_pins(void)	
{
	at91_set_gpio_output(AT91_PIN_PA21, 1);
}struct at91_uart_port at91_ports[MAX_CHANNELS]={	{		.fun=configure_t6963c0_pins,	}};
void CHS_RSTLCD_ON()
{
	at91_set_gpio_output(AT91_PIN_PA21, 0);
}
void CHS_RSTLCD_OFF()
{
	at91_set_gpio_output(AT91_PIN_PA21, 1);	
}

void Lcdinit()
{
	uint16	i;	
	static	uint16	lcdbusytime,lcddelay;	
	
	CHS_RSTLCD_ON();
	for(lcddelay=0;lcddelay<=1000;lcddelay++);
	CHS_RSTLCD_OFF();		
			
	lcdbusytime=0;
		
	for(lcddelay=0;lcddelay<=10;lcddelay++);	T6963C_PUT_DATA(port,0);
	for(lcddelay=0;lcddelay<=10;lcddelay++);	T6963C_PUT_DATA(port,0);
	for(lcddelay=0;lcddelay<=10;lcddelay++);	T6963C_PUT_COM(port,INS_SET_GPH_HOM_ADR); 
			
	for(lcddelay=0;lcddelay<=10;lcddelay++);	T6963C_PUT_DATA(port,LCD_WIDTH);
	for(lcddelay=0;lcddelay<=10;lcddelay++);	T6963C_PUT_DATA(port,0);
	for(lcddelay=0;lcddelay<=10;lcddelay++);	T6963C_PUT_COM(port,INS_SET_GPH_AREA); 
			
	for(lcddelay=0;lcddelay<=10;lcddelay++);	T6963C_PUT_COM(port,INS_ITN_ROM); 
			
	for(lcddelay=0;lcddelay<=10;lcddelay++);	T6963C_PUT_COM(port,INS_TXT_OFF_GPH_ON); 	
		
	Lcd_Two_Para_WR( 0, 0, INS_SET_ADR_PTR );

		
	Lcd_Non_Para_WR( INS_DAT_AUT_WR );
	Lcd_RW_Busy();
	Lcd_Aut_RW_Busy();
	
	for(i=0;i<(LCD_HEIGHT*LCD_WIDTH);i++)
	{	
		*CHS_LCD_DAT = 0 ;	
		Lcd_Aut_RW_Busy();		
	}
	Lcd_Non_Para_WR( INS_DAT_AUT_STOP );	
	
}// *********************************************************************** //
uint8	Lcd_Ins_Status( void )
{
	if( ( T6963C_GET_COM(port) & 0x01 ) != 0 ) return ( LCD_IDLE );
	else return ( LCD_BUSY );
}	
// *********************************************************************** //
uint8	Lcd_Dat_Status( void )
{
	if( ( T6963C_GET_COM(port) & 0x02 ) != 0 ) return ( LCD_IDLE );
	else return ( LCD_BUSY );
}	
// *********************************************************************** //
uint8	Lcd_RW_Status( void )
{	
	if( ( T6963C_GET_COM(port) & 0x03 ) == 0x03 ) return ( LCD_IDLE );
	else return ( LCD_BUSY );
}		
// ************************************************************************ //
uint8	Lcd_Aut_RW_Status( void )
{	
	if( ( T6963C_GET_COM(port) & 0x08 ) != 0 ) return ( LCD_IDLE );	
	else return ( LCD_BUSY );
}
// ************************************************************************* //
void	Lcd_RW_Busy( void )
{
	static	uint16	lcdbusytime,lcddelay;
	
	while( ( T6963C_GET_COM(port) & 0x03 ) != 0x03 )
	{
		if(lcdbusytime<500)	lcdbusytime++;
		else
		{
			CHS_RSTLCD_ON();
			for(lcddelay=0;lcddelay<=1000;lcddelay++);
			CHS_RSTLCD_OFF();		
			
			lcdbusytime=0;
		
			for(lcddelay=0;lcddelay<=10;lcddelay++);	T6963C_PUT_DATA(port,0);
			for(lcddelay=0;lcddelay<=10;lcddelay++);	T6963C_PUT_DATA(port,0);
			for(lcddelay=0;lcddelay<=10;lcddelay++);	T6963C_PUT_COM(port,INS_SET_GPH_HOM_ADR); 
					
			for(lcddelay=0;lcddelay<=10;lcddelay++);	T6963C_PUT_DATA(port,LCD_WIDTH);
			for(lcddelay=0;lcddelay<=10;lcddelay++);	T6963C_PUT_DATA(port,0);
			for(lcddelay=0;lcddelay<=10;lcddelay++);	T6963C_PUT_COM(port,INS_SET_GPH_AREA); 
					
			for(lcddelay=0;lcddelay<=10;lcddelay++);	T6963C_PUT_COM(port,INS_ITN_ROM); 
					
			for(lcddelay=0;lcddelay<=10;lcddelay++);	T6963C_PUT_COM(port,INS_TXT_OFF_GPH_ON); 
					
		}
	}
	lcdbusytime=0;
}
//
void	Lcd_Aut_RW_Busy( void )
{
	static	uint16	lcdbusytime,lcddelay;
	
	while( ( *CHS_LCD_INS & 0x08 ) == 0 )
	{
		if(lcdbusytime<500)	lcdbusytime++;
		else
		{
			CHS_RSTLCD_ON();
			for(lcddelay=0;lcddelay<=1000;lcddelay++);
			CHS_RSTLCD_OFF();
						
			lcdbusytime=0;
		
			for(lcddelay=0;lcddelay<=10;lcddelay++);	T6963C_PUT_DATA(port,0);
			for(lcddelay=0;lcddelay<=10;lcddelay++);	T6963C_PUT_DATA(port,0);
			for(lcddelay=0;lcddelay<=10;lcddelay++);	T6963C_PUT_COM(port,INS_SET_GPH_HOM_ADR); 
					
			for(lcddelay=0;lcddelay<=10;lcddelay++);	T6963C_PUT_DATA(port,LCD_WIDTH);
			for(lcddelay=0;lcddelay<=10;lcddelay++);	T6963C_PUT_DATA(port,0);
			for(lcddelay=0;lcddelay<=10;lcddelay++);	T6963C_PUT_COM(port,INS_SET_GPH_AREA); 
					
			for(lcddelay=0;lcddelay<=10;lcddelay++);	T6963C_PUT_COM(port,INS_ITN_ROM); 
					
			for(lcddelay=0;lcddelay<=10;lcddelay++);	T6963C_PUT_COM(port,INS_TXT_OFF_GPH_ON); 
		}
	}
	lcdbusytime=0;
}
// *********************************************************************** //	
/*	双参数写入			*/
void	Lcd_Two_Para_WR( uint8 data1, uint8 data2, uint8 com )
{
	Lcd_RW_Busy( ); T6963C_PUT_DATA(port,data1);
	Lcd_RW_Busy( );	T6963C_PUT_DATA(port,data2);
	Lcd_RW_Busy( );	T6963C_PUT_COM(port,com); 
}	

/*	单参数写入			*/
void	Lcd_One_Para_WR( uint8 data, uint8 com )
{
	Lcd_RW_Busy( );	T6963C_PUT_DATA(port,data);
	Lcd_RW_Busy( );	T6963C_PUT_COM(port,com); 
}

/*	无参数写入			*/
void	Lcd_Non_Para_WR( uint8 com )
{
	Lcd_RW_Busy( );	T6963C_PUT_COM(port,com); 
}



⌨️ 快捷键说明

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