![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
n
Fork of LG by
Embed:
(wiki syntax)
Show/hide line numbers
MTimer.c
00001 #include "MTimer.h" 00002 #include "LPC17xx.h" 00003 #include "MTimer.h" 00004 #include "vibro.h" 00005 #include "QEI.h" 00006 #include "Global.h" 00007 #include "SPI.h" 00008 #include "InputOutput.h" 00009 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00010 ////////////////////////////////////////////////////////TIMER1//////////////////////////////////////////////////////////////////////////// 00011 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00012 00013 ////////////////////////////////////////////////////////////////////// 00014 /////////////////////инициализация таймера 1 ///////////////////////// 00015 ////////////////////////////////////////////////////////////////////// 00016 //unsigned int CountV=0; 00017 //unsigned int CountVf=0 ; 00018 unsigned int CountV31=0; 00019 unsigned int CountV255=0 ; 00020 unsigned int CountV64 = 0; 00021 unsigned int init_timer (unsigned int TimerInterval ) 00022 { 00023 //start DAC prepearing for writing 00024 LPC_TIM1->MR0 = TimerInterval; 00025 LPC_TIM1->MCR = 3; /* Interrupt and Reset on MR1 */ 00026 NVIC_EnableIRQ(TIMER1_IRQn ); 00027 //LPC_GPIO0->FIOSET |= (1<<5); 00028 00029 return 0; 00030 } 00031 00032 00033 ////////////////////////////////////////////////////////////////////// 00034 /////////////////////////включение таймера 1////////////////////////// 00035 ////////////////////////////////////////////////////////////////////// 00036 void enable_timer1( void ) 00037 { 00038 LPC_TIM1->TCR = 1; 00039 return; 00040 } 00041 00042 00043 ////////////////////////////////////////////////////////////////////// 00044 /////////////////////////прерывание таймера 1////////////////////////// 00045 ////////////////////////////////////////////////////////////////////// 00046 __irq void TIMER1_IRQHandler (void) 00047 { 00048 //LoopOn 00049 00050 00051 // Init_SPI_Exchange();// CS 00052 ResetCS(ADC); //prepare ADC for sampling 00053 SetDAC(DAC); 00054 00055 CountV255++; 00056 CountV255 &= 0xff; 00057 CountV31 =CountV255 & 0x1f; 00058 CountV64 = CountV255 & 0x3f; 00059 SetCS(ADC); //start ADC sampling 00060 ResetDAC(DAC); 00061 D_QEI(); 00062 00063 cheng(); 00064 00065 // CuruAngle = CuruAngle + Buff_32Point [CountVf] - 0xffff; 00066 CuruAngle = CuruAngle + Buff_32Point [CountV255] - 0xffff; 00067 00068 SPI_Exchange(); //Чтение ADS_SPI 00069 00070 LPC_TIM1->IR = 1; 00071 00072 } 00073 00074 00075 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00076 /////////////////////////////////////////////////TIMER2////////////////////////////////////////////////////////////////////////////////// 00077 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00078 00079 ////////////////////////////////////////////////////////////////////// 00080 /////////////////////инициализация таймера 2 ///////////////////////// 00081 ////////////////////////////////////////////////////////////////////// 00082 unsigned int Init_TIM2 (void) 00083 { 00084 LPC_TIM2->MR0 = 250; 00085 LPC_TIM2->MCR = 3; /* Interrupt and Reset on MR0 */ 00086 NVIC_EnableIRQ(TIMER2_IRQn ); 00087 return 1; 00088 } 00089 00090 00091 00092 ////////////////////////////////////////////////////////////////////// 00093 /////////////////////////включение таймера 2////////////////////////// 00094 ////////////////////////////////////////////////////////////////////// 00095 void enable_timer2(void) 00096 { 00097 LPC_TIM2->TCR = 1; 00098 LPC_TIM2->TCR = 0x01; 00099 } 00100 00101 00102 00103 /////////////////////////////////////////////////////////////////////// 00104 /////////////////////////прерывание таймера 2////////////////////////// 00105 /////////////////////////////////////////////////////////////////////// 00106 __irq void TIMER2_IRQHandler (void) 00107 { 00108 LPC_TIM2->IR = 1; 00109 00110 Global_Time++; 00111 00112 Time_UART++; 00113 00114 Time_vibro++; 00115 00116 Time_1kHz++; 00117 00118 VibroOut(); 00119 00120 00121 }
Generated on Tue Jul 12 2022 15:16:11 by
![doxygen](doxygen.png)