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

📄 uart.i

📁 该模板使用于周立功公司研发的EasyARM2100系列开发板
💻 I
字号:
#line 1 "src\\uart.c"
#line 1 "src\\config.h"























 












typedef unsigned char  uint8;                    
typedef signed   char  int8;                     
typedef unsigned short uint16;                   
typedef signed   short int16;                    
typedef unsigned int   uint32;                   
typedef signed   int   int32;                    
typedef float          fp32;                     
typedef double         fp64;                     

 
 
 
 



#line 1 "src\\LPC2294.h"


























 

 
 





 
 






 
 


 
 





 
 



 
 


  
 


 
 


 
 



 
 
#line 122 "src\\LPC2294.h"

 
 




 
 

























 
 
#line 168 "src\\LPC2294.h"

 
 
#line 183 "src\\LPC2294.h"

 
 
#line 193 "src\\LPC2294.h"

 
 
#line 203 "src\\LPC2294.h"

 
 
#line 213 "src\\LPC2294.h"

 
 
 






 












 





 
#line 252 "src\\LPC2294.h"

 
 
#line 278 "src\\LPC2294.h"

#line 302 "src\\LPC2294.h"

#line 326 "src\\LPC2294.h"

#line 350 "src\\LPC2294.h"

#line 374 "src\\LPC2294.h"

#line 398 "src\\LPC2294.h"





#line 411 "src\\LPC2294.h"


 
 
#line 431 "src\\LPC2294.h"



 
 
#line 452 "src\\LPC2294.h"



 
 
#line 472 "src\\LPC2294.h"

 
 



 






 
 


 
 
#line 517 "src\\LPC2294.h"

 
 





 
 
#line 534 "src\\LPC2294.h"














































 


#line 595 "src\\LPC2294.h"

#line 605 "src\\LPC2294.h"

#line 619 "src\\LPC2294.h"







 
#line 54 "src\\config.h"
#line 1 "src\\system.h"










#line 1 "src\\target.h"





























 










extern void Reset(void);
















 

extern void TargetInit(void);


















 





 



 
#line 12 "src\\system.h"
#line 1 "src\\uart.h"








 
void  DelayNS(uint32  dly);





 
void  UART0_Ini(uint32 bps);





 
void  UART0_SendByte(uint8 data);





 
void  UART1_Ini(uint32 bps);





 
void  UART1_SendByte(uint8 data);





 
void  UART0_SendStr(uint8 const *str);





 
void  SendByte0(uint8 data);





 
void  SendByte1(uint8 data);





 
void  ISendBuf0(void);





 
void  ISendBuf1(void);



#line 13 "src\\system.h"
#line 1 "src\\sys_init.h"





extern 	void	init_sys(void);
extern 	void 	init_io(void);
extern 	void 	init_clock(void);
extern 	void 	init_timer0(void);
extern 	void 	init_timer1(void);
extern 	void 	init_int0(void);
extern 	void 	init_int2(void);

#line 14 "src\\system.h"
#line 1 "src\\drv_uart.h"

typedef union{
 fp32    fat;
 uint16  word[2];
 uint8   byte[4];
}set_parm;
extern set_parm SET[5];







typedef union{
 fp32    fat;
 uint16  word[2];
 uint8   byte[4];
}amp_parm;
extern amp_parm AMP_P[7];
#line 28 "src\\drv_uart.h"


#line 37 "src\\drv_uart.h"


typedef union{
 fp32    fat;
 uint16  word[2];
 uint8   byte[4];
}status_parm;
extern status_parm        STU[8];

#line 54 "src\\drv_uart.h"

#line 63 "src\\drv_uart.h"




 
unsigned int crc16_bit(unsigned char *ptr,unsigned char len);        



 
uint16 crc16_tab(uint8 *ptr,uint8 len);      



 
unsigned char get_fanma(unsigned char dat);



 
void command(uint8 type);



 
void setting_parm(uint8 channel);



 
uint16 rec_crc16(uint8 *ptr,uint8 len);
#line 15 "src\\system.h"













 
















 




















#line 55 "src\\config.h"
 
 
 
 



 
 
 
 
 
 

						    

						    

						    

						    

#line 78 "src\\config.h"

   extern  void ee_write(unsigned char address , unsigned char data);
   extern unsigned char ee_read(unsigned char address);	
   extern void write_enable(void);
   extern void write_disable(void);
   extern void Delay(uint32 dly);






 
#line 2 "src\\uart.c"
uint8 rcv_buf[40],rcv_buf1[16];       
uint8 rcv_new,rcv_new1;          
uint8 answer_falg;





 
void  DelayNS(uint32  dly)
{  uint32  i;

   for(; dly>0; dly--) 
      for(i=0; i<50000; i++);
}





 
uint8 	uart0_rec_flag=0;
uint8  n=0,j=0;
uint8 temp;
uint8 head_cnt;
uint8 verify;
uint8 no_full;
uint8 head_buff[6];
uint8 recve_length;

