![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
forkd
Fork of LGstaandart by
Global.c@225:f8fee6c586cc, 2017-12-12 (annotated)
- Committer:
- Kovalev_D
- Date:
- Tue Dec 12 05:53:39 2017 +0000
- Revision:
- 225:f8fee6c586cc
- Parent:
- 222:7de7b3bf3a1d
- Child:
- 226:4a4d5bd5fcd7
new asc_gld
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
igor_v | 0:8ad47e2b6f00 | 1 | #include "Global.h" |
igor_v | 0:8ad47e2b6f00 | 2 | |
Kovalev_D | 89:a0d344db227e | 3 | unsigned int VibroReg = 0; //регистр состаяния вибропривода. |
Kovalev_D | 89:a0d344db227e | 4 | unsigned long Global_Time, Time_UART,Time_Sec,Time_vibro,Time_1kHz; |
Kovalev_D | 197:7a05523bf588 | 5 | float t1; |
Kovalev_D | 89:a0d344db227e | 6 | unsigned char BuffTemp[100]; |
Kovalev_D | 197:7a05523bf588 | 7 | unsigned char Time[1000]; |
Kovalev_D | 86:398da56ef751 | 8 | unsigned int Event1Hz; |
Kovalev_D | 208:19150d2b528f | 9 | unsigned int Event100Hz; |
Kovalev_D | 209:224e7331a061 | 10 | unsigned int Event250Hz; |
Kovalev_D | 124:9ae09249f842 | 11 | unsigned int Event500Hz; |
Kovalev_D | 203:3a6615de9581 | 12 | unsigned int Event1K; |
Kovalev_D | 214:4c70e452c491 | 13 | unsigned int Event1250Hz; |
Kovalev_D | 222:7de7b3bf3a1d | 14 | unsigned int Event5K; |
Kovalev_D | 88:b5c1d9d338d1 | 15 | unsigned int Event100K; |
Kovalev_D | 88:b5c1d9d338d1 | 16 | unsigned int EventVibro; |
Kovalev_D | 211:ac8251b067d2 | 17 | unsigned int MODFlag=0; |
Kovalev_D | 197:7a05523bf588 | 18 | unsigned int Time250Hz; |
Kovalev_D | 197:7a05523bf588 | 19 | unsigned int Event250Hz; |
Kovalev_D | 197:7a05523bf588 | 20 | |
Kovalev_D | 124:9ae09249f842 | 21 | unsigned int Time100K; |
Kovalev_D | 88:b5c1d9d338d1 | 22 | unsigned int Time1K; |
Kovalev_D | 214:4c70e452c491 | 23 | unsigned int Time1250Hz; |
Kovalev_D | 222:7de7b3bf3a1d | 24 | unsigned int Time5K; |
Kovalev_D | 124:9ae09249f842 | 25 | unsigned int Time500Hz; |
Kovalev_D | 209:224e7331a061 | 26 | unsigned int Time250Hz; |
Kovalev_D | 88:b5c1d9d338d1 | 27 | unsigned int Time1Hz; |
Kovalev_D | 208:19150d2b528f | 28 | unsigned int Time100Hz; |
Kovalev_D | 88:b5c1d9d338d1 | 29 | unsigned int Clock1Hz; |
Kovalev_D | 86:398da56ef751 | 30 | unsigned int ShiftD; |
Kovalev_D | 86:398da56ef751 | 31 | unsigned int ShiftL; |
Kovalev_D | 215:b58b887fd367 | 32 | |
Kovalev_D | 215:b58b887fd367 | 33 | |
Kovalev_D | 215:b58b887fd367 | 34 | |
Kovalev_D | 215:b58b887fd367 | 35 | |
Kovalev_D | 215:b58b887fd367 | 36 | |
Kovalev_D | 216:189b0ea1dc38 | 37 | int BuffADC_1Point [600]; |
Kovalev_D | 216:189b0ea1dc38 | 38 | int BuffADC_1Point_64 [100]; |
Kovalev_D | 216:189b0ea1dc38 | 39 | int BuffADC_1Point_Recalc [100]; |
Kovalev_D | 220:04c54405b82d | 40 | |
Kovalev_D | 220:04c54405b82d | 41 | int BuffADC_128Point [100]; |
Kovalev_D | 220:04c54405b82d | 42 | int BuffADC_64Point [100]; |
Kovalev_D | 220:04c54405b82d | 43 | int BuffADC_32Point [100]; |
Kovalev_D | 216:189b0ea1dc38 | 44 | int BuffADC_16Point [100]; |
Kovalev_D | 220:04c54405b82d | 45 | int BuffADC_10v [100]; |
Kovalev_D | 220:04c54405b82d | 46 | int BuffADC_10v_OLD [100]; |
Kovalev_D | 220:04c54405b82d | 47 | int BuffADC_10v_F [100]; |
Kovalev_D | 220:04c54405b82d | 48 | int BuffADC_znak [100]; |
Kovalev_D | 215:b58b887fd367 | 49 | |
Kovalev_D | 215:b58b887fd367 | 50 | int Buff_Restored_Mod [100]; |
Kovalev_D | 215:b58b887fd367 | 51 | int Buff_PLC_Eror [100]; |
Kovalev_D | 215:b58b887fd367 | 52 | int BSinMns [100]; |
Kovalev_D | 215:b58b887fd367 | 53 | int BSinPls [100]; |
Kovalev_D | 215:b58b887fd367 | 54 | int ADC_1Point =0; |
Kovalev_D | 215:b58b887fd367 | 55 | int ADC_32PointD =0; |
Kovalev_D | 220:04c54405b82d | 56 | |
Kovalev_D | 220:04c54405b82d | 57 | int ADC_128Point =0; |
Kovalev_D | 215:b58b887fd367 | 58 | int ADC_64Point =0; |
Kovalev_D | 220:04c54405b82d | 59 | int ADC_32Point =0; |
Kovalev_D | 215:b58b887fd367 | 60 | int ADC_16Point =0; |
Kovalev_D | 205:775d54fdf646 | 61 | //unsigned int EventMod; |
Kovalev_D | 140:1fbf117fc120 | 62 | |
Kovalev_D | 139:1716152517aa | 63 | |
Kovalev_D | 134:caf4c9cd5052 | 64 | __asm void boot_jump( uint32_t address ){ |
Kovalev_D | 134:caf4c9cd5052 | 65 | LDR SP, [R0] ;Load new stack pointer address |
Kovalev_D | 134:caf4c9cd5052 | 66 | LDR R0, [R0, #4] ;Load new program counter address |
Kovalev_D | 134:caf4c9cd5052 | 67 | BX R0 |
Kovalev_D | 134:caf4c9cd5052 | 68 | } |
Kovalev_D | 134:caf4c9cd5052 | 69 | |
Kovalev_D | 205:775d54fdf646 | 70 | void Param_init(void) |
Kovalev_D | 205:775d54fdf646 | 71 | { |
Kovalev_D | 208:19150d2b528f | 72 | int temp=0; |
Kovalev_D | 208:19150d2b528f | 73 | |
Kovalev_D | 205:775d54fdf646 | 74 | InitMOD(); |
Kovalev_D | 206:00341a03e05c | 75 | |
Kovalev_D | 211:ac8251b067d2 | 76 | Gyro.CuruAngleLog=0; |
Kovalev_D | 205:775d54fdf646 | 77 | Global_Time = 0; |
Kovalev_D | 88:b5c1d9d338d1 | 78 | Time_UART = 0; |
Kovalev_D | 88:b5c1d9d338d1 | 79 | Time_Sec = 0; |
Kovalev_D | 88:b5c1d9d338d1 | 80 | Time_vibro = 0; |
Kovalev_D | 214:4c70e452c491 | 81 | Time1250Hz = 0; |
Kovalev_D | 88:b5c1d9d338d1 | 82 | Time_1kHz = 0; |
Kovalev_D | 88:b5c1d9d338d1 | 83 | Event1Hz = 0; |
Kovalev_D | 88:b5c1d9d338d1 | 84 | Event1K = 0; |
Kovalev_D | 88:b5c1d9d338d1 | 85 | Event100K = 0; |
Kovalev_D | 88:b5c1d9d338d1 | 86 | EventVibro = 0; |
Kovalev_D | 88:b5c1d9d338d1 | 87 | Time1K = 0; |
Kovalev_D | 88:b5c1d9d338d1 | 88 | Time100K = 0; |
Kovalev_D | 88:b5c1d9d338d1 | 89 | Time1Hz = 0; |
Kovalev_D | 88:b5c1d9d338d1 | 90 | Clock1Hz = 0; |
Kovalev_D | 88:b5c1d9d338d1 | 91 | ShiftD = 0; |
Kovalev_D | 88:b5c1d9d338d1 | 92 | ShiftL = 0; |
Kovalev_D | 124:9ae09249f842 | 93 | Event500Hz = 0; |
Kovalev_D | 124:9ae09249f842 | 94 | Time500Hz = 0; |
Kovalev_D | 215:b58b887fd367 | 95 | |
Kovalev_D | 205:775d54fdf646 | 96 | Temp_AMP64P = 0; |
Kovalev_D | 215:b58b887fd367 | 97 | |
Kovalev_D | 205:775d54fdf646 | 98 | Gyro.Log = 0; |
Kovalev_D | 205:775d54fdf646 | 99 | Gyro.LogPLC = 0; |
Kovalev_D | 205:775d54fdf646 | 100 | Gyro.PLC_Lern = 0; |
Kovalev_D | 106:250ddd8629c6 | 101 | Gyro.CuruAngle = 0; |
Kovalev_D | 88:b5c1d9d338d1 | 102 | Pulse_8Point = 0; |
Kovalev_D | 88:b5c1d9d338d1 | 103 | Pulse_16Point = 0; |
Kovalev_D | 88:b5c1d9d338d1 | 104 | Pulse_16PointD = 0; |
Kovalev_D | 88:b5c1d9d338d1 | 105 | Pulse_32Point = 0; |
Kovalev_D | 209:224e7331a061 | 106 | Gyro.FlashMod = 0; |
Kovalev_D | 208:19150d2b528f | 107 | |
Kovalev_D | 205:775d54fdf646 | 108 | |
Kovalev_D | 205:775d54fdf646 | 109 | ///////////////////////////////////////////// |
Kovalev_D | 205:775d54fdf646 | 110 | ///////////инициализация таймеров//////////// |
Kovalev_D | 205:775d54fdf646 | 111 | ///////////////////////////////////////////// |
Kovalev_D | 205:775d54fdf646 | 112 | Init_TIM1(TIME_INTERVAL ); //Timer 1: CCLK / 7812 = 12800.819Hz; Vibro: Timer1/32 = 400.025Hz; 10ms??? |
Kovalev_D | 205:775d54fdf646 | 113 | Init_TIM2(); //Timer 2: CCLK / 4 / 250 = 100kHz |
Kovalev_D | 205:775d54fdf646 | 114 | ///////////////////////////////////////////// |
Kovalev_D | 205:775d54fdf646 | 115 | /////////////инициализация переменных в структ вибро///////////////// |
Kovalev_D | 206:00341a03e05c | 116 | |
Kovalev_D | 206:00341a03e05c | 117 | Gyro.DropDelayGLD = DropDelayGLD_0;//задержка на выдачу 45 микросекунд для любого адреса ГЛД |
Kovalev_D | 206:00341a03e05c | 118 | Gyro.PLC_Error2Mode = 1400; |
Kovalev_D | 206:00341a03e05c | 119 | Gyro.SOC_Out = 0xDD; |
Kovalev_D | 209:224e7331a061 | 120 | |
Kovalev_D | 209:224e7331a061 | 121 | Gyro.RgConMod = 1; |
Kovalev_D | 206:00341a03e05c | 122 | |
Kovalev_D | 206:00341a03e05c | 123 | GyroP.Str.ParamMod=0; |
Kovalev_D | 209:224e7331a061 | 124 | |
Kovalev_D | 209:224e7331a061 | 125 | ReadFlash (); |
Kovalev_D | 210:b02fa166315d | 126 | // GyroP.Str.ParamMod=0; |
Kovalev_D | 225:f8fee6c586cc | 127 | if(GyroP.Str.ParamMod==1) |
Kovalev_D | 211:ac8251b067d2 | 128 | { |
Kovalev_D | 220:04c54405b82d | 129 | Gyro.ShowMod2=0; |
Kovalev_D | 222:7de7b3bf3a1d | 130 | Gyro.TimeToJump = GyroP.Str.TimeToJump; |
Kovalev_D | 222:7de7b3bf3a1d | 131 | Gyro.JumpDelta = GyroP.Str.JumpDelta; |
Kovalev_D | 220:04c54405b82d | 132 | Gyro.ShiftMod = GyroP.Str.ShiftMod; |
Kovalev_D | 211:ac8251b067d2 | 133 | Gyro.PLC_Start = 0x7fff+GyroP.Str.PLC_Start; |
Kovalev_D | 225:f8fee6c586cc | 134 | Gyro.DownTreshold = (unsigned int)((GyroP.Str.DownTreshold-0x7fff)&0xffff); //27 |
Kovalev_D | 225:f8fee6c586cc | 135 | Gyro.HighTreshold = (unsigned int)((GyroP.Str.HighTreshold-0x7fff)&0xffff); |
Kovalev_D | 225:f8fee6c586cc | 136 | Gyro.PLCDelay = GyroP.Str.PLCDelay; |
Kovalev_D | 225:f8fee6c586cc | 137 | Gyro.ResetLevelCool = (unsigned int)((GyroP.Str.ResetLevelCool-0x7fff)&0xffff); //105 |
Kovalev_D | 225:f8fee6c586cc | 138 | Gyro.ResetLevelHeat = (unsigned int)((GyroP.Str.ResetLevelHeat-0x7fff)&0xffff); |
Kovalev_D | 211:ac8251b067d2 | 139 | Gyro.HFO_Gain = GyroP.Str.HFO_Gain; |
Kovalev_D | 211:ac8251b067d2 | 140 | Gyro.HFO_ref = (unsigned int)(GyroP.Str.HFO_ref)*0.82; |
Kovalev_D | 211:ac8251b067d2 | 141 | Gyro.LG_Type = GyroP.Str.LG_Type; |
Kovalev_D | 208:19150d2b528f | 142 | Gyro.My_Addres = GyroP.Str.My_Addres; // Gyro.My_Addres = 0; |
Kovalev_D | 209:224e7331a061 | 143 | Gyro.GLD_Serial = GyroP.Str.GLD_Serial; |
Kovalev_D | 209:224e7331a061 | 144 | Gyro.FrqHZ = (7680000/GyroP.Str.FrqHZ); |
Kovalev_D | 209:224e7331a061 | 145 | Gyro.Frq = ((7680000/GyroP.Str.FrqHZ)<<16); |
Kovalev_D | 209:224e7331a061 | 146 | Gyro.FrqHZmin = ((7680000/GyroP.Str.FrqHZmin)<<16); |
Kovalev_D | 209:224e7331a061 | 147 | Gyro.FrqHZmax = ((7680000/GyroP.Str.FrqHZmax)<<16); |
Kovalev_D | 208:19150d2b528f | 148 | Gyro.FrqChengSpeed = GyroP.Str.FrqChengSpeed; |
Kovalev_D | 208:19150d2b528f | 149 | Gyro.PLC_Gain = GyroP.Str.PLC_Gain; |
Kovalev_D | 208:19150d2b528f | 150 | Gyro.PLC_Phase = GyroP.Str.PLC_Phase; |
Kovalev_D | 208:19150d2b528f | 151 | Gyro.ModAmp = GyroP.Str.ModAmp; |
Kovalev_D | 208:19150d2b528f | 152 | Gyro.FrqPhase = GyroP.Str.FrqPhase; |
Kovalev_D | 214:4c70e452c491 | 153 | Gyro.AmpPer = 700;//GyroP.Str.AmpPer*100; |
Kovalev_D | 214:4c70e452c491 | 154 | Gyro.Amp =(GyroP.Str.AmpPer<<17); |
Kovalev_D | 208:19150d2b528f | 155 | Gyro.AmpSpeed = GyroP.Str.AmpSpeed; |
Kovalev_D | 208:19150d2b528f | 156 | Gyro.AmpPerDel = GyroP.Str.AmpPerDel; |
Kovalev_D | 208:19150d2b528f | 157 | temp=((GyroP.Str.VB_Fdf_Hi<<16) | GyroP.Str.VB_Fdf_Lo); |
Kovalev_D | 210:b02fa166315d | 158 | temp=temp*20; |
Kovalev_D | 208:19150d2b528f | 159 | Gyro.AmpTarget=(unsigned int)(temp); |
Kovalev_D | 208:19150d2b528f | 160 | Gyro.AmpPerMin = GyroP.Str.AmpPerMin; |
Kovalev_D | 208:19150d2b528f | 161 | Gyro.AmpPerMax = GyroP.Str.AmpPerMax; |
Kovalev_D | 208:19150d2b528f | 162 | Gyro.AmpMin = GyroP.Str.AmpMin; |
Kovalev_D | 208:19150d2b528f | 163 | Gyro.AmpTD = GyroP.Str.AmpTD; |
Kovalev_D | 214:4c70e452c491 | 164 | F_vib=(103200000<<5)/((Gyro.Frq)>>10);//периуд вибро. |
Kovalev_D | 214:4c70e452c491 | 165 | T_vibP = F_vib/10000; |
Kovalev_D | 214:4c70e452c491 | 166 | T_vib_1 = Gyro.AmpPer * T_vibP; |
Kovalev_D | 214:4c70e452c491 | 167 | T_vib_2 = T_vibP * (10000-Gyro.AmpPer); |
Kovalev_D | 214:4c70e452c491 | 168 | LPC_MCPWM->LIM1 = F_vib; |
Kovalev_D | 214:4c70e452c491 | 169 | LPC_MCPWM->LIM2 = F_vib; |
Kovalev_D | 214:4c70e452c491 | 170 | LPC_MCPWM->MAT1 = T_vib_1; |
Kovalev_D | 214:4c70e452c491 | 171 | LPC_MCPWM->MAT2 = T_vib_2; |
Kovalev_D | 211:ac8251b067d2 | 172 | if(Gyro.LG_Type==1){ |
Kovalev_D | 225:f8fee6c586cc | 173 | //Gyro.HFO_Max=((int)(GyroP.Str.DAC_current_Work*0.67)-2000); |
Kovalev_D | 225:f8fee6c586cc | 174 | Gyro.HFO_Max=0xffff-GyroP.Str.DAC_current_Work; |
Kovalev_D | 225:f8fee6c586cc | 175 | |
Kovalev_D | 225:f8fee6c586cc | 176 | //Gyro.HFO_Min=((int)(GyroP.Str.DAC_current_Start*0.67)-2000); |
Kovalev_D | 225:f8fee6c586cc | 177 | Gyro.HFO_Min= 0xffff-GyroP.Str.DAC_current_Start; |
Kovalev_D | 211:ac8251b067d2 | 178 | } |
Kovalev_D | 211:ac8251b067d2 | 179 | else Spi.DAC_A = ((((int)(GyroP.Str.DAC_current_Work+0x7fff) & 0xffff)+22544)*0.65); |
Kovalev_D | 209:224e7331a061 | 180 | Gyro.DacIn = GyroP.Str.DAC_current_Work; |
Kovalev_D | 208:19150d2b528f | 181 | // Gyro.TermoNKU = GyroP.Str.TermoNKU<<2; |
Kovalev_D | 209:224e7331a061 | 182 | Gyro.Firmware_Version = 0x11; |
Kovalev_D | 208:19150d2b528f | 183 | // Spi.DAC_A = GyroP.Str.DAC_A; |
Kovalev_D | 209:224e7331a061 | 184 | // Spi.DAC_B = GyroP.Str.DAC_B; |
Kovalev_D | 208:19150d2b528f | 185 | Gyro.Gain_Sin = GyroP.Str.Gain_Sin; |
Kovalev_D | 208:19150d2b528f | 186 | Gyro.Gain_Cos = GyroP.Str.Gain_Cos; |
Kovalev_D | 208:19150d2b528f | 187 | Out_G_photo(Gyro.Gain_Sin, Gyro.Gain_Cos); |
Kovalev_D | 206:00341a03e05c | 188 | } |
Kovalev_D | 206:00341a03e05c | 189 | else |
Kovalev_D | 206:00341a03e05c | 190 | { |
Kovalev_D | 211:ac8251b067d2 | 191 | Gyro.DownTreshold = GyroP.Str.DownTreshold; //27 |
Kovalev_D | 211:ac8251b067d2 | 192 | Gyro.HighTreshold = GyroP.Str.HighTreshold; |
Kovalev_D | 225:f8fee6c586cc | 193 | Gyro.PLCDelay = 5000; |
Kovalev_D | 211:ac8251b067d2 | 194 | Gyro.ResetLevelCool = 56000; //105 |
Kovalev_D | 211:ac8251b067d2 | 195 | Gyro.ResetLevelHeat = 15000; |
Kovalev_D | 211:ac8251b067d2 | 196 | Gyro.HFO_ref = 13000; |
Kovalev_D | 211:ac8251b067d2 | 197 | Gyro.LG_Type = 0; |
Kovalev_D | 208:19150d2b528f | 198 | Gyro.PLC_Phase = 3; |
Kovalev_D | 208:19150d2b528f | 199 | Gyro.PLC_Gain = 3; |
Kovalev_D | 208:19150d2b528f | 200 | Gyro.FrqPhase = 8; |
Kovalev_D | 207:d1ce992f5d17 | 201 | Gyro.FrqHZ = 403; |
Kovalev_D | 206:00341a03e05c | 202 | Gyro.Frq = Gyro.FrqHZ<<16; |
Kovalev_D | 206:00341a03e05c | 203 | Gyro.FrqHZmin = 350<<16; |
Kovalev_D | 206:00341a03e05c | 204 | Gyro.FrqHZmax = 450<<16; |
Kovalev_D | 206:00341a03e05c | 205 | Gyro.FrqChengSpeed = 100; |
Kovalev_D | 206:00341a03e05c | 206 | Gyro.ModAmp = 250; |
Kovalev_D | 208:19150d2b528f | 207 | Gyro.AmpPer = 20; |
Kovalev_D | 207:d1ce992f5d17 | 208 | Gyro.AmpPerMin = 2; |
Kovalev_D | 206:00341a03e05c | 209 | Gyro.AmpPerMax = 90; |
Kovalev_D | 206:00341a03e05c | 210 | Gyro.AmpSpeed = 1; |
Kovalev_D | 207:d1ce992f5d17 | 211 | Gyro.AmpPerDel = 3; |
Kovalev_D | 208:19150d2b528f | 212 | Gyro.AmpTarget = 5500;// целевая амплитуда ВП |
Kovalev_D | 208:19150d2b528f | 213 | Gyro.Amp = 20*65535; |
Kovalev_D | 207:d1ce992f5d17 | 214 | Gyro.AmpMin = 20;// минимальное значение AmpT;5 |
Kovalev_D | 208:19150d2b528f | 215 | Gyro.AmpTD = 20;//////////////////////////////////////////////////////// |
Kovalev_D | 206:00341a03e05c | 216 | Gyro.TermoNKU = 44700;//48824*0,0061-273=25 С° |
Kovalev_D | 211:ac8251b067d2 | 217 | Spi.DAC_B = Gyro.PLC_Start; |
Kovalev_D | 206:00341a03e05c | 218 | Gyro.PLC_Error2Mode = 1400; //для записи мод |
Kovalev_D | 207:d1ce992f5d17 | 219 | Gyro.Gain_Sin = 175; |
Kovalev_D | 207:d1ce992f5d17 | 220 | Gyro.Gain_Cos = 215; |
Kovalev_D | 209:224e7331a061 | 221 | Gyro.Firmware_Version = 0x11; //версия программы |
Kovalev_D | 205:775d54fdf646 | 222 | Gyro.GLD_Serial = 123; //серийный номер |
Kovalev_D | 182:ebcd2bc3be8f | 223 | Gyro.My_Addres = 0; //адрес глд |
Kovalev_D | 208:19150d2b528f | 224 | Gyro.Tmp_OffsetT4 = 0; |
Kovalev_D | 208:19150d2b528f | 225 | Gyro.Tmp_OffsetT5 = 0; |
Kovalev_D | 208:19150d2b528f | 226 | Gyro.Tmp_scaleT4 = 1; //53 |
Kovalev_D | 208:19150d2b528f | 227 | Gyro.Tmp_scaleT5 = 1; |
Kovalev_D | 208:19150d2b528f | 228 | |
Kovalev_D | 208:19150d2b528f | 229 | Gyro.DAC_current_Work =50000; //3 |
Kovalev_D | 208:19150d2b528f | 230 | Gyro.DAC_current_Start =41000; |
Kovalev_D | 211:ac8251b067d2 | 231 | |
Kovalev_D | 214:4c70e452c491 | 232 | |
Kovalev_D | 214:4c70e452c491 | 233 | F_vib=(103200000<<5)/((Gyro.Frq)>>10);//периуд вибро. |
Kovalev_D | 214:4c70e452c491 | 234 | T_vibP = F_vib/10000; |
Kovalev_D | 214:4c70e452c491 | 235 | T_vib_1 = Gyro.AmpPer * T_vibP; |
Kovalev_D | 214:4c70e452c491 | 236 | T_vib_2 = T_vibP * (10000-Gyro.AmpPer); |
Kovalev_D | 214:4c70e452c491 | 237 | LPC_MCPWM->LIM1 = F_vib; |
Kovalev_D | 214:4c70e452c491 | 238 | LPC_MCPWM->LIM2 = F_vib; |
Kovalev_D | 214:4c70e452c491 | 239 | LPC_MCPWM->MAT1 = T_vib_1; |
Kovalev_D | 214:4c70e452c491 | 240 | LPC_MCPWM->MAT2 = T_vib_2; |
Kovalev_D | 206:00341a03e05c | 241 | } |
Kovalev_D | 211:ac8251b067d2 | 242 | Spi.DAC_B=Gyro.PLC_Start; |
Kovalev_D | 188:4c523cc373cc | 243 | switch(Gyro.My_Addres){//смещение поджига и подсветки в зависимости от адреса ГЛД |
Kovalev_D | 188:4c523cc373cc | 244 | case 0: |
Kovalev_D | 209:224e7331a061 | 245 | Gyro.Discharg = StartDischarg << ShiftStart0; |
Kovalev_D | 188:4c523cc373cc | 246 | Gyro.BackLight = StartBackLight << ShiftStart0; |
Kovalev_D | 188:4c523cc373cc | 247 | break; |
Kovalev_D | 188:4c523cc373cc | 248 | case 1: |
Kovalev_D | 209:224e7331a061 | 249 | Gyro.Discharg = StartDischarg << ShiftStart1; |
Kovalev_D | 188:4c523cc373cc | 250 | Gyro.BackLight = StartBackLight << ShiftStart1; |
Kovalev_D | 188:4c523cc373cc | 251 | break; |
Kovalev_D | 188:4c523cc373cc | 252 | case 2: |
Kovalev_D | 209:224e7331a061 | 253 | Gyro.Discharg = StartDischarg << ShiftStart2; |
Kovalev_D | 188:4c523cc373cc | 254 | Gyro.BackLight = StartBackLight << ShiftStart2; |
Kovalev_D | 188:4c523cc373cc | 255 | break; |
Kovalev_D | 188:4c523cc373cc | 256 | case 3: |
Kovalev_D | 209:224e7331a061 | 257 | Gyro.Discharg = StartDischarg << ShiftStart3; |
Kovalev_D | 188:4c523cc373cc | 258 | Gyro.BackLight = StartBackLight << ShiftStart3; |
Kovalev_D | 188:4c523cc373cc | 259 | break; |
Kovalev_D | 205:775d54fdf646 | 260 | } |
Kovalev_D | 205:775d54fdf646 | 261 | |
Kovalev_D | 88:b5c1d9d338d1 | 262 | ///////////////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 263 | //////инициализация цап_LPC (р0.26 цап выход)//////// |
Kovalev_D | 88:b5c1d9d338d1 | 264 | ///////////////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 265 | LPC_PINCON->PINSEL1 = 0x00200000; |
Kovalev_D | 88:b5c1d9d338d1 | 266 | ///////////////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 267 | ////////////начальное значение для цап/////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 268 | //////////////////середина шкалы///////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 269 | ///////////////////////////////////////////////////// |
Kovalev_D | 205:775d54fdf646 | 270 | |
Kovalev_D | 86:398da56ef751 | 271 | //////////////////////////////////////////////////// |
Kovalev_D | 86:398da56ef751 | 272 | /////////////поправочный коэффициент///////////////// |
Kovalev_D | 86:398da56ef751 | 273 | /////////для цапов (граници +-12.5 вольт)//////////// |
Kovalev_D | 86:398da56ef751 | 274 | ///////////////////////////////////////////////////// |
Kovalev_D | 86:398da56ef751 | 275 | K_DAC=65535.0/(65535.0+(deltaDAC+deltaDAC/2)); |
Kovalev_D | 86:398da56ef751 | 276 | K_DAC=0.8; |
Kovalev_D | 88:b5c1d9d338d1 | 277 | |
Kovalev_D | 86:398da56ef751 | 278 | ///////////////////////////////////////////////////// |
Kovalev_D | 86:398da56ef751 | 279 | /////////////обнуление переменых для///////////////// |
Kovalev_D | 86:398da56ef751 | 280 | ///////////////переменных энкодера/////////////////// |
Kovalev_D | 86:398da56ef751 | 281 | ///////////////////////////////////////////////////// |
Kovalev_D | 205:775d54fdf646 | 282 | secPuls =0;// переменная для конопки поджига аск глд(временная) |
Kovalev_D | 112:4a96133a1311 | 283 | Gyro.CaunPlus =0; |
Kovalev_D | 112:4a96133a1311 | 284 | Gyro.CaunMin =0; |
Kovalev_D | 88:b5c1d9d338d1 | 285 | Cur_QEI=0; |
Kovalev_D | 86:398da56ef751 | 286 | Last_QEI=0; |
Kovalev_D | 205:775d54fdf646 | 287 | } |
Kovalev_D | 205:775d54fdf646 | 288 | |
Kovalev_D | 205:775d54fdf646 | 289 | void GLD_Init(void) |
Kovalev_D | 214:4c70e452c491 | 290 | { |
Kovalev_D | 214:4c70e452c491 | 291 | int Dummy; // инициализация мусорки для очистки буфера приема. |
Kovalev_D | 214:4c70e452c491 | 292 | |
Kovalev_D | 214:4c70e452c491 | 293 | |
Kovalev_D | 222:7de7b3bf3a1d | 294 | if(Gyro.LG_Type==1)Spi.DAC_A=Gyro.HFO_Max; |
Kovalev_D | 214:4c70e452c491 | 295 | |
Kovalev_D | 214:4c70e452c491 | 296 | |
Kovalev_D | 214:4c70e452c491 | 297 | |
Kovalev_D | 86:398da56ef751 | 298 | ///////////////////////////////////////////////////// |
Kovalev_D | 87:7e575d26d6d0 | 299 | /////////////инициализация энкодера////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 300 | ///////////////////////////////////////////////////// |
Kovalev_D | 214:4c70e452c491 | 301 | |
Kovalev_D | 87:7e575d26d6d0 | 302 | LPC_SC->PCONP |= (1<<18);//0x00040000; включение квадратурного энкодера. |
Kovalev_D | 170:d099c3025f87 | 303 | LPC_SC->PCLKSEL1 |= 0x00000001; // выбор частоты для кв.э. CLK=103MHz |
Kovalev_D | 87:7e575d26d6d0 | 304 | LPC_PINCON->PINSEL3 &= ~0x4100; |
Kovalev_D | 87:7e575d26d6d0 | 305 | LPC_PINCON->PINSEL3 |= 0x4100; //P1.20, p1.23 установить как входы кв.э |
Kovalev_D | 89:a0d344db227e | 306 | LPC_PINCON->PINMODE3 |= 0x3C300; //P1.20, p1.23 |
Kovalev_D | 86:398da56ef751 | 307 | |
Kovalev_D | 220:04c54405b82d | 308 | //Gyro.ShiftMod=150; |
Kovalev_D | 87:7e575d26d6d0 | 309 | LPC_QEI->MAXPOS = MAX_QEI_CNT; //LPC_QEI->"регистор максимального положения" = 2147483646 |
Kovalev_D | 89:a0d344db227e | 310 | LPC_QEI->FILTER = 2; // фильтр( ?? ) |
Kovalev_D | 87:7e575d26d6d0 | 311 | LPC_QEI->CON = 0xF; //сбросить в ноль все счетчики кв.э. (скорость, направление, позицию и тд) |
Kovalev_D | 214:4c70e452c491 | 312 | LPC_QEI->CONF = (1<<2) |(0<<1); //Quadrature inputs, no inverting,only A pulses are counted |
Kovalev_D | 87:7e575d26d6d0 | 313 | |
Kovalev_D | 87:7e575d26d6d0 | 314 | LPC_QEI->CLR = 0x1fff; //r. сбросить все прерывания |
Kovalev_D | 87:7e575d26d6d0 | 315 | LPC_QEI->IEC = 0x1fff; //r. запретить прерывание при изменении направления |
Kovalev_D | 87:7e575d26d6d0 | 316 | |
Kovalev_D | 98:95b8e79f13e1 | 317 | /*NVIC_SetPriority(QEI_IRQn, 0); |
Kovalev_D | 98:95b8e79f13e1 | 318 | NVIC_EnableIRQ(QEI_IRQn);*/ |
Kovalev_D | 88:b5c1d9d338d1 | 319 | ////////////////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 320 | ////////////////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 321 | |
Kovalev_D | 88:b5c1d9d338d1 | 322 | |
Kovalev_D | 89:a0d344db227e | 323 | ////////////////////////////////////////////////////// |
Kovalev_D | 89:a0d344db227e | 324 | ///////////////////////I2C//////////////////////////// |
Kovalev_D | 89:a0d344db227e | 325 | ////////////////////////////////////////////////////// |
Kovalev_D | 87:7e575d26d6d0 | 326 | |
Kovalev_D | 89:a0d344db227e | 327 | LPC_SC->PCONP |= (1 << 19);//включение интерфейса I2C. |
Kovalev_D | 88:b5c1d9d338d1 | 328 | |
Kovalev_D | 89:a0d344db227e | 329 | /* set PIO0.27 and PIO0.28 to I2C0 SDA and SCK */ |
Kovalev_D | 89:a0d344db227e | 330 | /* function to 01 on both SDA and SCK. */ |
Kovalev_D | 89:a0d344db227e | 331 | LPC_PINCON->PINSEL1 &= ~0x03C00000; //P0.27 - SDA. |
Kovalev_D | 89:a0d344db227e | 332 | LPC_PINCON->PINSEL1 |= 0x01400000; //P0.28 - SCK. |
Kovalev_D | 86:398da56ef751 | 333 | |
Kovalev_D | 89:a0d344db227e | 334 | // подтверждение Флаг флаг разрешения |
Kovalev_D | 89:a0d344db227e | 335 | /*сброс флагоф флага прерывания I2C старта интерфейса I2C */ |
Kovalev_D | 89:a0d344db227e | 336 | LPC_I2C0->CONCLR = I2CONCLR_AAC | I2CONCLR_SIC | I2CONCLR_STAC | I2CONCLR_I2ENC; // установка микроконтроллера в режим мастера |
Kovalev_D | 86:398da56ef751 | 337 | |
Kovalev_D | 89:a0d344db227e | 338 | /*--- Reset registers ---*/ |
Kovalev_D | 89:a0d344db227e | 339 | LPC_I2C0->SCLL = I2SCLL_SCLL; // - счетчик scl low time period |
Kovalev_D | 89:a0d344db227e | 340 | LPC_I2C0->SCLH = I2SCLH_SCLH; // - счетчик scl high time period |
Kovalev_D | 99:3d8f206ceac2 | 341 | |
Kovalev_D | 99:3d8f206ceac2 | 342 | I2CMasterBuffer[0] = A_ADDRESS; |
Kovalev_D | 99:3d8f206ceac2 | 343 | I2CMasterBuffer[1] = WRITE_CMD; |
Kovalev_D | 99:3d8f206ceac2 | 344 | I2CMasterBuffer[3] = B_ADDRESS; |
Kovalev_D | 99:3d8f206ceac2 | 345 | I2CMasterBuffer[4] = WRITE_CMD; |
Kovalev_D | 99:3d8f206ceac2 | 346 | |
Kovalev_D | 89:a0d344db227e | 347 | LPC_I2C0->CONSET = I2CONSET_I2EN; //включение интерфейса I2C. |
Kovalev_D | 89:a0d344db227e | 348 | ////////////////////////////////////////////////////////// |
Kovalev_D | 89:a0d344db227e | 349 | ////////////////////////////////////////////////////////// |
Kovalev_D | 86:398da56ef751 | 350 | |
Kovalev_D | 86:398da56ef751 | 351 | |
Kovalev_D | 86:398da56ef751 | 352 | |
Kovalev_D | 92:c892f0311aa7 | 353 | |
Kovalev_D | 92:c892f0311aa7 | 354 | |
Kovalev_D | 92:c892f0311aa7 | 355 | |
Kovalev_D | 92:c892f0311aa7 | 356 | /////////////////////////////////////////////////////// |
Kovalev_D | 92:c892f0311aa7 | 357 | /////////////////////////////////////////////////////// |
Kovalev_D | 92:c892f0311aa7 | 358 | //////////////////////////SPI////////////////////////// |
Kovalev_D | 92:c892f0311aa7 | 359 | /////////////////////////////////////////////////////// |
Kovalev_D | 92:c892f0311aa7 | 360 | Dummy = Dummy; |
Kovalev_D | 92:c892f0311aa7 | 361 | |
Kovalev_D | 92:c892f0311aa7 | 362 | /* Enable AHB clock to the SSP0, SSP1 */ |
Kovalev_D | 92:c892f0311aa7 | 363 | LPC_SC->PCONP |= (0x1<<21); // включение SSP0. |
Kovalev_D | 92:c892f0311aa7 | 364 | |
Kovalev_D | 92:c892f0311aa7 | 365 | /* выбор частоты для переферии используем по умолчания с делителем основной на 4 */ |
Kovalev_D | 92:c892f0311aa7 | 366 | LPC_SC->PCLKSEL1 &= ~(0x3<<10); //00 CLK/4; 1 CLK; 2 CLK/2; 3 CLK/8 |
Kovalev_D | 92:c892f0311aa7 | 367 | LPC_SC->PCLKSEL1 |= (0x0<<10); //00 CLK/4; 1 CLK; 2 CLK/2; 3 CLK/ |
Kovalev_D | 92:c892f0311aa7 | 368 | |
Kovalev_D | 92:c892f0311aa7 | 369 | // P0.15~0.18 as SSP0 |
Kovalev_D | 92:c892f0311aa7 | 370 | LPC_PINCON->PINSEL0 &= ~(0x3UL<<30); //установит Р 0.15 |
Kovalev_D | 92:c892f0311aa7 | 371 | LPC_PINCON->PINSEL0 |= (0x2UL<<30); //частота для синхронизациии Master - slave |
Kovalev_D | 92:c892f0311aa7 | 372 | |
Kovalev_D | 92:c892f0311aa7 | 373 | LPC_PINCON->PINSEL1 &= ~((0x3<<0)|(0x3<<2)|(0x3<<4)); // устанивоить Р 0.17 и Р 0.18 |
Kovalev_D | 92:c892f0311aa7 | 374 | LPC_PINCON->PINSEL1 |= ((0x2<<2)|(0x2<<4)); // как MISO0 и MOSI0 |
Kovalev_D | 92:c892f0311aa7 | 375 | |
Kovalev_D | 92:c892f0311aa7 | 376 | LPC_PINCON->PINMODE0 &= ~(0x3UL<<30);// ? установление на Р 0.15 режима On-Chip pull-down resistor enabled |
Kovalev_D | 92:c892f0311aa7 | 377 | LPC_PINCON->PINMODE0 |= (0x3UL<<30);// ? установление на Р 0.15 режима On-Chip pull-down resistor enabled |
Kovalev_D | 92:c892f0311aa7 | 378 | |
Kovalev_D | 92:c892f0311aa7 | 379 | LPC_PINCON->PINMODE1 &= ~((0x3<<2)|(0x3<<4));// ? установление на Р 0.17 и Р 0.18 режима On-Chip pull-down resistor enabled |
Kovalev_D | 92:c892f0311aa7 | 380 | LPC_PINCON->PINMODE1 |= ((0x3<<2)|(0x3<<4));// ? установление на Р 0.17 и Р 0.18 режима On-Chip pull-down resistor enabled |
Kovalev_D | 92:c892f0311aa7 | 381 | |
Kovalev_D | 92:c892f0311aa7 | 382 | LPC_SSP0->CR0 = ((3<<8)|(0<<7)|(0<<4) |0xF); // (0xF)-установление DSS(Data sise select) в 16-битный формат, (3<<8 scr - выбор частоты), |
Kovalev_D | 92:c892f0311aa7 | 383 | // низкий уровень линии тактирования между кадрами, прикрепление передачи к первому нарастанию тактового мигнала |
Kovalev_D | 92:c892f0311aa7 | 384 | // формат кадра TI. |
Kovalev_D | 92:c892f0311aa7 | 385 | |
Kovalev_D | 92:c892f0311aa7 | 386 | /* SSPCPSR clock prescale register, master mode, minimum divisor is 0x02 */ |
Kovalev_D | 92:c892f0311aa7 | 387 | LPC_SSP0->CPSR = 0x2; // freq = CLK/(cpsdvr*(scr+1)) = 1.6 MHz |
Kovalev_D | 92:c892f0311aa7 | 388 | |
Kovalev_D | 92:c892f0311aa7 | 389 | /*SSP enable, master mode */ |
Kovalev_D | 92:c892f0311aa7 | 390 | LPC_SSP0->CR1 = SSPCR1_SSE; |
Kovalev_D | 92:c892f0311aa7 | 391 | // LPC_SSP1->CR1 = SSPCR1_SSE; |
Kovalev_D | 190:289514f730ee | 392 | while (LPC_SSP0->SR & SSP_BUSY); |
Kovalev_D | 92:c892f0311aa7 | 393 | while (LPC_SSP0->SR & RX_SSP_notEMPT) /* clear the RxFIFO */ |
Kovalev_D | 92:c892f0311aa7 | 394 | Dummy = LPC_SSP0->DR; |
Kovalev_D | 92:c892f0311aa7 | 395 | //all pins after reset is in GPIO mode, so CS pins needn't to configure |
Kovalev_D | 92:c892f0311aa7 | 396 | LPC_GPIO0->FIODIR |= (1<<16); // P0.16 defined as CS for ADC |
Kovalev_D | 92:c892f0311aa7 | 397 | LPC_GPIO0->FIOSET |= (1<<16); // set CS for ADC |
Kovalev_D | 92:c892f0311aa7 | 398 | |
Kovalev_D | 92:c892f0311aa7 | 399 | LPC_GPIO0->FIODIR |= (1<<23); // P defined as CS for DAC |
Kovalev_D | 92:c892f0311aa7 | 400 | LPC_GPIO0->FIOCLR |= (1<<23); // set CS for DAC |
Kovalev_D | 92:c892f0311aa7 | 401 | while (LPC_SSP1->SR & RX_SSP_notEMPT) |
Kovalev_D | 92:c892f0311aa7 | 402 | Dummy = LPC_SSP1->DR; /* clear the RxFIFO */ |
Kovalev_D | 92:c892f0311aa7 | 403 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////// |
Kovalev_D | 92:c892f0311aa7 | 404 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////// |
Kovalev_D | 92:c892f0311aa7 | 405 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////// |
Kovalev_D | 92:c892f0311aa7 | 406 | |
Kovalev_D | 92:c892f0311aa7 | 407 | |
Kovalev_D | 92:c892f0311aa7 | 408 | |
Kovalev_D | 92:c892f0311aa7 | 409 | |
Kovalev_D | 86:398da56ef751 | 410 | ///////////////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 411 | /////////////////инициализация ног/////////////////// |
Kovalev_D | 86:398da56ef751 | 412 | ///////////////////////////////////////////////////// |
Kovalev_D | 89:a0d344db227e | 413 | |
Kovalev_D | 89:a0d344db227e | 414 | ///////////////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 415 | Gyro.PinRegOld = 0xffffffff; |
Kovalev_D | 88:b5c1d9d338d1 | 416 | Gyro.PinReg = 0; // всЁ выключенно |
Kovalev_D | 88:b5c1d9d338d1 | 417 | PinCheng(); |
Kovalev_D | 89:a0d344db227e | 418 | ///////////////////////////////////////////////////// |
Kovalev_D | 193:a0fe8bfc97e4 | 419 | Gyro.ModeOut=0; |
Kovalev_D | 87:7e575d26d6d0 | 420 | ///////////////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 421 | //////////////отладочный светодиод/////////////////// |
Kovalev_D | 87:7e575d26d6d0 | 422 | ///////////////////////////////////////////////////// |
Kovalev_D | 98:95b8e79f13e1 | 423 | |
Kovalev_D | 98:95b8e79f13e1 | 424 | LPC_PINCON->PINSEL0 &= ~(0x00<<28); |
Kovalev_D | 214:4c70e452c491 | 425 | LPC_PINCON->PINSEL0 |= (0x00<<28); |
Kovalev_D | 190:289514f730ee | 426 | LPC_PINCON->PINMODE0 |= (0x3<<28); |
Kovalev_D | 190:289514f730ee | 427 | LPC_GPIO1->FIODIR |= (1<<30); |
Kovalev_D | 87:7e575d26d6d0 | 428 | ///////////////////////////////////////////////////// |
Kovalev_D | 87:7e575d26d6d0 | 429 | ///////////////////////////////////////////////////// |
Kovalev_D | 193:a0fe8bfc97e4 | 430 | NVIC_EnableIRQ(EINT3_IRQn); |
Kovalev_D | 193:a0fe8bfc97e4 | 431 | // LPC_GPIOINT->IO0IntEnF |= (1<<1); /* enable falling edge irq */ |
Kovalev_D | 193:a0fe8bfc97e4 | 432 | LPC_GPIOINT->IO0IntEnR |= (1<<1); /* enable rasing edge irq */ |
Kovalev_D | 87:7e575d26d6d0 | 433 | ///////////////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 434 | ////////////////управление уартом//////////////////// |
Kovalev_D | 87:7e575d26d6d0 | 435 | ///////////////////////////////////////////////////// |
Kovalev_D | 89:a0d344db227e | 436 | LPC_GPIO2->FIODIR |= (1<<7);//направление ноги uart enable |
Kovalev_D | 87:7e575d26d6d0 | 437 | ///////////////////////////////////////////////////// |
Kovalev_D | 87:7e575d26d6d0 | 438 | ///////////////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 439 | |
Kovalev_D | 88:b5c1d9d338d1 | 440 | |
Kovalev_D | 88:b5c1d9d338d1 | 441 | |
Kovalev_D | 87:7e575d26d6d0 | 442 | ///////////////////////////////////////////////////// |
Kovalev_D | 89:a0d344db227e | 443 | ///////////////////////поджиг//////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 444 | ///////////////////////////////////////////////////// |
Kovalev_D | 98:95b8e79f13e1 | 445 | LPC_PINCON->PINSEL0 &= ~(3<<8); //e. P0.4 is GPIO pin (запись ( 00 ) в 9:8 бит PISEL0 выбор P0.4 как GPIO) |
Kovalev_D | 98:95b8e79f13e1 | 446 | LPC_PINCON->PINMODE0 |= (3<<8); //e. P0.4 is GPIO pin (запись ( 11 ) в 9:8 бит PINMODE0 "для включения подтягивающего резистора") |
Kovalev_D | 87:7e575d26d6d0 | 447 | LPC_GPIO0->FIODIR |= (1<<4); //e. P0.4 is output (запись ( 1 ) в 5 бит FIODIR выбор P0.4 как выход) |
Kovalev_D | 87:7e575d26d6d0 | 448 | ///////////////////////////////////////////////////// |
Kovalev_D | 87:7e575d26d6d0 | 449 | ///////////////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 450 | |
Kovalev_D | 88:b5c1d9d338d1 | 451 | |
Kovalev_D | 88:b5c1d9d338d1 | 452 | |
Kovalev_D | 87:7e575d26d6d0 | 453 | ///////////////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 454 | /////////////////////вибро 1///////////////////////// |
Kovalev_D | 87:7e575d26d6d0 | 455 | ///////////////////////////////////////////////////// |
Kovalev_D | 98:95b8e79f13e1 | 456 | LPC_PINCON->PINSEL3 &= ~(0x00<<18); //e. P1.25 is GPIO pin |
Kovalev_D | 98:95b8e79f13e1 | 457 | LPC_PINCON->PINSEL3 |= (0x00<<18); //e. P1.25 is GPIO pin |
Kovalev_D | 87:7e575d26d6d0 | 458 | LPC_PINCON->PINMODE3 |= (3<<18); //e. P1.25 (включениe подтягивающего резистора") |
Kovalev_D | 87:7e575d26d6d0 | 459 | LPC_GPIO1->FIODIR |= (1<<25); //e. P0.5 is output (запись ( 1 ) в 5 бит FIODIR выбор P0.5 как выход) |
Kovalev_D | 87:7e575d26d6d0 | 460 | LPC_GPIO1->FIOCLR |= (1<<25); |
Kovalev_D | 88:b5c1d9d338d1 | 461 | ////////////////////////////////////////////////////// |
Kovalev_D | 89:a0d344db227e | 462 | //////////////////////вибро 2///////////////////////// |
Kovalev_D | 89:a0d344db227e | 463 | ////////////////////////////////////////////////////// |
Kovalev_D | 98:95b8e79f13e1 | 464 | LPC_PINCON->PINSEL3 &= ~(0x00<<24); //e. P1.28 is GPIO pin |
Kovalev_D | 98:95b8e79f13e1 | 465 | LPC_PINCON->PINSEL3 |= (0x00<<24); //e. P1.28 is GPIO pin |
Kovalev_D | 87:7e575d26d6d0 | 466 | LPC_PINCON->PINMODE3 |= (3<<24); //e. P1.28 is GPIO pin (запись ( 11 ) в бит PINMODE0 "для включения подтягивающего резистора") |
Kovalev_D | 87:7e575d26d6d0 | 467 | LPC_GPIO1->FIODIR |= (1<<28); //e. P1.28 is output (запись ( 1 ) в 5 бит FIODIR выбор P0.5 как выход) |
Kovalev_D | 87:7e575d26d6d0 | 468 | LPC_GPIO1->FIOCLR |= (1<<28); |
Kovalev_D | 87:7e575d26d6d0 | 469 | ///////////////////////////////////////////////////// |
Kovalev_D | 87:7e575d26d6d0 | 470 | ///////////////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 471 | |
Kovalev_D | 88:b5c1d9d338d1 | 472 | |
Kovalev_D | 88:b5c1d9d338d1 | 473 | |
Kovalev_D | 87:7e575d26d6d0 | 474 | ///////////////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 475 | /////////////инициализация подсветки///////////////// |
Kovalev_D | 87:7e575d26d6d0 | 476 | ///////////////////////////////////////////////////// |
Kovalev_D | 98:95b8e79f13e1 | 477 | LPC_PINCON->PINSEL2 &= ~(0x00<<24); |
Kovalev_D | 98:95b8e79f13e1 | 478 | LPC_PINCON->PINSEL2 |= (0x00<<24); //e. P2.12 is GPIO pin |
Kovalev_D | 87:7e575d26d6d0 | 479 | LPC_PINCON->PINMODE3 |= (3<<24); //e. P1.28 is GPIO pin (запись ( 11 ) в бит PINMODE0 "для включения подтягивающего резистора") |
Kovalev_D | 87:7e575d26d6d0 | 480 | LPC_GPIO2->FIODIR |= (1<<12); //e. P1.28 is output (запись ( 1 ) в 5 бит FIODIR выбор P0.5 как выход) |
Kovalev_D | 87:7e575d26d6d0 | 481 | LPC_GPIO2->FIOCLR |= (1<<12); |
Kovalev_D | 88:b5c1d9d338d1 | 482 | /////////////////////////////////////////////////////// |
Kovalev_D | 86:398da56ef751 | 483 | /////////////////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 484 | |
Kovalev_D | 88:b5c1d9d338d1 | 485 | |
Kovalev_D | 88:b5c1d9d338d1 | 486 | /////////////////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 487 | /////////////////////////////////////////////////////// |
Kovalev_D | 89:a0d344db227e | 488 | ///////////////////включение таймеров////////////////// |
Kovalev_D | 89:a0d344db227e | 489 | /////////////////////////////////////////////////////// |
Kovalev_D | 86:398da56ef751 | 490 | enable_timer1(); |
Kovalev_D | 86:398da56ef751 | 491 | enable_timer2(); |
Kovalev_D | 89:a0d344db227e | 492 | /////////////////////////////////////////////////////// |
Kovalev_D | 89:a0d344db227e | 493 | |
Kovalev_D | 89:a0d344db227e | 494 | ////////////////////////////////////////////////////////////////// |
Kovalev_D | 89:a0d344db227e | 495 | // LPC_GPIO0->FIOCLR = (1<<5);/////////////отключение поджига |
Kovalev_D | 90:d9b6a4bc5065 | 496 | |
Kovalev_D | 90:d9b6a4bc5065 | 497 | |
Kovalev_D | 90:d9b6a4bc5065 | 498 | |
Kovalev_D | 90:d9b6a4bc5065 | 499 | /////////////////////////////////////////////////////// |
Kovalev_D | 90:d9b6a4bc5065 | 500 | /////////////////////////////////////////////////////// |
Kovalev_D | 90:d9b6a4bc5065 | 501 | //////////////////////////SPI////////////////////////// |
Kovalev_D | 90:d9b6a4bc5065 | 502 | /////////////////////////////////////////////////////// |
Kovalev_D | 90:d9b6a4bc5065 | 503 | Dummy = Dummy; |
Kovalev_D | 90:d9b6a4bc5065 | 504 | |
Kovalev_D | 90:d9b6a4bc5065 | 505 | /* Enable AHB clock to the SSP0, SSP1 */ |
Kovalev_D | 90:d9b6a4bc5065 | 506 | LPC_SC->PCONP |= (0x1<<21); // включение SSP0. |
Kovalev_D | 90:d9b6a4bc5065 | 507 | |
Kovalev_D | 90:d9b6a4bc5065 | 508 | /* выбор частоты для переферии используем по умолчания с делителем основной на 4 */ |
Kovalev_D | 90:d9b6a4bc5065 | 509 | LPC_SC->PCLKSEL1 &= ~(0x3<<10); //00 CLK/4; 1 CLK; 2 CLK/2; 3 CLK/8 |
Kovalev_D | 90:d9b6a4bc5065 | 510 | LPC_SC->PCLKSEL1 |= (0x0<<10); //00 CLK/4; 1 CLK; 2 CLK/2; 3 CLK/ |
Kovalev_D | 90:d9b6a4bc5065 | 511 | |
Kovalev_D | 90:d9b6a4bc5065 | 512 | // P0.15~0.18 as SSP0 |
Kovalev_D | 90:d9b6a4bc5065 | 513 | LPC_PINCON->PINSEL0 &= ~(0x3UL<<30); //установит Р 0.15 |
Kovalev_D | 90:d9b6a4bc5065 | 514 | LPC_PINCON->PINSEL0 |= (0x2UL<<30); //частота для синхронизациии Master - slave |
Kovalev_D | 90:d9b6a4bc5065 | 515 | |
Kovalev_D | 90:d9b6a4bc5065 | 516 | LPC_PINCON->PINSEL1 &= ~((0x3<<0)|(0x3<<2)|(0x3<<4)); // устанивоить Р 0.17 и Р 0.18 |
Kovalev_D | 90:d9b6a4bc5065 | 517 | LPC_PINCON->PINSEL1 |= ((0x2<<2)|(0x2<<4)); // как MISO0 и MOSI0 |
Kovalev_D | 90:d9b6a4bc5065 | 518 | |
Kovalev_D | 90:d9b6a4bc5065 | 519 | LPC_PINCON->PINMODE0 &= ~(0x3UL<<30);// ? установление на Р 0.15 режима On-Chip pull-down resistor enabled |
Kovalev_D | 90:d9b6a4bc5065 | 520 | LPC_PINCON->PINMODE0 |= (0x3UL<<30);// ? установление на Р 0.15 режима On-Chip pull-down resistor enabled |
Kovalev_D | 90:d9b6a4bc5065 | 521 | |
Kovalev_D | 90:d9b6a4bc5065 | 522 | LPC_PINCON->PINMODE1 &= ~((0x3<<2)|(0x3<<4));// ? установление на Р 0.17 и Р 0.18 режима On-Chip pull-down resistor enabled |
Kovalev_D | 90:d9b6a4bc5065 | 523 | LPC_PINCON->PINMODE1 |= ((0x3<<2)|(0x3<<4));// ? установление на Р 0.17 и Р 0.18 режима On-Chip pull-down resistor enabled |
Kovalev_D | 90:d9b6a4bc5065 | 524 | |
Kovalev_D | 90:d9b6a4bc5065 | 525 | LPC_SSP0->CR0 = ((3<<8)|(0<<7)|(0<<4) |0xF); // (0xF)-установление DSS(Data sise select) в 16-битный формат, (3<<8 scr - выбор частоты), |
Kovalev_D | 90:d9b6a4bc5065 | 526 | // низкий уровень линии тактирования между кадрами, прикрепление передачи к первому нарастанию тактового мигнала |
Kovalev_D | 90:d9b6a4bc5065 | 527 | // формат кадра TI. |
Kovalev_D | 90:d9b6a4bc5065 | 528 | |
Kovalev_D | 90:d9b6a4bc5065 | 529 | /* SSPCPSR clock prescale register, master mode, minimum divisor is 0x02 */ |
Kovalev_D | 90:d9b6a4bc5065 | 530 | LPC_SSP0->CPSR = 0x2; // freq = CLK/(cpsdvr*(scr+1)) = 1.6 MHz |
Kovalev_D | 90:d9b6a4bc5065 | 531 | |
Kovalev_D | 90:d9b6a4bc5065 | 532 | /*SSP enable, master mode */ |
Kovalev_D | 90:d9b6a4bc5065 | 533 | LPC_SSP0->CR1 = SSPCR1_SSE; |
Kovalev_D | 90:d9b6a4bc5065 | 534 | // LPC_SSP1->CR1 = SSPCR1_SSE; |
Kovalev_D | 90:d9b6a4bc5065 | 535 | while (LPC_SSP0->SR & SSP_BUSY); |
Kovalev_D | 170:d099c3025f87 | 536 | while (LPC_SSP0->SR & RX_SSP_notEMPT) /* clear the RxFIFO */ |
Kovalev_D | 90:d9b6a4bc5065 | 537 | Dummy = LPC_SSP0->DR; |
Kovalev_D | 90:d9b6a4bc5065 | 538 | //all pins after reset is in GPIO mode, so CS pins needn't to configure |
Kovalev_D | 90:d9b6a4bc5065 | 539 | LPC_GPIO0->FIODIR |= (1<<16); // P0.16 defined as CS for ADC |
Kovalev_D | 90:d9b6a4bc5065 | 540 | LPC_GPIO0->FIOSET |= (1<<16); // set CS for ADC |
Kovalev_D | 90:d9b6a4bc5065 | 541 | |
Kovalev_D | 92:c892f0311aa7 | 542 | LPC_GPIO0->FIODIR |= (1<<23); // P defined as CS for DAC |
Kovalev_D | 92:c892f0311aa7 | 543 | LPC_GPIO0->FIOCLR |= (1<<23); // set CS for DAC |
Kovalev_D | 92:c892f0311aa7 | 544 | while (LPC_SSP1->SR & RX_SSP_notEMPT) |
Kovalev_D | 92:c892f0311aa7 | 545 | Dummy = LPC_SSP1->DR; /* clear the RxFIFO */ |
Kovalev_D | 205:775d54fdf646 | 546 | //Gyro=GyroP.str; |
Kovalev_D | 205:775d54fdf646 | 547 | //Gyro = (*(struct Gyro*)(&GyroP.Str)); |
Kovalev_D | 90:d9b6a4bc5065 | 548 | |
Kovalev_D | 86:398da56ef751 | 549 | } |
igor_v | 13:e2a1d18677b8 | 550 | |
igor_v | 0:8ad47e2b6f00 | 551 | |
igor_v | 0:8ad47e2b6f00 | 552 | |
igor_v | 0:8ad47e2b6f00 | 553 | |
igor_v | 0:8ad47e2b6f00 | 554 |