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

📄 timer.c

📁 S3C2440A + ADS 控制timer 的驱动
💻 C
字号:
#include "timer.h"
#include "key.h"
#include  "2440addr.h"
#include "uart.h"
#include "led.h"

int timer4_count=0x0; //the timer4_count controll vary time,led on/off

void __irq Timer4(void)    //this use timer4 controll interrupt
{
   rSRCPND &= ~(1<<14); 
   rSRCPND |=  (1<<14);
   
   
   rINTPND &= ~(1<<14);
   rINTPND |=  (1<<14);
  
	key_scan ();	   //key_scan() in" key.c"  this controll of take out repeat for key 

	time_count();      //this enter for vary time controll led on/off

	//Timer1_Eint ();

}


 void time_count(void)  // this controll led on/off entren

 	{
 	    timer4_count++;

		  if(!(timer4_count%30000))
      {
      	  led_onRun();
      }
	    if(!(timer4_count%50000))
	  	{
	  	    led_onAll();

	    }

	   /*if(!(timer4_count%50000))
	  	{
	  	    led_offAll();

	    }*/
		
   
       // timer4_count=0;
	  //if(timer4_count%500);
   }


 void  Timer4_Eint (void)       //timer4 intialize
{

		rTCFG0 &= ~(0xff<<8);
		rTCFG0 |= (2500<<8);
		
	    rTCFG1 &= ~(0xff<<16);
		rTCFG1 |= (0x00<<16);
		
		rTCNTB4 = 10; 

		rTCON  &= ~(1<<21);
		rTCON  |= (7<<20);
		//rTCON = ((rTCON&(~(1<<21)))|1<<21);

		rSRCPND |= BIT_TIMER4; //to clear the previous pending states

		rINTPND |= BIT_TIMER4;  //to clear the previous rINTPND states

		rINTMSK &= ~(1<<14);
		
		rTCON  &= ~(1<<21);
		rTCON |= (1<<20)|(1<<22);
		
		pISR_TIMER4 = (unsigned)Timer4;
		     
        
  }


 
  void	Timer1_Eint (void)  //timer1 initialize to controll BEEP_PWM
 {    
         rGPBCON &= ~(3<<2);
		 rGPBCON |= (2<<2);
 
		 rTCFG0 &= ~(0xff);
		 rTCFG0 |= (2500);
		 
		 rTCFG1 &= ~((0xf<<20)|(0xf<<4));
		 rTCFG1 |= ((0x0<<20)|(0x0<<4));
		 
		 rTCNTB1 = 100; 
		 rTCMPB1 = rTCNTB1>>2;	// 50%
 
		 rTCON	&= ~(1<<9);
		 rTCON	|= (0xb<<8);
		 
		 rTCON	&= ~(1<<9);
	   

		 
   }
 
 
 

⌨️ 快捷键说明

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