123
Fork of LG by
main.c@103:e96f08947def, 2016-03-30 (annotated)
- Committer:
- Kovalev_D
- Date:
- Wed Mar 30 14:20:03 2016 +0000
- Revision:
- 103:e96f08947def
- Parent:
- 99:3d8f206ceac2
- Child:
- 104:ab1cb4ff56b2
Gain
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
igor_v | 7: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 | 28:17c84ed091b3 | 15 | последнии изменения |
igor_v | 28:17c84ed091b3 | 16 | //2016_02_03_17_47 |
igor_v | 29: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 | 10:8d2edc51f3c9 | 26 | |
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 |
Diletant | 74:f4d9c3403578 | 31 | |
igor_v | 0:8ad47e2b6f00 | 32 | extern uint32_t CMD_Mode; |
igor_v | 52:30f2e52a493f | 33 | unsigned int secPuls; |
igor_v | 52:30f2e52a493f | 34 | float DACF, K_DAC; |
igor_v | 51:81f47b817071 | 35 | |
igor_v | 52:30f2e52a493f | 36 | int main (void) |
igor_v | 52:30f2e52a493f | 37 | { |
Kovalev_D | 96:1c8536458119 | 38 | int i,ttemp; |
Kovalev_D | 92:c892f0311aa7 | 39 | |
Kovalev_D | 88:b5c1d9d338d1 | 40 | //DMA_Init(); // Инициализация DMA не используем |
Kovalev_D | 88:b5c1d9d338d1 | 41 | //DACInit(); // инициализация ЦАП. |
Kovalev_D | 92:c892f0311aa7 | 42 | //UART_DMA_Init(); //инициализация DMA для UART.//не используем |
Kovalev_D | 89:a0d344db227e | 43 | //WDTInit(); |
Kovalev_D | 99:3d8f206ceac2 | 44 | // G_Photo_Init(); //инициализация интерфейса I2C для фотодетектора. |
Kovalev_D | 86:398da56ef751 | 45 | //инициализация |
Kovalev_D | 92:c892f0311aa7 | 46 | |
Kovalev_D | 92:c892f0311aa7 | 47 | |
Kovalev_D | 92:c892f0311aa7 | 48 | |
Kovalev_D | 86:398da56ef751 | 49 | SystemInit1(); // Инициализация контроллера: установка тактовых частот |
Kovalev_D | 86:398da56ef751 | 50 | FlashDMA_Init(); // Загрузка параметров с флэш |
Kovalev_D | 86:398da56ef751 | 51 | SystemCoreClockUpdate1(); // расчет тактовой частоты процессора перед инициализацией UART - 100MHz |
Kovalev_D | 88:b5c1d9d338d1 | 52 | |
Kovalev_D | 86:398da56ef751 | 53 | GLD_Init(); |
Kovalev_D | 92:c892f0311aa7 | 54 | ///////////старый UART |
igor_v | 91:a2bb81eaa183 | 55 | // UARTInit(); // инициализация UART0 на скорость 38400. |
igor_v | 91:a2bb81eaa183 | 56 | // UART1_Init(); // инициализация UART1 на скорость 38400. |
Kovalev_D | 88:b5c1d9d338d1 | 57 | |
igor_v | 91:a2bb81eaa183 | 58 | |
Kovalev_D | 96:1c8536458119 | 59 | UART_InitSet (0, 115200, 0x03); // надо проверить, мож чо с ногам |
Kovalev_D | 92:c892f0311aa7 | 60 | UART_InitSet (1, 38400, 0x03); |
Kovalev_D | 99:3d8f206ceac2 | 61 | |
Kovalev_D | 86:398da56ef751 | 62 | //////////// |
Kovalev_D | 90:d9b6a4bc5065 | 63 | //DAC_ADC_Exchange_Init(); // инициализация обмена АЦП и ЦАП. |
Kovalev_D | 88:b5c1d9d338d1 | 64 | |
Diletant | 46:2670fa0fcebc | 65 | IntLatch_Init(); // инициализация внутренней защелки. |
Diletant | 46:2670fa0fcebc | 66 | ExtLatch_Init(); // инициализация внешней защелки. |
igor_v | 21:bc8c1cec3da6 | 67 | LoadFlashParam(FromFLASH); //загрузка параметров. |
Kovalev_D | 89:a0d344db227e | 68 | |
Kovalev_D | 92:c892f0311aa7 | 69 | |
Kovalev_D | 103:e96f08947def | 70 | |
Kovalev_D | 89:a0d344db227e | 71 | |
Kovalev_D | 92:c892f0311aa7 | 72 | |
igor_v | 28:17c84ed091b3 | 73 | open_all_loops(); //#define open_all_loops() RgConA = 0 (Основной регистр управления устройства (0 - включить, 1 - отключить)). |
igor_v | 28:17c84ed091b3 | 74 | Output.Str.HF_reg = Device_blk.Str.HF_min; //HFO output voltage = максивальное напряжение на ГВЧ. |
igor_v | 28:17c84ed091b3 | 75 | init_PLC(); //Инициализация СРП(регулировка периметра) |
igor_v | 28:17c84ed091b3 | 76 | init_Dither_reg(); //инициализация вибропривода |
igor_v | 28:17c84ed091b3 | 77 | RgConB = RATE_VIBRO_1; // дополнительный регистр управления = разность вибросчетчиков после фильтра скольз.среднего(#define RATE_VIBRO_1 0x0001) |
Kovalev_D | 86:398da56ef751 | 78 | close_all_loops(); |
igor_v | 51:81f47b817071 | 79 | |
igor_v | 51:81f47b817071 | 80 | |
igor_v | 51:81f47b817071 | 81 | |
igor_v | 51:81f47b817071 | 82 | |
igor_v | 51:81f47b817071 | 83 | |
Kovalev_D | 47:d902ef6f7564 | 84 | WriteCon1("\n\r ...GL start programm uart ACK.... "); |
Kovalev_D | 47:d902ef6f7564 | 85 | WriteCon("\n\r ...GL start programm uart Tech.... "); |
igor_v | 15:f5191a1c3805 | 86 | sprintf(Time,"\r\nCompiled: %s %s.",__DATE__, __TIME__ ); //Подготовка даты и времени компиляции |
igor_v | 13:e2a1d18677b8 | 87 | WriteCon(Time); |
igor_v | 11:af609f6dee46 | 88 | |
igor_v | 37:bdd52117b56e | 89 | |
igor_v | 11:af609f6dee46 | 90 | |
Kovalev_D | 50:0e3d47f18a50 | 91 | while ( 1 ) { //основной цикл. |
Kovalev_D | 92:c892f0311aa7 | 92 | Concol (); // Проврка 0 консоли (вход и выход) |
Kovalev_D | 93:b3803774f110 | 93 | |
Kovalev_D | 93:b3803774f110 | 94 | Concol1 (); // Проврка 0 консоли (вход и выход) |
Kovalev_D | 99:3d8f206ceac2 | 95 | Read_CMD(); |
Kovalev_D | 103:e96f08947def | 96 | |
igor_v | 3:ed8744c5f67a | 97 | if (OutBufConCount) OutBufConCount--; |
igor_v | 48:8697dfe679b9 | 98 | |
Kovalev_D | 95:dd51e577e114 | 99 | if (ReadCon (Time)) { |
igor_v | 48:8697dfe679b9 | 100 | |
igor_v | 16:18e3fd7b92d0 | 101 | if (Time[0] == 'h') { // если ввели буквц h то выдать подсказку. сделанно через принф ОЧЕНЬ плохо в работе не использовать |
igor_v | 15:f5191a1c3805 | 102 | sprintf(Time,"\r\nCompiled: %s %s.",__DATE__, __TIME__ ); //Подготовка даты и времени компиляции |
igor_v | 15:f5191a1c3805 | 103 | WriteCon(Time); |
igor_v | 52:30f2e52a493f | 104 | sprintf(Time,"--%d.%3.d.%2.d.",Time1Hz,Time1K,Time100K); //Временно выдачпа временни из трех чисел |
igor_v | 15:f5191a1c3805 | 105 | WriteCon(Time); |
igor_v | 52:30f2e52a493f | 106 | } |
igor_v | 52:30f2e52a493f | 107 | if (Time[0] == 'D') { |
igor_v | 52:30f2e52a493f | 108 | Gyro.Discharg = StartDischarg; |
igor_v | 15:f5191a1c3805 | 109 | } |
igor_v | 52:30f2e52a493f | 110 | if (Time[0] == 'L') { |
igor_v | 52:30f2e52a493f | 111 | Gyro.BackLight = StartBackLight; |
igor_v | 52:30f2e52a493f | 112 | } |
Kovalev_D | 98:95b8e79f13e1 | 113 | |
Kovalev_D | 98:95b8e79f13e1 | 114 | |
Kovalev_D | 98:95b8e79f13e1 | 115 | |
Kovalev_D | 98:95b8e79f13e1 | 116 | |
Kovalev_D | 98:95b8e79f13e1 | 117 | |
Kovalev_D | 98:95b8e79f13e1 | 118 | |
Kovalev_D | 98:95b8e79f13e1 | 119 | if (Time[0] == '1') { // выдача технологическая |
Kovalev_D | 88:b5c1d9d338d1 | 120 | sprintf(Time,"\r\n"); |
Kovalev_D | 95:dd51e577e114 | 121 | WriteCon(Time); |
Kovalev_D | 96:1c8536458119 | 122 | for (int i = 0; i < 32; i++ )sprintf((Time + i * 9)," <%05d> ",Buff_1Point[i]); |
igor_v | 52:30f2e52a493f | 123 | WriteCon(Time); |
igor_v | 52:30f2e52a493f | 124 | } |
Kovalev_D | 98:95b8e79f13e1 | 125 | |
Kovalev_D | 98:95b8e79f13e1 | 126 | if (Time[0] == '2') { // выдача технологическая |
Kovalev_D | 98:95b8e79f13e1 | 127 | sprintf(Time,"\r\n"); |
Kovalev_D | 98:95b8e79f13e1 | 128 | WriteCon(Time); |
Kovalev_D | 98:95b8e79f13e1 | 129 | for (int i = 0; i < 32; i++ )sprintf((Time + i * 9)," <%05d> ", Buff_8Point[i]); |
Kovalev_D | 98:95b8e79f13e1 | 130 | WriteCon(Time); |
Kovalev_D | 98:95b8e79f13e1 | 131 | } |
Kovalev_D | 98:95b8e79f13e1 | 132 | if (Time[0] == '3') { // выдача технологическая |
Kovalev_D | 98:95b8e79f13e1 | 133 | sprintf(Time,"\r\n"); |
Kovalev_D | 98:95b8e79f13e1 | 134 | WriteCon(Time); |
Kovalev_D | 98:95b8e79f13e1 | 135 | for (int i = 0; i < 32; i++ )sprintf((Time + i * 9)," <%05d> ", Buff_16Point[i]); |
Kovalev_D | 98:95b8e79f13e1 | 136 | WriteCon(Time); |
Kovalev_D | 98:95b8e79f13e1 | 137 | } |
Kovalev_D | 98:95b8e79f13e1 | 138 | |
Kovalev_D | 98:95b8e79f13e1 | 139 | if (Time[0] == '4') { // выдача технологическая |
Kovalev_D | 98:95b8e79f13e1 | 140 | sprintf(Time,"\r\n"); |
Kovalev_D | 98:95b8e79f13e1 | 141 | WriteCon(Time); |
Kovalev_D | 98:95b8e79f13e1 | 142 | for (int i = 0; i < 32; i++ )sprintf((Time + i * 9)," <%05d> ", Buff_16PointD[i]); |
Kovalev_D | 98:95b8e79f13e1 | 143 | WriteCon(Time); |
Kovalev_D | 98:95b8e79f13e1 | 144 | } |
Kovalev_D | 98:95b8e79f13e1 | 145 | |
Kovalev_D | 98:95b8e79f13e1 | 146 | if (Time[0] == '5') { // выдача технологическая |
Kovalev_D | 98:95b8e79f13e1 | 147 | sprintf(Time,"\r\n"); |
Kovalev_D | 98:95b8e79f13e1 | 148 | WriteCon(Time); |
Kovalev_D | 98:95b8e79f13e1 | 149 | for (int i = 0; i < 32; i++ )sprintf((Time + i * 9)," <%05d> ",Buff_32Point[i]); |
Kovalev_D | 98:95b8e79f13e1 | 150 | WriteCon(Time); |
Kovalev_D | 98:95b8e79f13e1 | 151 | } |
Kovalev_D | 98:95b8e79f13e1 | 152 | |
Kovalev_D | 98:95b8e79f13e1 | 153 | if (Time[0] == '6') { // выдача технологическая |
Kovalev_D | 98:95b8e79f13e1 | 154 | sprintf(Time,"\r\n"); |
Kovalev_D | 98:95b8e79f13e1 | 155 | WriteCon(Time); |
Kovalev_D | 98:95b8e79f13e1 | 156 | for (int i = 0; i < 32; i++ )sprintf((Time + i * 9)," <%05d> ",Buff_Restored_sin[i]); |
Kovalev_D | 98:95b8e79f13e1 | 157 | WriteCon(Time); |
Kovalev_D | 98:95b8e79f13e1 | 158 | } |
Kovalev_D | 95:dd51e577e114 | 159 | |
Kovalev_D | 95:dd51e577e114 | 160 | |
Kovalev_D | 98:95b8e79f13e1 | 161 | if (Time[0] == '7') { // выдача технологическая |
Kovalev_D | 95:dd51e577e114 | 162 | sprintf(Time,"\r\n"); |
Kovalev_D | 95:dd51e577e114 | 163 | WriteCon(Time); |
Kovalev_D | 96:1c8536458119 | 164 | for (int i = 0; i < 32; i++ )sprintf((Time + i * 10)," <%07d> ",Buff_AMP64P[i]-(Buff_AMP[i])); |
Kovalev_D | 95:dd51e577e114 | 165 | WriteCon(Time); |
Kovalev_D | 95:dd51e577e114 | 166 | } |
Kovalev_D | 98:95b8e79f13e1 | 167 | if (Time[0] == '9') { // выдача технологическая |
Kovalev_D | 98:95b8e79f13e1 | 168 | sprintf(Time,"\r\n"); |
Kovalev_D | 98:95b8e79f13e1 | 169 | WriteCon(Time); |
Kovalev_D | 98:95b8e79f13e1 | 170 | for (int i = 0; i < 32; i++ )sprintf((Time)," <%07d> ",Gyro.Frq); |
Kovalev_D | 98:95b8e79f13e1 | 171 | WriteCon(Time); |
Kovalev_D | 98:95b8e79f13e1 | 172 | } |
Kovalev_D | 98:95b8e79f13e1 | 173 | |
Kovalev_D | 98:95b8e79f13e1 | 174 | if (Time[0] == 'p') { // выдача технологическая |
Kovalev_D | 98:95b8e79f13e1 | 175 | sprintf(Time,"\r\n"); |
Kovalev_D | 98:95b8e79f13e1 | 176 | WriteCon(Time); |
Kovalev_D | 99:3d8f206ceac2 | 177 | for (int i = 0; i < 32; i++ )sprintf((Time)," <%07d> ",Cur_Amp); |
Kovalev_D | 98:95b8e79f13e1 | 178 | WriteCon(Time); |
Kovalev_D | 98:95b8e79f13e1 | 179 | } |
Kovalev_D | 99:3d8f206ceac2 | 180 | if (Time[0] == 'm') { // выдача технологическая |
Kovalev_D | 99:3d8f206ceac2 | 181 | sprintf(Time,"\r\n"); |
Kovalev_D | 99:3d8f206ceac2 | 182 | WriteCon(Time); |
Kovalev_D | 99:3d8f206ceac2 | 183 | sprintf((Time)," <%07d> ",Cur_Amp); WriteCon(Time); |
Kovalev_D | 99:3d8f206ceac2 | 184 | sprintf((Time)," <%07d> ",Znak_Amp); WriteCon(Time); |
Kovalev_D | 99:3d8f206ceac2 | 185 | sprintf((Time)," <%07d> ",Spi.DAC_B); WriteCon(Time); |
Kovalev_D | 99:3d8f206ceac2 | 186 | |
Kovalev_D | 99:3d8f206ceac2 | 187 | |
Kovalev_D | 99:3d8f206ceac2 | 188 | |
Kovalev_D | 99:3d8f206ceac2 | 189 | |
Kovalev_D | 99:3d8f206ceac2 | 190 | } |
Kovalev_D | 98:95b8e79f13e1 | 191 | if (Time[0] == 'V') { // выдача технологическая |
Kovalev_D | 98:95b8e79f13e1 | 192 | Gyro.Frq+=65000; |
Kovalev_D | 98:95b8e79f13e1 | 193 | } |
Kovalev_D | 98:95b8e79f13e1 | 194 | if (Time[0] == 'v') { // выдача технологическая |
Kovalev_D | 98:95b8e79f13e1 | 195 | Gyro.Frq-=65000; |
Kovalev_D | 98:95b8e79f13e1 | 196 | } |
Kovalev_D | 96:1c8536458119 | 197 | |
Kovalev_D | 98:95b8e79f13e1 | 198 | if (Time[0] == '8') { // выдача технологическая |
Kovalev_D | 96:1c8536458119 | 199 | sprintf(Time,"\r\n"); |
Kovalev_D | 96:1c8536458119 | 200 | WriteCon(Time); |
Kovalev_D | 96:1c8536458119 | 201 | // for (int i = 0; i < 32; i++ )sprintf((Time + i * 9)," <%05d> ",Buff_AMP64P[i]-(Buff_AMP[i]*2)); |
Kovalev_D | 96:1c8536458119 | 202 | for (int i = 0; i < 32; i++ ) |
Kovalev_D | 96:1c8536458119 | 203 | { |
Kovalev_D | 96:1c8536458119 | 204 | ttemp=(Buff_AMP64P[i]-(Buff_AMP[i])); |
Kovalev_D | 96:1c8536458119 | 205 | if (ttemp < 0) WriteCon("1"); else WriteCon("0"); |
Kovalev_D | 96:1c8536458119 | 206 | } |
Kovalev_D | 96:1c8536458119 | 207 | // WriteCon(Time); |
Kovalev_D | 96:1c8536458119 | 208 | } |
Kovalev_D | 95:dd51e577e114 | 209 | |
Kovalev_D | 98:95b8e79f13e1 | 210 | if (Time[0] == 'b') { // выдача технологическая |
Kovalev_D | 92:c892f0311aa7 | 211 | sprintf(Time,"\r\n"); |
Kovalev_D | 95:dd51e577e114 | 212 | WriteCon(Time); |
Kovalev_D | 98:95b8e79f13e1 | 213 | |
Kovalev_D | 98:95b8e79f13e1 | 214 | for (int i = 0; i < 32; i++ ) |
Kovalev_D | 98:95b8e79f13e1 | 215 | { |
Kovalev_D | 98:95b8e79f13e1 | 216 | ttemp=(Buff_Restored_sin[i]); |
Kovalev_D | 98:95b8e79f13e1 | 217 | if (ttemp < 0) WriteCon("1"); else WriteCon("0"); |
Kovalev_D | 98:95b8e79f13e1 | 218 | } |
Kovalev_D | 98:95b8e79f13e1 | 219 | |
Kovalev_D | 92:c892f0311aa7 | 220 | } |
Kovalev_D | 98:95b8e79f13e1 | 221 | |
Kovalev_D | 92:c892f0311aa7 | 222 | Read_CMD(); |
Kovalev_D | 95:dd51e577e114 | 223 | } |
igor_v | 38:716472a4492e | 224 | if (OutBufCon1Count) OutBufCon1Count--; |
Kovalev_D | 92:c892f0311aa7 | 225 | // Read_CMD(); |
igor_v | 52:30f2e52a493f | 226 | |
Kovalev_D | 88:b5c1d9d338d1 | 227 | Event_1Hz(); |
Kovalev_D | 88:b5c1d9d338d1 | 228 | Event_1KHz(); |
Kovalev_D | 88:b5c1d9d338d1 | 229 | Event_100KHz(); |
Kovalev_D | 88:b5c1d9d338d1 | 230 | Event_Vibro(); |
Kovalev_D | 92:c892f0311aa7 | 231 | |
Kovalev_D | 88:b5c1d9d338d1 | 232 | } |
igor_v | 0:8ad47e2b6f00 | 233 | } |
igor_v | 0:8ad47e2b6f00 | 234 | |
igor_v | 0:8ad47e2b6f00 | 235 | /****************************************************************************** |
igor_v | 0:8ad47e2b6f00 | 236 | ** End Of File |
igor_v | 0:8ad47e2b6f00 | 237 | ******************************************************************************/ |
igor_v | 0:8ad47e2b6f00 | 238 | |
igor_v | 0:8ad47e2b6f00 | 239 |