![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
forkd
Fork of LGstaandart by
Global.c@232:130a2b5003e6, 2018-01-31 (annotated)
- Committer:
- Kovalev_D
- Date:
- Wed Jan 31 13:41:23 2018 +0000
- Revision:
- 232:130a2b5003e6
- Parent:
- 231:079835d508ef
static termocorr
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 | 231:079835d508ef | 7 | unsigned char Time[512]; |
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 | 231:079835d508ef | 14 | unsigned int Event10K; |
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 | 231:079835d508ef | 24 | unsigned int Time10K; |
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 | 231:079835d508ef | 30 | |
Kovalev_D | 231:079835d508ef | 31 | |
Kovalev_D | 231:079835d508ef | 32 | |
Kovalev_D | 231:079835d508ef | 33 | |
Kovalev_D | 231:079835d508ef | 34 | __asm void boot_jump( uint32_t address ) |
Kovalev_D | 231:079835d508ef | 35 | { |
Kovalev_D | 231:079835d508ef | 36 | LDR SP, [R0] ;Load new stack pointer address |
Kovalev_D | 231:079835d508ef | 37 | LDR R0, [R0, #4] ;Load new program counter address |
Kovalev_D | 231:079835d508ef | 38 | BX R0 |
Kovalev_D | 231:079835d508ef | 39 | } |
Kovalev_D | 231:079835d508ef | 40 | |
Kovalev_D | 215:b58b887fd367 | 41 | |
Kovalev_D | 215:b58b887fd367 | 42 | |
Kovalev_D | 215:b58b887fd367 | 43 | |
Kovalev_D | 215:b58b887fd367 | 44 | |
Kovalev_D | 215:b58b887fd367 | 45 | |
Kovalev_D | 231:079835d508ef | 46 | uint32_t convertStrToTime(const char *str) { |
Kovalev_D | 231:079835d508ef | 47 | char mon[3]; |
Kovalev_D | 231:079835d508ef | 48 | int day, mon_int, year; |
Kovalev_D | 231:079835d508ef | 49 | |
Kovalev_D | 231:079835d508ef | 50 | mon[0] = str[0]; |
Kovalev_D | 231:079835d508ef | 51 | mon[1] = str[1]; |
Kovalev_D | 231:079835d508ef | 52 | mon[2] = str[2]; |
Kovalev_D | 231:079835d508ef | 53 | |
Kovalev_D | 231:079835d508ef | 54 | int year_pos = 6; |
Kovalev_D | 231:079835d508ef | 55 | |
Kovalev_D | 231:079835d508ef | 56 | day = str[4] - 48; |
Kovalev_D | 231:079835d508ef | 57 | if (str[5] != ' ') { |
Kovalev_D | 231:079835d508ef | 58 | day = day * 10 + str[5] - 48; |
Kovalev_D | 231:079835d508ef | 59 | year_pos = 7; |
Kovalev_D | 231:079835d508ef | 60 | } |
Kovalev_D | 231:079835d508ef | 61 | |
Kovalev_D | 231:079835d508ef | 62 | year = (str[year_pos] - 48) * 1000 + (str[year_pos + 1] - 48) * 100 + (str[year_pos + 2] - 48) * 10 + (str[year_pos + 3] - 48) - 2018; |
Kovalev_D | 215:b58b887fd367 | 63 | |
Kovalev_D | 231:079835d508ef | 64 | mon_int = 0; |
Kovalev_D | 231:079835d508ef | 65 | switch (mon[0]) { |
Kovalev_D | 231:079835d508ef | 66 | case 'J': |
Kovalev_D | 231:079835d508ef | 67 | switch (mon[1]) { |
Kovalev_D | 231:079835d508ef | 68 | case 'a': |
Kovalev_D | 231:079835d508ef | 69 | mon_int = 1; |
Kovalev_D | 231:079835d508ef | 70 | break; |
Kovalev_D | 231:079835d508ef | 71 | case 'u': |
Kovalev_D | 231:079835d508ef | 72 | switch (mon[2]) { |
Kovalev_D | 231:079835d508ef | 73 | case 'n': |
Kovalev_D | 231:079835d508ef | 74 | mon_int = 6; |
Kovalev_D | 231:079835d508ef | 75 | break; |
Kovalev_D | 231:079835d508ef | 76 | case 'l': |
Kovalev_D | 231:079835d508ef | 77 | mon_int = 7; |
Kovalev_D | 231:079835d508ef | 78 | break; |
Kovalev_D | 231:079835d508ef | 79 | } |
Kovalev_D | 231:079835d508ef | 80 | } |
Kovalev_D | 231:079835d508ef | 81 | break; |
Kovalev_D | 231:079835d508ef | 82 | case 'F': |
Kovalev_D | 231:079835d508ef | 83 | mon_int = 2; |
Kovalev_D | 231:079835d508ef | 84 | break; |
Kovalev_D | 231:079835d508ef | 85 | case 'M': |
Kovalev_D | 231:079835d508ef | 86 | switch (mon[2]) { |
Kovalev_D | 231:079835d508ef | 87 | case 'r': |
Kovalev_D | 231:079835d508ef | 88 | mon_int = 3; |
Kovalev_D | 231:079835d508ef | 89 | break; |
Kovalev_D | 231:079835d508ef | 90 | case 'y': |
Kovalev_D | 231:079835d508ef | 91 | mon_int = 5; |
Kovalev_D | 231:079835d508ef | 92 | break; |
Kovalev_D | 231:079835d508ef | 93 | } |
Kovalev_D | 231:079835d508ef | 94 | break; |
Kovalev_D | 231:079835d508ef | 95 | case 'A': |
Kovalev_D | 231:079835d508ef | 96 | switch (mon[1]) { |
Kovalev_D | 231:079835d508ef | 97 | case 'p': |
Kovalev_D | 231:079835d508ef | 98 | mon_int = 4; |
Kovalev_D | 231:079835d508ef | 99 | break; |
Kovalev_D | 231:079835d508ef | 100 | case 'u': |
Kovalev_D | 231:079835d508ef | 101 | mon_int = 8; |
Kovalev_D | 231:079835d508ef | 102 | break; |
Kovalev_D | 231:079835d508ef | 103 | } |
Kovalev_D | 231:079835d508ef | 104 | break; |
Kovalev_D | 231:079835d508ef | 105 | case 'S': |
Kovalev_D | 231:079835d508ef | 106 | mon_int = 9; |
Kovalev_D | 231:079835d508ef | 107 | break; |
Kovalev_D | 231:079835d508ef | 108 | case 'O': |
Kovalev_D | 231:079835d508ef | 109 | mon_int = 10; |
Kovalev_D | 231:079835d508ef | 110 | break; |
Kovalev_D | 231:079835d508ef | 111 | case 'N': |
Kovalev_D | 231:079835d508ef | 112 | mon_int = 11; |
Kovalev_D | 231:079835d508ef | 113 | break; |
Kovalev_D | 231:079835d508ef | 114 | case 'D': |
Kovalev_D | 231:079835d508ef | 115 | mon_int = 12; |
Kovalev_D | 231:079835d508ef | 116 | break; |
Kovalev_D | 231:079835d508ef | 117 | default: |
Kovalev_D | 231:079835d508ef | 118 | mon_int = 0; |
Kovalev_D | 231:079835d508ef | 119 | break; |
Kovalev_D | 231:079835d508ef | 120 | } |
Kovalev_D | 220:04c54405b82d | 121 | |
Kovalev_D | 231:079835d508ef | 122 | uint32_t time_in_days = day; |
Kovalev_D | 231:079835d508ef | 123 | |
Kovalev_D | 231:079835d508ef | 124 | for (int i = 0; i <= year; ++i) { |
Kovalev_D | 231:079835d508ef | 125 | for (int j = 1; j < mon_int; ++j) { |
Kovalev_D | 231:079835d508ef | 126 | switch (mon_int) { |
Kovalev_D | 231:079835d508ef | 127 | case 1: |
Kovalev_D | 231:079835d508ef | 128 | case 3: |
Kovalev_D | 231:079835d508ef | 129 | case 5: |
Kovalev_D | 231:079835d508ef | 130 | case 7: |
Kovalev_D | 231:079835d508ef | 131 | case 8: |
Kovalev_D | 231:079835d508ef | 132 | case 10: |
Kovalev_D | 231:079835d508ef | 133 | case 12: |
Kovalev_D | 231:079835d508ef | 134 | time_in_days += 31; |
Kovalev_D | 231:079835d508ef | 135 | break; |
Kovalev_D | 231:079835d508ef | 136 | case 4: |
Kovalev_D | 231:079835d508ef | 137 | case 6: |
Kovalev_D | 231:079835d508ef | 138 | case 9: |
Kovalev_D | 231:079835d508ef | 139 | case 11: |
Kovalev_D | 231:079835d508ef | 140 | time_in_days += 30; |
Kovalev_D | 231:079835d508ef | 141 | break; |
Kovalev_D | 231:079835d508ef | 142 | case 2: |
Kovalev_D | 231:079835d508ef | 143 | if ((((i + 2018) % 4 == 0) && ((i + 2018) % 100 != 0)) || ((i + 2018) % 400 == 0)) { |
Kovalev_D | 231:079835d508ef | 144 | time_in_days += 29; |
Kovalev_D | 231:079835d508ef | 145 | } else { |
Kovalev_D | 231:079835d508ef | 146 | time_in_days += 28; |
Kovalev_D | 231:079835d508ef | 147 | } |
Kovalev_D | 231:079835d508ef | 148 | break; |
Kovalev_D | 231:079835d508ef | 149 | default: |
Kovalev_D | 231:079835d508ef | 150 | break; |
Kovalev_D | 231:079835d508ef | 151 | } |
Kovalev_D | 231:079835d508ef | 152 | } |
Kovalev_D | 231:079835d508ef | 153 | } |
Kovalev_D | 231:079835d508ef | 154 | |
Kovalev_D | 231:079835d508ef | 155 | return time_in_days; |
Kovalev_D | 231:079835d508ef | 156 | } |
Kovalev_D | 140:1fbf117fc120 | 157 | |
Kovalev_D | 139:1716152517aa | 158 | |
Kovalev_D | 231:079835d508ef | 159 | |
Kovalev_D | 231:079835d508ef | 160 | |
Kovalev_D | 231:079835d508ef | 161 | |
Kovalev_D | 231:079835d508ef | 162 | |
Kovalev_D | 231:079835d508ef | 163 | |
Kovalev_D | 231:079835d508ef | 164 | |
Kovalev_D | 231:079835d508ef | 165 | /* |
Kovalev_D | 231:079835d508ef | 166 | |
Kovalev_D | 231:079835d508ef | 167 | int32_t convertStrToTime(char *str) { |
Kovalev_D | 231:079835d508ef | 168 | struct tm time_format; |
Kovalev_D | 231:079835d508ef | 169 | char mon[3]; |
Kovalev_D | 231:079835d508ef | 170 | int day, mon_int, year; |
Kovalev_D | 231:079835d508ef | 171 | int year_pos = 6; |
Kovalev_D | 231:079835d508ef | 172 | time_t time_sec; |
Kovalev_D | 231:079835d508ef | 173 | |
Kovalev_D | 231:079835d508ef | 174 | mon[0] = str[0]; |
Kovalev_D | 231:079835d508ef | 175 | mon[1] = str[1]; |
Kovalev_D | 231:079835d508ef | 176 | mon[2] = str[2]; |
Kovalev_D | 231:079835d508ef | 177 | |
Kovalev_D | 231:079835d508ef | 178 | |
Kovalev_D | 231:079835d508ef | 179 | |
Kovalev_D | 231:079835d508ef | 180 | day = str[4] - 48; |
Kovalev_D | 231:079835d508ef | 181 | if (str[5] != ' ') { |
Kovalev_D | 231:079835d508ef | 182 | day = day * 10 + str[5] - 48; |
Kovalev_D | 231:079835d508ef | 183 | year_pos = 7; |
Kovalev_D | 231:079835d508ef | 184 | } |
Kovalev_D | 231:079835d508ef | 185 | |
Kovalev_D | 231:079835d508ef | 186 | year = (str[year_pos] - 48) * 1000 + (str[year_pos + 1] - 48) * 100 + (str[year_pos + 2] - 48) * 10 + (str[year_pos + 3] - 48); |
Kovalev_D | 231:079835d508ef | 187 | |
Kovalev_D | 231:079835d508ef | 188 | //sscanf(str, "%s%d%d", mon, &day, &year); |
Kovalev_D | 231:079835d508ef | 189 | |
Kovalev_D | 231:079835d508ef | 190 | mon_int = 0; |
Kovalev_D | 231:079835d508ef | 191 | switch (mon[0]) { |
Kovalev_D | 231:079835d508ef | 192 | case 'J': |
Kovalev_D | 231:079835d508ef | 193 | switch (mon[1]) { |
Kovalev_D | 231:079835d508ef | 194 | case 'a': |
Kovalev_D | 231:079835d508ef | 195 | mon_int = 1; |
Kovalev_D | 231:079835d508ef | 196 | break; |
Kovalev_D | 231:079835d508ef | 197 | case 'u': |
Kovalev_D | 231:079835d508ef | 198 | switch (mon[2]) { |
Kovalev_D | 231:079835d508ef | 199 | case 'n': |
Kovalev_D | 231:079835d508ef | 200 | mon_int = 6; |
Kovalev_D | 231:079835d508ef | 201 | break; |
Kovalev_D | 231:079835d508ef | 202 | case 'l': |
Kovalev_D | 231:079835d508ef | 203 | mon_int = 7; |
Kovalev_D | 231:079835d508ef | 204 | break; |
Kovalev_D | 231:079835d508ef | 205 | } |
Kovalev_D | 231:079835d508ef | 206 | } |
Kovalev_D | 231:079835d508ef | 207 | break; |
Kovalev_D | 231:079835d508ef | 208 | case 'F': |
Kovalev_D | 231:079835d508ef | 209 | mon_int = 2; |
Kovalev_D | 231:079835d508ef | 210 | break; |
Kovalev_D | 231:079835d508ef | 211 | case 'M': |
Kovalev_D | 231:079835d508ef | 212 | switch (mon[2]) { |
Kovalev_D | 231:079835d508ef | 213 | case 'r': |
Kovalev_D | 231:079835d508ef | 214 | mon_int = 3; |
Kovalev_D | 231:079835d508ef | 215 | break; |
Kovalev_D | 231:079835d508ef | 216 | case 'y': |
Kovalev_D | 231:079835d508ef | 217 | mon_int = 5; |
Kovalev_D | 231:079835d508ef | 218 | break; |
Kovalev_D | 231:079835d508ef | 219 | } |
Kovalev_D | 231:079835d508ef | 220 | break; |
Kovalev_D | 231:079835d508ef | 221 | case 'A': |
Kovalev_D | 231:079835d508ef | 222 | switch (mon[1]) { |
Kovalev_D | 231:079835d508ef | 223 | case 'p': |
Kovalev_D | 231:079835d508ef | 224 | mon_int = 4; |
Kovalev_D | 231:079835d508ef | 225 | break; |
Kovalev_D | 231:079835d508ef | 226 | case 'u': |
Kovalev_D | 231:079835d508ef | 227 | mon_int = 8; |
Kovalev_D | 231:079835d508ef | 228 | break; |
Kovalev_D | 231:079835d508ef | 229 | } |
Kovalev_D | 231:079835d508ef | 230 | break; |
Kovalev_D | 231:079835d508ef | 231 | case 'S': |
Kovalev_D | 231:079835d508ef | 232 | mon_int = 9; |
Kovalev_D | 231:079835d508ef | 233 | break; |
Kovalev_D | 231:079835d508ef | 234 | case 'O': |
Kovalev_D | 231:079835d508ef | 235 | mon_int = 10; |
Kovalev_D | 231:079835d508ef | 236 | break; |
Kovalev_D | 231:079835d508ef | 237 | case 'N': |
Kovalev_D | 231:079835d508ef | 238 | mon_int = 11; |
Kovalev_D | 231:079835d508ef | 239 | break; |
Kovalev_D | 231:079835d508ef | 240 | case 'D': |
Kovalev_D | 231:079835d508ef | 241 | mon_int = 12; |
Kovalev_D | 231:079835d508ef | 242 | break; |
Kovalev_D | 231:079835d508ef | 243 | default: |
Kovalev_D | 231:079835d508ef | 244 | mon_int = 0; |
Kovalev_D | 231:079835d508ef | 245 | break; |
Kovalev_D | 231:079835d508ef | 246 | } |
Kovalev_D | 231:079835d508ef | 247 | |
Kovalev_D | 231:079835d508ef | 248 | time_format.tm_mday = day; |
Kovalev_D | 231:079835d508ef | 249 | time_format.tm_mon = mon_int - 1; |
Kovalev_D | 231:079835d508ef | 250 | time_format.tm_year = year - 1900; |
Kovalev_D | 231:079835d508ef | 251 | |
Kovalev_D | 231:079835d508ef | 252 | time_sec = mktime(&time_format) / 60 / 60 / 24; |
Kovalev_D | 231:079835d508ef | 253 | sprintf((Time),"%d\r\n",time_sec); |
Kovalev_D | 231:079835d508ef | 254 | WriteCon(Time); |
Kovalev_D | 231:079835d508ef | 255 | |
Kovalev_D | 231:079835d508ef | 256 | return time_sec; |
Kovalev_D | 134:caf4c9cd5052 | 257 | } |
Kovalev_D | 134:caf4c9cd5052 | 258 | |
Kovalev_D | 231:079835d508ef | 259 | |
Kovalev_D | 231:079835d508ef | 260 | */ |
Kovalev_D | 205:775d54fdf646 | 261 | void Param_init(void) |
Kovalev_D | 205:775d54fdf646 | 262 | { |
Kovalev_D | 208:19150d2b528f | 263 | int temp=0; |
Kovalev_D | 231:079835d508ef | 264 | unsigned int TempTermodataHi; |
Kovalev_D | 231:079835d508ef | 265 | unsigned int TempTermodataLo; |
Kovalev_D | 231:079835d508ef | 266 | Gyro.CurTermoCompens = 200; |
Kovalev_D | 211:ac8251b067d2 | 267 | Gyro.CuruAngleLog=0; |
Kovalev_D | 205:775d54fdf646 | 268 | Global_Time = 0; |
Kovalev_D | 88:b5c1d9d338d1 | 269 | Time_UART = 0; |
Kovalev_D | 88:b5c1d9d338d1 | 270 | Time_Sec = 0; |
Kovalev_D | 88:b5c1d9d338d1 | 271 | Time_vibro = 0; |
Kovalev_D | 214:4c70e452c491 | 272 | Time1250Hz = 0; |
Kovalev_D | 88:b5c1d9d338d1 | 273 | Time_1kHz = 0; |
Kovalev_D | 88:b5c1d9d338d1 | 274 | Event1Hz = 0; |
Kovalev_D | 88:b5c1d9d338d1 | 275 | Event1K = 0; |
Kovalev_D | 88:b5c1d9d338d1 | 276 | Event100K = 0; |
Kovalev_D | 88:b5c1d9d338d1 | 277 | EventVibro = 0; |
Kovalev_D | 88:b5c1d9d338d1 | 278 | Time1K = 0; |
Kovalev_D | 88:b5c1d9d338d1 | 279 | Time100K = 0; |
Kovalev_D | 88:b5c1d9d338d1 | 280 | Time1Hz = 0; |
Kovalev_D | 88:b5c1d9d338d1 | 281 | Clock1Hz = 0; |
Kovalev_D | 124:9ae09249f842 | 282 | Event500Hz = 0; |
Kovalev_D | 124:9ae09249f842 | 283 | Time500Hz = 0; |
Kovalev_D | 215:b58b887fd367 | 284 | |
Kovalev_D | 231:079835d508ef | 285 | |
Kovalev_D | 215:b58b887fd367 | 286 | |
Kovalev_D | 205:775d54fdf646 | 287 | Gyro.Log = 0; |
Kovalev_D | 205:775d54fdf646 | 288 | Gyro.LogPLC = 0; |
Kovalev_D | 205:775d54fdf646 | 289 | Gyro.PLC_Lern = 0; |
Kovalev_D | 106:250ddd8629c6 | 290 | Gyro.CuruAngle = 0; |
Kovalev_D | 88:b5c1d9d338d1 | 291 | Pulse_8Point = 0; |
Kovalev_D | 88:b5c1d9d338d1 | 292 | Pulse_16Point = 0; |
Kovalev_D | 88:b5c1d9d338d1 | 293 | Pulse_16PointD = 0; |
Kovalev_D | 88:b5c1d9d338d1 | 294 | Pulse_32Point = 0; |
Kovalev_D | 209:224e7331a061 | 295 | Gyro.FlashMod = 0; |
Kovalev_D | 208:19150d2b528f | 296 | |
Kovalev_D | 205:775d54fdf646 | 297 | |
Kovalev_D | 205:775d54fdf646 | 298 | ///////////////////////////////////////////// |
Kovalev_D | 205:775d54fdf646 | 299 | ///////////инициализация таймеров//////////// |
Kovalev_D | 205:775d54fdf646 | 300 | ///////////////////////////////////////////// |
Kovalev_D | 205:775d54fdf646 | 301 | Init_TIM1(TIME_INTERVAL ); //Timer 1: CCLK / 7812 = 12800.819Hz; Vibro: Timer1/32 = 400.025Hz; 10ms??? |
Kovalev_D | 205:775d54fdf646 | 302 | Init_TIM2(); //Timer 2: CCLK / 4 / 250 = 100kHz |
Kovalev_D | 205:775d54fdf646 | 303 | ///////////////////////////////////////////// |
Kovalev_D | 205:775d54fdf646 | 304 | /////////////инициализация переменных в структ вибро///////////////// |
Kovalev_D | 206:00341a03e05c | 305 | |
Kovalev_D | 206:00341a03e05c | 306 | Gyro.DropDelayGLD = DropDelayGLD_0;//задержка на выдачу 45 микросекунд для любого адреса ГЛД |
Kovalev_D | 206:00341a03e05c | 307 | Gyro.PLC_Error2Mode = 1400; |
Kovalev_D | 206:00341a03e05c | 308 | Gyro.SOC_Out = 0xDD; |
Kovalev_D | 209:224e7331a061 | 309 | |
Kovalev_D | 209:224e7331a061 | 310 | Gyro.RgConMod = 1; |
Kovalev_D | 206:00341a03e05c | 311 | |
Kovalev_D | 206:00341a03e05c | 312 | GyroP.Str.ParamMod=0; |
Kovalev_D | 209:224e7331a061 | 313 | |
Kovalev_D | 209:224e7331a061 | 314 | ReadFlash (); |
Kovalev_D | 210:b02fa166315d | 315 | // GyroP.Str.ParamMod=0; |
Kovalev_D | 225:f8fee6c586cc | 316 | if(GyroP.Str.ParamMod==1) |
Kovalev_D | 211:ac8251b067d2 | 317 | { |
Kovalev_D | 220:04c54405b82d | 318 | Gyro.ShowMod2=0; |
Kovalev_D | 232:130a2b5003e6 | 319 | // Gyro.TermoMod = GyroP.Str.TermoMode; |
Kovalev_D | 232:130a2b5003e6 | 320 | |
Kovalev_D | 232:130a2b5003e6 | 321 | |
Kovalev_D | 232:130a2b5003e6 | 322 | |
Kovalev_D | 232:130a2b5003e6 | 323 | |
Kovalev_D | 232:130a2b5003e6 | 324 | |
Kovalev_D | 222:7de7b3bf3a1d | 325 | Gyro.TimeToJump = GyroP.Str.TimeToJump; |
Kovalev_D | 222:7de7b3bf3a1d | 326 | Gyro.JumpDelta = GyroP.Str.JumpDelta; |
Kovalev_D | 220:04c54405b82d | 327 | Gyro.ShiftMod = GyroP.Str.ShiftMod; |
Kovalev_D | 211:ac8251b067d2 | 328 | Gyro.PLC_Start = 0x7fff+GyroP.Str.PLC_Start; |
Kovalev_D | 225:f8fee6c586cc | 329 | Gyro.DownTreshold = (unsigned int)((GyroP.Str.DownTreshold-0x7fff)&0xffff); //27 |
Kovalev_D | 225:f8fee6c586cc | 330 | Gyro.HighTreshold = (unsigned int)((GyroP.Str.HighTreshold-0x7fff)&0xffff); |
Kovalev_D | 225:f8fee6c586cc | 331 | Gyro.PLCDelay = GyroP.Str.PLCDelay; |
Kovalev_D | 225:f8fee6c586cc | 332 | Gyro.ResetLevelCool = (unsigned int)((GyroP.Str.ResetLevelCool-0x7fff)&0xffff); //105 |
Kovalev_D | 225:f8fee6c586cc | 333 | Gyro.ResetLevelHeat = (unsigned int)((GyroP.Str.ResetLevelHeat-0x7fff)&0xffff); |
Kovalev_D | 211:ac8251b067d2 | 334 | Gyro.HFO_Gain = GyroP.Str.HFO_Gain; |
Kovalev_D | 232:130a2b5003e6 | 335 | Gyro.HFO_Gain_Reset_PLC = GyroP.Str.HFO_Gain_Reset_PLC; |
Kovalev_D | 226:4a4d5bd5fcd7 | 336 | Gyro.HFO_ref = (unsigned int)(GyroP.Str.HFO_ref); |
Kovalev_D | 211:ac8251b067d2 | 337 | Gyro.LG_Type = GyroP.Str.LG_Type; |
Kovalev_D | 226:4a4d5bd5fcd7 | 338 | Gyro.LG_Type = 1; |
Kovalev_D | 208:19150d2b528f | 339 | Gyro.My_Addres = GyroP.Str.My_Addres; // Gyro.My_Addres = 0; |
Kovalev_D | 209:224e7331a061 | 340 | Gyro.GLD_Serial = GyroP.Str.GLD_Serial; |
Kovalev_D | 209:224e7331a061 | 341 | Gyro.FrqHZ = (7680000/GyroP.Str.FrqHZ); |
Kovalev_D | 209:224e7331a061 | 342 | Gyro.Frq = ((7680000/GyroP.Str.FrqHZ)<<16); |
Kovalev_D | 209:224e7331a061 | 343 | Gyro.FrqHZmin = ((7680000/GyroP.Str.FrqHZmin)<<16); |
Kovalev_D | 209:224e7331a061 | 344 | Gyro.FrqHZmax = ((7680000/GyroP.Str.FrqHZmax)<<16); |
Kovalev_D | 208:19150d2b528f | 345 | Gyro.FrqChengSpeed = GyroP.Str.FrqChengSpeed; |
Kovalev_D | 208:19150d2b528f | 346 | Gyro.PLC_Gain = GyroP.Str.PLC_Gain; |
Kovalev_D | 208:19150d2b528f | 347 | Gyro.PLC_Phase = GyroP.Str.PLC_Phase; |
Kovalev_D | 208:19150d2b528f | 348 | Gyro.ModAmp = GyroP.Str.ModAmp; |
Kovalev_D | 208:19150d2b528f | 349 | Gyro.FrqPhase = GyroP.Str.FrqPhase; |
Kovalev_D | 232:130a2b5003e6 | 350 | //Gyro.AmpPer = 700;//GyroP.Str.AmpPer*100; |
Kovalev_D | 214:4c70e452c491 | 351 | Gyro.Amp =(GyroP.Str.AmpPer<<17); |
Kovalev_D | 208:19150d2b528f | 352 | Gyro.AmpSpeed = GyroP.Str.AmpSpeed; |
Kovalev_D | 208:19150d2b528f | 353 | Gyro.AmpPerDel = GyroP.Str.AmpPerDel; |
Kovalev_D | 208:19150d2b528f | 354 | temp=((GyroP.Str.VB_Fdf_Hi<<16) | GyroP.Str.VB_Fdf_Lo); |
Kovalev_D | 210:b02fa166315d | 355 | temp=temp*20; |
Kovalev_D | 208:19150d2b528f | 356 | Gyro.AmpTarget=(unsigned int)(temp); |
Kovalev_D | 208:19150d2b528f | 357 | Gyro.AmpPerMin = GyroP.Str.AmpPerMin; |
Kovalev_D | 208:19150d2b528f | 358 | Gyro.AmpPerMax = GyroP.Str.AmpPerMax; |
Kovalev_D | 208:19150d2b528f | 359 | Gyro.AmpMin = GyroP.Str.AmpMin; |
Kovalev_D | 208:19150d2b528f | 360 | Gyro.AmpTD = GyroP.Str.AmpTD; |
Kovalev_D | 232:130a2b5003e6 | 361 | |
Kovalev_D | 214:4c70e452c491 | 362 | F_vib=(103200000<<5)/((Gyro.Frq)>>10);//периуд вибро. |
Kovalev_D | 214:4c70e452c491 | 363 | T_vibP = F_vib/10000; |
Kovalev_D | 214:4c70e452c491 | 364 | T_vib_1 = Gyro.AmpPer * T_vibP; |
Kovalev_D | 214:4c70e452c491 | 365 | T_vib_2 = T_vibP * (10000-Gyro.AmpPer); |
Kovalev_D | 214:4c70e452c491 | 366 | LPC_MCPWM->LIM1 = F_vib; |
Kovalev_D | 214:4c70e452c491 | 367 | LPC_MCPWM->LIM2 = F_vib; |
Kovalev_D | 214:4c70e452c491 | 368 | LPC_MCPWM->MAT1 = T_vib_1; |
Kovalev_D | 214:4c70e452c491 | 369 | LPC_MCPWM->MAT2 = T_vib_2; |
Kovalev_D | 211:ac8251b067d2 | 370 | if(Gyro.LG_Type==1){ |
Kovalev_D | 225:f8fee6c586cc | 371 | //Gyro.HFO_Max=((int)(GyroP.Str.DAC_current_Work*0.67)-2000); |
Kovalev_D | 225:f8fee6c586cc | 372 | Gyro.HFO_Max=0xffff-GyroP.Str.DAC_current_Work; |
Kovalev_D | 225:f8fee6c586cc | 373 | |
Kovalev_D | 225:f8fee6c586cc | 374 | //Gyro.HFO_Min=((int)(GyroP.Str.DAC_current_Start*0.67)-2000); |
Kovalev_D | 225:f8fee6c586cc | 375 | Gyro.HFO_Min= 0xffff-GyroP.Str.DAC_current_Start; |
Kovalev_D | 211:ac8251b067d2 | 376 | } |
Kovalev_D | 211:ac8251b067d2 | 377 | else Spi.DAC_A = ((((int)(GyroP.Str.DAC_current_Work+0x7fff) & 0xffff)+22544)*0.65); |
Kovalev_D | 209:224e7331a061 | 378 | Gyro.DacIn = GyroP.Str.DAC_current_Work; |
Kovalev_D | 208:19150d2b528f | 379 | // Gyro.TermoNKU = GyroP.Str.TermoNKU<<2; |
Kovalev_D | 231:079835d508ef | 380 | Gyro.Firmware_Version = 17543; |
Kovalev_D | 208:19150d2b528f | 381 | // Spi.DAC_A = GyroP.Str.DAC_A; |
Kovalev_D | 209:224e7331a061 | 382 | // Spi.DAC_B = GyroP.Str.DAC_B; |
Kovalev_D | 208:19150d2b528f | 383 | Gyro.Gain_Sin = GyroP.Str.Gain_Sin; |
Kovalev_D | 208:19150d2b528f | 384 | Gyro.Gain_Cos = GyroP.Str.Gain_Cos; |
Kovalev_D | 208:19150d2b528f | 385 | Out_G_photo(Gyro.Gain_Sin, Gyro.Gain_Cos); |
Kovalev_D | 232:130a2b5003e6 | 386 | |
Kovalev_D | 232:130a2b5003e6 | 387 | if(GyroP.Str.Tmp_OffsetT4&0x8000) Gyro.Tmp_OffsetT4 = GyroP.Str.Tmp_OffsetT4 - 65536; |
Kovalev_D | 232:130a2b5003e6 | 388 | else Gyro.Tmp_OffsetT4 = GyroP.Str.Tmp_OffsetT4; |
Kovalev_D | 232:130a2b5003e6 | 389 | |
Kovalev_D | 232:130a2b5003e6 | 390 | if(GyroP.Str.Tmp_OffsetT5&0x8000) Gyro.Tmp_OffsetT5 = GyroP.Str.Tmp_OffsetT5 - 65536; |
Kovalev_D | 232:130a2b5003e6 | 391 | else Gyro.Tmp_OffsetT5 = GyroP.Str.Tmp_OffsetT5; |
Kovalev_D | 232:130a2b5003e6 | 392 | |
Kovalev_D | 232:130a2b5003e6 | 393 | |
Kovalev_D | 232:130a2b5003e6 | 394 | |
Kovalev_D | 231:079835d508ef | 395 | |
Kovalev_D | 232:130a2b5003e6 | 396 | if(GyroP.Str.TStatic_0&0x8000) TermoCorrStatic.TermoTempStatic.Str.TermoTempStatic_0 = GyroP.Str.TStatic_0 - 65536; |
Kovalev_D | 232:130a2b5003e6 | 397 | else TermoCorrStatic.TermoTempStatic.Str.TermoTempStatic_0 = GyroP.Str.TStatic_0; |
Kovalev_D | 232:130a2b5003e6 | 398 | |
Kovalev_D | 232:130a2b5003e6 | 399 | if(GyroP.Str.TStatic_1&0x8000) TermoCorrStatic.TermoTempStatic.Str.TermoTempStatic_1 = GyroP.Str.TStatic_1 - 65536; |
Kovalev_D | 232:130a2b5003e6 | 400 | else TermoCorrStatic.TermoTempStatic.Str.TermoTempStatic_1 = GyroP.Str.TStatic_1; |
Kovalev_D | 232:130a2b5003e6 | 401 | |
Kovalev_D | 232:130a2b5003e6 | 402 | if(GyroP.Str.TStatic_2&0x8000) TermoCorrStatic.TermoTempStatic.Str.TermoTempStatic_2 = GyroP.Str.TStatic_2-65536; |
Kovalev_D | 232:130a2b5003e6 | 403 | else TermoCorrStatic.TermoTempStatic.Str.TermoTempStatic_2 = GyroP.Str.TStatic_2; |
Kovalev_D | 232:130a2b5003e6 | 404 | |
Kovalev_D | 232:130a2b5003e6 | 405 | if(GyroP.Str.TStatic_3&0x8000) TermoCorrStatic.TermoTempStatic.Str.TermoTempStatic_3 = GyroP.Str.TStatic_3-65536; |
Kovalev_D | 232:130a2b5003e6 | 406 | else TermoCorrStatic.TermoTempStatic.Str.TermoTempStatic_3 = GyroP.Str.TStatic_3; |
Kovalev_D | 232:130a2b5003e6 | 407 | |
Kovalev_D | 232:130a2b5003e6 | 408 | if(GyroP.Str.TStatic_4&0x8000) TermoCorrStatic.TermoTempStatic.Str.TermoTempStatic_4 = GyroP.Str.TStatic_4-65536; |
Kovalev_D | 232:130a2b5003e6 | 409 | else TermoCorrStatic.TermoTempStatic.Str.TermoTempStatic_4 = GyroP.Str.TStatic_4; |
Kovalev_D | 232:130a2b5003e6 | 410 | |
Kovalev_D | 232:130a2b5003e6 | 411 | if(GyroP.Str.TStatic_5&0x8000) TermoCorrStatic.TermoTempStatic.Str.TermoTempStatic_5 = GyroP.Str.TStatic_5-65536; |
Kovalev_D | 232:130a2b5003e6 | 412 | else TermoCorrStatic.TermoTempStatic.Str.TermoTempStatic_5 = GyroP.Str.TStatic_5; |
Kovalev_D | 232:130a2b5003e6 | 413 | |
Kovalev_D | 232:130a2b5003e6 | 414 | if(GyroP.Str.TStatic_6&0x8000) TermoCorrStatic.TermoTempStatic.Str.TermoTempStatic_6 = GyroP.Str.TStatic_6-65536; |
Kovalev_D | 232:130a2b5003e6 | 415 | else TermoCorrStatic.TermoTempStatic.Str.TermoTempStatic_6 = GyroP.Str.TStatic_6; |
Kovalev_D | 232:130a2b5003e6 | 416 | |
Kovalev_D | 232:130a2b5003e6 | 417 | if(GyroP.Str.TStatic_7&0x8000) TermoCorrStatic.TermoTempStatic.Str.TermoTempStatic_7 = GyroP.Str.TStatic_7-65536; |
Kovalev_D | 232:130a2b5003e6 | 418 | else TermoCorrStatic.TermoTempStatic.Str.TermoTempStatic_7 = GyroP.Str.TStatic_7; |
Kovalev_D | 232:130a2b5003e6 | 419 | |
Kovalev_D | 232:130a2b5003e6 | 420 | if(GyroP.Str.TStatic_8&0x8000) TermoCorrStatic.TermoTempStatic.Str.TermoTempStatic_8 = GyroP.Str.TStatic_8-65536; |
Kovalev_D | 232:130a2b5003e6 | 421 | else TermoCorrStatic.TermoTempStatic.Str.TermoTempStatic_8 = GyroP.Str.TStatic_8; |
Kovalev_D | 232:130a2b5003e6 | 422 | |
Kovalev_D | 232:130a2b5003e6 | 423 | if(GyroP.Str.TStatic_9&0x8000) TermoCorrStatic.TermoTempStatic.Str.TermoTempStatic_9 = GyroP.Str.TStatic_9-65536; |
Kovalev_D | 232:130a2b5003e6 | 424 | else TermoCorrStatic.TermoTempStatic.Str.TermoTempStatic_9 = GyroP.Str.TStatic_9; |
Kovalev_D | 232:130a2b5003e6 | 425 | |
Kovalev_D | 232:130a2b5003e6 | 426 | if(GyroP.Str.TStatic_10&0x8000) TermoCorrStatic.TermoTempStatic.Str.TermoTempStatic_10 = GyroP.Str.TStatic_10-65536; |
Kovalev_D | 232:130a2b5003e6 | 427 | else TermoCorrStatic.TermoTempStatic.Str.TermoTempStatic_10 = GyroP.Str.TStatic_10; |
Kovalev_D | 232:130a2b5003e6 | 428 | |
Kovalev_D | 232:130a2b5003e6 | 429 | if(GyroP.Str.TStatic_11&0x8000) TermoCorrStatic.TermoTempStatic.Str.TermoTempStatic_11 = GyroP.Str.TStatic_11-65536; |
Kovalev_D | 232:130a2b5003e6 | 430 | else TermoCorrStatic.TermoTempStatic.Str.TermoTempStatic_11 = GyroP.Str.TStatic_11; |
Kovalev_D | 232:130a2b5003e6 | 431 | |
Kovalev_D | 232:130a2b5003e6 | 432 | if(GyroP.Str.TStatic_12&0x8000) TermoCorrStatic.TermoTempStatic.Str.TermoTempStatic_12 = GyroP.Str.TStatic_12-65536; |
Kovalev_D | 232:130a2b5003e6 | 433 | else TermoCorrStatic.TermoTempStatic.Str.TermoTempStatic_12 = GyroP.Str.TStatic_12; |
Kovalev_D | 232:130a2b5003e6 | 434 | |
Kovalev_D | 232:130a2b5003e6 | 435 | if(GyroP.Str.TStatic_13&0x8000) TermoCorrStatic.TermoTempStatic.Str.TermoTempStatic_13 = GyroP.Str.TStatic_13-65536; |
Kovalev_D | 232:130a2b5003e6 | 436 | else TermoCorrStatic.TermoTempStatic.Str.TermoTempStatic_13 = GyroP.Str.TStatic_13; |
Kovalev_D | 232:130a2b5003e6 | 437 | |
Kovalev_D | 232:130a2b5003e6 | 438 | |
Kovalev_D | 231:079835d508ef | 439 | |
Kovalev_D | 231:079835d508ef | 440 | |
Kovalev_D | 231:079835d508ef | 441 | TermoCorrStatic.TermoDeltaStatic.Str.TermoDeltaStatic_0 = Float(GyroP.Str.TermoDeltaStatic_0, GyroP.Str.TermoDeltaStatic_1 ); |
Kovalev_D | 231:079835d508ef | 442 | TermoCorrStatic.TermoDeltaStatic.Str.TermoDeltaStatic_1 = Float(GyroP.Str.TermoDeltaStatic_2, GyroP.Str.TermoDeltaStatic_3 ); |
Kovalev_D | 231:079835d508ef | 443 | TermoCorrStatic.TermoDeltaStatic.Str.TermoDeltaStatic_2 = Float(GyroP.Str.TermoDeltaStatic_4, GyroP.Str.TermoDeltaStatic_5 ); |
Kovalev_D | 231:079835d508ef | 444 | TermoCorrStatic.TermoDeltaStatic.Str.TermoDeltaStatic_3 = Float(GyroP.Str.TermoDeltaStatic_6, GyroP.Str.TermoDeltaStatic_7 ); |
Kovalev_D | 231:079835d508ef | 445 | TermoCorrStatic.TermoDeltaStatic.Str.TermoDeltaStatic_4 = Float(GyroP.Str.TermoDeltaStatic_8, GyroP.Str.TermoDeltaStatic_9 ); |
Kovalev_D | 231:079835d508ef | 446 | TermoCorrStatic.TermoDeltaStatic.Str.TermoDeltaStatic_5 = Float(GyroP.Str.TermoDeltaStatic_10,GyroP.Str.TermoDeltaStatic_11); |
Kovalev_D | 231:079835d508ef | 447 | TermoCorrStatic.TermoDeltaStatic.Str.TermoDeltaStatic_6 = Float(GyroP.Str.TermoDeltaStatic_12,GyroP.Str.TermoDeltaStatic_13); |
Kovalev_D | 231:079835d508ef | 448 | TermoCorrStatic.TermoDeltaStatic.Str.TermoDeltaStatic_7 = Float(GyroP.Str.TermoDeltaStatic_14,GyroP.Str.TermoDeltaStatic_15); |
Kovalev_D | 231:079835d508ef | 449 | TermoCorrStatic.TermoDeltaStatic.Str.TermoDeltaStatic_8 = Float(GyroP.Str.TermoDeltaStatic_16,GyroP.Str.TermoDeltaStatic_17); |
Kovalev_D | 231:079835d508ef | 450 | TermoCorrStatic.TermoDeltaStatic.Str.TermoDeltaStatic_9 = Float(GyroP.Str.TermoDeltaStatic_18,GyroP.Str.TermoDeltaStatic_19); |
Kovalev_D | 231:079835d508ef | 451 | TermoCorrStatic.TermoDeltaStatic.Str.TermoDeltaStatic_10 = Float(GyroP.Str.TermoDeltaStatic_20,GyroP.Str.TermoDeltaStatic_21); |
Kovalev_D | 231:079835d508ef | 452 | TermoCorrStatic.TermoDeltaStatic.Str.TermoDeltaStatic_11 = Float(GyroP.Str.TermoDeltaStatic_22,GyroP.Str.TermoDeltaStatic_23); |
Kovalev_D | 231:079835d508ef | 453 | TermoCorrStatic.TermoDeltaStatic.Str.TermoDeltaStatic_12 = Float(GyroP.Str.TermoDeltaStatic_24,GyroP.Str.TermoDeltaStatic_25); |
Kovalev_D | 231:079835d508ef | 454 | TermoCorrStatic.TermoDeltaStatic.Str.TermoDeltaStatic_13 = Float(GyroP.Str.TermoDeltaStatic_26,GyroP.Str.TermoDeltaStatic_27); |
Kovalev_D | 231:079835d508ef | 455 | |
Kovalev_D | 232:130a2b5003e6 | 456 | |
Kovalev_D | 232:130a2b5003e6 | 457 | /* |
Kovalev_D | 232:130a2b5003e6 | 458 | TermoCorrStatic.TermoDeltaStatic.Str.TermoDeltaStatic_0 = Float(GyroP.Str.TermoDeltaStatic_1, GyroP.Str.TermoDeltaStatic_0); |
Kovalev_D | 232:130a2b5003e6 | 459 | TermoCorrStatic.TermoDeltaStatic.Str.TermoDeltaStatic_1 = Float(GyroP.Str.TermoDeltaStatic_3, GyroP.Str.TermoDeltaStatic_2); |
Kovalev_D | 232:130a2b5003e6 | 460 | TermoCorrStatic.TermoDeltaStatic.Str.TermoDeltaStatic_2 = Float(GyroP.Str.TermoDeltaStatic_5, GyroP.Str.TermoDeltaStatic_4); |
Kovalev_D | 232:130a2b5003e6 | 461 | TermoCorrStatic.TermoDeltaStatic.Str.TermoDeltaStatic_3 = Float(GyroP.Str.TermoDeltaStatic_7, GyroP.Str.TermoDeltaStatic_6); |
Kovalev_D | 232:130a2b5003e6 | 462 | TermoCorrStatic.TermoDeltaStatic.Str.TermoDeltaStatic_4 = Float(GyroP.Str.TermoDeltaStatic_9, GyroP.Str.TermoDeltaStatic_8); |
Kovalev_D | 232:130a2b5003e6 | 463 | TermoCorrStatic.TermoDeltaStatic.Str.TermoDeltaStatic_5 = Float(GyroP.Str.TermoDeltaStatic_11,GyroP.Str.TermoDeltaStatic_10); |
Kovalev_D | 232:130a2b5003e6 | 464 | TermoCorrStatic.TermoDeltaStatic.Str.TermoDeltaStatic_6 = Float(GyroP.Str.TermoDeltaStatic_13,GyroP.Str.TermoDeltaStatic_12); |
Kovalev_D | 232:130a2b5003e6 | 465 | TermoCorrStatic.TermoDeltaStatic.Str.TermoDeltaStatic_7 = Float(GyroP.Str.TermoDeltaStatic_15,GyroP.Str.TermoDeltaStatic_14); |
Kovalev_D | 232:130a2b5003e6 | 466 | TermoCorrStatic.TermoDeltaStatic.Str.TermoDeltaStatic_8 = Float(GyroP.Str.TermoDeltaStatic_17,GyroP.Str.TermoDeltaStatic_16); |
Kovalev_D | 232:130a2b5003e6 | 467 | TermoCorrStatic.TermoDeltaStatic.Str.TermoDeltaStatic_9 = Float(GyroP.Str.TermoDeltaStatic_19,GyroP.Str.TermoDeltaStatic_18); |
Kovalev_D | 232:130a2b5003e6 | 468 | TermoCorrStatic.TermoDeltaStatic.Str.TermoDeltaStatic_10 = Float(GyroP.Str.TermoDeltaStatic_21,GyroP.Str.TermoDeltaStatic_20); |
Kovalev_D | 232:130a2b5003e6 | 469 | TermoCorrStatic.TermoDeltaStatic.Str.TermoDeltaStatic_11 = Float(GyroP.Str.TermoDeltaStatic_23,GyroP.Str.TermoDeltaStatic_22); |
Kovalev_D | 232:130a2b5003e6 | 470 | TermoCorrStatic.TermoDeltaStatic.Str.TermoDeltaStatic_12 = Float(GyroP.Str.TermoDeltaStatic_25,GyroP.Str.TermoDeltaStatic_24); |
Kovalev_D | 232:130a2b5003e6 | 471 | TermoCorrStatic.TermoDeltaStatic.Str.TermoDeltaStatic_13 = Float(GyroP.Str.TermoDeltaStatic_27,GyroP.Str.TermoDeltaStatic_26); |
Kovalev_D | 232:130a2b5003e6 | 472 | */ |
Kovalev_D | 232:130a2b5003e6 | 473 | if(GyroP.Str.TDCool_0&0x8000) TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_0 = GyroP.Str.TDCool_0-65536; |
Kovalev_D | 232:130a2b5003e6 | 474 | else TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_0 = GyroP.Str.TDCool_0; |
Kovalev_D | 232:130a2b5003e6 | 475 | |
Kovalev_D | 232:130a2b5003e6 | 476 | if(GyroP.Str.TDCool_1&0x8000) TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_1 = GyroP.Str.TDCool_1-65536; |
Kovalev_D | 232:130a2b5003e6 | 477 | else TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_1 = GyroP.Str.TDCool_1; |
Kovalev_D | 232:130a2b5003e6 | 478 | |
Kovalev_D | 232:130a2b5003e6 | 479 | if(GyroP.Str.TDCool_2&0x8000) TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_2 = GyroP.Str.TDCool_2-65536; |
Kovalev_D | 232:130a2b5003e6 | 480 | else TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_2 = GyroP.Str.TDCool_2; |
Kovalev_D | 232:130a2b5003e6 | 481 | |
Kovalev_D | 232:130a2b5003e6 | 482 | if(GyroP.Str.TDCool_3&0x8000) TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_3 = GyroP.Str.TDCool_3-65536; |
Kovalev_D | 232:130a2b5003e6 | 483 | else TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_3 = GyroP.Str.TDCool_3; |
Kovalev_D | 232:130a2b5003e6 | 484 | |
Kovalev_D | 232:130a2b5003e6 | 485 | if(GyroP.Str.TDCool_4&0x8000) TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_4 = GyroP.Str.TDCool_4-65536; |
Kovalev_D | 232:130a2b5003e6 | 486 | else TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_4 = GyroP.Str.TDCool_4; |
Kovalev_D | 232:130a2b5003e6 | 487 | |
Kovalev_D | 232:130a2b5003e6 | 488 | if(GyroP.Str.TDCool_5&0x8000) TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_5 = GyroP.Str.TDCool_5-65536; |
Kovalev_D | 232:130a2b5003e6 | 489 | else TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_5 = GyroP.Str.TDCool_5; |
Kovalev_D | 232:130a2b5003e6 | 490 | |
Kovalev_D | 232:130a2b5003e6 | 491 | if(GyroP.Str.TDCool_6&0x8000) TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_6 = GyroP.Str.TDCool_6-65536; |
Kovalev_D | 232:130a2b5003e6 | 492 | else TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_6 = GyroP.Str.TDCool_6; |
Kovalev_D | 232:130a2b5003e6 | 493 | |
Kovalev_D | 232:130a2b5003e6 | 494 | if(GyroP.Str.TDCool_7&0x8000) TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_7 = GyroP.Str.TDCool_7-65536; |
Kovalev_D | 232:130a2b5003e6 | 495 | else TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_7 = GyroP.Str.TDCool_7; |
Kovalev_D | 232:130a2b5003e6 | 496 | |
Kovalev_D | 232:130a2b5003e6 | 497 | if(GyroP.Str.TDCool_8&0x8000) TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_8 = GyroP.Str.TDCool_8-65536; |
Kovalev_D | 232:130a2b5003e6 | 498 | else TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_8 = GyroP.Str.TDCool_8; |
Kovalev_D | 232:130a2b5003e6 | 499 | |
Kovalev_D | 232:130a2b5003e6 | 500 | if(GyroP.Str.TDCool_9&0x8000) TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_9 = GyroP.Str.TDCool_9-65536; |
Kovalev_D | 232:130a2b5003e6 | 501 | else TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_9 = GyroP.Str.TDCool_9; |
Kovalev_D | 232:130a2b5003e6 | 502 | |
Kovalev_D | 232:130a2b5003e6 | 503 | if(GyroP.Str.TDCool_10&0x8000) TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_10 = GyroP.Str.TDCool_10-65536; |
Kovalev_D | 232:130a2b5003e6 | 504 | else TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_10 = GyroP.Str.TDCool_10; |
Kovalev_D | 232:130a2b5003e6 | 505 | |
Kovalev_D | 232:130a2b5003e6 | 506 | if(GyroP.Str.TDCool_11&0x8000) TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_11 = GyroP.Str.TDCool_11-65536; |
Kovalev_D | 232:130a2b5003e6 | 507 | else TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_11 = GyroP.Str.TDCool_11; |
Kovalev_D | 232:130a2b5003e6 | 508 | |
Kovalev_D | 232:130a2b5003e6 | 509 | if(GyroP.Str.TDCool_12&0x8000) TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_12 = GyroP.Str.TDCool_12-65536; |
Kovalev_D | 232:130a2b5003e6 | 510 | else TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_12 = GyroP.Str.TDCool_12; |
Kovalev_D | 232:130a2b5003e6 | 511 | |
Kovalev_D | 232:130a2b5003e6 | 512 | if(GyroP.Str.TDCool_13&0x8000) TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_13 = GyroP.Str.TDCool_13-65536; |
Kovalev_D | 232:130a2b5003e6 | 513 | else TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_13 = GyroP.Str.TDCool_13; |
Kovalev_D | 232:130a2b5003e6 | 514 | |
Kovalev_D | 232:130a2b5003e6 | 515 | /* |
Kovalev_D | 232:130a2b5003e6 | 516 | TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_0 = GyroP.Str.TDCool_0; |
Kovalev_D | 231:079835d508ef | 517 | TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_1 = GyroP.Str.TDCool_1; |
Kovalev_D | 231:079835d508ef | 518 | TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_2 = GyroP.Str.TDCool_2; |
Kovalev_D | 231:079835d508ef | 519 | TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_3 = GyroP.Str.TDCool_3; |
Kovalev_D | 231:079835d508ef | 520 | TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_4 = GyroP.Str.TDCool_4; |
Kovalev_D | 231:079835d508ef | 521 | TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_5 = GyroP.Str.TDCool_5; |
Kovalev_D | 231:079835d508ef | 522 | TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_6 = GyroP.Str.TDCool_6; |
Kovalev_D | 231:079835d508ef | 523 | TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_7 = GyroP.Str.TDCool_7; |
Kovalev_D | 231:079835d508ef | 524 | TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_8 = GyroP.Str.TDCool_8; |
Kovalev_D | 231:079835d508ef | 525 | TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_9 = GyroP.Str.TDCool_9; |
Kovalev_D | 231:079835d508ef | 526 | TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_10 = GyroP.Str.TDCool_10; |
Kovalev_D | 231:079835d508ef | 527 | TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_11 = GyroP.Str.TDCool_11; |
Kovalev_D | 231:079835d508ef | 528 | TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_12 = GyroP.Str.TDCool_12; |
Kovalev_D | 231:079835d508ef | 529 | TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_13 = GyroP.Str.TDCool_13; |
Kovalev_D | 231:079835d508ef | 530 | |
Kovalev_D | 232:130a2b5003e6 | 531 | */ |
Kovalev_D | 231:079835d508ef | 532 | |
Kovalev_D | 232:130a2b5003e6 | 533 | TermoCorrDynamic.TermoDeltaDynamic.Str.TermoDeltaDynamic_0 = Float(GyroP.Str.TermoDynamicData_0, GyroP.Str.TermoDynamicData_1 ); |
Kovalev_D | 232:130a2b5003e6 | 534 | TermoCorrDynamic.TermoDeltaDynamic.Str.TermoDeltaDynamic_1 = Float(GyroP.Str.TermoDynamicData_2, GyroP.Str.TermoDynamicData_3 ); |
Kovalev_D | 232:130a2b5003e6 | 535 | TermoCorrDynamic.TermoDeltaDynamic.Str.TermoDeltaDynamic_2 = Float(GyroP.Str.TermoDynamicData_4, GyroP.Str.TermoDynamicData_5 ); |
Kovalev_D | 232:130a2b5003e6 | 536 | TermoCorrDynamic.TermoDeltaDynamic.Str.TermoDeltaDynamic_3 = Float(GyroP.Str.TermoDynamicData_6, GyroP.Str.TermoDynamicData_7 ); |
Kovalev_D | 232:130a2b5003e6 | 537 | TermoCorrDynamic.TermoDeltaDynamic.Str.TermoDeltaDynamic_4 = Float(GyroP.Str.TermoDynamicData_8, GyroP.Str.TermoDynamicData_9 ); |
Kovalev_D | 232:130a2b5003e6 | 538 | TermoCorrDynamic.TermoDeltaDynamic.Str.TermoDeltaDynamic_5 = Float(GyroP.Str.TermoDynamicData_10, GyroP.Str.TermoDynamicData_11); |
Kovalev_D | 232:130a2b5003e6 | 539 | TermoCorrDynamic.TermoDeltaDynamic.Str.TermoDeltaDynamic_6 = Float(GyroP.Str.TermoDynamicData_12, GyroP.Str.TermoDynamicData_13); |
Kovalev_D | 232:130a2b5003e6 | 540 | TermoCorrDynamic.TermoDeltaDynamic.Str.TermoDeltaDynamic_7 = Float(GyroP.Str.TermoDynamicData_14, GyroP.Str.TermoDynamicData_15); |
Kovalev_D | 232:130a2b5003e6 | 541 | TermoCorrDynamic.TermoDeltaDynamic.Str.TermoDeltaDynamic_8 = Float(GyroP.Str.TermoDynamicData_16, GyroP.Str.TermoDynamicData_17); |
Kovalev_D | 232:130a2b5003e6 | 542 | TermoCorrDynamic.TermoDeltaDynamic.Str.TermoDeltaDynamic_9 = Float(GyroP.Str.TermoDynamicData_18, GyroP.Str.TermoDynamicData_19); |
Kovalev_D | 232:130a2b5003e6 | 543 | TermoCorrDynamic.TermoDeltaDynamic.Str.TermoDeltaDynamic_10 = Float(GyroP.Str.TermoDynamicData_20, GyroP.Str.TermoDynamicData_21); |
Kovalev_D | 232:130a2b5003e6 | 544 | TermoCorrDynamic.TermoDeltaDynamic.Str.TermoDeltaDynamic_11 = Float(GyroP.Str.TermoDynamicData_22, GyroP.Str.TermoDynamicData_23); |
Kovalev_D | 232:130a2b5003e6 | 545 | TermoCorrDynamic.TermoDeltaDynamic.Str.TermoDeltaDynamic_12 = Float(GyroP.Str.TermoDynamicData_24, GyroP.Str.TermoDynamicData_25); |
Kovalev_D | 232:130a2b5003e6 | 546 | TermoCorrDynamic.TermoDeltaDynamic.Str.TermoDeltaDynamic_13 = Float(GyroP.Str.TermoDynamicData_26, GyroP.Str.TermoDynamicData_27); |
Kovalev_D | 206:00341a03e05c | 547 | } |
Kovalev_D | 206:00341a03e05c | 548 | else |
Kovalev_D | 206:00341a03e05c | 549 | { |
Kovalev_D | 211:ac8251b067d2 | 550 | Gyro.DownTreshold = GyroP.Str.DownTreshold; //27 |
Kovalev_D | 211:ac8251b067d2 | 551 | Gyro.HighTreshold = GyroP.Str.HighTreshold; |
Kovalev_D | 225:f8fee6c586cc | 552 | Gyro.PLCDelay = 5000; |
Kovalev_D | 211:ac8251b067d2 | 553 | Gyro.ResetLevelCool = 56000; //105 |
Kovalev_D | 211:ac8251b067d2 | 554 | Gyro.ResetLevelHeat = 15000; |
Kovalev_D | 211:ac8251b067d2 | 555 | Gyro.HFO_ref = 13000; |
Kovalev_D | 211:ac8251b067d2 | 556 | Gyro.LG_Type = 0; |
Kovalev_D | 208:19150d2b528f | 557 | Gyro.PLC_Phase = 3; |
Kovalev_D | 208:19150d2b528f | 558 | Gyro.PLC_Gain = 3; |
Kovalev_D | 208:19150d2b528f | 559 | Gyro.FrqPhase = 8; |
Kovalev_D | 207:d1ce992f5d17 | 560 | Gyro.FrqHZ = 403; |
Kovalev_D | 206:00341a03e05c | 561 | Gyro.Frq = Gyro.FrqHZ<<16; |
Kovalev_D | 206:00341a03e05c | 562 | Gyro.FrqHZmin = 350<<16; |
Kovalev_D | 206:00341a03e05c | 563 | Gyro.FrqHZmax = 450<<16; |
Kovalev_D | 206:00341a03e05c | 564 | Gyro.FrqChengSpeed = 100; |
Kovalev_D | 206:00341a03e05c | 565 | Gyro.ModAmp = 250; |
Kovalev_D | 208:19150d2b528f | 566 | Gyro.AmpPer = 20; |
Kovalev_D | 207:d1ce992f5d17 | 567 | Gyro.AmpPerMin = 2; |
Kovalev_D | 206:00341a03e05c | 568 | Gyro.AmpPerMax = 90; |
Kovalev_D | 206:00341a03e05c | 569 | Gyro.AmpSpeed = 1; |
Kovalev_D | 207:d1ce992f5d17 | 570 | Gyro.AmpPerDel = 3; |
Kovalev_D | 208:19150d2b528f | 571 | Gyro.AmpTarget = 5500;// целевая амплитуда ВП |
Kovalev_D | 208:19150d2b528f | 572 | Gyro.Amp = 20*65535; |
Kovalev_D | 207:d1ce992f5d17 | 573 | Gyro.AmpMin = 20;// минимальное значение AmpT;5 |
Kovalev_D | 208:19150d2b528f | 574 | Gyro.AmpTD = 20;//////////////////////////////////////////////////////// |
Kovalev_D | 206:00341a03e05c | 575 | Gyro.TermoNKU = 44700;//48824*0,0061-273=25 С° |
Kovalev_D | 211:ac8251b067d2 | 576 | Spi.DAC_B = Gyro.PLC_Start; |
Kovalev_D | 206:00341a03e05c | 577 | Gyro.PLC_Error2Mode = 1400; //для записи мод |
Kovalev_D | 207:d1ce992f5d17 | 578 | Gyro.Gain_Sin = 175; |
Kovalev_D | 207:d1ce992f5d17 | 579 | Gyro.Gain_Cos = 215; |
Kovalev_D | 209:224e7331a061 | 580 | Gyro.Firmware_Version = 0x11; //версия программы |
Kovalev_D | 205:775d54fdf646 | 581 | Gyro.GLD_Serial = 123; //серийный номер |
Kovalev_D | 182:ebcd2bc3be8f | 582 | Gyro.My_Addres = 0; //адрес глд |
Kovalev_D | 208:19150d2b528f | 583 | Gyro.Tmp_OffsetT4 = 0; |
Kovalev_D | 208:19150d2b528f | 584 | Gyro.Tmp_OffsetT5 = 0; |
Kovalev_D | 208:19150d2b528f | 585 | Gyro.Tmp_scaleT4 = 1; //53 |
Kovalev_D | 208:19150d2b528f | 586 | Gyro.Tmp_scaleT5 = 1; |
Kovalev_D | 208:19150d2b528f | 587 | |
Kovalev_D | 208:19150d2b528f | 588 | Gyro.DAC_current_Work =50000; //3 |
Kovalev_D | 208:19150d2b528f | 589 | Gyro.DAC_current_Start =41000; |
Kovalev_D | 211:ac8251b067d2 | 590 | |
Kovalev_D | 214:4c70e452c491 | 591 | |
Kovalev_D | 214:4c70e452c491 | 592 | F_vib=(103200000<<5)/((Gyro.Frq)>>10);//периуд вибро. |
Kovalev_D | 214:4c70e452c491 | 593 | T_vibP = F_vib/10000; |
Kovalev_D | 214:4c70e452c491 | 594 | T_vib_1 = Gyro.AmpPer * T_vibP; |
Kovalev_D | 214:4c70e452c491 | 595 | T_vib_2 = T_vibP * (10000-Gyro.AmpPer); |
Kovalev_D | 214:4c70e452c491 | 596 | LPC_MCPWM->LIM1 = F_vib; |
Kovalev_D | 214:4c70e452c491 | 597 | LPC_MCPWM->LIM2 = F_vib; |
Kovalev_D | 214:4c70e452c491 | 598 | LPC_MCPWM->MAT1 = T_vib_1; |
Kovalev_D | 214:4c70e452c491 | 599 | LPC_MCPWM->MAT2 = T_vib_2; |
Kovalev_D | 206:00341a03e05c | 600 | } |
Kovalev_D | 211:ac8251b067d2 | 601 | Spi.DAC_B=Gyro.PLC_Start; |
Kovalev_D | 188:4c523cc373cc | 602 | switch(Gyro.My_Addres){//смещение поджига и подсветки в зависимости от адреса ГЛД |
Kovalev_D | 188:4c523cc373cc | 603 | case 0: |
Kovalev_D | 209:224e7331a061 | 604 | Gyro.Discharg = StartDischarg << ShiftStart0; |
Kovalev_D | 188:4c523cc373cc | 605 | Gyro.BackLight = StartBackLight << ShiftStart0; |
Kovalev_D | 188:4c523cc373cc | 606 | break; |
Kovalev_D | 188:4c523cc373cc | 607 | case 1: |
Kovalev_D | 209:224e7331a061 | 608 | Gyro.Discharg = StartDischarg << ShiftStart1; |
Kovalev_D | 188:4c523cc373cc | 609 | Gyro.BackLight = StartBackLight << ShiftStart1; |
Kovalev_D | 188:4c523cc373cc | 610 | break; |
Kovalev_D | 188:4c523cc373cc | 611 | case 2: |
Kovalev_D | 209:224e7331a061 | 612 | Gyro.Discharg = StartDischarg << ShiftStart2; |
Kovalev_D | 188:4c523cc373cc | 613 | Gyro.BackLight = StartBackLight << ShiftStart2; |
Kovalev_D | 188:4c523cc373cc | 614 | break; |
Kovalev_D | 188:4c523cc373cc | 615 | case 3: |
Kovalev_D | 209:224e7331a061 | 616 | Gyro.Discharg = StartDischarg << ShiftStart3; |
Kovalev_D | 188:4c523cc373cc | 617 | Gyro.BackLight = StartBackLight << ShiftStart3; |
Kovalev_D | 188:4c523cc373cc | 618 | break; |
Kovalev_D | 205:775d54fdf646 | 619 | } |
Kovalev_D | 205:775d54fdf646 | 620 | |
Kovalev_D | 88:b5c1d9d338d1 | 621 | ///////////////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 622 | //////инициализация цап_LPC (р0.26 цап выход)//////// |
Kovalev_D | 88:b5c1d9d338d1 | 623 | ///////////////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 624 | LPC_PINCON->PINSEL1 = 0x00200000; |
Kovalev_D | 88:b5c1d9d338d1 | 625 | ///////////////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 626 | ////////////начальное значение для цап/////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 627 | //////////////////середина шкалы///////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 628 | ///////////////////////////////////////////////////// |
Kovalev_D | 205:775d54fdf646 | 629 | |
Kovalev_D | 86:398da56ef751 | 630 | //////////////////////////////////////////////////// |
Kovalev_D | 86:398da56ef751 | 631 | /////////////поправочный коэффициент///////////////// |
Kovalev_D | 86:398da56ef751 | 632 | /////////для цапов (граници +-12.5 вольт)//////////// |
Kovalev_D | 86:398da56ef751 | 633 | ///////////////////////////////////////////////////// |
Kovalev_D | 86:398da56ef751 | 634 | K_DAC=65535.0/(65535.0+(deltaDAC+deltaDAC/2)); |
Kovalev_D | 86:398da56ef751 | 635 | K_DAC=0.8; |
Kovalev_D | 88:b5c1d9d338d1 | 636 | |
Kovalev_D | 86:398da56ef751 | 637 | ///////////////////////////////////////////////////// |
Kovalev_D | 86:398da56ef751 | 638 | /////////////обнуление переменых для///////////////// |
Kovalev_D | 86:398da56ef751 | 639 | ///////////////переменных энкодера/////////////////// |
Kovalev_D | 86:398da56ef751 | 640 | ///////////////////////////////////////////////////// |
Kovalev_D | 205:775d54fdf646 | 641 | secPuls =0;// переменная для конопки поджига аск глд(временная) |
Kovalev_D | 112:4a96133a1311 | 642 | Gyro.CaunPlus =0; |
Kovalev_D | 112:4a96133a1311 | 643 | Gyro.CaunMin =0; |
Kovalev_D | 88:b5c1d9d338d1 | 644 | Cur_QEI=0; |
Kovalev_D | 86:398da56ef751 | 645 | Last_QEI=0; |
Kovalev_D | 205:775d54fdf646 | 646 | } |
Kovalev_D | 226:4a4d5bd5fcd7 | 647 | void BUTTON_init(void) { |
Kovalev_D | 232:130a2b5003e6 | 648 | if(Gyro.EXT_Latch)Gyro.EXT_Latch=0; |
Kovalev_D | 232:130a2b5003e6 | 649 | else Gyro.EXT_Latch=1; |
Kovalev_D | 232:130a2b5003e6 | 650 | LPC_GPIOINT->IO2IntClr |= (1 << 10); |
Kovalev_D | 232:130a2b5003e6 | 651 | } |
Kovalev_D | 205:775d54fdf646 | 652 | |
Kovalev_D | 226:4a4d5bd5fcd7 | 653 | /*void EINT3_IRQHandler() |
Kovalev_D | 226:4a4d5bd5fcd7 | 654 | { |
Kovalev_D | 226:4a4d5bd5fcd7 | 655 | if(Gyro.EXT_Latch)Gyro.EXT_Latch=0; |
Kovalev_D | 226:4a4d5bd5fcd7 | 656 | else Gyro.EXT_Latch=1; |
Kovalev_D | 226:4a4d5bd5fcd7 | 657 | LPC_GPIOINT->IO2IntClr |= (1 << 10); |
Kovalev_D | 226:4a4d5bd5fcd7 | 658 | }*/ |
Kovalev_D | 205:775d54fdf646 | 659 | void GLD_Init(void) |
Kovalev_D | 214:4c70e452c491 | 660 | { |
Kovalev_D | 214:4c70e452c491 | 661 | int Dummy; // инициализация мусорки для очистки буфера приема. |
Kovalev_D | 226:4a4d5bd5fcd7 | 662 | BUTTON_init(); |
Kovalev_D | 214:4c70e452c491 | 663 | |
Kovalev_D | 222:7de7b3bf3a1d | 664 | if(Gyro.LG_Type==1)Spi.DAC_A=Gyro.HFO_Max; |
Kovalev_D | 214:4c70e452c491 | 665 | |
Kovalev_D | 214:4c70e452c491 | 666 | |
Kovalev_D | 214:4c70e452c491 | 667 | |
Kovalev_D | 86:398da56ef751 | 668 | ///////////////////////////////////////////////////// |
Kovalev_D | 87:7e575d26d6d0 | 669 | /////////////инициализация энкодера////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 670 | ///////////////////////////////////////////////////// |
Kovalev_D | 214:4c70e452c491 | 671 | |
Kovalev_D | 87:7e575d26d6d0 | 672 | LPC_SC->PCONP |= (1<<18);//0x00040000; включение квадратурного энкодера. |
Kovalev_D | 170:d099c3025f87 | 673 | LPC_SC->PCLKSEL1 |= 0x00000001; // выбор частоты для кв.э. CLK=103MHz |
Kovalev_D | 87:7e575d26d6d0 | 674 | LPC_PINCON->PINSEL3 &= ~0x4100; |
Kovalev_D | 87:7e575d26d6d0 | 675 | LPC_PINCON->PINSEL3 |= 0x4100; //P1.20, p1.23 установить как входы кв.э |
Kovalev_D | 89:a0d344db227e | 676 | LPC_PINCON->PINMODE3 |= 0x3C300; //P1.20, p1.23 |
Kovalev_D | 86:398da56ef751 | 677 | |
Kovalev_D | 220:04c54405b82d | 678 | //Gyro.ShiftMod=150; |
Kovalev_D | 87:7e575d26d6d0 | 679 | LPC_QEI->MAXPOS = MAX_QEI_CNT; //LPC_QEI->"регистор максимального положения" = 2147483646 |
Kovalev_D | 89:a0d344db227e | 680 | LPC_QEI->FILTER = 2; // фильтр( ?? ) |
Kovalev_D | 87:7e575d26d6d0 | 681 | LPC_QEI->CON = 0xF; //сбросить в ноль все счетчики кв.э. (скорость, направление, позицию и тд) |
Kovalev_D | 214:4c70e452c491 | 682 | LPC_QEI->CONF = (1<<2) |(0<<1); //Quadrature inputs, no inverting,only A pulses are counted |
Kovalev_D | 87:7e575d26d6d0 | 683 | |
Kovalev_D | 87:7e575d26d6d0 | 684 | LPC_QEI->CLR = 0x1fff; //r. сбросить все прерывания |
Kovalev_D | 87:7e575d26d6d0 | 685 | LPC_QEI->IEC = 0x1fff; //r. запретить прерывание при изменении направления |
Kovalev_D | 87:7e575d26d6d0 | 686 | |
Kovalev_D | 98:95b8e79f13e1 | 687 | /*NVIC_SetPriority(QEI_IRQn, 0); |
Kovalev_D | 98:95b8e79f13e1 | 688 | NVIC_EnableIRQ(QEI_IRQn);*/ |
Kovalev_D | 88:b5c1d9d338d1 | 689 | ////////////////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 690 | ////////////////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 691 | |
Kovalev_D | 88:b5c1d9d338d1 | 692 | |
Kovalev_D | 89:a0d344db227e | 693 | ////////////////////////////////////////////////////// |
Kovalev_D | 89:a0d344db227e | 694 | ///////////////////////I2C//////////////////////////// |
Kovalev_D | 89:a0d344db227e | 695 | ////////////////////////////////////////////////////// |
Kovalev_D | 87:7e575d26d6d0 | 696 | |
Kovalev_D | 89:a0d344db227e | 697 | LPC_SC->PCONP |= (1 << 19);//включение интерфейса I2C. |
Kovalev_D | 88:b5c1d9d338d1 | 698 | |
Kovalev_D | 89:a0d344db227e | 699 | /* set PIO0.27 and PIO0.28 to I2C0 SDA and SCK */ |
Kovalev_D | 89:a0d344db227e | 700 | /* function to 01 on both SDA and SCK. */ |
Kovalev_D | 89:a0d344db227e | 701 | LPC_PINCON->PINSEL1 &= ~0x03C00000; //P0.27 - SDA. |
Kovalev_D | 89:a0d344db227e | 702 | LPC_PINCON->PINSEL1 |= 0x01400000; //P0.28 - SCK. |
Kovalev_D | 86:398da56ef751 | 703 | |
Kovalev_D | 89:a0d344db227e | 704 | // подтверждение Флаг флаг разрешения |
Kovalev_D | 89:a0d344db227e | 705 | /*сброс флагоф флага прерывания I2C старта интерфейса I2C */ |
Kovalev_D | 89:a0d344db227e | 706 | LPC_I2C0->CONCLR = I2CONCLR_AAC | I2CONCLR_SIC | I2CONCLR_STAC | I2CONCLR_I2ENC; // установка микроконтроллера в режим мастера |
Kovalev_D | 86:398da56ef751 | 707 | |
Kovalev_D | 89:a0d344db227e | 708 | /*--- Reset registers ---*/ |
Kovalev_D | 89:a0d344db227e | 709 | LPC_I2C0->SCLL = I2SCLL_SCLL; // - счетчик scl low time period |
Kovalev_D | 89:a0d344db227e | 710 | LPC_I2C0->SCLH = I2SCLH_SCLH; // - счетчик scl high time period |
Kovalev_D | 99:3d8f206ceac2 | 711 | |
Kovalev_D | 99:3d8f206ceac2 | 712 | I2CMasterBuffer[0] = A_ADDRESS; |
Kovalev_D | 99:3d8f206ceac2 | 713 | I2CMasterBuffer[1] = WRITE_CMD; |
Kovalev_D | 99:3d8f206ceac2 | 714 | I2CMasterBuffer[3] = B_ADDRESS; |
Kovalev_D | 99:3d8f206ceac2 | 715 | I2CMasterBuffer[4] = WRITE_CMD; |
Kovalev_D | 99:3d8f206ceac2 | 716 | |
Kovalev_D | 89:a0d344db227e | 717 | LPC_I2C0->CONSET = I2CONSET_I2EN; //включение интерфейса I2C. |
Kovalev_D | 89:a0d344db227e | 718 | ////////////////////////////////////////////////////////// |
Kovalev_D | 89:a0d344db227e | 719 | ////////////////////////////////////////////////////////// |
Kovalev_D | 86:398da56ef751 | 720 | |
Kovalev_D | 86:398da56ef751 | 721 | |
Kovalev_D | 86:398da56ef751 | 722 | |
Kovalev_D | 92:c892f0311aa7 | 723 | |
Kovalev_D | 92:c892f0311aa7 | 724 | |
Kovalev_D | 92:c892f0311aa7 | 725 | |
Kovalev_D | 92:c892f0311aa7 | 726 | /////////////////////////////////////////////////////// |
Kovalev_D | 92:c892f0311aa7 | 727 | /////////////////////////////////////////////////////// |
Kovalev_D | 92:c892f0311aa7 | 728 | //////////////////////////SPI////////////////////////// |
Kovalev_D | 92:c892f0311aa7 | 729 | /////////////////////////////////////////////////////// |
Kovalev_D | 92:c892f0311aa7 | 730 | Dummy = Dummy; |
Kovalev_D | 92:c892f0311aa7 | 731 | |
Kovalev_D | 92:c892f0311aa7 | 732 | /* Enable AHB clock to the SSP0, SSP1 */ |
Kovalev_D | 92:c892f0311aa7 | 733 | LPC_SC->PCONP |= (0x1<<21); // включение SSP0. |
Kovalev_D | 92:c892f0311aa7 | 734 | |
Kovalev_D | 92:c892f0311aa7 | 735 | /* выбор частоты для переферии используем по умолчания с делителем основной на 4 */ |
Kovalev_D | 92:c892f0311aa7 | 736 | LPC_SC->PCLKSEL1 &= ~(0x3<<10); //00 CLK/4; 1 CLK; 2 CLK/2; 3 CLK/8 |
Kovalev_D | 92:c892f0311aa7 | 737 | LPC_SC->PCLKSEL1 |= (0x0<<10); //00 CLK/4; 1 CLK; 2 CLK/2; 3 CLK/ |
Kovalev_D | 92:c892f0311aa7 | 738 | |
Kovalev_D | 92:c892f0311aa7 | 739 | // P0.15~0.18 as SSP0 |
Kovalev_D | 92:c892f0311aa7 | 740 | LPC_PINCON->PINSEL0 &= ~(0x3UL<<30); //установит Р 0.15 |
Kovalev_D | 92:c892f0311aa7 | 741 | LPC_PINCON->PINSEL0 |= (0x2UL<<30); //частота для синхронизациии Master - slave |
Kovalev_D | 92:c892f0311aa7 | 742 | |
Kovalev_D | 92:c892f0311aa7 | 743 | LPC_PINCON->PINSEL1 &= ~((0x3<<0)|(0x3<<2)|(0x3<<4)); // устанивоить Р 0.17 и Р 0.18 |
Kovalev_D | 92:c892f0311aa7 | 744 | LPC_PINCON->PINSEL1 |= ((0x2<<2)|(0x2<<4)); // как MISO0 и MOSI0 |
Kovalev_D | 92:c892f0311aa7 | 745 | |
Kovalev_D | 92:c892f0311aa7 | 746 | LPC_PINCON->PINMODE0 &= ~(0x3UL<<30);// ? установление на Р 0.15 режима On-Chip pull-down resistor enabled |
Kovalev_D | 92:c892f0311aa7 | 747 | LPC_PINCON->PINMODE0 |= (0x3UL<<30);// ? установление на Р 0.15 режима On-Chip pull-down resistor enabled |
Kovalev_D | 92:c892f0311aa7 | 748 | |
Kovalev_D | 92:c892f0311aa7 | 749 | LPC_PINCON->PINMODE1 &= ~((0x3<<2)|(0x3<<4));// ? установление на Р 0.17 и Р 0.18 режима On-Chip pull-down resistor enabled |
Kovalev_D | 92:c892f0311aa7 | 750 | LPC_PINCON->PINMODE1 |= ((0x3<<2)|(0x3<<4));// ? установление на Р 0.17 и Р 0.18 режима On-Chip pull-down resistor enabled |
Kovalev_D | 92:c892f0311aa7 | 751 | |
Kovalev_D | 92:c892f0311aa7 | 752 | LPC_SSP0->CR0 = ((3<<8)|(0<<7)|(0<<4) |0xF); // (0xF)-установление DSS(Data sise select) в 16-битный формат, (3<<8 scr - выбор частоты), |
Kovalev_D | 92:c892f0311aa7 | 753 | // низкий уровень линии тактирования между кадрами, прикрепление передачи к первому нарастанию тактового мигнала |
Kovalev_D | 92:c892f0311aa7 | 754 | // формат кадра TI. |
Kovalev_D | 92:c892f0311aa7 | 755 | |
Kovalev_D | 92:c892f0311aa7 | 756 | /* SSPCPSR clock prescale register, master mode, minimum divisor is 0x02 */ |
Kovalev_D | 92:c892f0311aa7 | 757 | LPC_SSP0->CPSR = 0x2; // freq = CLK/(cpsdvr*(scr+1)) = 1.6 MHz |
Kovalev_D | 92:c892f0311aa7 | 758 | |
Kovalev_D | 92:c892f0311aa7 | 759 | /*SSP enable, master mode */ |
Kovalev_D | 92:c892f0311aa7 | 760 | LPC_SSP0->CR1 = SSPCR1_SSE; |
Kovalev_D | 92:c892f0311aa7 | 761 | // LPC_SSP1->CR1 = SSPCR1_SSE; |
Kovalev_D | 190:289514f730ee | 762 | while (LPC_SSP0->SR & SSP_BUSY); |
Kovalev_D | 92:c892f0311aa7 | 763 | while (LPC_SSP0->SR & RX_SSP_notEMPT) /* clear the RxFIFO */ |
Kovalev_D | 92:c892f0311aa7 | 764 | Dummy = LPC_SSP0->DR; |
Kovalev_D | 92:c892f0311aa7 | 765 | //all pins after reset is in GPIO mode, so CS pins needn't to configure |
Kovalev_D | 92:c892f0311aa7 | 766 | LPC_GPIO0->FIODIR |= (1<<16); // P0.16 defined as CS for ADC |
Kovalev_D | 92:c892f0311aa7 | 767 | LPC_GPIO0->FIOSET |= (1<<16); // set CS for ADC |
Kovalev_D | 92:c892f0311aa7 | 768 | |
Kovalev_D | 92:c892f0311aa7 | 769 | LPC_GPIO0->FIODIR |= (1<<23); // P defined as CS for DAC |
Kovalev_D | 92:c892f0311aa7 | 770 | LPC_GPIO0->FIOCLR |= (1<<23); // set CS for DAC |
Kovalev_D | 92:c892f0311aa7 | 771 | while (LPC_SSP1->SR & RX_SSP_notEMPT) |
Kovalev_D | 92:c892f0311aa7 | 772 | Dummy = LPC_SSP1->DR; /* clear the RxFIFO */ |
Kovalev_D | 92:c892f0311aa7 | 773 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////// |
Kovalev_D | 92:c892f0311aa7 | 774 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////// |
Kovalev_D | 92:c892f0311aa7 | 775 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////// |
Kovalev_D | 92:c892f0311aa7 | 776 | |
Kovalev_D | 92:c892f0311aa7 | 777 | |
Kovalev_D | 92:c892f0311aa7 | 778 | |
Kovalev_D | 92:c892f0311aa7 | 779 | |
Kovalev_D | 86:398da56ef751 | 780 | ///////////////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 781 | /////////////////инициализация ног/////////////////// |
Kovalev_D | 86:398da56ef751 | 782 | ///////////////////////////////////////////////////// |
Kovalev_D | 89:a0d344db227e | 783 | |
Kovalev_D | 89:a0d344db227e | 784 | ///////////////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 785 | Gyro.PinRegOld = 0xffffffff; |
Kovalev_D | 88:b5c1d9d338d1 | 786 | Gyro.PinReg = 0; // всЁ выключенно |
Kovalev_D | 88:b5c1d9d338d1 | 787 | PinCheng(); |
Kovalev_D | 89:a0d344db227e | 788 | ///////////////////////////////////////////////////// |
Kovalev_D | 193:a0fe8bfc97e4 | 789 | Gyro.ModeOut=0; |
Kovalev_D | 87:7e575d26d6d0 | 790 | ///////////////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 791 | //////////////отладочный светодиод/////////////////// |
Kovalev_D | 87:7e575d26d6d0 | 792 | ///////////////////////////////////////////////////// |
Kovalev_D | 98:95b8e79f13e1 | 793 | |
Kovalev_D | 98:95b8e79f13e1 | 794 | LPC_PINCON->PINSEL0 &= ~(0x00<<28); |
Kovalev_D | 214:4c70e452c491 | 795 | LPC_PINCON->PINSEL0 |= (0x00<<28); |
Kovalev_D | 190:289514f730ee | 796 | LPC_PINCON->PINMODE0 |= (0x3<<28); |
Kovalev_D | 190:289514f730ee | 797 | LPC_GPIO1->FIODIR |= (1<<30); |
Kovalev_D | 87:7e575d26d6d0 | 798 | ///////////////////////////////////////////////////// |
Kovalev_D | 87:7e575d26d6d0 | 799 | ///////////////////////////////////////////////////// |
Kovalev_D | 193:a0fe8bfc97e4 | 800 | NVIC_EnableIRQ(EINT3_IRQn); |
Kovalev_D | 193:a0fe8bfc97e4 | 801 | LPC_GPIOINT->IO0IntEnR |= (1<<1); /* enable rasing edge irq */ |
Kovalev_D | 87:7e575d26d6d0 | 802 | ///////////////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 803 | ////////////////управление уартом//////////////////// |
Kovalev_D | 87:7e575d26d6d0 | 804 | ///////////////////////////////////////////////////// |
Kovalev_D | 89:a0d344db227e | 805 | LPC_GPIO2->FIODIR |= (1<<7);//направление ноги uart enable |
Kovalev_D | 87:7e575d26d6d0 | 806 | ///////////////////////////////////////////////////// |
Kovalev_D | 87:7e575d26d6d0 | 807 | ///////////////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 808 | |
Kovalev_D | 88:b5c1d9d338d1 | 809 | |
Kovalev_D | 88:b5c1d9d338d1 | 810 | |
Kovalev_D | 87:7e575d26d6d0 | 811 | ///////////////////////////////////////////////////// |
Kovalev_D | 89:a0d344db227e | 812 | ///////////////////////поджиг//////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 813 | ///////////////////////////////////////////////////// |
Kovalev_D | 98:95b8e79f13e1 | 814 | LPC_PINCON->PINSEL0 &= ~(3<<8); //e. P0.4 is GPIO pin (запись ( 00 ) в 9:8 бит PISEL0 выбор P0.4 как GPIO) |
Kovalev_D | 98:95b8e79f13e1 | 815 | LPC_PINCON->PINMODE0 |= (3<<8); //e. P0.4 is GPIO pin (запись ( 11 ) в 9:8 бит PINMODE0 "для включения подтягивающего резистора") |
Kovalev_D | 226:4a4d5bd5fcd7 | 816 | LPC_GPIO0->FIODIR |= (1<<4); //e. P0.4 is output (запись ( 1 ) в 5 бит FIODIR выбор P0.4 как выход) |
Kovalev_D | 87:7e575d26d6d0 | 817 | ///////////////////////////////////////////////////// |
Kovalev_D | 87:7e575d26d6d0 | 818 | ///////////////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 819 | |
Kovalev_D | 88:b5c1d9d338d1 | 820 | |
Kovalev_D | 88:b5c1d9d338d1 | 821 | |
Kovalev_D | 87:7e575d26d6d0 | 822 | ///////////////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 823 | /////////////////////вибро 1///////////////////////// |
Kovalev_D | 87:7e575d26d6d0 | 824 | ///////////////////////////////////////////////////// |
Kovalev_D | 98:95b8e79f13e1 | 825 | LPC_PINCON->PINSEL3 &= ~(0x00<<18); //e. P1.25 is GPIO pin |
Kovalev_D | 98:95b8e79f13e1 | 826 | LPC_PINCON->PINSEL3 |= (0x00<<18); //e. P1.25 is GPIO pin |
Kovalev_D | 87:7e575d26d6d0 | 827 | LPC_PINCON->PINMODE3 |= (3<<18); //e. P1.25 (включениe подтягивающего резистора") |
Kovalev_D | 87:7e575d26d6d0 | 828 | LPC_GPIO1->FIODIR |= (1<<25); //e. P0.5 is output (запись ( 1 ) в 5 бит FIODIR выбор P0.5 как выход) |
Kovalev_D | 87:7e575d26d6d0 | 829 | LPC_GPIO1->FIOCLR |= (1<<25); |
Kovalev_D | 88:b5c1d9d338d1 | 830 | ////////////////////////////////////////////////////// |
Kovalev_D | 89:a0d344db227e | 831 | //////////////////////вибро 2///////////////////////// |
Kovalev_D | 89:a0d344db227e | 832 | ////////////////////////////////////////////////////// |
Kovalev_D | 98:95b8e79f13e1 | 833 | LPC_PINCON->PINSEL3 &= ~(0x00<<24); //e. P1.28 is GPIO pin |
Kovalev_D | 98:95b8e79f13e1 | 834 | LPC_PINCON->PINSEL3 |= (0x00<<24); //e. P1.28 is GPIO pin |
Kovalev_D | 87:7e575d26d6d0 | 835 | LPC_PINCON->PINMODE3 |= (3<<24); //e. P1.28 is GPIO pin (запись ( 11 ) в бит PINMODE0 "для включения подтягивающего резистора") |
Kovalev_D | 87:7e575d26d6d0 | 836 | LPC_GPIO1->FIODIR |= (1<<28); //e. P1.28 is output (запись ( 1 ) в 5 бит FIODIR выбор P0.5 как выход) |
Kovalev_D | 87:7e575d26d6d0 | 837 | LPC_GPIO1->FIOCLR |= (1<<28); |
Kovalev_D | 87:7e575d26d6d0 | 838 | ///////////////////////////////////////////////////// |
Kovalev_D | 87:7e575d26d6d0 | 839 | ///////////////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 840 | |
Kovalev_D | 88:b5c1d9d338d1 | 841 | |
Kovalev_D | 88:b5c1d9d338d1 | 842 | |
Kovalev_D | 87:7e575d26d6d0 | 843 | ///////////////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 844 | /////////////инициализация подсветки///////////////// |
Kovalev_D | 87:7e575d26d6d0 | 845 | ///////////////////////////////////////////////////// |
Kovalev_D | 98:95b8e79f13e1 | 846 | LPC_PINCON->PINSEL2 &= ~(0x00<<24); |
Kovalev_D | 98:95b8e79f13e1 | 847 | LPC_PINCON->PINSEL2 |= (0x00<<24); //e. P2.12 is GPIO pin |
Kovalev_D | 87:7e575d26d6d0 | 848 | LPC_PINCON->PINMODE3 |= (3<<24); //e. P1.28 is GPIO pin (запись ( 11 ) в бит PINMODE0 "для включения подтягивающего резистора") |
Kovalev_D | 87:7e575d26d6d0 | 849 | LPC_GPIO2->FIODIR |= (1<<12); //e. P1.28 is output (запись ( 1 ) в 5 бит FIODIR выбор P0.5 как выход) |
Kovalev_D | 87:7e575d26d6d0 | 850 | LPC_GPIO2->FIOCLR |= (1<<12); |
Kovalev_D | 88:b5c1d9d338d1 | 851 | /////////////////////////////////////////////////////// |
Kovalev_D | 86:398da56ef751 | 852 | /////////////////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 853 | |
Kovalev_D | 88:b5c1d9d338d1 | 854 | |
Kovalev_D | 88:b5c1d9d338d1 | 855 | /////////////////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 856 | /////////////////////////////////////////////////////// |
Kovalev_D | 89:a0d344db227e | 857 | ///////////////////включение таймеров////////////////// |
Kovalev_D | 89:a0d344db227e | 858 | /////////////////////////////////////////////////////// |
Kovalev_D | 86:398da56ef751 | 859 | enable_timer1(); |
Kovalev_D | 86:398da56ef751 | 860 | enable_timer2(); |
Kovalev_D | 89:a0d344db227e | 861 | /////////////////////////////////////////////////////// |
Kovalev_D | 89:a0d344db227e | 862 | |
Kovalev_D | 89:a0d344db227e | 863 | ////////////////////////////////////////////////////////////////// |
Kovalev_D | 89:a0d344db227e | 864 | // LPC_GPIO0->FIOCLR = (1<<5);/////////////отключение поджига |
Kovalev_D | 90:d9b6a4bc5065 | 865 | |
Kovalev_D | 90:d9b6a4bc5065 | 866 | |
Kovalev_D | 90:d9b6a4bc5065 | 867 | |
Kovalev_D | 90:d9b6a4bc5065 | 868 | /////////////////////////////////////////////////////// |
Kovalev_D | 90:d9b6a4bc5065 | 869 | /////////////////////////////////////////////////////// |
Kovalev_D | 90:d9b6a4bc5065 | 870 | //////////////////////////SPI////////////////////////// |
Kovalev_D | 90:d9b6a4bc5065 | 871 | /////////////////////////////////////////////////////// |
Kovalev_D | 90:d9b6a4bc5065 | 872 | Dummy = Dummy; |
Kovalev_D | 90:d9b6a4bc5065 | 873 | |
Kovalev_D | 90:d9b6a4bc5065 | 874 | /* Enable AHB clock to the SSP0, SSP1 */ |
Kovalev_D | 90:d9b6a4bc5065 | 875 | LPC_SC->PCONP |= (0x1<<21); // включение SSP0. |
Kovalev_D | 90:d9b6a4bc5065 | 876 | |
Kovalev_D | 90:d9b6a4bc5065 | 877 | /* выбор частоты для переферии используем по умолчания с делителем основной на 4 */ |
Kovalev_D | 90:d9b6a4bc5065 | 878 | LPC_SC->PCLKSEL1 &= ~(0x3<<10); //00 CLK/4; 1 CLK; 2 CLK/2; 3 CLK/8 |
Kovalev_D | 90:d9b6a4bc5065 | 879 | LPC_SC->PCLKSEL1 |= (0x0<<10); //00 CLK/4; 1 CLK; 2 CLK/2; 3 CLK/ |
Kovalev_D | 90:d9b6a4bc5065 | 880 | |
Kovalev_D | 90:d9b6a4bc5065 | 881 | // P0.15~0.18 as SSP0 |
Kovalev_D | 90:d9b6a4bc5065 | 882 | LPC_PINCON->PINSEL0 &= ~(0x3UL<<30); //установит Р 0.15 |
Kovalev_D | 90:d9b6a4bc5065 | 883 | LPC_PINCON->PINSEL0 |= (0x2UL<<30); //частота для синхронизациии Master - slave |
Kovalev_D | 90:d9b6a4bc5065 | 884 | |
Kovalev_D | 90:d9b6a4bc5065 | 885 | LPC_PINCON->PINSEL1 &= ~((0x3<<0)|(0x3<<2)|(0x3<<4)); // устанивоить Р 0.17 и Р 0.18 |
Kovalev_D | 90:d9b6a4bc5065 | 886 | LPC_PINCON->PINSEL1 |= ((0x2<<2)|(0x2<<4)); // как MISO0 и MOSI0 |
Kovalev_D | 90:d9b6a4bc5065 | 887 | |
Kovalev_D | 90:d9b6a4bc5065 | 888 | LPC_PINCON->PINMODE0 &= ~(0x3UL<<30);// ? установление на Р 0.15 режима On-Chip pull-down resistor enabled |
Kovalev_D | 90:d9b6a4bc5065 | 889 | LPC_PINCON->PINMODE0 |= (0x3UL<<30);// ? установление на Р 0.15 режима On-Chip pull-down resistor enabled |
Kovalev_D | 90:d9b6a4bc5065 | 890 | |
Kovalev_D | 90:d9b6a4bc5065 | 891 | LPC_PINCON->PINMODE1 &= ~((0x3<<2)|(0x3<<4));// ? установление на Р 0.17 и Р 0.18 режима On-Chip pull-down resistor enabled |
Kovalev_D | 90:d9b6a4bc5065 | 892 | LPC_PINCON->PINMODE1 |= ((0x3<<2)|(0x3<<4));// ? установление на Р 0.17 и Р 0.18 режима On-Chip pull-down resistor enabled |
Kovalev_D | 90:d9b6a4bc5065 | 893 | |
Kovalev_D | 90:d9b6a4bc5065 | 894 | LPC_SSP0->CR0 = ((3<<8)|(0<<7)|(0<<4) |0xF); // (0xF)-установление DSS(Data sise select) в 16-битный формат, (3<<8 scr - выбор частоты), |
Kovalev_D | 90:d9b6a4bc5065 | 895 | // низкий уровень линии тактирования между кадрами, прикрепление передачи к первому нарастанию тактового мигнала |
Kovalev_D | 90:d9b6a4bc5065 | 896 | // формат кадра TI. |
Kovalev_D | 90:d9b6a4bc5065 | 897 | |
Kovalev_D | 90:d9b6a4bc5065 | 898 | /* SSPCPSR clock prescale register, master mode, minimum divisor is 0x02 */ |
Kovalev_D | 90:d9b6a4bc5065 | 899 | LPC_SSP0->CPSR = 0x2; // freq = CLK/(cpsdvr*(scr+1)) = 1.6 MHz |
Kovalev_D | 90:d9b6a4bc5065 | 900 | |
Kovalev_D | 90:d9b6a4bc5065 | 901 | /*SSP enable, master mode */ |
Kovalev_D | 90:d9b6a4bc5065 | 902 | LPC_SSP0->CR1 = SSPCR1_SSE; |
Kovalev_D | 90:d9b6a4bc5065 | 903 | // LPC_SSP1->CR1 = SSPCR1_SSE; |
Kovalev_D | 90:d9b6a4bc5065 | 904 | while (LPC_SSP0->SR & SSP_BUSY); |
Kovalev_D | 170:d099c3025f87 | 905 | while (LPC_SSP0->SR & RX_SSP_notEMPT) /* clear the RxFIFO */ |
Kovalev_D | 90:d9b6a4bc5065 | 906 | Dummy = LPC_SSP0->DR; |
Kovalev_D | 90:d9b6a4bc5065 | 907 | //all pins after reset is in GPIO mode, so CS pins needn't to configure |
Kovalev_D | 90:d9b6a4bc5065 | 908 | LPC_GPIO0->FIODIR |= (1<<16); // P0.16 defined as CS for ADC |
Kovalev_D | 90:d9b6a4bc5065 | 909 | LPC_GPIO0->FIOSET |= (1<<16); // set CS for ADC |
Kovalev_D | 90:d9b6a4bc5065 | 910 | |
Kovalev_D | 92:c892f0311aa7 | 911 | LPC_GPIO0->FIODIR |= (1<<23); // P defined as CS for DAC |
Kovalev_D | 92:c892f0311aa7 | 912 | LPC_GPIO0->FIOCLR |= (1<<23); // set CS for DAC |
Kovalev_D | 92:c892f0311aa7 | 913 | while (LPC_SSP1->SR & RX_SSP_notEMPT) |
Kovalev_D | 92:c892f0311aa7 | 914 | Dummy = LPC_SSP1->DR; /* clear the RxFIFO */ |
Kovalev_D | 205:775d54fdf646 | 915 | //Gyro=GyroP.str; |
Kovalev_D | 205:775d54fdf646 | 916 | //Gyro = (*(struct Gyro*)(&GyroP.Str)); |
Kovalev_D | 90:d9b6a4bc5065 | 917 | |
Kovalev_D | 86:398da56ef751 | 918 | } |
igor_v | 13:e2a1d18677b8 | 919 | |
igor_v | 0:8ad47e2b6f00 | 920 | |
igor_v | 0:8ad47e2b6f00 | 921 | |
igor_v | 0:8ad47e2b6f00 | 922 | |
igor_v | 0:8ad47e2b6f00 | 923 |