![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
forkd
Fork of LGstaandart by
MTimer.c@226:4a4d5bd5fcd7, 2017-12-26 (annotated)
- Committer:
- Kovalev_D
- Date:
- Tue Dec 26 05:14:09 2017 +0000
- Revision:
- 226:4a4d5bd5fcd7
- Parent:
- 225:f8fee6c586cc
- Child:
- 227:2774b56bfab0
4hfo_1plc
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
igor_v | 0:8ad47e2b6f00 | 1 | #include "MTimer.h" |
igor_v | 0:8ad47e2b6f00 | 2 | #include "LPC17xx.h" |
igor_v | 0:8ad47e2b6f00 | 3 | #include "MTimer.h" |
igor_v | 0:8ad47e2b6f00 | 4 | #include "vibro.h" |
igor_v | 0:8ad47e2b6f00 | 5 | #include "QEI.h" |
igor_v | 0:8ad47e2b6f00 | 6 | #include "Global.h" |
igor_v | 0:8ad47e2b6f00 | 7 | #include "SPI.h" |
igor_v | 0:8ad47e2b6f00 | 8 | #include "InputOutput.h" |
Kovalev_D | 112:4a96133a1311 | 9 | |
Kovalev_D | 197:7a05523bf588 | 10 | unsigned int CountV64=0; |
igor_v | 0:8ad47e2b6f00 | 11 | unsigned int CountV31=0; |
Kovalev_D | 197:7a05523bf588 | 12 | unsigned int CountV255=0; |
Kovalev_D | 215:b58b887fd367 | 13 | unsigned int CountV511=0; |
Kovalev_D | 209:224e7331a061 | 14 | unsigned int f,MODCount=0; |
Kovalev_D | 124:9ae09249f842 | 15 | int loop=0; |
Kovalev_D | 208:19150d2b528f | 16 | int t; |
Kovalev_D | 88:b5c1d9d338d1 | 17 | ///////////////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 18 | /////////////////////EVENT/////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 19 | ///////////////////////////////////////////////////// |
Kovalev_D | 89:a0d344db227e | 20 | ///////////////////////////////////////////////////// |
Kovalev_D | 214:4c70e452c491 | 21 | ///////////////////// 1250Hz /////////////////////////// |
Kovalev_D | 214:4c70e452c491 | 22 | ///////////////////////////////////////////////////// |
Kovalev_D | 214:4c70e452c491 | 23 | void Event_1250Hz(void)// событие раз в 1,25 КГц |
Kovalev_D | 214:4c70e452c491 | 24 | { |
Kovalev_D | 214:4c70e452c491 | 25 | if(Event1250Hz) |
Kovalev_D | 214:4c70e452c491 | 26 | { |
Kovalev_D | 214:4c70e452c491 | 27 | Gyro.EvenRate7=1; |
Kovalev_D | 215:b58b887fd367 | 28 | |
Kovalev_D | 214:4c70e452c491 | 29 | Event1250Hz--; |
Kovalev_D | 215:b58b887fd367 | 30 | |
Kovalev_D | 214:4c70e452c491 | 31 | } |
Kovalev_D | 214:4c70e452c491 | 32 | } |
Kovalev_D | 222:7de7b3bf3a1d | 33 | |
Kovalev_D | 222:7de7b3bf3a1d | 34 | |
Kovalev_D | 222:7de7b3bf3a1d | 35 | |
Kovalev_D | 222:7de7b3bf3a1d | 36 | |
Kovalev_D | 222:7de7b3bf3a1d | 37 | void JumpMod(void) |
Kovalev_D | 222:7de7b3bf3a1d | 38 | { |
Kovalev_D | 222:7de7b3bf3a1d | 39 | static int JumpFlag=0; |
Kovalev_D | 222:7de7b3bf3a1d | 40 | switch(JumpFlag) { |
Kovalev_D | 222:7de7b3bf3a1d | 41 | case 0: |
Kovalev_D | 222:7de7b3bf3a1d | 42 | Spi.DAC_B-=Gyro.JumpDelta; |
Kovalev_D | 222:7de7b3bf3a1d | 43 | JumpFlag=1; |
Kovalev_D | 222:7de7b3bf3a1d | 44 | break; |
Kovalev_D | 222:7de7b3bf3a1d | 45 | case 1: |
Kovalev_D | 222:7de7b3bf3a1d | 46 | Spi.DAC_B+=Gyro.JumpDelta; |
Kovalev_D | 222:7de7b3bf3a1d | 47 | JumpFlag=0; |
Kovalev_D | 222:7de7b3bf3a1d | 48 | break; |
Kovalev_D | 222:7de7b3bf3a1d | 49 | } |
Kovalev_D | 222:7de7b3bf3a1d | 50 | |
Kovalev_D | 222:7de7b3bf3a1d | 51 | } |
Kovalev_D | 222:7de7b3bf3a1d | 52 | |
Kovalev_D | 222:7de7b3bf3a1d | 53 | |
Kovalev_D | 214:4c70e452c491 | 54 | ///////////////////////////////////////////////////// |
Kovalev_D | 89:a0d344db227e | 55 | ///////////////////// 1Hz /////////////////////////// |
Kovalev_D | 89:a0d344db227e | 56 | ///////////////////////////////////////////////////// |
Kovalev_D | 222:7de7b3bf3a1d | 57 | |
Kovalev_D | 88:b5c1d9d338d1 | 58 | void Event_1Hz(void)// событие раз в 1 Гц |
Kovalev_D | 222:7de7b3bf3a1d | 59 | { |
Kovalev_D | 222:7de7b3bf3a1d | 60 | static int tempdac=0,tempdac1,JumpTimer=0; |
Kovalev_D | 115:e5a230e5af52 | 61 | if (Event1Hz) |
Kovalev_D | 222:7de7b3bf3a1d | 62 | { |
Kovalev_D | 226:4a4d5bd5fcd7 | 63 | |
Kovalev_D | 226:4a4d5bd5fcd7 | 64 | |
Kovalev_D | 226:4a4d5bd5fcd7 | 65 | /* sprintf((Time),"%d \r\n",Gyro.EXT_Latch); |
Kovalev_D | 226:4a4d5bd5fcd7 | 66 | WriteCon(Time);*/ |
Kovalev_D | 226:4a4d5bd5fcd7 | 67 | |
Kovalev_D | 226:4a4d5bd5fcd7 | 68 | |
Kovalev_D | 222:7de7b3bf3a1d | 69 | if(Gyro.RgConA&0x4) JumpTimer=0; |
Kovalev_D | 222:7de7b3bf3a1d | 70 | else |
Kovalev_D | 222:7de7b3bf3a1d | 71 | { |
Kovalev_D | 222:7de7b3bf3a1d | 72 | /*sprintf((Time),"%d %d\r\n",Gyro.RgConA,JumpTimer); |
Kovalev_D | 222:7de7b3bf3a1d | 73 | WriteCon(Time);*/ |
Kovalev_D | 222:7de7b3bf3a1d | 74 | JumpTimer++; |
Kovalev_D | 222:7de7b3bf3a1d | 75 | if(JumpTimer>(Gyro.TimeToJump-1)) |
Kovalev_D | 222:7de7b3bf3a1d | 76 | { |
Kovalev_D | 225:f8fee6c586cc | 77 | Gyro.PLCDelay = GyroP.Str.PLCDelay; |
Kovalev_D | 222:7de7b3bf3a1d | 78 | JumpMod(); |
Kovalev_D | 222:7de7b3bf3a1d | 79 | JumpTimer=0; |
Kovalev_D | 222:7de7b3bf3a1d | 80 | } |
Kovalev_D | 222:7de7b3bf3a1d | 81 | } |
Kovalev_D | 222:7de7b3bf3a1d | 82 | |
Kovalev_D | 222:7de7b3bf3a1d | 83 | |
Kovalev_D | 222:7de7b3bf3a1d | 84 | /*if(Gyro.ShowMod2) |
Kovalev_D | 220:04c54405b82d | 85 | { |
Kovalev_D | 220:04c54405b82d | 86 | sprintf((Time),"%d %d %d\r\n",Spi.DAC_B,AMPSUM_DESP,Spi.DAC_A); |
Kovalev_D | 220:04c54405b82d | 87 | WriteCon(Time); |
Kovalev_D | 220:04c54405b82d | 88 | Spi.DAC_B+=200; |
Kovalev_D | 222:7de7b3bf3a1d | 89 | }*/ |
Kovalev_D | 222:7de7b3bf3a1d | 90 | |
Kovalev_D | 208:19150d2b528f | 91 | Discharg(); |
Kovalev_D | 208:19150d2b528f | 92 | BackLight(); |
Kovalev_D | 208:19150d2b528f | 93 | Gyro.Rate1_Event = 1; |
Kovalev_D | 208:19150d2b528f | 94 | Event1Hz--; |
Kovalev_D | 208:19150d2b528f | 95 | Time1Hz++; |
Kovalev_D | 214:4c70e452c491 | 96 | // sprintf((Time),"%d \r\n",Gyro.ModeOut ); |
Kovalev_D | 214:4c70e452c491 | 97 | // WriteCon(Time); |
Kovalev_D | 222:7de7b3bf3a1d | 98 | } |
Kovalev_D | 88:b5c1d9d338d1 | 99 | } |
Kovalev_D | 222:7de7b3bf3a1d | 100 | |
Kovalev_D | 89:a0d344db227e | 101 | ///////////////////////////////////////////////////// |
Kovalev_D | 89:a0d344db227e | 102 | ///////////////////// 1kHz ////////////////////////// |
Kovalev_D | 197:7a05523bf588 | 103 | ///////////////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 104 | void Event_1KHz(void)// событие раз в 1 кГц |
Kovalev_D | 214:4c70e452c491 | 105 | { if (Event1K) |
Kovalev_D | 116:66f1f0ff2dab | 106 | { |
Kovalev_D | 214:4c70e452c491 | 107 | if(Gyro.PLCDelay) Gyro.PLCDelay--; |
Kovalev_D | 88:b5c1d9d338d1 | 108 | Event1K --; |
Kovalev_D | 215:b58b887fd367 | 109 | |
Kovalev_D | 116:66f1f0ff2dab | 110 | Time1K++;//первый ++ работает каждые 125 (event100kHz)второй был в 100 кГц |
Kovalev_D | 209:224e7331a061 | 111 | if (Time1K > 1000) |
Kovalev_D | 115:e5a230e5af52 | 112 | { |
Kovalev_D | 208:19150d2b528f | 113 | Time1K -=1000; |
Kovalev_D | 88:b5c1d9d338d1 | 114 | Event1Hz ++; |
Kovalev_D | 88:b5c1d9d338d1 | 115 | } |
Kovalev_D | 209:224e7331a061 | 116 | |
Kovalev_D | 214:4c70e452c491 | 117 | } |
Kovalev_D | 88:b5c1d9d338d1 | 118 | } |
Kovalev_D | 209:224e7331a061 | 119 | |
Kovalev_D | 222:7de7b3bf3a1d | 120 | void Event_5KHz(void)// событие раз в 5 кГц |
Kovalev_D | 218:b4067cac75c0 | 121 | { |
Kovalev_D | 218:b4067cac75c0 | 122 | int temp=0; |
Kovalev_D | 222:7de7b3bf3a1d | 123 | if (Event5K) |
Kovalev_D | 222:7de7b3bf3a1d | 124 | { |
Kovalev_D | 222:7de7b3bf3a1d | 125 | Gyro.EvenRate5K++; |
Kovalev_D | 222:7de7b3bf3a1d | 126 | Event5K --; |
Kovalev_D | 209:224e7331a061 | 127 | } |
Kovalev_D | 209:224e7331a061 | 128 | } |
Kovalev_D | 124:9ae09249f842 | 129 | void Event_500Hz(void)// событие раз в 500 Гц |
Kovalev_D | 124:9ae09249f842 | 130 | { |
Kovalev_D | 124:9ae09249f842 | 131 | if(Event500Hz) |
Kovalev_D | 225:f8fee6c586cc | 132 | { |
Kovalev_D | 225:f8fee6c586cc | 133 | if(Gyro.Debag2) |
Kovalev_D | 225:f8fee6c586cc | 134 | { |
Kovalev_D | 226:4a4d5bd5fcd7 | 135 | sprintf((Time),"%d %d \r\n", (0xffff-Spi.DAC_A)-30000, ((Spi.DAC_B-0x7fff)&0xffff)); |
Kovalev_D | 225:f8fee6c586cc | 136 | WriteCon(Time); |
Kovalev_D | 225:f8fee6c586cc | 137 | } |
Kovalev_D | 205:775d54fdf646 | 138 | Event500Hz--; |
Kovalev_D | 208:19150d2b528f | 139 | Gyro.Event_500Hz=1;// Event 500Гц выдачи данных для постройки графика управления вибро |
Kovalev_D | 197:7a05523bf588 | 140 | } |
Kovalev_D | 197:7a05523bf588 | 141 | } |
Kovalev_D | 209:224e7331a061 | 142 | void Event_250Hz(void) |
Kovalev_D | 209:224e7331a061 | 143 | { |
Kovalev_D | 209:224e7331a061 | 144 | if(Event250Hz) |
Kovalev_D | 209:224e7331a061 | 145 | { |
Kovalev_D | 218:b4067cac75c0 | 146 | |
Kovalev_D | 209:224e7331a061 | 147 | // Gyro.CuruAngle=0; |
Kovalev_D | 209:224e7331a061 | 148 | Event250Hz--; |
Kovalev_D | 209:224e7331a061 | 149 | MODCount++; |
Kovalev_D | 209:224e7331a061 | 150 | } |
Kovalev_D | 209:224e7331a061 | 151 | } |
Kovalev_D | 89:a0d344db227e | 152 | ///////////////////////////////////////////////////// |
Kovalev_D | 89:a0d344db227e | 153 | ///////////////////// 100kHz ////////////////////////// |
Kovalev_D | 89:a0d344db227e | 154 | ///////////////////////////////////////////////////// |
Kovalev_D | 193:a0fe8bfc97e4 | 155 | void Event_100KHz(void)// событие раз в 100 кГц |
Kovalev_D | 88:b5c1d9d338d1 | 156 | { |
Kovalev_D | 162:44e4ded32c6a | 157 | |
Kovalev_D | 88:b5c1d9d338d1 | 158 | if (Event100K) { |
Kovalev_D | 197:7a05523bf588 | 159 | |
Kovalev_D | 88:b5c1d9d338d1 | 160 | Event100K --; |
Kovalev_D | 197:7a05523bf588 | 161 | |
Kovalev_D | 124:9ae09249f842 | 162 | if (OutBufCon1Count)OutBufCon1Count--; // обратный отсчет для управления ногой и формирование задержки на выдачу |
Kovalev_D | 124:9ae09249f842 | 163 | |
Kovalev_D | 124:9ae09249f842 | 164 | PinCheng(); // чтение регистра состояния выводов(вибро, полсветка, поджиг, LED) и управление выводами. |
Kovalev_D | 88:b5c1d9d338d1 | 165 | } |
Kovalev_D | 88:b5c1d9d338d1 | 166 | } |
Kovalev_D | 89:a0d344db227e | 167 | ///////////////////////////////////////////////////// |
Kovalev_D | 89:a0d344db227e | 168 | //////////////////vibro EVENT//////////////////////// |
Kovalev_D | 89:a0d344db227e | 169 | ///////////////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 170 | void Event_Vibro(void)// событие от вибр |
Kovalev_D | 88:b5c1d9d338d1 | 171 | { |
Kovalev_D | 88:b5c1d9d338d1 | 172 | if (EventVibro) { |
Kovalev_D | 88:b5c1d9d338d1 | 173 | EventVibro --; |
Kovalev_D | 88:b5c1d9d338d1 | 174 | } |
Kovalev_D | 88:b5c1d9d338d1 | 175 | } |
Kovalev_D | 89:a0d344db227e | 176 | ///////////////////////////////////////////////////// |
Kovalev_D | 89:a0d344db227e | 177 | ///////////////////////////////////////////////////// |
Kovalev_D | 89:a0d344db227e | 178 | ///////////////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 179 | |
Kovalev_D | 88:b5c1d9d338d1 | 180 | |
Kovalev_D | 112:4a96133a1311 | 181 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
Kovalev_D | 112:4a96133a1311 | 182 | ////////////////////////////////////////////////////////TIMER1//////////////////////////////////////////////////////////////////////////// |
Kovalev_D | 112:4a96133a1311 | 183 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
Kovalev_D | 112:4a96133a1311 | 184 | |
Kovalev_D | 112:4a96133a1311 | 185 | ////////////////////////////////////////////////////////////////////// |
Kovalev_D | 112:4a96133a1311 | 186 | /////////////////////инициализация таймера 1 ///////////////////////// |
Kovalev_D | 112:4a96133a1311 | 187 | ////////////////////////////////////////////////////////////////////// |
Kovalev_D | 112:4a96133a1311 | 188 | |
Kovalev_D | 112:4a96133a1311 | 189 | unsigned int Init_TIM1 (unsigned int TimerInterval ) |
Kovalev_D | 112:4a96133a1311 | 190 | { |
Kovalev_D | 214:4c70e452c491 | 191 | // LPC_SC->PCLKSEL0 |= (1<<4); |
Kovalev_D | 220:04c54405b82d | 192 | |
Kovalev_D | 112:4a96133a1311 | 193 | LPC_TIM1->MR0 = TimerInterval; |
Kovalev_D | 112:4a96133a1311 | 194 | LPC_TIM1->MCR = 3; /* Interrupt and Reset on MR1 */ |
Kovalev_D | 112:4a96133a1311 | 195 | NVIC_EnableIRQ(TIMER1_IRQn); |
Kovalev_D | 112:4a96133a1311 | 196 | } |
Kovalev_D | 112:4a96133a1311 | 197 | |
Kovalev_D | 112:4a96133a1311 | 198 | |
igor_v | 0:8ad47e2b6f00 | 199 | ////////////////////////////////////////////////////////////////////// |
igor_v | 21:bc8c1cec3da6 | 200 | /////////////////////////включение таймера 1////////////////////////// |
igor_v | 0:8ad47e2b6f00 | 201 | ////////////////////////////////////////////////////////////////////// |
igor_v | 21:bc8c1cec3da6 | 202 | void enable_timer1( void ) |
igor_v | 21:bc8c1cec3da6 | 203 | { |
igor_v | 21:bc8c1cec3da6 | 204 | LPC_TIM1->TCR = 1; |
igor_v | 21:bc8c1cec3da6 | 205 | return; |
igor_v | 21:bc8c1cec3da6 | 206 | } |
igor_v | 0:8ad47e2b6f00 | 207 | |
igor_v | 0:8ad47e2b6f00 | 208 | |
igor_v | 0:8ad47e2b6f00 | 209 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
igor_v | 0:8ad47e2b6f00 | 210 | /////////////////////////////////////////////////TIMER2////////////////////////////////////////////////////////////////////////////////// |
igor_v | 0:8ad47e2b6f00 | 211 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
igor_v | 21:bc8c1cec3da6 | 212 | |
igor_v | 0:8ad47e2b6f00 | 213 | ////////////////////////////////////////////////////////////////////// |
igor_v | 21:bc8c1cec3da6 | 214 | /////////////////////инициализация таймера 2 ///////////////////////// |
igor_v | 0:8ad47e2b6f00 | 215 | ////////////////////////////////////////////////////////////////////// |
igor_v | 21:bc8c1cec3da6 | 216 | unsigned int Init_TIM2 (void) |
igor_v | 21:bc8c1cec3da6 | 217 | { |
Kovalev_D | 124:9ae09249f842 | 218 | LPC_TIM2->MR0 = 257; |
igor_v | 21:bc8c1cec3da6 | 219 | LPC_TIM2->MCR = 3; /* Interrupt and Reset on MR0 */ |
igor_v | 21:bc8c1cec3da6 | 220 | NVIC_EnableIRQ(TIMER2_IRQn); |
igor_v | 21:bc8c1cec3da6 | 221 | return 1; |
igor_v | 21:bc8c1cec3da6 | 222 | } |
igor_v | 0:8ad47e2b6f00 | 223 | |
igor_v | 21:bc8c1cec3da6 | 224 | ////////////////////////////////////////////////////////////////////// |
igor_v | 21:bc8c1cec3da6 | 225 | /////////////////////////включение таймера 2////////////////////////// |
igor_v | 21:bc8c1cec3da6 | 226 | ////////////////////////////////////////////////////////////////////// |
igor_v | 21:bc8c1cec3da6 | 227 | void enable_timer2(void) |
igor_v | 21:bc8c1cec3da6 | 228 | { |
igor_v | 21:bc8c1cec3da6 | 229 | LPC_TIM2->TCR = 1; |
igor_v | 21:bc8c1cec3da6 | 230 | LPC_TIM2->TCR = 0x01; |
igor_v | 21:bc8c1cec3da6 | 231 | } |
igor_v | 21:bc8c1cec3da6 | 232 | |
igor_v | 21:bc8c1cec3da6 | 233 | |
Kovalev_D | 112:4a96133a1311 | 234 | ////////////////////////////////////////////////////////////////////// |
Kovalev_D | 112:4a96133a1311 | 235 | /////////////////////////прерывание таймера 1////////////////////////// |
Kovalev_D | 112:4a96133a1311 | 236 | ////////////////////////////////////////////////////////////////////// |
Kovalev_D | 215:b58b887fd367 | 237 | __irq void TIMER1_IRQHandler (void)//13.27 kHz(vibro*32) |
Kovalev_D | 205:775d54fdf646 | 238 | { |
Kovalev_D | 208:19150d2b528f | 239 | |
igor_v | 114:5cc38a53d8a7 | 240 | ResetCS(ADC); //prepare ADC for sampling |
Kovalev_D | 112:4a96133a1311 | 241 | SetDAC(DAC); |
Kovalev_D | 208:19150d2b528f | 242 | Global_Time++; |
igor_v | 114:5cc38a53d8a7 | 243 | CountV255++; // инкремент счеттчика |
Kovalev_D | 215:b58b887fd367 | 244 | CountV511++; |
Kovalev_D | 164:6f43f85fdd8d | 245 | CountV255 &= 0xff; // ОБРЕЗАНИЕ СЧЕТЧИКА |
Kovalev_D | 215:b58b887fd367 | 246 | CountV511 &= 0x1ff; |
Kovalev_D | 197:7a05523bf588 | 247 | CountV64 = CountV255 & 0x3f; |
Kovalev_D | 197:7a05523bf588 | 248 | CountV31 = CountV255 & 0x1f; // малый счетчик |
Kovalev_D | 197:7a05523bf588 | 249 | |
Kovalev_D | 112:4a96133a1311 | 250 | D_QEI(); //чтение данных по счетчику |
Kovalev_D | 143:2b15794a6cd2 | 251 | cheng(); // выставление флагов в 32 тактном цикле. |
Kovalev_D | 116:66f1f0ff2dab | 252 | |
Kovalev_D | 116:66f1f0ff2dab | 253 | |
Kovalev_D | 116:66f1f0ff2dab | 254 | SetCS(ADC); //start ADC sampling |
Kovalev_D | 116:66f1f0ff2dab | 255 | ResetDAC(DAC); |
Kovalev_D | 197:7a05523bf588 | 256 | SPI_Exchange(); //Чтение ADC_SPI |
igor_v | 114:5cc38a53d8a7 | 257 | |
Kovalev_D | 214:4c70e452c491 | 258 | LPC_TIM1->IR = 1; |
Kovalev_D | 208:19150d2b528f | 259 | |
Kovalev_D | 112:4a96133a1311 | 260 | } |
Kovalev_D | 112:4a96133a1311 | 261 | |
igor_v | 21:bc8c1cec3da6 | 262 | /////////////////////////////////////////////////////////////////////// |
igor_v | 21:bc8c1cec3da6 | 263 | /////////////////////////прерывание таймера 2////////////////////////// |
igor_v | 21:bc8c1cec3da6 | 264 | /////////////////////////////////////////////////////////////////////// |
igor_v | 21:bc8c1cec3da6 | 265 | __irq void TIMER2_IRQHandler (void) |
Kovalev_D | 210:b02fa166315d | 266 | { |
Kovalev_D | 213:9953db9543d6 | 267 | /// LoopOn |
igor_v | 21:bc8c1cec3da6 | 268 | LPC_TIM2->IR = 1; |
Kovalev_D | 213:9953db9543d6 | 269 | if (Gyro.UARTFlag) |
Kovalev_D | 213:9953db9543d6 | 270 | { |
Kovalev_D | 213:9953db9543d6 | 271 | if(Time_UART) Time_UART--; |
Kovalev_D | 213:9953db9543d6 | 272 | } |
Kovalev_D | 214:4c70e452c491 | 273 | // |
Kovalev_D | 214:4c70e452c491 | 274 | |
igor_v | 21:bc8c1cec3da6 | 275 | Time_vibro++; |
Kovalev_D | 214:4c70e452c491 | 276 | // VibroOut(); |
Kovalev_D | 112:4a96133a1311 | 277 | Gyro.VibroOutF=1; |
Kovalev_D | 214:4c70e452c491 | 278 | Event100K ++; |
Kovalev_D | 214:4c70e452c491 | 279 | Time1250Hz++; |
Kovalev_D | 197:7a05523bf588 | 280 | Time500Hz++; |
Kovalev_D | 209:224e7331a061 | 281 | Time250Hz++; |
Kovalev_D | 197:7a05523bf588 | 282 | Time100K++; |
Kovalev_D | 222:7de7b3bf3a1d | 283 | Time5K++; |
Kovalev_D | 209:224e7331a061 | 284 | //Time2K++; |
Kovalev_D | 205:775d54fdf646 | 285 | // Time250Hz++; |
Kovalev_D | 214:4c70e452c491 | 286 | |
Kovalev_D | 214:4c70e452c491 | 287 | if (Time1250Hz > 79) |
Kovalev_D | 214:4c70e452c491 | 288 | { |
Kovalev_D | 214:4c70e452c491 | 289 | Time1250Hz -= 80; |
Kovalev_D | 214:4c70e452c491 | 290 | Event1250Hz ++; |
Kovalev_D | 214:4c70e452c491 | 291 | } |
Kovalev_D | 197:7a05523bf588 | 292 | if (Time100K == 100) |
Kovalev_D | 214:4c70e452c491 | 293 | { // LoopOn |
Kovalev_D | 197:7a05523bf588 | 294 | Time100K = 0; |
Kovalev_D | 197:7a05523bf588 | 295 | Event1K ++; |
Kovalev_D | 214:4c70e452c491 | 296 | // LoopOn |
Kovalev_D | 197:7a05523bf588 | 297 | } |
Kovalev_D | 209:224e7331a061 | 298 | |
Kovalev_D | 225:f8fee6c586cc | 299 | if (Time5K > 200000) |
Kovalev_D | 222:7de7b3bf3a1d | 300 | { Time5K = 0; |
Kovalev_D | 225:f8fee6c586cc | 301 | if(Gyro.Debag) |
Kovalev_D | 225:f8fee6c586cc | 302 | { |
Kovalev_D | 225:f8fee6c586cc | 303 | for(int q=0; q<64; q++) |
Kovalev_D | 225:f8fee6c586cc | 304 | { |
Kovalev_D | 225:f8fee6c586cc | 305 | sprintf((Time),"%i \r\n", ModArraySin [q]); |
Kovalev_D | 225:f8fee6c586cc | 306 | WriteCon(Time); |
Kovalev_D | 225:f8fee6c586cc | 307 | } |
Kovalev_D | 225:f8fee6c586cc | 308 | } |
Kovalev_D | 222:7de7b3bf3a1d | 309 | Event5K ++; |
Kovalev_D | 209:224e7331a061 | 310 | } |
Kovalev_D | 209:224e7331a061 | 311 | |
Kovalev_D | 197:7a05523bf588 | 312 | if (Time500Hz > 200) |
Kovalev_D | 208:19150d2b528f | 313 | { // LoopOn |
Kovalev_D | 197:7a05523bf588 | 314 | Time500Hz -= 200; |
Kovalev_D | 208:19150d2b528f | 315 | Event500Hz ++; |
Kovalev_D | 197:7a05523bf588 | 316 | } |
Kovalev_D | 209:224e7331a061 | 317 | |
Kovalev_D | 209:224e7331a061 | 318 | if (Time250Hz > 6) |
Kovalev_D | 209:224e7331a061 | 319 | { // LoopOn |
Kovalev_D | 209:224e7331a061 | 320 | Time250Hz -= 6; |
Kovalev_D | 209:224e7331a061 | 321 | Event250Hz ++; |
Kovalev_D | 209:224e7331a061 | 322 | } |
Kovalev_D | 210:b02fa166315d | 323 | |
Kovalev_D | 213:9953db9543d6 | 324 | //LoopOff |
igor_v | 21:bc8c1cec3da6 | 325 | } |