![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
forkd
Fork of LG2 by
main.c@97:a0f76c0c7692, 2016-03-28 (annotated)
- Committer:
- Kovalev_D
- Date:
- Mon Mar 28 15:32:21 2016 +0000
- Revision:
- 97:a0f76c0c7692
- Parent:
- 96:1c8536458119
- Child:
- 98:95b8e79f13e1
1
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 | 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 | 90:d9b6a4bc5065 | 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); |
igor_v | 91:a2bb81eaa183 | 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 | 97:a0f76c0c7692 | 70 | Out_G_photo(20, 20); //запись в буфер мастера принятые от функции данные (60,60) и установка флага старта передачи и занятой шины. |
Kovalev_D | 89:a0d344db227e | 71 | |
Kovalev_D | 92:c892f0311aa7 | 72 | |
igor_v | 30:17c84ed091b3 | 73 | open_all_loops(); //#define open_all_loops() RgConA = 0 (Основной регистр управления устройства (0 - включить, 1 - отключить)). |
igor_v | 30:17c84ed091b3 | 74 | Output.Str.HF_reg = Device_blk.Str.HF_min; //HFO output voltage = максивальное напряжение на ГВЧ. |
igor_v | 30:17c84ed091b3 | 75 | init_PLC(); //Инициализация СРП(регулировка периметра) |
igor_v | 30:17c84ed091b3 | 76 | init_Dither_reg(); //инициализация вибропривода |
igor_v | 30: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 | 92:c892f0311aa7 | 95 | Read_CMD(); |
igor_v | 3:ed8744c5f67a | 96 | if (OutBufConCount) OutBufConCount--; |
igor_v | 48:8697dfe679b9 | 97 | |
Kovalev_D | 95:dd51e577e114 | 98 | if (ReadCon (Time)) { |
igor_v | 48:8697dfe679b9 | 99 | |
igor_v | 16:18e3fd7b92d0 | 100 | if (Time[0] == 'h') { // если ввели буквц h то выдать подсказку. сделанно через принф ОЧЕНЬ плохо в работе не использовать |
igor_v | 15:f5191a1c3805 | 101 | sprintf(Time,"\r\nCompiled: %s %s.",__DATE__, __TIME__ ); //Подготовка даты и времени компиляции |
igor_v | 15:f5191a1c3805 | 102 | WriteCon(Time); |
igor_v | 52:30f2e52a493f | 103 | sprintf(Time,"--%d.%3.d.%2.d.",Time1Hz,Time1K,Time100K); //Временно выдачпа временни из трех чисел |
igor_v | 15:f5191a1c3805 | 104 | WriteCon(Time); |
igor_v | 52:30f2e52a493f | 105 | } |
Kovalev_D | 92:c892f0311aa7 | 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 | } |
igor_v | 52:30f2e52a493f | 113 | if (Time[0] == '1') { // выдача технологическая |
Kovalev_D | 88:b5c1d9d338d1 | 114 | sprintf(Time,"\r\n"); |
Kovalev_D | 95:dd51e577e114 | 115 | WriteCon(Time); |
Kovalev_D | 96:1c8536458119 | 116 | for (int i = 0; i < 32; i++ )sprintf((Time + i * 9)," <%05d> ",Buff_1Point[i]); |
igor_v | 52:30f2e52a493f | 117 | WriteCon(Time); |
igor_v | 52:30f2e52a493f | 118 | } |
Kovalev_D | 96:1c8536458119 | 119 | // Buff_Restored_sin |
Kovalev_D | 95:dd51e577e114 | 120 | |
Kovalev_D | 95:dd51e577e114 | 121 | |
Kovalev_D | 95:dd51e577e114 | 122 | if (Time[0] == '2') { // выдача технологическая |
Kovalev_D | 95:dd51e577e114 | 123 | sprintf(Time,"\r\n"); |
Kovalev_D | 95:dd51e577e114 | 124 | WriteCon(Time); |
Kovalev_D | 96:1c8536458119 | 125 | for (int i = 0; i < 32; i++ )sprintf((Time + i * 10)," <%07d> ",Buff_AMP64P[i]-(Buff_AMP[i])); |
Kovalev_D | 95:dd51e577e114 | 126 | WriteCon(Time); |
Kovalev_D | 95:dd51e577e114 | 127 | } |
Kovalev_D | 96:1c8536458119 | 128 | |
Kovalev_D | 96:1c8536458119 | 129 | |
Kovalev_D | 96:1c8536458119 | 130 | |
Kovalev_D | 96:1c8536458119 | 131 | if (Time[0] == '3') { // выдача технологическая |
Kovalev_D | 96:1c8536458119 | 132 | sprintf(Time,"\r\n"); |
Kovalev_D | 96:1c8536458119 | 133 | WriteCon(Time); |
Kovalev_D | 96:1c8536458119 | 134 | // for (int i = 0; i < 32; i++ )sprintf((Time + i * 9)," <%05d> ",Buff_AMP64P[i]-(Buff_AMP[i]*2)); |
Kovalev_D | 96:1c8536458119 | 135 | for (int i = 0; i < 32; i++ ) |
Kovalev_D | 96:1c8536458119 | 136 | { |
Kovalev_D | 96:1c8536458119 | 137 | ttemp=(Buff_AMP64P[i]-(Buff_AMP[i])); |
Kovalev_D | 96:1c8536458119 | 138 | if (ttemp < 0) WriteCon("1"); else WriteCon("0"); |
Kovalev_D | 96:1c8536458119 | 139 | } |
Kovalev_D | 96:1c8536458119 | 140 | // WriteCon(Time); |
Kovalev_D | 96:1c8536458119 | 141 | } |
Kovalev_D | 95:dd51e577e114 | 142 | |
Kovalev_D | 95:dd51e577e114 | 143 | |
Kovalev_D | 95:dd51e577e114 | 144 | |
Kovalev_D | 92:c892f0311aa7 | 145 | if (Time[0] == 'j') { // выдача технологическая |
Kovalev_D | 92:c892f0311aa7 | 146 | sprintf(Time,"\r\n"); |
Kovalev_D | 95:dd51e577e114 | 147 | WriteCon(Time); |
Kovalev_D | 92:c892f0311aa7 | 148 | for (int i = 0; i < 32; i++ ) WriteConByte(Buff_32Point[i]); |
Kovalev_D | 92:c892f0311aa7 | 149 | |
Kovalev_D | 92:c892f0311aa7 | 150 | } |
Kovalev_D | 92:c892f0311aa7 | 151 | Read_CMD(); |
Kovalev_D | 95:dd51e577e114 | 152 | } |
igor_v | 38:716472a4492e | 153 | if (OutBufCon1Count) OutBufCon1Count--; |
Kovalev_D | 92:c892f0311aa7 | 154 | // Read_CMD(); |
igor_v | 52:30f2e52a493f | 155 | |
Kovalev_D | 88:b5c1d9d338d1 | 156 | Event_1Hz(); |
Kovalev_D | 88:b5c1d9d338d1 | 157 | Event_1KHz(); |
Kovalev_D | 88:b5c1d9d338d1 | 158 | Event_100KHz(); |
Kovalev_D | 88:b5c1d9d338d1 | 159 | Event_Vibro(); |
Kovalev_D | 92:c892f0311aa7 | 160 | |
Kovalev_D | 88:b5c1d9d338d1 | 161 | } |
igor_v | 0:8ad47e2b6f00 | 162 | } |
igor_v | 0:8ad47e2b6f00 | 163 | |
igor_v | 0:8ad47e2b6f00 | 164 | /****************************************************************************** |
igor_v | 0:8ad47e2b6f00 | 165 | ** End Of File |
igor_v | 0:8ad47e2b6f00 | 166 | ******************************************************************************/ |
igor_v | 0:8ad47e2b6f00 | 167 | |
igor_v | 0:8ad47e2b6f00 | 168 |