![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
forkd
Fork of LGstaandart by
Global.c@231:079835d508ef, 2018-01-25 (annotated)
- Committer:
- Kovalev_D
- Date:
- Thu Jan 25 13:59:43 2018 +0000
- Revision:
- 231:079835d508ef
- Parent:
- 227:2774b56bfab0
- Child:
- 232:130a2b5003e6
termo
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 | 222:7de7b3bf3a1d | 319 | Gyro.TimeToJump = GyroP.Str.TimeToJump; |
Kovalev_D | 222:7de7b3bf3a1d | 320 | Gyro.JumpDelta = GyroP.Str.JumpDelta; |
Kovalev_D | 220:04c54405b82d | 321 | Gyro.ShiftMod = GyroP.Str.ShiftMod; |
Kovalev_D | 211:ac8251b067d2 | 322 | Gyro.PLC_Start = 0x7fff+GyroP.Str.PLC_Start; |
Kovalev_D | 225:f8fee6c586cc | 323 | Gyro.DownTreshold = (unsigned int)((GyroP.Str.DownTreshold-0x7fff)&0xffff); //27 |
Kovalev_D | 225:f8fee6c586cc | 324 | Gyro.HighTreshold = (unsigned int)((GyroP.Str.HighTreshold-0x7fff)&0xffff); |
Kovalev_D | 225:f8fee6c586cc | 325 | Gyro.PLCDelay = GyroP.Str.PLCDelay; |
Kovalev_D | 225:f8fee6c586cc | 326 | Gyro.ResetLevelCool = (unsigned int)((GyroP.Str.ResetLevelCool-0x7fff)&0xffff); //105 |
Kovalev_D | 225:f8fee6c586cc | 327 | Gyro.ResetLevelHeat = (unsigned int)((GyroP.Str.ResetLevelHeat-0x7fff)&0xffff); |
Kovalev_D | 211:ac8251b067d2 | 328 | Gyro.HFO_Gain = GyroP.Str.HFO_Gain; |
Kovalev_D | 226:4a4d5bd5fcd7 | 329 | Gyro.HFO_ref = (unsigned int)(GyroP.Str.HFO_ref); |
Kovalev_D | 211:ac8251b067d2 | 330 | Gyro.LG_Type = GyroP.Str.LG_Type; |
Kovalev_D | 226:4a4d5bd5fcd7 | 331 | Gyro.LG_Type = 1; |
Kovalev_D | 208:19150d2b528f | 332 | Gyro.My_Addres = GyroP.Str.My_Addres; // Gyro.My_Addres = 0; |
Kovalev_D | 209:224e7331a061 | 333 | Gyro.GLD_Serial = GyroP.Str.GLD_Serial; |
Kovalev_D | 209:224e7331a061 | 334 | Gyro.FrqHZ = (7680000/GyroP.Str.FrqHZ); |
Kovalev_D | 209:224e7331a061 | 335 | Gyro.Frq = ((7680000/GyroP.Str.FrqHZ)<<16); |
Kovalev_D | 209:224e7331a061 | 336 | Gyro.FrqHZmin = ((7680000/GyroP.Str.FrqHZmin)<<16); |
Kovalev_D | 209:224e7331a061 | 337 | Gyro.FrqHZmax = ((7680000/GyroP.Str.FrqHZmax)<<16); |
Kovalev_D | 208:19150d2b528f | 338 | Gyro.FrqChengSpeed = GyroP.Str.FrqChengSpeed; |
Kovalev_D | 208:19150d2b528f | 339 | Gyro.PLC_Gain = GyroP.Str.PLC_Gain; |
Kovalev_D | 208:19150d2b528f | 340 | Gyro.PLC_Phase = GyroP.Str.PLC_Phase; |
Kovalev_D | 208:19150d2b528f | 341 | Gyro.ModAmp = GyroP.Str.ModAmp; |
Kovalev_D | 208:19150d2b528f | 342 | Gyro.FrqPhase = GyroP.Str.FrqPhase; |
Kovalev_D | 214:4c70e452c491 | 343 | Gyro.AmpPer = 700;//GyroP.Str.AmpPer*100; |
Kovalev_D | 214:4c70e452c491 | 344 | Gyro.Amp =(GyroP.Str.AmpPer<<17); |
Kovalev_D | 208:19150d2b528f | 345 | Gyro.AmpSpeed = GyroP.Str.AmpSpeed; |
Kovalev_D | 208:19150d2b528f | 346 | Gyro.AmpPerDel = GyroP.Str.AmpPerDel; |
Kovalev_D | 208:19150d2b528f | 347 | temp=((GyroP.Str.VB_Fdf_Hi<<16) | GyroP.Str.VB_Fdf_Lo); |
Kovalev_D | 210:b02fa166315d | 348 | temp=temp*20; |
Kovalev_D | 208:19150d2b528f | 349 | Gyro.AmpTarget=(unsigned int)(temp); |
Kovalev_D | 208:19150d2b528f | 350 | Gyro.AmpPerMin = GyroP.Str.AmpPerMin; |
Kovalev_D | 208:19150d2b528f | 351 | Gyro.AmpPerMax = GyroP.Str.AmpPerMax; |
Kovalev_D | 208:19150d2b528f | 352 | Gyro.AmpMin = GyroP.Str.AmpMin; |
Kovalev_D | 208:19150d2b528f | 353 | Gyro.AmpTD = GyroP.Str.AmpTD; |
Kovalev_D | 214:4c70e452c491 | 354 | F_vib=(103200000<<5)/((Gyro.Frq)>>10);//периуд вибро. |
Kovalev_D | 214:4c70e452c491 | 355 | T_vibP = F_vib/10000; |
Kovalev_D | 214:4c70e452c491 | 356 | T_vib_1 = Gyro.AmpPer * T_vibP; |
Kovalev_D | 214:4c70e452c491 | 357 | T_vib_2 = T_vibP * (10000-Gyro.AmpPer); |
Kovalev_D | 214:4c70e452c491 | 358 | LPC_MCPWM->LIM1 = F_vib; |
Kovalev_D | 214:4c70e452c491 | 359 | LPC_MCPWM->LIM2 = F_vib; |
Kovalev_D | 214:4c70e452c491 | 360 | LPC_MCPWM->MAT1 = T_vib_1; |
Kovalev_D | 214:4c70e452c491 | 361 | LPC_MCPWM->MAT2 = T_vib_2; |
Kovalev_D | 211:ac8251b067d2 | 362 | if(Gyro.LG_Type==1){ |
Kovalev_D | 225:f8fee6c586cc | 363 | //Gyro.HFO_Max=((int)(GyroP.Str.DAC_current_Work*0.67)-2000); |
Kovalev_D | 225:f8fee6c586cc | 364 | Gyro.HFO_Max=0xffff-GyroP.Str.DAC_current_Work; |
Kovalev_D | 225:f8fee6c586cc | 365 | |
Kovalev_D | 225:f8fee6c586cc | 366 | //Gyro.HFO_Min=((int)(GyroP.Str.DAC_current_Start*0.67)-2000); |
Kovalev_D | 225:f8fee6c586cc | 367 | Gyro.HFO_Min= 0xffff-GyroP.Str.DAC_current_Start; |
Kovalev_D | 211:ac8251b067d2 | 368 | } |
Kovalev_D | 211:ac8251b067d2 | 369 | else Spi.DAC_A = ((((int)(GyroP.Str.DAC_current_Work+0x7fff) & 0xffff)+22544)*0.65); |
Kovalev_D | 209:224e7331a061 | 370 | Gyro.DacIn = GyroP.Str.DAC_current_Work; |
Kovalev_D | 208:19150d2b528f | 371 | // Gyro.TermoNKU = GyroP.Str.TermoNKU<<2; |
Kovalev_D | 231:079835d508ef | 372 | Gyro.Firmware_Version = 17543; |
Kovalev_D | 208:19150d2b528f | 373 | // Spi.DAC_A = GyroP.Str.DAC_A; |
Kovalev_D | 209:224e7331a061 | 374 | // Spi.DAC_B = GyroP.Str.DAC_B; |
Kovalev_D | 208:19150d2b528f | 375 | Gyro.Gain_Sin = GyroP.Str.Gain_Sin; |
Kovalev_D | 208:19150d2b528f | 376 | Gyro.Gain_Cos = GyroP.Str.Gain_Cos; |
Kovalev_D | 208:19150d2b528f | 377 | Out_G_photo(Gyro.Gain_Sin, Gyro.Gain_Cos); |
Kovalev_D | 231:079835d508ef | 378 | |
Kovalev_D | 231:079835d508ef | 379 | |
Kovalev_D | 231:079835d508ef | 380 | TermoCorrStatic.TermoTempStatic.Str.TermoTempStatic_0 = GyroP.Str.TStatic_0; |
Kovalev_D | 231:079835d508ef | 381 | TermoCorrStatic.TermoTempStatic.Str.TermoTempStatic_1 = GyroP.Str.TStatic_1; |
Kovalev_D | 231:079835d508ef | 382 | TermoCorrStatic.TermoTempStatic.Str.TermoTempStatic_2 = GyroP.Str.TStatic_2; |
Kovalev_D | 231:079835d508ef | 383 | TermoCorrStatic.TermoTempStatic.Str.TermoTempStatic_3 = GyroP.Str.TStatic_3; |
Kovalev_D | 231:079835d508ef | 384 | TermoCorrStatic.TermoTempStatic.Str.TermoTempStatic_4 = GyroP.Str.TStatic_4; |
Kovalev_D | 231:079835d508ef | 385 | TermoCorrStatic.TermoTempStatic.Str.TermoTempStatic_5 = GyroP.Str.TStatic_5; |
Kovalev_D | 231:079835d508ef | 386 | TermoCorrStatic.TermoTempStatic.Str.TermoTempStatic_6 = GyroP.Str.TStatic_6; |
Kovalev_D | 231:079835d508ef | 387 | TermoCorrStatic.TermoTempStatic.Str.TermoTempStatic_7 = GyroP.Str.TStatic_7; |
Kovalev_D | 231:079835d508ef | 388 | TermoCorrStatic.TermoTempStatic.Str.TermoTempStatic_8 = GyroP.Str.TStatic_8; |
Kovalev_D | 231:079835d508ef | 389 | TermoCorrStatic.TermoTempStatic.Str.TermoTempStatic_9 = GyroP.Str.TStatic_9; |
Kovalev_D | 231:079835d508ef | 390 | TermoCorrStatic.TermoTempStatic.Str.TermoTempStatic_10 = GyroP.Str.TStatic_10; |
Kovalev_D | 231:079835d508ef | 391 | TermoCorrStatic.TermoTempStatic.Str.TermoTempStatic_11 = GyroP.Str.TStatic_11; |
Kovalev_D | 231:079835d508ef | 392 | TermoCorrStatic.TermoTempStatic.Str.TermoTempStatic_12 = GyroP.Str.TStatic_12; |
Kovalev_D | 231:079835d508ef | 393 | TermoCorrStatic.TermoTempStatic.Str.TermoTempStatic_13 = GyroP.Str.TStatic_13; |
Kovalev_D | 231:079835d508ef | 394 | |
Kovalev_D | 231:079835d508ef | 395 | |
Kovalev_D | 231:079835d508ef | 396 | TermoCorrStatic.TermoDeltaStatic.Str.TermoDeltaStatic_0 = Float(GyroP.Str.TermoDeltaStatic_0, GyroP.Str.TermoDeltaStatic_1 ); |
Kovalev_D | 231:079835d508ef | 397 | TermoCorrStatic.TermoDeltaStatic.Str.TermoDeltaStatic_1 = Float(GyroP.Str.TermoDeltaStatic_2, GyroP.Str.TermoDeltaStatic_3 ); |
Kovalev_D | 231:079835d508ef | 398 | TermoCorrStatic.TermoDeltaStatic.Str.TermoDeltaStatic_2 = Float(GyroP.Str.TermoDeltaStatic_4, GyroP.Str.TermoDeltaStatic_5 ); |
Kovalev_D | 231:079835d508ef | 399 | TermoCorrStatic.TermoDeltaStatic.Str.TermoDeltaStatic_3 = Float(GyroP.Str.TermoDeltaStatic_6, GyroP.Str.TermoDeltaStatic_7 ); |
Kovalev_D | 231:079835d508ef | 400 | TermoCorrStatic.TermoDeltaStatic.Str.TermoDeltaStatic_4 = Float(GyroP.Str.TermoDeltaStatic_8, GyroP.Str.TermoDeltaStatic_9 ); |
Kovalev_D | 231:079835d508ef | 401 | TermoCorrStatic.TermoDeltaStatic.Str.TermoDeltaStatic_5 = Float(GyroP.Str.TermoDeltaStatic_10,GyroP.Str.TermoDeltaStatic_11); |
Kovalev_D | 231:079835d508ef | 402 | TermoCorrStatic.TermoDeltaStatic.Str.TermoDeltaStatic_6 = Float(GyroP.Str.TermoDeltaStatic_12,GyroP.Str.TermoDeltaStatic_13); |
Kovalev_D | 231:079835d508ef | 403 | TermoCorrStatic.TermoDeltaStatic.Str.TermoDeltaStatic_7 = Float(GyroP.Str.TermoDeltaStatic_14,GyroP.Str.TermoDeltaStatic_15); |
Kovalev_D | 231:079835d508ef | 404 | TermoCorrStatic.TermoDeltaStatic.Str.TermoDeltaStatic_8 = Float(GyroP.Str.TermoDeltaStatic_16,GyroP.Str.TermoDeltaStatic_17); |
Kovalev_D | 231:079835d508ef | 405 | TermoCorrStatic.TermoDeltaStatic.Str.TermoDeltaStatic_9 = Float(GyroP.Str.TermoDeltaStatic_18,GyroP.Str.TermoDeltaStatic_19); |
Kovalev_D | 231:079835d508ef | 406 | TermoCorrStatic.TermoDeltaStatic.Str.TermoDeltaStatic_10 = Float(GyroP.Str.TermoDeltaStatic_20,GyroP.Str.TermoDeltaStatic_21); |
Kovalev_D | 231:079835d508ef | 407 | TermoCorrStatic.TermoDeltaStatic.Str.TermoDeltaStatic_11 = Float(GyroP.Str.TermoDeltaStatic_22,GyroP.Str.TermoDeltaStatic_23); |
Kovalev_D | 231:079835d508ef | 408 | TermoCorrStatic.TermoDeltaStatic.Str.TermoDeltaStatic_12 = Float(GyroP.Str.TermoDeltaStatic_24,GyroP.Str.TermoDeltaStatic_25); |
Kovalev_D | 231:079835d508ef | 409 | TermoCorrStatic.TermoDeltaStatic.Str.TermoDeltaStatic_13 = Float(GyroP.Str.TermoDeltaStatic_26,GyroP.Str.TermoDeltaStatic_27); |
Kovalev_D | 231:079835d508ef | 410 | |
Kovalev_D | 231:079835d508ef | 411 | |
Kovalev_D | 231:079835d508ef | 412 | TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_0 = GyroP.Str.TDCool_0; |
Kovalev_D | 231:079835d508ef | 413 | TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_1 = GyroP.Str.TDCool_1; |
Kovalev_D | 231:079835d508ef | 414 | TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_2 = GyroP.Str.TDCool_2; |
Kovalev_D | 231:079835d508ef | 415 | TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_3 = GyroP.Str.TDCool_3; |
Kovalev_D | 231:079835d508ef | 416 | TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_4 = GyroP.Str.TDCool_4; |
Kovalev_D | 231:079835d508ef | 417 | TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_5 = GyroP.Str.TDCool_5; |
Kovalev_D | 231:079835d508ef | 418 | TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_6 = GyroP.Str.TDCool_6; |
Kovalev_D | 231:079835d508ef | 419 | TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_7 = GyroP.Str.TDCool_7; |
Kovalev_D | 231:079835d508ef | 420 | TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_8 = GyroP.Str.TDCool_8; |
Kovalev_D | 231:079835d508ef | 421 | TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_9 = GyroP.Str.TDCool_9; |
Kovalev_D | 231:079835d508ef | 422 | TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_10 = GyroP.Str.TDCool_10; |
Kovalev_D | 231:079835d508ef | 423 | TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_11 = GyroP.Str.TDCool_11; |
Kovalev_D | 231:079835d508ef | 424 | TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_12 = GyroP.Str.TDCool_12; |
Kovalev_D | 231:079835d508ef | 425 | TermoCorrDynamic.TermoTempDynamic.Str.TermoTempDynamic_13 = GyroP.Str.TDCool_13; |
Kovalev_D | 231:079835d508ef | 426 | |
Kovalev_D | 231:079835d508ef | 427 | |
Kovalev_D | 231:079835d508ef | 428 | |
Kovalev_D | 231:079835d508ef | 429 | TermoCorrDynamic.TermoDeltaDynamic.Str.TermoDeltaDynamic_0 = Float(GyroP.Str.TermoDynamicDataHeat0, GyroP.Str.TermoDynamicDataHeat1 ); |
Kovalev_D | 231:079835d508ef | 430 | TermoCorrDynamic.TermoDeltaDynamic.Str.TermoDeltaDynamic_1 = Float(GyroP.Str.TermoDynamicDataHeat2, GyroP.Str.TermoDynamicDataHeat3 ); |
Kovalev_D | 231:079835d508ef | 431 | TermoCorrDynamic.TermoDeltaDynamic.Str.TermoDeltaDynamic_2 = Float(GyroP.Str.TermoDynamicDataHeat4, GyroP.Str.TermoDynamicDataHeat5 ); |
Kovalev_D | 231:079835d508ef | 432 | TermoCorrDynamic.TermoDeltaDynamic.Str.TermoDeltaDynamic_3 = Float(GyroP.Str.TermoDynamicDataHeat6, GyroP.Str.TermoDynamicDataHeat7 ); |
Kovalev_D | 231:079835d508ef | 433 | TermoCorrDynamic.TermoDeltaDynamic.Str.TermoDeltaDynamic_4 = Float(GyroP.Str.TermoDynamicDataHeat8, GyroP.Str.TermoDynamicDataHeat9 ); |
Kovalev_D | 231:079835d508ef | 434 | TermoCorrDynamic.TermoDeltaDynamic.Str.TermoDeltaDynamic_5 = Float(GyroP.Str.TermoDynamicDataHeat10,GyroP.Str.TermoDynamicDataHeat11); |
Kovalev_D | 231:079835d508ef | 435 | TermoCorrDynamic.TermoDeltaDynamic.Str.TermoDeltaDynamic_6 = Float(GyroP.Str.TermoDynamicDataHeat12,GyroP.Str.TermoDynamicDataHeat13); |
Kovalev_D | 231:079835d508ef | 436 | TermoCorrDynamic.TermoDeltaDynamic.Str.TermoDeltaDynamic_7 = Float(GyroP.Str.TermoDynamicDataHeat14,GyroP.Str.TermoDynamicDataHeat15); |
Kovalev_D | 231:079835d508ef | 437 | TermoCorrDynamic.TermoDeltaDynamic.Str.TermoDeltaDynamic_8 = Float(GyroP.Str.TermoDynamicDataHeat16,GyroP.Str.TermoDynamicDataHeat17); |
Kovalev_D | 231:079835d508ef | 438 | TermoCorrDynamic.TermoDeltaDynamic.Str.TermoDeltaDynamic_9 = Float(GyroP.Str.TermoDynamicDataHeat18,GyroP.Str.TermoDynamicDataHeat19); |
Kovalev_D | 231:079835d508ef | 439 | TermoCorrDynamic.TermoDeltaDynamic.Str.TermoDeltaDynamic_10 = Float(GyroP.Str.TermoDynamicDataHeat20,GyroP.Str.TermoDynamicDataHeat21); |
Kovalev_D | 231:079835d508ef | 440 | TermoCorrDynamic.TermoDeltaDynamic.Str.TermoDeltaDynamic_11 = Float(GyroP.Str.TermoDynamicDataHeat22,GyroP.Str.TermoDynamicDataHeat23); |
Kovalev_D | 231:079835d508ef | 441 | TermoCorrDynamic.TermoDeltaDynamic.Str.TermoDeltaDynamic_12 = Float(GyroP.Str.TermoDynamicDataHeat24,GyroP.Str.TermoDynamicDataHeat25); |
Kovalev_D | 231:079835d508ef | 442 | TermoCorrDynamic.TermoDeltaDynamic.Str.TermoDeltaDynamic_13 = Float(GyroP.Str.TermoDynamicDataHeat26,GyroP.Str.TermoDynamicDataHeat27); |
Kovalev_D | 206:00341a03e05c | 443 | } |
Kovalev_D | 206:00341a03e05c | 444 | else |
Kovalev_D | 206:00341a03e05c | 445 | { |
Kovalev_D | 211:ac8251b067d2 | 446 | Gyro.DownTreshold = GyroP.Str.DownTreshold; //27 |
Kovalev_D | 211:ac8251b067d2 | 447 | Gyro.HighTreshold = GyroP.Str.HighTreshold; |
Kovalev_D | 225:f8fee6c586cc | 448 | Gyro.PLCDelay = 5000; |
Kovalev_D | 211:ac8251b067d2 | 449 | Gyro.ResetLevelCool = 56000; //105 |
Kovalev_D | 211:ac8251b067d2 | 450 | Gyro.ResetLevelHeat = 15000; |
Kovalev_D | 211:ac8251b067d2 | 451 | Gyro.HFO_ref = 13000; |
Kovalev_D | 211:ac8251b067d2 | 452 | Gyro.LG_Type = 0; |
Kovalev_D | 208:19150d2b528f | 453 | Gyro.PLC_Phase = 3; |
Kovalev_D | 208:19150d2b528f | 454 | Gyro.PLC_Gain = 3; |
Kovalev_D | 208:19150d2b528f | 455 | Gyro.FrqPhase = 8; |
Kovalev_D | 207:d1ce992f5d17 | 456 | Gyro.FrqHZ = 403; |
Kovalev_D | 206:00341a03e05c | 457 | Gyro.Frq = Gyro.FrqHZ<<16; |
Kovalev_D | 206:00341a03e05c | 458 | Gyro.FrqHZmin = 350<<16; |
Kovalev_D | 206:00341a03e05c | 459 | Gyro.FrqHZmax = 450<<16; |
Kovalev_D | 206:00341a03e05c | 460 | Gyro.FrqChengSpeed = 100; |
Kovalev_D | 206:00341a03e05c | 461 | Gyro.ModAmp = 250; |
Kovalev_D | 208:19150d2b528f | 462 | Gyro.AmpPer = 20; |
Kovalev_D | 207:d1ce992f5d17 | 463 | Gyro.AmpPerMin = 2; |
Kovalev_D | 206:00341a03e05c | 464 | Gyro.AmpPerMax = 90; |
Kovalev_D | 206:00341a03e05c | 465 | Gyro.AmpSpeed = 1; |
Kovalev_D | 207:d1ce992f5d17 | 466 | Gyro.AmpPerDel = 3; |
Kovalev_D | 208:19150d2b528f | 467 | Gyro.AmpTarget = 5500;// целевая амплитуда ВП |
Kovalev_D | 208:19150d2b528f | 468 | Gyro.Amp = 20*65535; |
Kovalev_D | 207:d1ce992f5d17 | 469 | Gyro.AmpMin = 20;// минимальное значение AmpT;5 |
Kovalev_D | 208:19150d2b528f | 470 | Gyro.AmpTD = 20;//////////////////////////////////////////////////////// |
Kovalev_D | 206:00341a03e05c | 471 | Gyro.TermoNKU = 44700;//48824*0,0061-273=25 С° |
Kovalev_D | 211:ac8251b067d2 | 472 | Spi.DAC_B = Gyro.PLC_Start; |
Kovalev_D | 206:00341a03e05c | 473 | Gyro.PLC_Error2Mode = 1400; //для записи мод |
Kovalev_D | 207:d1ce992f5d17 | 474 | Gyro.Gain_Sin = 175; |
Kovalev_D | 207:d1ce992f5d17 | 475 | Gyro.Gain_Cos = 215; |
Kovalev_D | 209:224e7331a061 | 476 | Gyro.Firmware_Version = 0x11; //версия программы |
Kovalev_D | 205:775d54fdf646 | 477 | Gyro.GLD_Serial = 123; //серийный номер |
Kovalev_D | 182:ebcd2bc3be8f | 478 | Gyro.My_Addres = 0; //адрес глд |
Kovalev_D | 208:19150d2b528f | 479 | Gyro.Tmp_OffsetT4 = 0; |
Kovalev_D | 208:19150d2b528f | 480 | Gyro.Tmp_OffsetT5 = 0; |
Kovalev_D | 208:19150d2b528f | 481 | Gyro.Tmp_scaleT4 = 1; //53 |
Kovalev_D | 208:19150d2b528f | 482 | Gyro.Tmp_scaleT5 = 1; |
Kovalev_D | 208:19150d2b528f | 483 | |
Kovalev_D | 208:19150d2b528f | 484 | Gyro.DAC_current_Work =50000; //3 |
Kovalev_D | 208:19150d2b528f | 485 | Gyro.DAC_current_Start =41000; |
Kovalev_D | 211:ac8251b067d2 | 486 | |
Kovalev_D | 214:4c70e452c491 | 487 | |
Kovalev_D | 214:4c70e452c491 | 488 | F_vib=(103200000<<5)/((Gyro.Frq)>>10);//периуд вибро. |
Kovalev_D | 214:4c70e452c491 | 489 | T_vibP = F_vib/10000; |
Kovalev_D | 214:4c70e452c491 | 490 | T_vib_1 = Gyro.AmpPer * T_vibP; |
Kovalev_D | 214:4c70e452c491 | 491 | T_vib_2 = T_vibP * (10000-Gyro.AmpPer); |
Kovalev_D | 214:4c70e452c491 | 492 | LPC_MCPWM->LIM1 = F_vib; |
Kovalev_D | 214:4c70e452c491 | 493 | LPC_MCPWM->LIM2 = F_vib; |
Kovalev_D | 214:4c70e452c491 | 494 | LPC_MCPWM->MAT1 = T_vib_1; |
Kovalev_D | 214:4c70e452c491 | 495 | LPC_MCPWM->MAT2 = T_vib_2; |
Kovalev_D | 206:00341a03e05c | 496 | } |
Kovalev_D | 211:ac8251b067d2 | 497 | Spi.DAC_B=Gyro.PLC_Start; |
Kovalev_D | 188:4c523cc373cc | 498 | switch(Gyro.My_Addres){//смещение поджига и подсветки в зависимости от адреса ГЛД |
Kovalev_D | 188:4c523cc373cc | 499 | case 0: |
Kovalev_D | 209:224e7331a061 | 500 | Gyro.Discharg = StartDischarg << ShiftStart0; |
Kovalev_D | 188:4c523cc373cc | 501 | Gyro.BackLight = StartBackLight << ShiftStart0; |
Kovalev_D | 188:4c523cc373cc | 502 | break; |
Kovalev_D | 188:4c523cc373cc | 503 | case 1: |
Kovalev_D | 209:224e7331a061 | 504 | Gyro.Discharg = StartDischarg << ShiftStart1; |
Kovalev_D | 188:4c523cc373cc | 505 | Gyro.BackLight = StartBackLight << ShiftStart1; |
Kovalev_D | 188:4c523cc373cc | 506 | break; |
Kovalev_D | 188:4c523cc373cc | 507 | case 2: |
Kovalev_D | 209:224e7331a061 | 508 | Gyro.Discharg = StartDischarg << ShiftStart2; |
Kovalev_D | 188:4c523cc373cc | 509 | Gyro.BackLight = StartBackLight << ShiftStart2; |
Kovalev_D | 188:4c523cc373cc | 510 | break; |
Kovalev_D | 188:4c523cc373cc | 511 | case 3: |
Kovalev_D | 209:224e7331a061 | 512 | Gyro.Discharg = StartDischarg << ShiftStart3; |
Kovalev_D | 188:4c523cc373cc | 513 | Gyro.BackLight = StartBackLight << ShiftStart3; |
Kovalev_D | 188:4c523cc373cc | 514 | break; |
Kovalev_D | 205:775d54fdf646 | 515 | } |
Kovalev_D | 205:775d54fdf646 | 516 | |
Kovalev_D | 88:b5c1d9d338d1 | 517 | ///////////////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 518 | //////инициализация цап_LPC (р0.26 цап выход)//////// |
Kovalev_D | 88:b5c1d9d338d1 | 519 | ///////////////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 520 | LPC_PINCON->PINSEL1 = 0x00200000; |
Kovalev_D | 88:b5c1d9d338d1 | 521 | ///////////////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 522 | ////////////начальное значение для цап/////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 523 | //////////////////середина шкалы///////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 524 | ///////////////////////////////////////////////////// |
Kovalev_D | 205:775d54fdf646 | 525 | |
Kovalev_D | 86:398da56ef751 | 526 | //////////////////////////////////////////////////// |
Kovalev_D | 86:398da56ef751 | 527 | /////////////поправочный коэффициент///////////////// |
Kovalev_D | 86:398da56ef751 | 528 | /////////для цапов (граници +-12.5 вольт)//////////// |
Kovalev_D | 86:398da56ef751 | 529 | ///////////////////////////////////////////////////// |
Kovalev_D | 86:398da56ef751 | 530 | K_DAC=65535.0/(65535.0+(deltaDAC+deltaDAC/2)); |
Kovalev_D | 86:398da56ef751 | 531 | K_DAC=0.8; |
Kovalev_D | 88:b5c1d9d338d1 | 532 | |
Kovalev_D | 86:398da56ef751 | 533 | ///////////////////////////////////////////////////// |
Kovalev_D | 86:398da56ef751 | 534 | /////////////обнуление переменых для///////////////// |
Kovalev_D | 86:398da56ef751 | 535 | ///////////////переменных энкодера/////////////////// |
Kovalev_D | 86:398da56ef751 | 536 | ///////////////////////////////////////////////////// |
Kovalev_D | 205:775d54fdf646 | 537 | secPuls =0;// переменная для конопки поджига аск глд(временная) |
Kovalev_D | 112:4a96133a1311 | 538 | Gyro.CaunPlus =0; |
Kovalev_D | 112:4a96133a1311 | 539 | Gyro.CaunMin =0; |
Kovalev_D | 88:b5c1d9d338d1 | 540 | Cur_QEI=0; |
Kovalev_D | 86:398da56ef751 | 541 | Last_QEI=0; |
Kovalev_D | 205:775d54fdf646 | 542 | } |
Kovalev_D | 226:4a4d5bd5fcd7 | 543 | void BUTTON_init(void) { |
Kovalev_D | 226:4a4d5bd5fcd7 | 544 | LPC_GPIO0->FIODIR &= ~(1 << 1); /* PORT2.10 defined as input */ |
Kovalev_D | 226:4a4d5bd5fcd7 | 545 | LPC_GPIOINT->IO0IntEnF |= (1 << 1); /* enable falling edge irq */ |
Kovalev_D | 205:775d54fdf646 | 546 | |
Kovalev_D | 226:4a4d5bd5fcd7 | 547 | NVIC_EnableIRQ(EINT3_IRQn); /* enable irq in nvic */ |
Kovalev_D | 226:4a4d5bd5fcd7 | 548 | } |
Kovalev_D | 226:4a4d5bd5fcd7 | 549 | /*void EINT3_IRQHandler() |
Kovalev_D | 226:4a4d5bd5fcd7 | 550 | { |
Kovalev_D | 226:4a4d5bd5fcd7 | 551 | if(Gyro.EXT_Latch)Gyro.EXT_Latch=0; |
Kovalev_D | 226:4a4d5bd5fcd7 | 552 | else Gyro.EXT_Latch=1; |
Kovalev_D | 226:4a4d5bd5fcd7 | 553 | LPC_GPIOINT->IO2IntClr |= (1 << 10); |
Kovalev_D | 226:4a4d5bd5fcd7 | 554 | }*/ |
Kovalev_D | 205:775d54fdf646 | 555 | void GLD_Init(void) |
Kovalev_D | 214:4c70e452c491 | 556 | { |
Kovalev_D | 214:4c70e452c491 | 557 | int Dummy; // инициализация мусорки для очистки буфера приема. |
Kovalev_D | 226:4a4d5bd5fcd7 | 558 | BUTTON_init(); |
Kovalev_D | 214:4c70e452c491 | 559 | |
Kovalev_D | 222:7de7b3bf3a1d | 560 | if(Gyro.LG_Type==1)Spi.DAC_A=Gyro.HFO_Max; |
Kovalev_D | 214:4c70e452c491 | 561 | |
Kovalev_D | 214:4c70e452c491 | 562 | |
Kovalev_D | 214:4c70e452c491 | 563 | |
Kovalev_D | 86:398da56ef751 | 564 | ///////////////////////////////////////////////////// |
Kovalev_D | 87:7e575d26d6d0 | 565 | /////////////инициализация энкодера////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 566 | ///////////////////////////////////////////////////// |
Kovalev_D | 214:4c70e452c491 | 567 | |
Kovalev_D | 87:7e575d26d6d0 | 568 | LPC_SC->PCONP |= (1<<18);//0x00040000; включение квадратурного энкодера. |
Kovalev_D | 170:d099c3025f87 | 569 | LPC_SC->PCLKSEL1 |= 0x00000001; // выбор частоты для кв.э. CLK=103MHz |
Kovalev_D | 87:7e575d26d6d0 | 570 | LPC_PINCON->PINSEL3 &= ~0x4100; |
Kovalev_D | 87:7e575d26d6d0 | 571 | LPC_PINCON->PINSEL3 |= 0x4100; //P1.20, p1.23 установить как входы кв.э |
Kovalev_D | 89:a0d344db227e | 572 | LPC_PINCON->PINMODE3 |= 0x3C300; //P1.20, p1.23 |
Kovalev_D | 86:398da56ef751 | 573 | |
Kovalev_D | 220:04c54405b82d | 574 | //Gyro.ShiftMod=150; |
Kovalev_D | 87:7e575d26d6d0 | 575 | LPC_QEI->MAXPOS = MAX_QEI_CNT; //LPC_QEI->"регистор максимального положения" = 2147483646 |
Kovalev_D | 89:a0d344db227e | 576 | LPC_QEI->FILTER = 2; // фильтр( ?? ) |
Kovalev_D | 87:7e575d26d6d0 | 577 | LPC_QEI->CON = 0xF; //сбросить в ноль все счетчики кв.э. (скорость, направление, позицию и тд) |
Kovalev_D | 214:4c70e452c491 | 578 | LPC_QEI->CONF = (1<<2) |(0<<1); //Quadrature inputs, no inverting,only A pulses are counted |
Kovalev_D | 87:7e575d26d6d0 | 579 | |
Kovalev_D | 87:7e575d26d6d0 | 580 | LPC_QEI->CLR = 0x1fff; //r. сбросить все прерывания |
Kovalev_D | 87:7e575d26d6d0 | 581 | LPC_QEI->IEC = 0x1fff; //r. запретить прерывание при изменении направления |
Kovalev_D | 87:7e575d26d6d0 | 582 | |
Kovalev_D | 98:95b8e79f13e1 | 583 | /*NVIC_SetPriority(QEI_IRQn, 0); |
Kovalev_D | 98:95b8e79f13e1 | 584 | NVIC_EnableIRQ(QEI_IRQn);*/ |
Kovalev_D | 88:b5c1d9d338d1 | 585 | ////////////////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 586 | ////////////////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 587 | |
Kovalev_D | 88:b5c1d9d338d1 | 588 | |
Kovalev_D | 89:a0d344db227e | 589 | ////////////////////////////////////////////////////// |
Kovalev_D | 89:a0d344db227e | 590 | ///////////////////////I2C//////////////////////////// |
Kovalev_D | 89:a0d344db227e | 591 | ////////////////////////////////////////////////////// |
Kovalev_D | 87:7e575d26d6d0 | 592 | |
Kovalev_D | 89:a0d344db227e | 593 | LPC_SC->PCONP |= (1 << 19);//включение интерфейса I2C. |
Kovalev_D | 88:b5c1d9d338d1 | 594 | |
Kovalev_D | 89:a0d344db227e | 595 | /* set PIO0.27 and PIO0.28 to I2C0 SDA and SCK */ |
Kovalev_D | 89:a0d344db227e | 596 | /* function to 01 on both SDA and SCK. */ |
Kovalev_D | 89:a0d344db227e | 597 | LPC_PINCON->PINSEL1 &= ~0x03C00000; //P0.27 - SDA. |
Kovalev_D | 89:a0d344db227e | 598 | LPC_PINCON->PINSEL1 |= 0x01400000; //P0.28 - SCK. |
Kovalev_D | 86:398da56ef751 | 599 | |
Kovalev_D | 89:a0d344db227e | 600 | // подтверждение Флаг флаг разрешения |
Kovalev_D | 89:a0d344db227e | 601 | /*сброс флагоф флага прерывания I2C старта интерфейса I2C */ |
Kovalev_D | 89:a0d344db227e | 602 | LPC_I2C0->CONCLR = I2CONCLR_AAC | I2CONCLR_SIC | I2CONCLR_STAC | I2CONCLR_I2ENC; // установка микроконтроллера в режим мастера |
Kovalev_D | 86:398da56ef751 | 603 | |
Kovalev_D | 89:a0d344db227e | 604 | /*--- Reset registers ---*/ |
Kovalev_D | 89:a0d344db227e | 605 | LPC_I2C0->SCLL = I2SCLL_SCLL; // - счетчик scl low time period |
Kovalev_D | 89:a0d344db227e | 606 | LPC_I2C0->SCLH = I2SCLH_SCLH; // - счетчик scl high time period |
Kovalev_D | 99:3d8f206ceac2 | 607 | |
Kovalev_D | 99:3d8f206ceac2 | 608 | I2CMasterBuffer[0] = A_ADDRESS; |
Kovalev_D | 99:3d8f206ceac2 | 609 | I2CMasterBuffer[1] = WRITE_CMD; |
Kovalev_D | 99:3d8f206ceac2 | 610 | I2CMasterBuffer[3] = B_ADDRESS; |
Kovalev_D | 99:3d8f206ceac2 | 611 | I2CMasterBuffer[4] = WRITE_CMD; |
Kovalev_D | 99:3d8f206ceac2 | 612 | |
Kovalev_D | 89:a0d344db227e | 613 | LPC_I2C0->CONSET = I2CONSET_I2EN; //включение интерфейса I2C. |
Kovalev_D | 89:a0d344db227e | 614 | ////////////////////////////////////////////////////////// |
Kovalev_D | 89:a0d344db227e | 615 | ////////////////////////////////////////////////////////// |
Kovalev_D | 86:398da56ef751 | 616 | |
Kovalev_D | 86:398da56ef751 | 617 | |
Kovalev_D | 86:398da56ef751 | 618 | |
Kovalev_D | 92:c892f0311aa7 | 619 | |
Kovalev_D | 92:c892f0311aa7 | 620 | |
Kovalev_D | 92:c892f0311aa7 | 621 | |
Kovalev_D | 92:c892f0311aa7 | 622 | /////////////////////////////////////////////////////// |
Kovalev_D | 92:c892f0311aa7 | 623 | /////////////////////////////////////////////////////// |
Kovalev_D | 92:c892f0311aa7 | 624 | //////////////////////////SPI////////////////////////// |
Kovalev_D | 92:c892f0311aa7 | 625 | /////////////////////////////////////////////////////// |
Kovalev_D | 92:c892f0311aa7 | 626 | Dummy = Dummy; |
Kovalev_D | 92:c892f0311aa7 | 627 | |
Kovalev_D | 92:c892f0311aa7 | 628 | /* Enable AHB clock to the SSP0, SSP1 */ |
Kovalev_D | 92:c892f0311aa7 | 629 | LPC_SC->PCONP |= (0x1<<21); // включение SSP0. |
Kovalev_D | 92:c892f0311aa7 | 630 | |
Kovalev_D | 92:c892f0311aa7 | 631 | /* выбор частоты для переферии используем по умолчания с делителем основной на 4 */ |
Kovalev_D | 92:c892f0311aa7 | 632 | LPC_SC->PCLKSEL1 &= ~(0x3<<10); //00 CLK/4; 1 CLK; 2 CLK/2; 3 CLK/8 |
Kovalev_D | 92:c892f0311aa7 | 633 | LPC_SC->PCLKSEL1 |= (0x0<<10); //00 CLK/4; 1 CLK; 2 CLK/2; 3 CLK/ |
Kovalev_D | 92:c892f0311aa7 | 634 | |
Kovalev_D | 92:c892f0311aa7 | 635 | // P0.15~0.18 as SSP0 |
Kovalev_D | 92:c892f0311aa7 | 636 | LPC_PINCON->PINSEL0 &= ~(0x3UL<<30); //установит Р 0.15 |
Kovalev_D | 92:c892f0311aa7 | 637 | LPC_PINCON->PINSEL0 |= (0x2UL<<30); //частота для синхронизациии Master - slave |
Kovalev_D | 92:c892f0311aa7 | 638 | |
Kovalev_D | 92:c892f0311aa7 | 639 | LPC_PINCON->PINSEL1 &= ~((0x3<<0)|(0x3<<2)|(0x3<<4)); // устанивоить Р 0.17 и Р 0.18 |
Kovalev_D | 92:c892f0311aa7 | 640 | LPC_PINCON->PINSEL1 |= ((0x2<<2)|(0x2<<4)); // как MISO0 и MOSI0 |
Kovalev_D | 92:c892f0311aa7 | 641 | |
Kovalev_D | 92:c892f0311aa7 | 642 | LPC_PINCON->PINMODE0 &= ~(0x3UL<<30);// ? установление на Р 0.15 режима On-Chip pull-down resistor enabled |
Kovalev_D | 92:c892f0311aa7 | 643 | LPC_PINCON->PINMODE0 |= (0x3UL<<30);// ? установление на Р 0.15 режима On-Chip pull-down resistor enabled |
Kovalev_D | 92:c892f0311aa7 | 644 | |
Kovalev_D | 92:c892f0311aa7 | 645 | LPC_PINCON->PINMODE1 &= ~((0x3<<2)|(0x3<<4));// ? установление на Р 0.17 и Р 0.18 режима On-Chip pull-down resistor enabled |
Kovalev_D | 92:c892f0311aa7 | 646 | LPC_PINCON->PINMODE1 |= ((0x3<<2)|(0x3<<4));// ? установление на Р 0.17 и Р 0.18 режима On-Chip pull-down resistor enabled |
Kovalev_D | 92:c892f0311aa7 | 647 | |
Kovalev_D | 92:c892f0311aa7 | 648 | LPC_SSP0->CR0 = ((3<<8)|(0<<7)|(0<<4) |0xF); // (0xF)-установление DSS(Data sise select) в 16-битный формат, (3<<8 scr - выбор частоты), |
Kovalev_D | 92:c892f0311aa7 | 649 | // низкий уровень линии тактирования между кадрами, прикрепление передачи к первому нарастанию тактового мигнала |
Kovalev_D | 92:c892f0311aa7 | 650 | // формат кадра TI. |
Kovalev_D | 92:c892f0311aa7 | 651 | |
Kovalev_D | 92:c892f0311aa7 | 652 | /* SSPCPSR clock prescale register, master mode, minimum divisor is 0x02 */ |
Kovalev_D | 92:c892f0311aa7 | 653 | LPC_SSP0->CPSR = 0x2; // freq = CLK/(cpsdvr*(scr+1)) = 1.6 MHz |
Kovalev_D | 92:c892f0311aa7 | 654 | |
Kovalev_D | 92:c892f0311aa7 | 655 | /*SSP enable, master mode */ |
Kovalev_D | 92:c892f0311aa7 | 656 | LPC_SSP0->CR1 = SSPCR1_SSE; |
Kovalev_D | 92:c892f0311aa7 | 657 | // LPC_SSP1->CR1 = SSPCR1_SSE; |
Kovalev_D | 190:289514f730ee | 658 | while (LPC_SSP0->SR & SSP_BUSY); |
Kovalev_D | 92:c892f0311aa7 | 659 | while (LPC_SSP0->SR & RX_SSP_notEMPT) /* clear the RxFIFO */ |
Kovalev_D | 92:c892f0311aa7 | 660 | Dummy = LPC_SSP0->DR; |
Kovalev_D | 92:c892f0311aa7 | 661 | //all pins after reset is in GPIO mode, so CS pins needn't to configure |
Kovalev_D | 92:c892f0311aa7 | 662 | LPC_GPIO0->FIODIR |= (1<<16); // P0.16 defined as CS for ADC |
Kovalev_D | 92:c892f0311aa7 | 663 | LPC_GPIO0->FIOSET |= (1<<16); // set CS for ADC |
Kovalev_D | 92:c892f0311aa7 | 664 | |
Kovalev_D | 92:c892f0311aa7 | 665 | LPC_GPIO0->FIODIR |= (1<<23); // P defined as CS for DAC |
Kovalev_D | 92:c892f0311aa7 | 666 | LPC_GPIO0->FIOCLR |= (1<<23); // set CS for DAC |
Kovalev_D | 92:c892f0311aa7 | 667 | while (LPC_SSP1->SR & RX_SSP_notEMPT) |
Kovalev_D | 92:c892f0311aa7 | 668 | Dummy = LPC_SSP1->DR; /* clear the RxFIFO */ |
Kovalev_D | 92:c892f0311aa7 | 669 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////// |
Kovalev_D | 92:c892f0311aa7 | 670 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////// |
Kovalev_D | 92:c892f0311aa7 | 671 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////// |
Kovalev_D | 92:c892f0311aa7 | 672 | |
Kovalev_D | 92:c892f0311aa7 | 673 | |
Kovalev_D | 92:c892f0311aa7 | 674 | |
Kovalev_D | 92:c892f0311aa7 | 675 | |
Kovalev_D | 86:398da56ef751 | 676 | ///////////////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 677 | /////////////////инициализация ног/////////////////// |
Kovalev_D | 86:398da56ef751 | 678 | ///////////////////////////////////////////////////// |
Kovalev_D | 89:a0d344db227e | 679 | |
Kovalev_D | 89:a0d344db227e | 680 | ///////////////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 681 | Gyro.PinRegOld = 0xffffffff; |
Kovalev_D | 88:b5c1d9d338d1 | 682 | Gyro.PinReg = 0; // всЁ выключенно |
Kovalev_D | 88:b5c1d9d338d1 | 683 | PinCheng(); |
Kovalev_D | 89:a0d344db227e | 684 | ///////////////////////////////////////////////////// |
Kovalev_D | 193:a0fe8bfc97e4 | 685 | Gyro.ModeOut=0; |
Kovalev_D | 87:7e575d26d6d0 | 686 | ///////////////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 687 | //////////////отладочный светодиод/////////////////// |
Kovalev_D | 87:7e575d26d6d0 | 688 | ///////////////////////////////////////////////////// |
Kovalev_D | 98:95b8e79f13e1 | 689 | |
Kovalev_D | 98:95b8e79f13e1 | 690 | LPC_PINCON->PINSEL0 &= ~(0x00<<28); |
Kovalev_D | 214:4c70e452c491 | 691 | LPC_PINCON->PINSEL0 |= (0x00<<28); |
Kovalev_D | 190:289514f730ee | 692 | LPC_PINCON->PINMODE0 |= (0x3<<28); |
Kovalev_D | 190:289514f730ee | 693 | LPC_GPIO1->FIODIR |= (1<<30); |
Kovalev_D | 87:7e575d26d6d0 | 694 | ///////////////////////////////////////////////////// |
Kovalev_D | 87:7e575d26d6d0 | 695 | ///////////////////////////////////////////////////// |
Kovalev_D | 193:a0fe8bfc97e4 | 696 | NVIC_EnableIRQ(EINT3_IRQn); |
Kovalev_D | 193:a0fe8bfc97e4 | 697 | LPC_GPIOINT->IO0IntEnR |= (1<<1); /* enable rasing edge irq */ |
Kovalev_D | 87:7e575d26d6d0 | 698 | ///////////////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 699 | ////////////////управление уартом//////////////////// |
Kovalev_D | 87:7e575d26d6d0 | 700 | ///////////////////////////////////////////////////// |
Kovalev_D | 89:a0d344db227e | 701 | LPC_GPIO2->FIODIR |= (1<<7);//направление ноги uart enable |
Kovalev_D | 87:7e575d26d6d0 | 702 | ///////////////////////////////////////////////////// |
Kovalev_D | 87:7e575d26d6d0 | 703 | ///////////////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 704 | |
Kovalev_D | 88:b5c1d9d338d1 | 705 | |
Kovalev_D | 88:b5c1d9d338d1 | 706 | |
Kovalev_D | 87:7e575d26d6d0 | 707 | ///////////////////////////////////////////////////// |
Kovalev_D | 89:a0d344db227e | 708 | ///////////////////////поджиг//////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 709 | ///////////////////////////////////////////////////// |
Kovalev_D | 98:95b8e79f13e1 | 710 | LPC_PINCON->PINSEL0 &= ~(3<<8); //e. P0.4 is GPIO pin (запись ( 00 ) в 9:8 бит PISEL0 выбор P0.4 как GPIO) |
Kovalev_D | 98:95b8e79f13e1 | 711 | LPC_PINCON->PINMODE0 |= (3<<8); //e. P0.4 is GPIO pin (запись ( 11 ) в 9:8 бит PINMODE0 "для включения подтягивающего резистора") |
Kovalev_D | 226:4a4d5bd5fcd7 | 712 | LPC_GPIO0->FIODIR |= (1<<4); //e. P0.4 is output (запись ( 1 ) в 5 бит FIODIR выбор P0.4 как выход) |
Kovalev_D | 87:7e575d26d6d0 | 713 | ///////////////////////////////////////////////////// |
Kovalev_D | 87:7e575d26d6d0 | 714 | ///////////////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 715 | |
Kovalev_D | 88:b5c1d9d338d1 | 716 | |
Kovalev_D | 88:b5c1d9d338d1 | 717 | |
Kovalev_D | 87:7e575d26d6d0 | 718 | ///////////////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 719 | /////////////////////вибро 1///////////////////////// |
Kovalev_D | 87:7e575d26d6d0 | 720 | ///////////////////////////////////////////////////// |
Kovalev_D | 98:95b8e79f13e1 | 721 | LPC_PINCON->PINSEL3 &= ~(0x00<<18); //e. P1.25 is GPIO pin |
Kovalev_D | 98:95b8e79f13e1 | 722 | LPC_PINCON->PINSEL3 |= (0x00<<18); //e. P1.25 is GPIO pin |
Kovalev_D | 87:7e575d26d6d0 | 723 | LPC_PINCON->PINMODE3 |= (3<<18); //e. P1.25 (включениe подтягивающего резистора") |
Kovalev_D | 87:7e575d26d6d0 | 724 | LPC_GPIO1->FIODIR |= (1<<25); //e. P0.5 is output (запись ( 1 ) в 5 бит FIODIR выбор P0.5 как выход) |
Kovalev_D | 87:7e575d26d6d0 | 725 | LPC_GPIO1->FIOCLR |= (1<<25); |
Kovalev_D | 88:b5c1d9d338d1 | 726 | ////////////////////////////////////////////////////// |
Kovalev_D | 89:a0d344db227e | 727 | //////////////////////вибро 2///////////////////////// |
Kovalev_D | 89:a0d344db227e | 728 | ////////////////////////////////////////////////////// |
Kovalev_D | 98:95b8e79f13e1 | 729 | LPC_PINCON->PINSEL3 &= ~(0x00<<24); //e. P1.28 is GPIO pin |
Kovalev_D | 98:95b8e79f13e1 | 730 | LPC_PINCON->PINSEL3 |= (0x00<<24); //e. P1.28 is GPIO pin |
Kovalev_D | 87:7e575d26d6d0 | 731 | LPC_PINCON->PINMODE3 |= (3<<24); //e. P1.28 is GPIO pin (запись ( 11 ) в бит PINMODE0 "для включения подтягивающего резистора") |
Kovalev_D | 87:7e575d26d6d0 | 732 | LPC_GPIO1->FIODIR |= (1<<28); //e. P1.28 is output (запись ( 1 ) в 5 бит FIODIR выбор P0.5 как выход) |
Kovalev_D | 87:7e575d26d6d0 | 733 | LPC_GPIO1->FIOCLR |= (1<<28); |
Kovalev_D | 87:7e575d26d6d0 | 734 | ///////////////////////////////////////////////////// |
Kovalev_D | 87:7e575d26d6d0 | 735 | ///////////////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 736 | |
Kovalev_D | 88:b5c1d9d338d1 | 737 | |
Kovalev_D | 88:b5c1d9d338d1 | 738 | |
Kovalev_D | 87:7e575d26d6d0 | 739 | ///////////////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 740 | /////////////инициализация подсветки///////////////// |
Kovalev_D | 87:7e575d26d6d0 | 741 | ///////////////////////////////////////////////////// |
Kovalev_D | 98:95b8e79f13e1 | 742 | LPC_PINCON->PINSEL2 &= ~(0x00<<24); |
Kovalev_D | 98:95b8e79f13e1 | 743 | LPC_PINCON->PINSEL2 |= (0x00<<24); //e. P2.12 is GPIO pin |
Kovalev_D | 87:7e575d26d6d0 | 744 | LPC_PINCON->PINMODE3 |= (3<<24); //e. P1.28 is GPIO pin (запись ( 11 ) в бит PINMODE0 "для включения подтягивающего резистора") |
Kovalev_D | 87:7e575d26d6d0 | 745 | LPC_GPIO2->FIODIR |= (1<<12); //e. P1.28 is output (запись ( 1 ) в 5 бит FIODIR выбор P0.5 как выход) |
Kovalev_D | 87:7e575d26d6d0 | 746 | LPC_GPIO2->FIOCLR |= (1<<12); |
Kovalev_D | 88:b5c1d9d338d1 | 747 | /////////////////////////////////////////////////////// |
Kovalev_D | 86:398da56ef751 | 748 | /////////////////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 749 | |
Kovalev_D | 88:b5c1d9d338d1 | 750 | |
Kovalev_D | 88:b5c1d9d338d1 | 751 | /////////////////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 752 | /////////////////////////////////////////////////////// |
Kovalev_D | 89:a0d344db227e | 753 | ///////////////////включение таймеров////////////////// |
Kovalev_D | 89:a0d344db227e | 754 | /////////////////////////////////////////////////////// |
Kovalev_D | 86:398da56ef751 | 755 | enable_timer1(); |
Kovalev_D | 86:398da56ef751 | 756 | enable_timer2(); |
Kovalev_D | 89:a0d344db227e | 757 | /////////////////////////////////////////////////////// |
Kovalev_D | 89:a0d344db227e | 758 | |
Kovalev_D | 89:a0d344db227e | 759 | ////////////////////////////////////////////////////////////////// |
Kovalev_D | 89:a0d344db227e | 760 | // LPC_GPIO0->FIOCLR = (1<<5);/////////////отключение поджига |
Kovalev_D | 90:d9b6a4bc5065 | 761 | |
Kovalev_D | 90:d9b6a4bc5065 | 762 | |
Kovalev_D | 90:d9b6a4bc5065 | 763 | |
Kovalev_D | 90:d9b6a4bc5065 | 764 | /////////////////////////////////////////////////////// |
Kovalev_D | 90:d9b6a4bc5065 | 765 | /////////////////////////////////////////////////////// |
Kovalev_D | 90:d9b6a4bc5065 | 766 | //////////////////////////SPI////////////////////////// |
Kovalev_D | 90:d9b6a4bc5065 | 767 | /////////////////////////////////////////////////////// |
Kovalev_D | 90:d9b6a4bc5065 | 768 | Dummy = Dummy; |
Kovalev_D | 90:d9b6a4bc5065 | 769 | |
Kovalev_D | 90:d9b6a4bc5065 | 770 | /* Enable AHB clock to the SSP0, SSP1 */ |
Kovalev_D | 90:d9b6a4bc5065 | 771 | LPC_SC->PCONP |= (0x1<<21); // включение SSP0. |
Kovalev_D | 90:d9b6a4bc5065 | 772 | |
Kovalev_D | 90:d9b6a4bc5065 | 773 | /* выбор частоты для переферии используем по умолчания с делителем основной на 4 */ |
Kovalev_D | 90:d9b6a4bc5065 | 774 | LPC_SC->PCLKSEL1 &= ~(0x3<<10); //00 CLK/4; 1 CLK; 2 CLK/2; 3 CLK/8 |
Kovalev_D | 90:d9b6a4bc5065 | 775 | LPC_SC->PCLKSEL1 |= (0x0<<10); //00 CLK/4; 1 CLK; 2 CLK/2; 3 CLK/ |
Kovalev_D | 90:d9b6a4bc5065 | 776 | |
Kovalev_D | 90:d9b6a4bc5065 | 777 | // P0.15~0.18 as SSP0 |
Kovalev_D | 90:d9b6a4bc5065 | 778 | LPC_PINCON->PINSEL0 &= ~(0x3UL<<30); //установит Р 0.15 |
Kovalev_D | 90:d9b6a4bc5065 | 779 | LPC_PINCON->PINSEL0 |= (0x2UL<<30); //частота для синхронизациии Master - slave |
Kovalev_D | 90:d9b6a4bc5065 | 780 | |
Kovalev_D | 90:d9b6a4bc5065 | 781 | LPC_PINCON->PINSEL1 &= ~((0x3<<0)|(0x3<<2)|(0x3<<4)); // устанивоить Р 0.17 и Р 0.18 |
Kovalev_D | 90:d9b6a4bc5065 | 782 | LPC_PINCON->PINSEL1 |= ((0x2<<2)|(0x2<<4)); // как MISO0 и MOSI0 |
Kovalev_D | 90:d9b6a4bc5065 | 783 | |
Kovalev_D | 90:d9b6a4bc5065 | 784 | LPC_PINCON->PINMODE0 &= ~(0x3UL<<30);// ? установление на Р 0.15 режима On-Chip pull-down resistor enabled |
Kovalev_D | 90:d9b6a4bc5065 | 785 | LPC_PINCON->PINMODE0 |= (0x3UL<<30);// ? установление на Р 0.15 режима On-Chip pull-down resistor enabled |
Kovalev_D | 90:d9b6a4bc5065 | 786 | |
Kovalev_D | 90:d9b6a4bc5065 | 787 | LPC_PINCON->PINMODE1 &= ~((0x3<<2)|(0x3<<4));// ? установление на Р 0.17 и Р 0.18 режима On-Chip pull-down resistor enabled |
Kovalev_D | 90:d9b6a4bc5065 | 788 | LPC_PINCON->PINMODE1 |= ((0x3<<2)|(0x3<<4));// ? установление на Р 0.17 и Р 0.18 режима On-Chip pull-down resistor enabled |
Kovalev_D | 90:d9b6a4bc5065 | 789 | |
Kovalev_D | 90:d9b6a4bc5065 | 790 | LPC_SSP0->CR0 = ((3<<8)|(0<<7)|(0<<4) |0xF); // (0xF)-установление DSS(Data sise select) в 16-битный формат, (3<<8 scr - выбор частоты), |
Kovalev_D | 90:d9b6a4bc5065 | 791 | // низкий уровень линии тактирования между кадрами, прикрепление передачи к первому нарастанию тактового мигнала |
Kovalev_D | 90:d9b6a4bc5065 | 792 | // формат кадра TI. |
Kovalev_D | 90:d9b6a4bc5065 | 793 | |
Kovalev_D | 90:d9b6a4bc5065 | 794 | /* SSPCPSR clock prescale register, master mode, minimum divisor is 0x02 */ |
Kovalev_D | 90:d9b6a4bc5065 | 795 | LPC_SSP0->CPSR = 0x2; // freq = CLK/(cpsdvr*(scr+1)) = 1.6 MHz |
Kovalev_D | 90:d9b6a4bc5065 | 796 | |
Kovalev_D | 90:d9b6a4bc5065 | 797 | /*SSP enable, master mode */ |
Kovalev_D | 90:d9b6a4bc5065 | 798 | LPC_SSP0->CR1 = SSPCR1_SSE; |
Kovalev_D | 90:d9b6a4bc5065 | 799 | // LPC_SSP1->CR1 = SSPCR1_SSE; |
Kovalev_D | 90:d9b6a4bc5065 | 800 | while (LPC_SSP0->SR & SSP_BUSY); |
Kovalev_D | 170:d099c3025f87 | 801 | while (LPC_SSP0->SR & RX_SSP_notEMPT) /* clear the RxFIFO */ |
Kovalev_D | 90:d9b6a4bc5065 | 802 | Dummy = LPC_SSP0->DR; |
Kovalev_D | 90:d9b6a4bc5065 | 803 | //all pins after reset is in GPIO mode, so CS pins needn't to configure |
Kovalev_D | 90:d9b6a4bc5065 | 804 | LPC_GPIO0->FIODIR |= (1<<16); // P0.16 defined as CS for ADC |
Kovalev_D | 90:d9b6a4bc5065 | 805 | LPC_GPIO0->FIOSET |= (1<<16); // set CS for ADC |
Kovalev_D | 90:d9b6a4bc5065 | 806 | |
Kovalev_D | 92:c892f0311aa7 | 807 | LPC_GPIO0->FIODIR |= (1<<23); // P defined as CS for DAC |
Kovalev_D | 92:c892f0311aa7 | 808 | LPC_GPIO0->FIOCLR |= (1<<23); // set CS for DAC |
Kovalev_D | 92:c892f0311aa7 | 809 | while (LPC_SSP1->SR & RX_SSP_notEMPT) |
Kovalev_D | 92:c892f0311aa7 | 810 | Dummy = LPC_SSP1->DR; /* clear the RxFIFO */ |
Kovalev_D | 205:775d54fdf646 | 811 | //Gyro=GyroP.str; |
Kovalev_D | 205:775d54fdf646 | 812 | //Gyro = (*(struct Gyro*)(&GyroP.Str)); |
Kovalev_D | 90:d9b6a4bc5065 | 813 | |
Kovalev_D | 86:398da56ef751 | 814 | } |
igor_v | 13:e2a1d18677b8 | 815 | |
igor_v | 0:8ad47e2b6f00 | 816 | |
igor_v | 0:8ad47e2b6f00 | 817 | |
igor_v | 0:8ad47e2b6f00 | 818 | |
igor_v | 0:8ad47e2b6f00 | 819 |