![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
fork
Fork of LG by
main.c@136:19b9e6abb86f, 2016-04-15 (annotated)
- Committer:
- Kovalev_D
- Date:
- Fri Apr 15 14:20:15 2016 +0000
- Revision:
- 136:19b9e6abb86f
- Parent:
- 135:c1e30e0e8949
- Child:
- 138:14a0c452cf32
flash
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
igor_v | 8:5188b1448d34 | 1 | //ssdfwewedfsfds |
igor_v | 0:8ad47e2b6f00 | 2 | /****************************************Copyright (c)**************************************************** |
igor_v | 0:8ad47e2b6f00 | 3 | **--------------File Info--------------------------------------------------------------------------------- |
igor_v | 0:8ad47e2b6f00 | 4 | ** File name: main.c |
igor_v | 0:8ad47e2b6f00 | 5 | ** Last modified Date: 2011-10-24 |
igor_v | 0:8ad47e2b6f00 | 6 | ** Last Version: V1.00 |
igor_v | 0:8ad47e2b6f00 | 7 | ** Descriptions: The main() function |
igor_v | 0:8ad47e2b6f00 | 8 | ** |
igor_v | 0:8ad47e2b6f00 | 9 | **-------------------------------------------------------------------------------------------------------- |
igor_v | 0:8ad47e2b6f00 | 10 | ** Created by: Electrooptica Incorp. |
igor_v | 0:8ad47e2b6f00 | 11 | ** Created date: 2011-08-22 |
igor_v | 0:8ad47e2b6f00 | 12 | ** Version: V1.00 |
igor_v | 3:ed8744c5f67a | 13 | ** Descriptions: |
igor_v | 3:ed8744c5f67a | 14 | **-------------------------------------------------------------------------------------------------------- |
igor_v | 30:17c84ed091b3 | 15 | последнии изменения |
igor_v | 30:17c84ed091b3 | 16 | //2016_02_03_17_47 |
igor_v | 31:c783288001b5 | 17 | //2016_02_06 igor |
igor_v | 37:bdd52117b56e | 18 | //2016_06 Dima |
Kovalev_D | 41:70d12776d1ef | 19 | //2016_02_06 21:20 Kovalev_D |
igor_v | 0:8ad47e2b6f00 | 20 | *********************************************************************************************************/ |
igor_v | 21:bc8c1cec3da6 | 21 | |
igor_v | 0:8ad47e2b6f00 | 22 | |
igor_v | 0:8ad47e2b6f00 | 23 | #include "Global.h" |
igor_v | 0:8ad47e2b6f00 | 24 | //#include <math.h> |
Diletant | 74:f4d9c3403578 | 25 | #include "Device.h" |
Kovalev_D | 130:1421dda4d7e7 | 26 | //#include "IAP.h" |
igor_v | 0:8ad47e2b6f00 | 27 | /****************************************************************************** |
igor_v | 0:8ad47e2b6f00 | 28 | ** Main Function main() |
igor_v | 0:8ad47e2b6f00 | 29 | ******************************************************************************/ |
Diletant | 75:cc1942179a2f | 30 | Device device; //Single global for all device hardware-independent algorithm |
Kovalev_D | 132:2c7bec5cf6fe | 31 | #define IMG_START_SECTOR 0x00010000 /* Sector 16 */ |
Kovalev_D | 136:19b9e6abb86f | 32 | #define IMG_END_SECTOR 0x00017FFF /* Sector 20 */ |
Kovalev_D | 136:19b9e6abb86f | 33 | |
Kovalev_D | 132:2c7bec5cf6fe | 34 | /* |
Kovalev_D | 132:2c7bec5cf6fe | 35 | #define IMG_START_SECTOR 0x00030000//0x00010000 /* Sector 16 |
Kovalev_D | 132:2c7bec5cf6fe | 36 | #define IMG_END_SECTOR 0x00037FFF */ |
Kovalev_D | 136:19b9e6abb86f | 37 | unsigned int addres; |
Kovalev_D | 136:19b9e6abb86f | 38 | |
Kovalev_D | 134:caf4c9cd5052 | 39 | uint32_t Result[5]; |
igor_v | 0:8ad47e2b6f00 | 40 | extern uint32_t CMD_Mode; |
igor_v | 52:30f2e52a493f | 41 | unsigned int secPuls; |
igor_v | 52:30f2e52a493f | 42 | float DACF, K_DAC; |
Kovalev_D | 107:4d178bcc9d8a | 43 | int tempAMP; |
Kovalev_D | 136:19b9e6abb86f | 44 | //unsigned int *Add; |
Kovalev_D | 136:19b9e6abb86f | 45 | |
Kovalev_D | 136:19b9e6abb86f | 46 | unsigned int status; |
Kovalev_D | 136:19b9e6abb86f | 47 | unsigned int Para; |
igor_v | 52:30f2e52a493f | 48 | int main (void) |
igor_v | 52:30f2e52a493f | 49 | { |
igor_v | 110:6406b7ac0442 | 50 | int ttemp; |
Kovalev_D | 136:19b9e6abb86f | 51 | |
igor_v | 110:6406b7ac0442 | 52 | unsigned int TempA; |
Kovalev_D | 136:19b9e6abb86f | 53 | SystemInit1(); // Инициализация контроллера: установка тактовых частот |
Kovalev_D | 136:19b9e6abb86f | 54 | addres = 0x10000; |
Kovalev_D | 133:90d0bf0e2996 | 55 | |
Kovalev_D | 133:90d0bf0e2996 | 56 | |
Kovalev_D | 134:caf4c9cd5052 | 57 | //FlashDMA_Init(); // Загрузка параметров с флэш |
Kovalev_D | 86:398da56ef751 | 58 | SystemCoreClockUpdate1(); // расчет тактовой частоты процессора перед инициализацией UART - 100MHz |
Kovalev_D | 88:b5c1d9d338d1 | 59 | |
Kovalev_D | 134:caf4c9cd5052 | 60 | |
Kovalev_D | 134:caf4c9cd5052 | 61 | |
Kovalev_D | 86:398da56ef751 | 62 | GLD_Init(); |
Kovalev_D | 92:c892f0311aa7 | 63 | ///////////старый UART |
igor_v | 91:a2bb81eaa183 | 64 | // UARTInit(); // инициализация UART0 на скорость 38400. |
igor_v | 91:a2bb81eaa183 | 65 | // UART1_Init(); // инициализация UART1 на скорость 38400. |
Kovalev_D | 88:b5c1d9d338d1 | 66 | |
igor_v | 91:a2bb81eaa183 | 67 | |
Kovalev_D | 134:caf4c9cd5052 | 68 | UART_InitSet (0, 921600, 0x03); // надо проверить, мож чо с ногам |
Kovalev_D | 129:406995a91322 | 69 | // UART_InitSet (1, 921600, 0x03); |
Kovalev_D | 129:406995a91322 | 70 | UART_InitSet (1, 115200, 0x03); |
Kovalev_D | 99:3d8f206ceac2 | 71 | |
Kovalev_D | 86:398da56ef751 | 72 | //////////// |
Kovalev_D | 90:d9b6a4bc5065 | 73 | //DAC_ADC_Exchange_Init(); // инициализация обмена АЦП и ЦАП. |
Kovalev_D | 88:b5c1d9d338d1 | 74 | |
Diletant | 46:2670fa0fcebc | 75 | IntLatch_Init(); // инициализация внутренней защелки. |
Diletant | 46:2670fa0fcebc | 76 | ExtLatch_Init(); // инициализация внешней защелки. |
igor_v | 21:bc8c1cec3da6 | 77 | LoadFlashParam(FromFLASH); //загрузка параметров. |
Kovalev_D | 89:a0d344db227e | 78 | |
Kovalev_D | 112:4a96133a1311 | 79 | // open_all_loops(); //#define open_all_loops() RgConA = 0 (Основной регистр управления устройства (0 - включить, 1 - отключить)). |
Kovalev_D | 129:406995a91322 | 80 | // Output.Str.HF_reg = Device_blk.Str.HF_min; //HFO output voltage = максивальное напряжение на ГВЧ. |
igor_v | 30:17c84ed091b3 | 81 | init_PLC(); //Инициализация СРП(регулировка периметра) |
igor_v | 30:17c84ed091b3 | 82 | init_Dither_reg(); //инициализация вибропривода |
Kovalev_D | 112:4a96133a1311 | 83 | // RgConB = RATE_VIBRO_1; // дополнительный регистр управления = разность вибросчетчиков после фильтра скольз.среднего(#define RATE_VIBRO_1 0x0001) |
Kovalev_D | 112:4a96133a1311 | 84 | // close_all_loops(); |
igor_v | 51:81f47b817071 | 85 | |
Kovalev_D | 105:bd01d8d20fb6 | 86 | Out_G_photo(200,200); //запись в буфер мастера принятые от функции данные (60,60) и установка флага старта передачи и занятой шины. |
Kovalev_D | 105:bd01d8d20fb6 | 87 | |
Kovalev_D | 47:d902ef6f7564 | 88 | WriteCon1("\n\r ...GL start programm uart ACK.... "); |
Kovalev_D | 47:d902ef6f7564 | 89 | WriteCon("\n\r ...GL start programm uart Tech.... "); |
igor_v | 15:f5191a1c3805 | 90 | sprintf(Time,"\r\nCompiled: %s %s.",__DATE__, __TIME__ ); //Подготовка даты и времени компиляции |
igor_v | 13:e2a1d18677b8 | 91 | WriteCon(Time); |
igor_v | 11:af609f6dee46 | 92 | |
igor_v | 127:6a7472d67804 | 93 | Gyro.PLC_Error2Mode = 10; // начальная задержка (неработает СРП) |
igor_v | 11:af609f6dee46 | 94 | |
Kovalev_D | 50:0e3d47f18a50 | 95 | while ( 1 ) { //основной цикл. |
Kovalev_D | 107:4d178bcc9d8a | 96 | |
Kovalev_D | 108:030cdde08314 | 97 | G_Photo_Exchange(); |
Kovalev_D | 108:030cdde08314 | 98 | Concol (); // Проврка 0 консоли (вход и выход) |
Kovalev_D | 93:b3803774f110 | 99 | Concol1 (); // Проврка 0 консоли (вход и выход) |
Kovalev_D | 99:3d8f206ceac2 | 100 | Read_CMD(); |
igor_v | 3:ed8744c5f67a | 101 | if (OutBufConCount) OutBufConCount--; |
Kovalev_D | 108:030cdde08314 | 102 | if (OutBufCon1Count) OutBufCon1Count--; |
Kovalev_D | 121:bbae560cdd43 | 103 | |
Kovalev_D | 95:dd51e577e114 | 104 | if (ReadCon (Time)) { |
Kovalev_D | 132:2c7bec5cf6fe | 105 | ///////////////////////////////////////////////////////////////// |
Kovalev_D | 132:2c7bec5cf6fe | 106 | //////////////////////////////////////////////////////////////// |
Kovalev_D | 132:2c7bec5cf6fe | 107 | //////////////////////Выбор FlashMod/////////////////////////// |
Kovalev_D | 132:2c7bec5cf6fe | 108 | //////////////////////////////////////////////////////////////// |
Kovalev_D | 132:2c7bec5cf6fe | 109 | |
Kovalev_D | 136:19b9e6abb86f | 110 | if (Time[0] == 'B') { |
Kovalev_D | 132:2c7bec5cf6fe | 111 | Gyro.FlashMod=1; |
Kovalev_D | 136:19b9e6abb86f | 112 | } |
Kovalev_D | 136:19b9e6abb86f | 113 | if (Time[0] == 'W') { |
Kovalev_D | 136:19b9e6abb86f | 114 | Gyro.FlashMod=2; |
Kovalev_D | 132:2c7bec5cf6fe | 115 | } |
Kovalev_D | 132:2c7bec5cf6fe | 116 | if (Time[0] == 'R') { |
Kovalev_D | 136:19b9e6abb86f | 117 | Gyro.FlashMod=3; |
Kovalev_D | 132:2c7bec5cf6fe | 118 | } |
Kovalev_D | 132:2c7bec5cf6fe | 119 | |
Kovalev_D | 136:19b9e6abb86f | 120 | |
Kovalev_D | 132:2c7bec5cf6fe | 121 | /////////////////////////////////////////////////////////////// |
Kovalev_D | 132:2c7bec5cf6fe | 122 | /////////////////////////////////////////////////////////////// |
Kovalev_D | 132:2c7bec5cf6fe | 123 | //////////////////////////////////////////////////////////////// |
igor_v | 48:8697dfe679b9 | 124 | |
igor_v | 16:18e3fd7b92d0 | 125 | if (Time[0] == 'h') { // если ввели буквц h то выдать подсказку. сделанно через принф ОЧЕНЬ плохо в работе не использовать |
igor_v | 15:f5191a1c3805 | 126 | sprintf(Time,"\r\nCompiled: %s %s.",__DATE__, __TIME__ ); //Подготовка даты и времени компиляции |
igor_v | 15:f5191a1c3805 | 127 | WriteCon(Time); |
igor_v | 52:30f2e52a493f | 128 | sprintf(Time,"--%d.%3.d.%2.d.",Time1Hz,Time1K,Time100K); //Временно выдачпа временни из трех чисел |
igor_v | 15:f5191a1c3805 | 129 | WriteCon(Time); |
igor_v | 52:30f2e52a493f | 130 | } |
igor_v | 52:30f2e52a493f | 131 | if (Time[0] == 'D') { |
igor_v | 52:30f2e52a493f | 132 | Gyro.Discharg = StartDischarg; |
igor_v | 15:f5191a1c3805 | 133 | } |
igor_v | 52:30f2e52a493f | 134 | if (Time[0] == 'L') { |
igor_v | 52:30f2e52a493f | 135 | Gyro.BackLight = StartBackLight; |
igor_v | 52:30f2e52a493f | 136 | } |
Kovalev_D | 98:95b8e79f13e1 | 137 | |
Kovalev_D | 108:030cdde08314 | 138 | if (Time[0] == 'F') { // выдача технологическая |
Kovalev_D | 105:bd01d8d20fb6 | 139 | sprintf(Time,"\r\n"); |
Kovalev_D | 105:bd01d8d20fb6 | 140 | WriteCon(Time); |
Kovalev_D | 105:bd01d8d20fb6 | 141 | sprintf((Time)," <%07d> <%07d>",Gyro.F_ras,Param2); |
Kovalev_D | 105:bd01d8d20fb6 | 142 | WriteCon(Time); |
Kovalev_D | 105:bd01d8d20fb6 | 143 | } |
Kovalev_D | 128:1e4675a36c93 | 144 | |
Kovalev_D | 128:1e4675a36c93 | 145 | if (Time[0] == 'q') { // внешняя защелка |
Kovalev_D | 128:1e4675a36c93 | 146 | Gyro.EXT_Latch=1; |
Kovalev_D | 128:1e4675a36c93 | 147 | } |
Kovalev_D | 98:95b8e79f13e1 | 148 | if (Time[0] == '1') { // выдача технологическая |
Kovalev_D | 88:b5c1d9d338d1 | 149 | sprintf(Time,"\r\n"); |
Kovalev_D | 95:dd51e577e114 | 150 | WriteCon(Time); |
Kovalev_D | 96:1c8536458119 | 151 | for (int i = 0; i < 32; i++ )sprintf((Time + i * 9)," <%05d> ",Buff_1Point[i]); |
igor_v | 52:30f2e52a493f | 152 | WriteCon(Time); |
igor_v | 52:30f2e52a493f | 153 | } |
Kovalev_D | 98:95b8e79f13e1 | 154 | |
Kovalev_D | 98:95b8e79f13e1 | 155 | if (Time[0] == '2') { // выдача технологическая |
Kovalev_D | 98:95b8e79f13e1 | 156 | sprintf(Time,"\r\n"); |
Kovalev_D | 98:95b8e79f13e1 | 157 | WriteCon(Time); |
Kovalev_D | 98:95b8e79f13e1 | 158 | for (int i = 0; i < 32; i++ )sprintf((Time + i * 9)," <%05d> ", Buff_8Point[i]); |
Kovalev_D | 98:95b8e79f13e1 | 159 | WriteCon(Time); |
Kovalev_D | 98:95b8e79f13e1 | 160 | } |
Kovalev_D | 98:95b8e79f13e1 | 161 | if (Time[0] == '3') { // выдача технологическая |
Kovalev_D | 98:95b8e79f13e1 | 162 | sprintf(Time,"\r\n"); |
Kovalev_D | 98:95b8e79f13e1 | 163 | WriteCon(Time); |
Kovalev_D | 98:95b8e79f13e1 | 164 | for (int i = 0; i < 32; i++ )sprintf((Time + i * 9)," <%05d> ", Buff_16Point[i]); |
Kovalev_D | 98:95b8e79f13e1 | 165 | WriteCon(Time); |
Kovalev_D | 98:95b8e79f13e1 | 166 | } |
Kovalev_D | 98:95b8e79f13e1 | 167 | |
Kovalev_D | 98:95b8e79f13e1 | 168 | if (Time[0] == '4') { // выдача технологическая |
Kovalev_D | 98:95b8e79f13e1 | 169 | sprintf(Time,"\r\n"); |
Kovalev_D | 98:95b8e79f13e1 | 170 | WriteCon(Time); |
Kovalev_D | 98:95b8e79f13e1 | 171 | for (int i = 0; i < 32; i++ )sprintf((Time + i * 9)," <%05d> ", Buff_16PointD[i]); |
Kovalev_D | 98:95b8e79f13e1 | 172 | WriteCon(Time); |
Kovalev_D | 98:95b8e79f13e1 | 173 | } |
Kovalev_D | 108:030cdde08314 | 174 | |
Kovalev_D | 108:030cdde08314 | 175 | |
Kovalev_D | 108:030cdde08314 | 176 | |
Kovalev_D | 104:ab1cb4ff56b2 | 177 | if (Time[0] == 'z') { // выдача технологическая |
Kovalev_D | 104:ab1cb4ff56b2 | 178 | sprintf(Time,"\r\n"); |
Kovalev_D | 104:ab1cb4ff56b2 | 179 | WriteCon(Time); |
Kovalev_D | 104:ab1cb4ff56b2 | 180 | |
Kovalev_D | 104:ab1cb4ff56b2 | 181 | for (int i = 0; i < 32; i++ ) |
Kovalev_D | 104:ab1cb4ff56b2 | 182 | { |
Kovalev_D | 104:ab1cb4ff56b2 | 183 | ttemp=(Buff_16PointD[i]); |
Kovalev_D | 104:ab1cb4ff56b2 | 184 | if (ttemp < 0) WriteCon("1"); else WriteCon("0"); |
Kovalev_D | 104:ab1cb4ff56b2 | 185 | } |
Kovalev_D | 104:ab1cb4ff56b2 | 186 | |
Kovalev_D | 104:ab1cb4ff56b2 | 187 | } |
Kovalev_D | 104:ab1cb4ff56b2 | 188 | |
Kovalev_D | 104:ab1cb4ff56b2 | 189 | |
Kovalev_D | 98:95b8e79f13e1 | 190 | if (Time[0] == '5') { // выдача технологическая |
Kovalev_D | 98:95b8e79f13e1 | 191 | sprintf(Time,"\r\n"); |
Kovalev_D | 98:95b8e79f13e1 | 192 | WriteCon(Time); |
Kovalev_D | 98:95b8e79f13e1 | 193 | for (int i = 0; i < 32; i++ )sprintf((Time + i * 9)," <%05d> ",Buff_32Point[i]); |
Kovalev_D | 98:95b8e79f13e1 | 194 | WriteCon(Time); |
Kovalev_D | 98:95b8e79f13e1 | 195 | } |
Kovalev_D | 98:95b8e79f13e1 | 196 | |
Kovalev_D | 98:95b8e79f13e1 | 197 | if (Time[0] == '6') { // выдача технологическая |
Kovalev_D | 98:95b8e79f13e1 | 198 | sprintf(Time,"\r\n"); |
Kovalev_D | 98:95b8e79f13e1 | 199 | WriteCon(Time); |
Kovalev_D | 98:95b8e79f13e1 | 200 | for (int i = 0; i < 32; i++ )sprintf((Time + i * 9)," <%05d> ",Buff_Restored_sin[i]); |
Kovalev_D | 98:95b8e79f13e1 | 201 | WriteCon(Time); |
Kovalev_D | 98:95b8e79f13e1 | 202 | } |
Kovalev_D | 95:dd51e577e114 | 203 | |
Kovalev_D | 95:dd51e577e114 | 204 | |
Kovalev_D | 104:ab1cb4ff56b2 | 205 | |
Kovalev_D | 104:ab1cb4ff56b2 | 206 | if (Time[0] == 'c') { // выдача технологическая |
Kovalev_D | 104:ab1cb4ff56b2 | 207 | sprintf(Time,"\r\n"); |
Kovalev_D | 104:ab1cb4ff56b2 | 208 | WriteCon(Time); |
Kovalev_D | 106:250ddd8629c6 | 209 | sprintf((Time)," <%07d> <%07d> <%07d> <%07d>", Gyro.F_ras,Gyro.F_ras/16, Gyro.Cnt_Pls, Gyro.Cnt_Mns); |
Kovalev_D | 104:ab1cb4ff56b2 | 210 | WriteCon(Time); |
Kovalev_D | 104:ab1cb4ff56b2 | 211 | } |
Kovalev_D | 104:ab1cb4ff56b2 | 212 | |
Kovalev_D | 104:ab1cb4ff56b2 | 213 | |
Kovalev_D | 104:ab1cb4ff56b2 | 214 | |
Kovalev_D | 98:95b8e79f13e1 | 215 | if (Time[0] == '7') { // выдача технологическая |
Kovalev_D | 95:dd51e577e114 | 216 | sprintf(Time,"\r\n"); |
Kovalev_D | 95:dd51e577e114 | 217 | WriteCon(Time); |
Kovalev_D | 96:1c8536458119 | 218 | for (int i = 0; i < 32; i++ )sprintf((Time + i * 10)," <%07d> ",Buff_AMP64P[i]-(Buff_AMP[i])); |
Kovalev_D | 95:dd51e577e114 | 219 | WriteCon(Time); |
Kovalev_D | 95:dd51e577e114 | 220 | } |
Kovalev_D | 98:95b8e79f13e1 | 221 | if (Time[0] == '9') { // выдача технологическая |
Kovalev_D | 98:95b8e79f13e1 | 222 | sprintf(Time,"\r\n"); |
Kovalev_D | 98:95b8e79f13e1 | 223 | WriteCon(Time); |
Kovalev_D | 98:95b8e79f13e1 | 224 | for (int i = 0; i < 32; i++ )sprintf((Time)," <%07d> ",Gyro.Frq); |
Kovalev_D | 98:95b8e79f13e1 | 225 | WriteCon(Time); |
Kovalev_D | 98:95b8e79f13e1 | 226 | } |
Kovalev_D | 98:95b8e79f13e1 | 227 | |
Kovalev_D | 98:95b8e79f13e1 | 228 | if (Time[0] == 'p') { // выдача технологическая |
Kovalev_D | 98:95b8e79f13e1 | 229 | sprintf(Time,"\r\n"); |
Kovalev_D | 98:95b8e79f13e1 | 230 | WriteCon(Time); |
Kovalev_D | 99:3d8f206ceac2 | 231 | for (int i = 0; i < 32; i++ )sprintf((Time)," <%07d> ",Cur_Amp); |
Kovalev_D | 98:95b8e79f13e1 | 232 | WriteCon(Time); |
Kovalev_D | 98:95b8e79f13e1 | 233 | } |
Kovalev_D | 99:3d8f206ceac2 | 234 | if (Time[0] == 'm') { // выдача технологическая |
Kovalev_D | 99:3d8f206ceac2 | 235 | sprintf(Time,"\r\n"); |
Kovalev_D | 99:3d8f206ceac2 | 236 | WriteCon(Time); |
Kovalev_D | 128:1e4675a36c93 | 237 | // sprintf((Time),"Cur_Amp <%07d> ", Cur_Amp); WriteCon(Time); |
Kovalev_D | 128:1e4675a36c93 | 238 | // sprintf((Time),"Znak_Amp <%07d> ", Znak_Amp); WriteCon(Time); |
Kovalev_D | 128:1e4675a36c93 | 239 | // sprintf((Time),"AD_Regul <%07d> ", AD_Regul); WriteCon(Time); |
Kovalev_D | 128:1e4675a36c93 | 240 | |
Kovalev_D | 128:1e4675a36c93 | 241 | sprintf((Time),"PLC_Delta <%07d> ", Gyro.PLC_Delta); WriteCon(Time); |
Kovalev_D | 128:1e4675a36c93 | 242 | sprintf((Time),"PLC_DeltaADD <%07d> ", Gyro.PLC_DeltaADD); WriteCon(Time); |
Kovalev_D | 109:ee0cff33ad3b | 243 | // printf((Time),"AD_Regul <%07d> ", Delta); WriteCon(Time); |
Kovalev_D | 109:ee0cff33ad3b | 244 | |
Kovalev_D | 109:ee0cff33ad3b | 245 | // sprintf((Time),"Spi.DAC_B <%07d> ",Spi.DAC_B); WriteCon(Time);*/ |
Kovalev_D | 109:ee0cff33ad3b | 246 | // sprintf((Time),"MaxAmp <%07d> ", MaxAmp); WriteCon(Time); |
Kovalev_D | 109:ee0cff33ad3b | 247 | // sprintf((Time),"CaunAddPlus <%07d> ", CaunAddPlus); WriteCon(Time); |
Kovalev_D | 109:ee0cff33ad3b | 248 | // sprintf((Time),"CaunAddMin <%07d> ", CaunAddMin); WriteCon(Time); |
Kovalev_D | 109:ee0cff33ad3b | 249 | // sprintf((Time)," Gyro.Amp <%07d> ",amp); WriteCon(Time); |
Kovalev_D | 108:030cdde08314 | 250 | |
Kovalev_D | 99:3d8f206ceac2 | 251 | } |
Kovalev_D | 98:95b8e79f13e1 | 252 | if (Time[0] == 'V') { // выдача технологическая |
Kovalev_D | 109:ee0cff33ad3b | 253 | // Gyro.Frq+=65000; |
Kovalev_D | 121:bbae560cdd43 | 254 | Spi.DAC_B += 200; |
Kovalev_D | 109:ee0cff33ad3b | 255 | |
Kovalev_D | 98:95b8e79f13e1 | 256 | } |
Kovalev_D | 98:95b8e79f13e1 | 257 | if (Time[0] == 'v') { // выдача технологическая |
Kovalev_D | 109:ee0cff33ad3b | 258 | //Gyro.Frq-=65000; |
Kovalev_D | 121:bbae560cdd43 | 259 | Spi.DAC_B -= 200; |
Kovalev_D | 98:95b8e79f13e1 | 260 | } |
Kovalev_D | 96:1c8536458119 | 261 | |
Kovalev_D | 98:95b8e79f13e1 | 262 | if (Time[0] == '8') { // выдача технологическая |
Kovalev_D | 96:1c8536458119 | 263 | sprintf(Time,"\r\n"); |
Kovalev_D | 96:1c8536458119 | 264 | WriteCon(Time); |
Kovalev_D | 96:1c8536458119 | 265 | // for (int i = 0; i < 32; i++ )sprintf((Time + i * 9)," <%05d> ",Buff_AMP64P[i]-(Buff_AMP[i]*2)); |
Kovalev_D | 96:1c8536458119 | 266 | for (int i = 0; i < 32; i++ ) |
Kovalev_D | 96:1c8536458119 | 267 | { |
Kovalev_D | 96:1c8536458119 | 268 | ttemp=(Buff_AMP64P[i]-(Buff_AMP[i])); |
Kovalev_D | 96:1c8536458119 | 269 | if (ttemp < 0) WriteCon("1"); else WriteCon("0"); |
Kovalev_D | 96:1c8536458119 | 270 | } |
Kovalev_D | 96:1c8536458119 | 271 | // WriteCon(Time); |
Kovalev_D | 96:1c8536458119 | 272 | } |
Kovalev_D | 95:dd51e577e114 | 273 | |
Kovalev_D | 98:95b8e79f13e1 | 274 | if (Time[0] == 'b') { // выдача технологическая |
Kovalev_D | 92:c892f0311aa7 | 275 | sprintf(Time,"\r\n"); |
Kovalev_D | 95:dd51e577e114 | 276 | WriteCon(Time); |
Kovalev_D | 98:95b8e79f13e1 | 277 | |
Kovalev_D | 98:95b8e79f13e1 | 278 | for (int i = 0; i < 32; i++ ) |
Kovalev_D | 98:95b8e79f13e1 | 279 | { |
Kovalev_D | 98:95b8e79f13e1 | 280 | ttemp=(Buff_Restored_sin[i]); |
Kovalev_D | 98:95b8e79f13e1 | 281 | if (ttemp < 0) WriteCon("1"); else WriteCon("0"); |
Kovalev_D | 98:95b8e79f13e1 | 282 | } |
Kovalev_D | 98:95b8e79f13e1 | 283 | |
Kovalev_D | 92:c892f0311aa7 | 284 | } |
Kovalev_D | 98:95b8e79f13e1 | 285 | |
Kovalev_D | 128:1e4675a36c93 | 286 | if (Gyro.PLC_Error2Mode) { // выдача технологическая |
Kovalev_D | 128:1e4675a36c93 | 287 | sprintf(Time,"\r\nPLC_Error2Mode"); |
Kovalev_D | 128:1e4675a36c93 | 288 | WriteCon(Time); |
Kovalev_D | 128:1e4675a36c93 | 289 | } |
Kovalev_D | 121:bbae560cdd43 | 290 | |
Kovalev_D | 95:dd51e577e114 | 291 | } |
Kovalev_D | 108:030cdde08314 | 292 | |
Kovalev_D | 136:19b9e6abb86f | 293 | |
Kovalev_D | 116:66f1f0ff2dab | 294 | |
Kovalev_D | 116:66f1f0ff2dab | 295 | Event_100KHz(); |
Kovalev_D | 88:b5c1d9d338d1 | 296 | Event_1KHz(); |
Kovalev_D | 124:9ae09249f842 | 297 | Event_500Hz(); |
Kovalev_D | 116:66f1f0ff2dab | 298 | Event_1Hz(); |
Kovalev_D | 124:9ae09249f842 | 299 | |
Kovalev_D | 88:b5c1d9d338d1 | 300 | Event_Vibro(); |
Kovalev_D | 124:9ae09249f842 | 301 | |
Kovalev_D | 124:9ae09249f842 | 302 | switch(Gyro.ModeOut) { |
Kovalev_D | 124:9ae09249f842 | 303 | case 1: |
Kovalev_D | 124:9ae09249f842 | 304 | if(Gyro.Rate1_Event==1)CMD_Rate(); |
Kovalev_D | 124:9ae09249f842 | 305 | break; |
Kovalev_D | 124:9ae09249f842 | 306 | case 2: |
Kovalev_D | 124:9ae09249f842 | 307 | if(Gyro.Rate2_Event==1)CMD_Rate2(); |
Kovalev_D | 124:9ae09249f842 | 308 | break; |
Kovalev_D | 124:9ae09249f842 | 309 | case 3: |
Kovalev_D | 124:9ae09249f842 | 310 | if(Gyro.Delta500_Event==1)CMD_Delta_500Hz(); |
Kovalev_D | 128:1e4675a36c93 | 311 | break; |
Kovalev_D | 128:1e4675a36c93 | 312 | case 4: |
Kovalev_D | 128:1e4675a36c93 | 313 | if(Gyro.EXT_Latch==1){CMD_Delta_Ext();} |
Kovalev_D | 128:1e4675a36c93 | 314 | break; |
Kovalev_D | 124:9ae09249f842 | 315 | } |
igor_v | 111:8ee1ef722ba7 | 316 | if (Spi.ADC_NewData == 1) // был приход новых данных по ацп сдесь сделать обработку информации и подготовку для выдачи делается 1 раз за вибро |
igor_v | 110:6406b7ac0442 | 317 | { |
igor_v | 114:5cc38a53d8a7 | 318 | // можно апихнкть в функцию |
igor_v | 110:6406b7ac0442 | 319 | Spi.ADC_NewData = 0; |
Kovalev_D | 113:8be429494918 | 320 | Gyro.Termo = Spi.ADC1; |
Kovalev_D | 113:8be429494918 | 321 | Gyro.In1 = Spi.ADC2; |
Kovalev_D | 113:8be429494918 | 322 | Gyro.In2 = Spi.ADC3; |
Kovalev_D | 113:8be429494918 | 323 | Gyro.DeltaT = Spi.ADC4; |
igor_v | 114:5cc38a53d8a7 | 324 | TempA = (0x7fff - Spi.ADC5) << 1; // перевернем знак и умножим на два (бало 32000...0 стало 0 ...64000) |
Kovalev_D | 112:4a96133a1311 | 325 | |
igor_v | 110:6406b7ac0442 | 326 | Gyro.ADF_Accum += TempA; |
igor_v | 110:6406b7ac0442 | 327 | Gyro.ADS_Accum += TempA; |
igor_v | 110:6406b7ac0442 | 328 | Gyro.ADF_Count ++; |
igor_v | 110:6406b7ac0442 | 329 | Gyro.ADS_Count ++; |
igor_v | 110:6406b7ac0442 | 330 | |
igor_v | 111:8ee1ef722ba7 | 331 | if (Gyro.ADF_Count > 15) // если прошло 16 тактов виброподвеса |
igor_v | 110:6406b7ac0442 | 332 | { |
igor_v | 111:8ee1ef722ba7 | 333 | Gyro.AD_Fast = Gyro.ADF_Accum << 12; //обновляем данные и приводим в один масштаб |
igor_v | 110:6406b7ac0442 | 334 | Gyro.ADF_Count = 0; |
igor_v | 110:6406b7ac0442 | 335 | Gyro.ADF_Accum = 0; |
igor_v | 110:6406b7ac0442 | 336 | Gyro.ADF_NewData = 1; |
igor_v | 110:6406b7ac0442 | 337 | } |
igor_v | 111:8ee1ef722ba7 | 338 | if (Gyro.ADS_Count > 255) // если прошло 256 тактов виброподвеса |
igor_v | 110:6406b7ac0442 | 339 | { |
igor_v | 111:8ee1ef722ba7 | 340 | Gyro.AD_Slow = Gyro.ADS_Accum << 8; //обновляем данные и приводим в один масштаб |
igor_v | 110:6406b7ac0442 | 341 | Gyro.ADS_Count = 0; |
igor_v | 110:6406b7ac0442 | 342 | Gyro.ADS_Accum = 0; |
igor_v | 110:6406b7ac0442 | 343 | Gyro.ADS_NewData = 1; |
igor_v | 110:6406b7ac0442 | 344 | } |
igor_v | 110:6406b7ac0442 | 345 | } |
Kovalev_D | 112:4a96133a1311 | 346 | |
Kovalev_D | 113:8be429494918 | 347 | |
Kovalev_D | 113:8be429494918 | 348 | |
Kovalev_D | 113:8be429494918 | 349 | |
igor_v | 111:8ee1ef722ba7 | 350 | if (Gyro.ADF_NewData == 1) // был приход новых данных После быстрого фильтра AD |
igor_v | 111:8ee1ef722ba7 | 351 | { |
Kovalev_D | 112:4a96133a1311 | 352 | Gyro.ADF_NewData = 0; |
igor_v | 114:5cc38a53d8a7 | 353 | }// можно запихнкть в функцию |
igor_v | 114:5cc38a53d8a7 | 354 | |
igor_v | 114:5cc38a53d8a7 | 355 | if (Gyro.ADS_NewData == 1) // был приход новых данных После Медленного фильтра AD |
igor_v | 114:5cc38a53d8a7 | 356 | { |
Kovalev_D | 116:66f1f0ff2dab | 357 | |
igor_v | 114:5cc38a53d8a7 | 358 | Gyro.ADS_NewData = 0; |
igor_v | 114:5cc38a53d8a7 | 359 | PlcRegul();//Расчет |
Kovalev_D | 113:8be429494918 | 360 | |
Kovalev_D | 112:4a96133a1311 | 361 | }// можно запихнкть в функцию |
Kovalev_D | 112:4a96133a1311 | 362 | |
igor_v | 114:5cc38a53d8a7 | 363 | if(Gyro.VibroFrqRegulF == 1) //Регулеровка частоты виброподвеса |
Kovalev_D | 112:4a96133a1311 | 364 | { |
Kovalev_D | 112:4a96133a1311 | 365 | Gyro.VibroFrqRegulF = 0; |
Kovalev_D | 112:4a96133a1311 | 366 | VibroFrqRegul(); |
Kovalev_D | 112:4a96133a1311 | 367 | } |
igor_v | 114:5cc38a53d8a7 | 368 | |
igor_v | 114:5cc38a53d8a7 | 369 | if(Gyro.VibroAMPRegulF == 1) //Регулеровка Амплитуды виброподвеса |
Kovalev_D | 112:4a96133a1311 | 370 | { |
Kovalev_D | 112:4a96133a1311 | 371 | Gyro.VibroAMPRegulF = 0; |
Kovalev_D | 112:4a96133a1311 | 372 | VibroAMPRegul(); |
Kovalev_D | 112:4a96133a1311 | 373 | } |
igor_v | 114:5cc38a53d8a7 | 374 | if(Gyro.VibroNoiseF == 1) //регулеровка ошумления, наверно нужно объеденить с регулеровкой ампитуды |
Kovalev_D | 112:4a96133a1311 | 375 | { |
Kovalev_D | 112:4a96133a1311 | 376 | Gyro.VibroNoiseF = 0; |
Kovalev_D | 112:4a96133a1311 | 377 | CalcAmpN(); |
Kovalev_D | 112:4a96133a1311 | 378 | } |
Kovalev_D | 113:8be429494918 | 379 | |
igor_v | 114:5cc38a53d8a7 | 380 | if(Gyro.VibroOutF== 1) // установка ног в регисторе тоже подумать , зачем отделный флаг? наверно |
Kovalev_D | 112:4a96133a1311 | 381 | { |
Kovalev_D | 112:4a96133a1311 | 382 | Gyro.VibroOutF = 0; |
Kovalev_D | 112:4a96133a1311 | 383 | VibroOut(); //Чтение ADS_SPI |
Kovalev_D | 112:4a96133a1311 | 384 | } |
Kovalev_D | 132:2c7bec5cf6fe | 385 | //&Gyro.Firmware_Version |
Kovalev_D | 132:2c7bec5cf6fe | 386 | ///////////////////////////////////////////////////////////////////////////////////////////////////////// |
Kovalev_D | 132:2c7bec5cf6fe | 387 | ///////////////////////////////////////////////////////////////////////////////////////////////////////// |
Kovalev_D | 132:2c7bec5cf6fe | 388 | /////////////////////////Работа с Flash////////////////////////////////////////////////////////////////// |
Kovalev_D | 132:2c7bec5cf6fe | 389 | ///////////////////////////////////////////////////////////////////////////////////////////////////////// |
Kovalev_D | 132:2c7bec5cf6fe | 390 | if(Gyro.FlashMod == 1) |
Kovalev_D | 132:2c7bec5cf6fe | 391 | { |
Kovalev_D | 132:2c7bec5cf6fe | 392 | |
Kovalev_D | 132:2c7bec5cf6fe | 393 | /* Prepare Sectors to be flashed */ |
Kovalev_D | 134:caf4c9cd5052 | 394 | NVIC_DisableIRQ(TIMER1_IRQn); |
Kovalev_D | 134:caf4c9cd5052 | 395 | NVIC_DisableIRQ(TIMER2_IRQn); |
Kovalev_D | 134:caf4c9cd5052 | 396 | NVIC_DisableIRQ(TIMER3_IRQn); |
Kovalev_D | 134:caf4c9cd5052 | 397 | NVIC_DisableIRQ(EINT3_IRQn); |
Kovalev_D | 134:caf4c9cd5052 | 398 | //SCB->VTOR = 0x00A000; |
Kovalev_D | 136:19b9e6abb86f | 399 | |
Kovalev_D | 135:c1e30e0e8949 | 400 | |
Kovalev_D | 135:c1e30e0e8949 | 401 | SystemInitDef(); |
Kovalev_D | 135:c1e30e0e8949 | 402 | vIAP_ReinvokeISP(); |
Kovalev_D | 136:19b9e6abb86f | 403 | } |
Kovalev_D | 133:90d0bf0e2996 | 404 | |
Kovalev_D | 132:2c7bec5cf6fe | 405 | |
Kovalev_D | 134:caf4c9cd5052 | 406 | if(Gyro.FlashMod == 2) |
Kovalev_D | 132:2c7bec5cf6fe | 407 | { |
Kovalev_D | 136:19b9e6abb86f | 408 | |
Kovalev_D | 136:19b9e6abb86f | 409 | NVIC_DisableIRQ(TIMER1_IRQn); |
Kovalev_D | 136:19b9e6abb86f | 410 | NVIC_DisableIRQ(TIMER2_IRQn); |
Kovalev_D | 136:19b9e6abb86f | 411 | NVIC_DisableIRQ(TIMER3_IRQn); |
Kovalev_D | 136:19b9e6abb86f | 412 | NVIC_DisableIRQ(EINT3_IRQn); |
Kovalev_D | 136:19b9e6abb86f | 413 | |
Kovalev_D | 136:19b9e6abb86f | 414 | SystemInitDef(); |
Kovalev_D | 136:19b9e6abb86f | 415 | |
Kovalev_D | 136:19b9e6abb86f | 416 | |
Kovalev_D | 136:19b9e6abb86f | 417 | |
Kovalev_D | 136:19b9e6abb86f | 418 | WriteCon("\r\n Start Prepare Sectors"); |
Kovalev_D | 136:19b9e6abb86f | 419 | if(u32IAP_PrepareSectors(18, 21) == IAP_STA_CMD_SUCCESS) |
Kovalev_D | 136:19b9e6abb86f | 420 | { |
Kovalev_D | 136:19b9e6abb86f | 421 | WriteCon("\r\nPrepare Sectors OK"); |
Kovalev_D | 136:19b9e6abb86f | 422 | WriteCon("\r\n Start Erase"); |
Kovalev_D | 136:19b9e6abb86f | 423 | |
Kovalev_D | 136:19b9e6abb86f | 424 | u32IAP_EraseSectors(IMG_START_SECTOR, IMG_END_SECTOR); |
Kovalev_D | 136:19b9e6abb86f | 425 | |
Kovalev_D | 136:19b9e6abb86f | 426 | WriteCon("\r\n AND Erase"); |
Kovalev_D | 136:19b9e6abb86f | 427 | } |
Kovalev_D | 136:19b9e6abb86f | 428 | else WriteCon("\r\nPrepare Sectors ERROR"); |
Kovalev_D | 136:19b9e6abb86f | 429 | SystemInit1(); |
Kovalev_D | 136:19b9e6abb86f | 430 | Gyro.FlashMod = 0; |
Kovalev_D | 136:19b9e6abb86f | 431 | //boot_jump(addres); |
Kovalev_D | 136:19b9e6abb86f | 432 | } |
Kovalev_D | 136:19b9e6abb86f | 433 | |
Kovalev_D | 136:19b9e6abb86f | 434 | |
Kovalev_D | 136:19b9e6abb86f | 435 | |
Kovalev_D | 136:19b9e6abb86f | 436 | |
Kovalev_D | 136:19b9e6abb86f | 437 | /* |
Kovalev_D | 136:19b9e6abb86f | 438 | #define IAP_STA_CMD_SUCCESS 0 |
Kovalev_D | 136:19b9e6abb86f | 439 | #define IAP_STA_INVALID_COMMAND 1 |
Kovalev_D | 136:19b9e6abb86f | 440 | #define IAP_STA_SRC_ADDR_ERROR 2 |
Kovalev_D | 136:19b9e6abb86f | 441 | #define IAP_STA_DST_ADDR_ERROR 3 |
Kovalev_D | 136:19b9e6abb86f | 442 | #define IAP_STA_SRC_ADDR_NOT_MAPPED 4 |
Kovalev_D | 136:19b9e6abb86f | 443 | #define IAP_STA_DST_ADDR_NOT_MAPPED 5 |
Kovalev_D | 136:19b9e6abb86f | 444 | #define IAP_STA_COUNT_ERROR 6 |
Kovalev_D | 136:19b9e6abb86f | 445 | #define IAP_STA_INVALID_SECTOR 7 |
Kovalev_D | 136:19b9e6abb86f | 446 | #define IAP_STA_SECTOR_NOT_BLANK 8 |
Kovalev_D | 136:19b9e6abb86f | 447 | #define IAP_STA_SECTOR_NOT_PREPARED_FOR_WRITE_OPERATION 9 |
Kovalev_D | 136:19b9e6abb86f | 448 | #define IAP_STA_COMPARE_ERROR 10 |
Kovalev_D | 136:19b9e6abb86f | 449 | #define IAP_STA_BUSY 11 |
Kovalev_D | 136:19b9e6abb86f | 450 | #define IAP_STA_INVALD_PARAM 12 |
Kovalev_D | 136:19b9e6abb86f | 451 | */ |
Kovalev_D | 136:19b9e6abb86f | 452 | |
Kovalev_D | 136:19b9e6abb86f | 453 | |
Kovalev_D | 136:19b9e6abb86f | 454 | |
Kovalev_D | 136:19b9e6abb86f | 455 | |
Kovalev_D | 136:19b9e6abb86f | 456 | |
Kovalev_D | 136:19b9e6abb86f | 457 | |
Kovalev_D | 136:19b9e6abb86f | 458 | |
Kovalev_D | 136:19b9e6abb86f | 459 | |
Kovalev_D | 136:19b9e6abb86f | 460 | |
Kovalev_D | 136:19b9e6abb86f | 461 | |
Kovalev_D | 136:19b9e6abb86f | 462 | |
Kovalev_D | 136:19b9e6abb86f | 463 | |
Kovalev_D | 136:19b9e6abb86f | 464 | |
Kovalev_D | 136:19b9e6abb86f | 465 | |
Kovalev_D | 136:19b9e6abb86f | 466 | |
Kovalev_D | 136:19b9e6abb86f | 467 | |
Kovalev_D | 136:19b9e6abb86f | 468 | |
Kovalev_D | 136:19b9e6abb86f | 469 | |
Kovalev_D | 136:19b9e6abb86f | 470 | |
Kovalev_D | 136:19b9e6abb86f | 471 | |
Kovalev_D | 136:19b9e6abb86f | 472 | if(Gyro.FlashMod == 3) |
Kovalev_D | 136:19b9e6abb86f | 473 | { |
Kovalev_D | 136:19b9e6abb86f | 474 | |
Kovalev_D | 136:19b9e6abb86f | 475 | ReadFlash(); |
Kovalev_D | 136:19b9e6abb86f | 476 | // SystemInitDef(); |
Kovalev_D | 136:19b9e6abb86f | 477 | // *status=(unsigned int*)addres; |
Kovalev_D | 136:19b9e6abb86f | 478 | /*NVIC_DisableIRQ(TIMER1_IRQn); |
Kovalev_D | 136:19b9e6abb86f | 479 | NVIC_DisableIRQ(TIMER2_IRQn); |
Kovalev_D | 136:19b9e6abb86f | 480 | NVIC_DisableIRQ(TIMER3_IRQn); |
Kovalev_D | 136:19b9e6abb86f | 481 | NVIC_DisableIRQ(EINT3_IRQn);*/ |
Kovalev_D | 136:19b9e6abb86f | 482 | Gyro.FlashMod = 0; |
Kovalev_D | 136:19b9e6abb86f | 483 | // memdump(addres,4); |
Kovalev_D | 136:19b9e6abb86f | 484 | // addres+=0x10; |
Kovalev_D | 136:19b9e6abb86f | 485 | // p = (unsigned int *)((unsigned int)base & ~(unsigned int)0x3); |
Kovalev_D | 136:19b9e6abb86f | 486 | // WriteCon(*addres); |
Kovalev_D | 136:19b9e6abb86f | 487 | // status=*addres; |
Kovalev_D | 136:19b9e6abb86f | 488 | // SystemInit1(); |
Kovalev_D | 136:19b9e6abb86f | 489 | // WriteCon(status); |
Kovalev_D | 136:19b9e6abb86f | 490 | // addres+=0x10; |
Kovalev_D | 136:19b9e6abb86f | 491 | |
Kovalev_D | 132:2c7bec5cf6fe | 492 | } |
Kovalev_D | 132:2c7bec5cf6fe | 493 | |
Kovalev_D | 132:2c7bec5cf6fe | 494 | |
Kovalev_D | 132:2c7bec5cf6fe | 495 | |
igor_v | 114:5cc38a53d8a7 | 496 | |
igor_v | 110:6406b7ac0442 | 497 | }//while |
Kovalev_D | 132:2c7bec5cf6fe | 498 | }//main |
igor_v | 0:8ad47e2b6f00 | 499 | |
igor_v | 0:8ad47e2b6f00 | 500 | /****************************************************************************** |
igor_v | 0:8ad47e2b6f00 | 501 | ** End Of File |
igor_v | 0:8ad47e2b6f00 | 502 | ******************************************************************************/ |
igor_v | 0:8ad47e2b6f00 | 503 | |
igor_v | 0:8ad47e2b6f00 | 504 |