fork

Dependencies:   mbed

Fork of LG by igor Apu

Revision:
21:bc8c1cec3da6
Parent:
15:f5191a1c3805
Child:
42:6fc307c4963e
--- a/MTimer.c	Tue Feb 02 17:14:25 2016 +0000
+++ b/MTimer.c	Wed Feb 03 07:19:30 2016 +0000
@@ -6,120 +6,116 @@
 #include "Global.h"
 #include "SPI.h"
 #include "InputOutput.h"
-		
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////TIMER1////////////////////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
 //////////////////////////////////////////////////////////////////////
-/////////////////////������������� ������� 1 /////////////////////////
+/////////////////////инициализация таймера 1 /////////////////////////
 //////////////////////////////////////////////////////////////////////
 //unsigned int CountV=0;
-//unsigned int CountVf=0 ;	
+//unsigned int CountVf=0 ;
 unsigned int CountV31=0;
-unsigned int CountV255=0 ;	
-		unsigned int init_timer (unsigned int TimerInterval )
-		{
-		  	    			//start DAC prepearing for writing
-			LPC_TIM1->MR0 = TimerInterval;
-			LPC_TIM1->MCR = 3;				/* Interrupt and Reset on MR1 */
-			NVIC_EnableIRQ(TIMER1_IRQn);
-			//LPC_GPIO0->FIOSET   |= (1<<5);
-			
-			return 0;
-		}
-		
-		
+unsigned int CountV255=0 ;
+unsigned int CountV64  = 0;
+unsigned int init_timer (unsigned int TimerInterval )
+{
+    //start DAC prepearing for writing
+    LPC_TIM1->MR0 = TimerInterval;
+    LPC_TIM1->MCR = 3;				/* Interrupt and Reset on MR1 */
+    NVIC_EnableIRQ(TIMER1_IRQn);
+    //LPC_GPIO0->FIOSET   |= (1<<5);
+
+    return 0;
+}
+
+
 //////////////////////////////////////////////////////////////////////
-/////////////////////////��������� ������� 1//////////////////////////
+/////////////////////////включение таймера 1//////////////////////////
 //////////////////////////////////////////////////////////////////////
-		void enable_timer1( void )
-		{
-			LPC_TIM1->TCR = 1;
-			return;
-		}
-		
-		
-//////////////////////////////////////////////////////////////////////
-/////////////////////////���������� ������� 1//////////////////////////
+void enable_timer1( void )
+{
+    LPC_TIM1->TCR = 1;
+    return;
+}
+
+
 //////////////////////////////////////////////////////////////////////
-		__irq void TIMER1_IRQHandler (void)  
-		{ 
-//LoopOn	
-			
-			
-		//  Init_SPI_Exchange();// CS
-			ResetCS(ADC);					  	 //prepare ADC for sampling
-		  SetDAC(DAC);		
-     	  
-			CountV255++;
-		  CountV255 &= 0xff;
-	  	CountV31 =CountV255 & 0x1f;
-			
-			SetCS(ADC);					    		//start ADC sampling
-	  	ResetDAC(DAC);
-			D_QEI();
-			
-			cheng();
-			
+/////////////////////////прерывание таймера 1//////////////////////////
+//////////////////////////////////////////////////////////////////////
+__irq void TIMER1_IRQHandler (void)
+{
+//LoopOn
+
+
+    //  Init_SPI_Exchange();// CS
+    ResetCS(ADC);					  	 //prepare ADC for sampling
+    SetDAC(DAC);
+
+    CountV255++;
+    CountV255 &= 0xff;
+    CountV31 =CountV255 & 0x1f;
+    CountV64 = CountV255 & 0x3f;
+    SetCS(ADC);					    		//start ADC sampling
+    ResetDAC(DAC);
+    D_QEI();
+
+    cheng();
+
 //			CuruAngle = CuruAngle + Buff_32Point [CountVf] - 0xffff;
-				CuruAngle = CuruAngle + Buff_32Point [CountV255] - 0xffff;
-			
-			SPI_Exchange(); //������ ADS_SPI
-			
-			LPC_TIM1->IR = 1;
-			
-		}
+    CuruAngle = CuruAngle + Buff_32Point [CountV255] - 0xffff;
+
+    SPI_Exchange(); //Чтение ADS_SPI
+
+    LPC_TIM1->IR = 1;
+
+}
 
 
 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 /////////////////////////////////////////////////TIMER2//////////////////////////////////////////////////////////////////////////////////
 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-		
-//////////////////////////////////////////////////////////////////////
-/////////////////////������������� ������� 2 /////////////////////////
+
 //////////////////////////////////////////////////////////////////////
-		unsigned int Init_TIM2 (void) 
-		{
-			LPC_TIM2->MR0 = 250;
-			LPC_TIM2->MCR = 3;				/* Interrupt and Reset on MR0 */
-			NVIC_EnableIRQ(TIMER2_IRQn);
-			return 1;
-		}
-
-		
-		
-//////////////////////////////////////////////////////////////////////
-/////////////////////////��������� ������� 2//////////////////////////
+/////////////////////инициализация таймера 2 /////////////////////////
 //////////////////////////////////////////////////////////////////////
-		void enable_timer2(void)
-		{
-			LPC_TIM2->TCR = 1;
-			LPC_TIM2->TCR = 0x01;
-		}
+unsigned int Init_TIM2 (void)
+{
+    LPC_TIM2->MR0 = 250;
+    LPC_TIM2->MCR = 3;				/* Interrupt and Reset on MR0 */
+    NVIC_EnableIRQ(TIMER2_IRQn);
+    return 1;
+}
 
-		
-		
-///////////////////////////////////////////////////////////////////////
-/////////////////////////���������� ������� 2//////////////////////////
-///////////////////////////////////////////////////////////////////////
-		__irq void TIMER2_IRQHandler (void)  
-		{	
-			LPC_TIM2->IR = 1;
-			
-			Global_Time++;
-			
-			Time_UART++;
-					
-			Time_vibro++;
-			
-			Time_1kHz++;
-			
-			VibroOut();
-			
-			Event100K++;
 
 
-			
-      
-		}
+//////////////////////////////////////////////////////////////////////
+/////////////////////////включение таймера 2//////////////////////////
+//////////////////////////////////////////////////////////////////////
+void enable_timer2(void)
+{
+    LPC_TIM2->TCR = 1;
+    LPC_TIM2->TCR = 0x01;
+}
+
+
+
+///////////////////////////////////////////////////////////////////////
+/////////////////////////прерывание таймера 2//////////////////////////
+///////////////////////////////////////////////////////////////////////
+__irq void TIMER2_IRQHandler (void)
+{
+    LPC_TIM2->IR = 1;
+
+    Global_Time++;
+
+    Time_UART++;
+
+    Time_vibro++;
+
+    Time_1kHz++;
+
+    VibroOut();
+
+
+}
\ No newline at end of file