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