extern  uint16 re_crc_value;
void   __irq IRQ_UART0(void)
{ 
    if(0x04==((*((volatile unsigned char *) 0xE000C008))&0x0F))
     { 
      
        if(no_full==0)
         {
          head_buff[n]=(*((volatile unsigned char *) 0xE000C000));
          n++;
         }
         
         if(n==6)                           
         {
         n=0;
         no_full=1;j=0;
         }
         
        if((no_full==1)&&(verify==0))       
        {
      
          if((head_buff[0]==0xff)&&(head_buff[1]==0xff)&&(head_buff[2]==0xff)&&(head_buff[3]==0xff)) 
       
           {
             recve_length=head_buff[4];    
             if(recve_length==30)       rcv_new = 1;
             else if(recve_length==34)  rcv_new = 2;  
             verify=1;
           }
        else recve_length=0;
         }
       if(recve_length>0)
         {
         rcv_buf[j-1]=(*((volatile unsigned char *) 0xE000C000));
          if(j==recve_length)              
           {
            j=0;
            recve_length=0;
            verify=0;
            no_full=0;  
            answer_falg=rcv_buf[0]; 
          
          
             
           }
           else j++;
        
         }   
        
     }
     (*((volatile unsigned long *) 0xFFFFF030)) = 0x00;              	    
     
}     





 
void  UART0_Ini(uint32 bps)
{  uint16 Fdiv;
   (*((volatile unsigned char *) 0xE000C00C)) = 0x83;		                  
   Fdiv = (((11059200 * 4) / 4) * 1 / 16) / bps;        
   (*((volatile unsigned char *) 0xE000C004)) = Fdiv / 256;							
   (*((volatile unsigned char *) 0xE000C000)) = Fdiv % 256;						
   (*((volatile unsigned char *) 0xE000C00C)) = 0x03;
   
   (*((volatile unsigned char *) 0xE000C008)) = 0x01;
   (*((volatile unsigned char *) 0xE000C004)) = 0x01;                         
     
   (*((volatile unsigned long *) 0xFFFFF00C)) &=~(1<<6);            
   (*((volatile unsigned long *) 0xFFFFF214))  = 0x20 | 6;          
   (*((volatile unsigned long *) 0xFFFFF114)) = (int)IRQ_UART0;     
   (*((volatile unsigned long *) 0xFFFFF010)) |=(1<<6);            
}				
	
          
			





 
void  UART0_SendByte(uint8 data)
{  (*((volatile unsigned char *) 0xE000C000)) = data;				    

   while( ((*((volatile unsigned char *) 0xE000C014))&0x40)==0 );	    
}





 
uint8 	uart1_rec_flag=0;
void   __irq IRQ_UART1(void)
{ 
   uint8  i;
    if    ( ((*((volatile unsigned long *) 0xE0028014))&0x00200000) == 0 ) (*((volatile unsigned long *) 0xE0028014)) |= 0x00200000;	
      else  (*((volatile unsigned long *) 0xE002801C)) |= 0x00200000;    		 	
  
   if( 0x04==((*((volatile unsigned char *) 0xE0010008))&0x0F))
    {   
      
       switch(uart1_rec_flag)
		{
		case 0:															
		 for(i=0; i<8; i++)
            { 
            rcv_buf1[i] = (*((volatile unsigned char *) 0xE0010000));                 
            }	
		uart1_rec_flag++;													
		break;
		case 1:
		   for(i=8; i<16; i++)
            { 
            rcv_buf1[i] = (*((volatile unsigned char *) 0xE0010000));                 
            }	
			
		uart1_rec_flag	=	0;											
		rcv_new1 = 1;    
	
		break;
		default:
		break;		
		}
     }  
      (*((volatile unsigned long *) 0xFFFFF030)) = 0x00;              	    
  
}     






 
void  UART1_Ini(uint32 bps)
{  uint16 Fdiv;
   (*((volatile unsigned char *) 0xE001000C)) = 0x83;		                  
   Fdiv = (((11059200 * 4) / 4) * 1 / 16) / bps;        
   (*((volatile unsigned char *) 0xE0010004)) = Fdiv / 256;							
   (*((volatile unsigned char *) 0xE0010000)) = Fdiv % 256;						
   (*((volatile unsigned char *) 0xE001000C)) = 0x03;
   
   (*((volatile unsigned char *) 0xE0010008)) = 0x81;                         
   (*((volatile unsigned char *) 0xE0010004)) = 0x01;                         
   
  
  
   (*((volatile unsigned long *) 0xFFFFF00C)) = 0x00000000;            
   (*((volatile unsigned long *) 0xFFFFF200)) = 0x27;                  
   (*((volatile unsigned long *) 0xFFFFF100)) = (int)IRQ_UART1;        
   (*((volatile unsigned long *) 0xFFFFF010)) = 0x00000080;            
}					





 
void  UART1_SendByte(uint8 data)
{  (*((volatile unsigned char *) 0xE0010000)) = data;				    
   (*((volatile unsigned long *) 0xE0028004))=0x00002000;
   while( ((*((volatile unsigned char *) 0xE0010014))&0x40)==0 ){;}	    
   (*((volatile unsigned long *) 0xE002800C))=0x00002000;
}





 
void  UART0_SendStr(uint8 const *str)
{  while(1)
   {  if( *str == '\0' ) break;
      UART0_SendByte(*str++);	    
   }
}







 
void  SendByte0(uint8 data)
{ 
 (*((volatile unsigned char *) 0xE000C000)) = data;                      	
}





 
void  SendByte1(uint8 data)
{  
 (*((volatile unsigned char *) 0xE0010000)) = data;                      	
}






 

void  ISendBuf0(void)
{  uint8  i;
         

















 
  for(i=0; i<16; i++) SendByte0(i);
   while( ((*((volatile unsigned char *) 0xE000C014))&0x20)==0 );         	
}               





 

void  ISendBuf1(void)
{  uint8  i;
   (*((volatile unsigned long *) 0xE0028004))|=0x00002000;
   for(i=0; i<16; i++)
   {
     SendByte1(rcv_buf1[i]);   
   }
   while( ((*((volatile unsigned char *) 0xE0010014))&0x20)==0 ){;}         	
   DelayNS(1);
   (*((volatile unsigned long *) 0xE002800C))|=0x00002000;
}               











































 



⌨️ 快捷键说明

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