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

📄 global_function.c

📁 ARM s3c44box的一些程序代码
💻 C
字号:
#include "global_function.h"


// enalbe the I bit in current CPSR
void EnableIRQ(void)
{
 	int tmp;
 	__asm
 	{
 		mrs		tmp,CPSR
 		bic		tmp,tmp,#0x80
 		msr		CPSR_c,tmp
 	}
}

// enable the F bit in current CPSR
void EnableFIQ(void)
{
	int tmp;
	__asm
	{
		mrs		tmp,CPSR	
		bic 	tmp,tmp,#0x40
		msr		CPSR_c,tmp
	}
}

// disable the I bit in current CPSR
void DisableIRQ(void)
{
 	int tmp;
 	__asm
 	{
 		mrs		tmp,CPSR
 		orr		tmp,tmp,#0x80
 		msr		CPSR_c,tmp
 	}
}

// enable the F bit in current CPSR
void DisableFIQ(void)
{
	int tmp;
	__asm
	{
		mrs		tmp,CPSR	
		orr 		tmp,tmp,#0x40
		msr		CPSR_c,tmp
	}
}

/*
// time delay -- unit: ms
// use timer5 to caculate delay time
// please considerate it carefully to avoid timer use conflict
void Delay(unsigned int count)
{
  	unsigned int rTCFG0_save, rTCFG1_save, rTCON_save;
  	unsigned int i = 0;
	
	rTCFG0_save = rTCFG0;
	rTCFG1_save = rTCFG1;
	rTCON_save  = rTCON;
	
    rTCFG0 = rTCFG0 & (B32)0xff00ffff | (B32)0x004a0000;  //timer5 prescaler = 74+1
    rTCFG1 = rTCFG1 & (B32)0xff0fffff | (B32)0x00300000;  //timer divider: 1/16
        							// 
    								// MCLK = 60M : period = 1/60 * 16 * 75 = 20us
	
    rTCNTB5 = (B32)100;				// 
    	
    for(i = 0; i < count; i++) 
      {
    	rTCON = rTCON & (B32)0xf0ffffff | (B32)0x02000000;	// auto-reload disable and load initial count num to counter
    	rTCON =	rTCON & (B32)0xf0ffffff | (B32)0x01000000;	// start counter
    	
    	while(1)
    	  {
    		if(rTCNTO5 == 0)
    			break;
    	  }
	  }
	  
	rTCFG0 = rTCFG0_save;
	rTCFG1 = rTCFG1_save;
	rTCON  = rTCON_save;
}
*/
void Delay(unsigned int count)
{
  unsigned int i, j;
  
  for(i = 0; i < count; i++)
  	for(j = 0; j < 1650; j++);
}



B8 getBCD(B8 count)
{
    switch(count)
    	{
    	 case 0	:	return(BCD_0);
    	 case 1	:    	return(BCD_1);
    	 case 2	:	return(BCD_2);
    	 case 3	:	return(BCD_3);
    	 case 4	:	return(BCD_4);
    	 case 5	:    	return(BCD_5);
    	 case 6	:	return(BCD_6);
    	 case 7	:	return(BCD_7);
	 case 8	:	return(BCD_8);
    	 case 9	:    	return(BCD_9);
    	 case 10	:	return(BCD_P);		//display: point
    	 default	:	return(BCD_E);		//display: E  ~~ error
    	}
}


void IntInit(void)
{
    //* int init
    rINTCON  = 0x1;					// IRQ/vectored IRQ enable
    rINTMOD  = 0x0;					// IRQ mode
    //EnableIRQ();
    //* int priority is default 
    //rINTPSLV
    //rINTPMST

    EnableIRQ();
}

⌨️ 快捷键说明

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