![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
forkd
Fork of LGstaandart by
main.c@27:101340a22746, 2016-02-03 (annotated)
- Committer:
- igor_v
- Date:
- Wed Feb 03 14:48:02 2016 +0000
- Revision:
- 27:101340a22746
- Parent:
- 21:bc8c1cec3da6
- Child:
- 28:1c9acd3b224d
- Child:
- 29:f9174eac3dee
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 | 0:8ad47e2b6f00 | 15 | *********************************************************************************************************/ |
igor_v | 21:bc8c1cec3da6 | 16 | |
igor_v | 0:8ad47e2b6f00 | 17 | |
igor_v | 0:8ad47e2b6f00 | 18 | #include "Global.h" |
igor_v | 0:8ad47e2b6f00 | 19 | //#include <math.h> |
igor_v | 0:8ad47e2b6f00 | 20 | |
Kovalev_D | 10:8d2edc51f3c9 | 21 | |
Kovalev_D | 10:8d2edc51f3c9 | 22 | |
Kovalev_D | 10:8d2edc51f3c9 | 23 | |
igor_v | 27:101340a22746 | 24 | //проба верси |
igor_v | 27:101340a22746 | 25 | //2016_02_03_17_47 |
Kovalev_D | 10:8d2edc51f3c9 | 26 | |
Kovalev_D | 10:8d2edc51f3c9 | 27 | |
Kovalev_D | 10:8d2edc51f3c9 | 28 | |
Kovalev_D | 10:8d2edc51f3c9 | 29 | |
Kovalev_D | 10:8d2edc51f3c9 | 30 | |
igor_v | 0:8ad47e2b6f00 | 31 | /****************************************************************************** |
igor_v | 0:8ad47e2b6f00 | 32 | ** Main Function main() |
igor_v | 0:8ad47e2b6f00 | 33 | ******************************************************************************/ |
igor_v | 0:8ad47e2b6f00 | 34 | extern uint32_t CMD_Mode; |
igor_v | 0:8ad47e2b6f00 | 35 | ////////////////////////////////////////////////////////////////////////////////////////////////////////// |
igor_v | 0:8ad47e2b6f00 | 36 | ////////////////////////////////////////////////////////////////////////////////////////////////////////// |
igor_v | 3:ed8744c5f67a | 37 | int i1 =0; |
igor_v | 0:8ad47e2b6f00 | 38 | //extern unsigned int Buff_QEI[256]; |
igor_v | 0:8ad47e2b6f00 | 39 | volatile unsigned int IRQ_Counter=0; |
igor_v | 0:8ad47e2b6f00 | 40 | volatile uint32_t timer1_counter = 0; |
igor_v | 0:8ad47e2b6f00 | 41 | int temp111=0,temp=0; |
igor_v | 0:8ad47e2b6f00 | 42 | int y = 0; |
igor_v | 0:8ad47e2b6f00 | 43 | int CuruAngleOld=0; |
igor_v | 0:8ad47e2b6f00 | 44 | unsigned int LightUpCount,BackLightCount,secPuls,CountBI,CmmandIn,tt,th; |
igor_v | 0:8ad47e2b6f00 | 45 | |
igor_v | 0:8ad47e2b6f00 | 46 | unsigned int paramV; |
igor_v | 0:8ad47e2b6f00 | 47 | |
igor_v | 0:8ad47e2b6f00 | 48 | |
igor_v | 0:8ad47e2b6f00 | 49 | |
igor_v | 0:8ad47e2b6f00 | 50 | void Led_init() |
igor_v | 0:8ad47e2b6f00 | 51 | { |
igor_v | 3:ed8744c5f67a | 52 | LPC_PINCON->PINSEL0 = (0x00<<28); |
igor_v | 3:ed8744c5f67a | 53 | LPC_GPIO1->FIODIR = (0x1<<30); |
igor_v | 3:ed8744c5f67a | 54 | LPC_PINCON->PINMODE0 = (0x3<<28); |
igor_v | 3:ed8744c5f67a | 55 | // LPC_GPIO1->FIOSET = (0x0<<30); |
igor_v | 3:ed8744c5f67a | 56 | // LPC_GPIO0->FIOSET = (1<<4); |
igor_v | 0:8ad47e2b6f00 | 57 | } |
igor_v | 3:ed8744c5f67a | 58 | |
igor_v | 0:8ad47e2b6f00 | 59 | int flag=0, TIME=0,t=0, Sec=0,tmpSec=0,SEC=0, mSec=0; |
igor_v | 0:8ad47e2b6f00 | 60 | int tempsec=0; |
igor_v | 0:8ad47e2b6f00 | 61 | float DACF, K_DAC; |
igor_v | 3:ed8744c5f67a | 62 | |
igor_v | 0:8ad47e2b6f00 | 63 | void Led_Blink() |
igor_v | 0:8ad47e2b6f00 | 64 | { |
igor_v | 3:ed8744c5f67a | 65 | if (flag == 0) { |
igor_v | 3:ed8744c5f67a | 66 | LPC_GPIO1->FIOSET = (0x1<<30); |
igor_v | 3:ed8744c5f67a | 67 | flag=1; |
igor_v | 3:ed8744c5f67a | 68 | } else { |
igor_v | 3:ed8744c5f67a | 69 | flag =0; |
igor_v | 3:ed8744c5f67a | 70 | LPC_GPIO1->FIOCLR = (0x01<<30); |
igor_v | 3:ed8744c5f67a | 71 | } |
igor_v | 0:8ad47e2b6f00 | 72 | } |
igor_v | 0:8ad47e2b6f00 | 73 | |
igor_v | 0:8ad47e2b6f00 | 74 | long LED_TEMP=0; |
igor_v | 11:af609f6dee46 | 75 | |
igor_v | 11:af609f6dee46 | 76 | |
igor_v | 11:af609f6dee46 | 77 | |
igor_v | 12:74bd0ecf7f83 | 78 | |
igor_v | 0:8ad47e2b6f00 | 79 | int main (void) |
igor_v | 0:8ad47e2b6f00 | 80 | { |
igor_v | 5:02e9f559395c | 81 | K_DAC=65535.0/(65535.0+(deltaDAC+deltaDAC/2)); |
igor_v | 5:02e9f559395c | 82 | K_DAC=0.8; |
igor_v | 0:8ad47e2b6f00 | 83 | |
igor_v | 5:02e9f559395c | 84 | Main.Firmware_Version=0x15; |
igor_v | 5:02e9f559395c | 85 | Main.GLD_Serial = 0x20; |
igor_v | 5:02e9f559395c | 86 | Main.My_Addres=0; |
igor_v | 5:02e9f559395c | 87 | LightUpCount=1000; |
igor_v | 5:02e9f559395c | 88 | BackLightCount=5000; |
igor_v | 5:02e9f559395c | 89 | secPuls=0; |
igor_v | 5:02e9f559395c | 90 | Pulse_midl = 0; |
igor_v | 5:02e9f559395c | 91 | PulseHalf = 0; |
igor_v | 5:02e9f559395c | 92 | CuruAngle = 0; |
igor_v | 5:02e9f559395c | 93 | Spi.DAC_A=0x7fff; |
igor_v | 6:6c5cd8c615cc | 94 | Spi.DAC_B = 0x7fff; |
igor_v | 21:bc8c1cec3da6 | 95 | //инициализация |
igor_v | 21:bc8c1cec3da6 | 96 | SystemInit(); // Инициализация системы |
igor_v | 21:bc8c1cec3da6 | 97 | Led_init(); |
igor_v | 11:af609f6dee46 | 98 | |
igor_v | 21:bc8c1cec3da6 | 99 | ///* |
igor_v | 21:bc8c1cec3da6 | 100 | //конфигурирование сигнала поджига |
igor_v | 21:bc8c1cec3da6 | 101 | LPC_PINCON->PINSEL0 &= ~(3<<8); //e. P0.4 is GPIO pin (запись ( 00 ) в 9:8 бит PISEL0 выбор P0.4 как GPIO) |
igor_v | 21:bc8c1cec3da6 | 102 | LPC_PINCON->PINMODE0 |= (3<<8); //e. P0.4 is GPIO pin (запись ( 11 ) в 9:8 бит PINMODE0 "для включения подтягивающего резистора") |
igor_v | 21:bc8c1cec3da6 | 103 | LPC_GPIO0->FIODIR |= (1<<4); //e. P0.4 is output (запись ( 1 ) в 5 бит FIODIR выбор P0.4 как выход) |
igor_v | 21:bc8c1cec3da6 | 104 | LightUpON //e. P0.4 is output (запись ( 1 ) в 5 бит CLR устанавливаем на P0.4 низкий уровень сигнала) |
igor_v | 21:bc8c1cec3da6 | 105 | /* |
igor_v | 21:bc8c1cec3da6 | 106 | LPC_PINCON->PINSEL0 &= ~(3<<10); //e. P0.4 is GPIO pin (запись ( 00 ) в 9:8 бит PISEL0 выбор P0.4 как GPIO) |
igor_v | 21:bc8c1cec3da6 | 107 | LPC_PINCON->PINMODE0 |= (3<<10); //e. P0.4 is GPIO pin (запись ( 11 ) в 9:8 бит PINMODE0 "для включения подтягивающего резистора") |
igor_v | 21:bc8c1cec3da6 | 108 | LPC_GPIO0->FIODIR |= (1<<5); //e. P0.4 is output (запись ( 1 ) в 5 бит FIODIR выбор P0.4 как выход) |
igor_v | 21:bc8c1cec3da6 | 109 | LPC_GPIO0->FIOCLR |= (1<<5); //e. P0.4 is output (запись ( 1 ) в 5 бит CLR устанавливаем на P0.4 низкий уровень сигнала)*/ |
igor_v | 12:74bd0ecf7f83 | 110 | |
igor_v | 3:ed8744c5f67a | 111 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
igor_v | 0:8ad47e2b6f00 | 112 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
igor_v | 3:ed8744c5f67a | 113 | |
igor_v | 21:bc8c1cec3da6 | 114 | |
igor_v | 21:bc8c1cec3da6 | 115 | LPC_PINCON->PINSEL3 = (0x00<<18); //e. P1.25 is GPIO pin |
igor_v | 21:bc8c1cec3da6 | 116 | LPC_PINCON->PINMODE3 |= (3<<18); //e. P1.25 (включениe подтягивающего резистора") |
igor_v | 21:bc8c1cec3da6 | 117 | LPC_GPIO1->FIODIR |= (1<<25); //e. P0.5 is output (запись ( 1 ) в 5 бит FIODIR выбор P0.5 как выход) |
igor_v | 21:bc8c1cec3da6 | 118 | LPC_GPIO1->FIOCLR |= (1<<25); |
igor_v | 21:bc8c1cec3da6 | 119 | |
igor_v | 21:bc8c1cec3da6 | 120 | |
igor_v | 0:8ad47e2b6f00 | 121 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
igor_v | 21:bc8c1cec3da6 | 122 | |
igor_v | 21:bc8c1cec3da6 | 123 | LPC_PINCON->PINSEL3 = (0x00<<24); //e. P1.28 is GPIO pin |
igor_v | 21:bc8c1cec3da6 | 124 | LPC_PINCON->PINMODE3 |= (3<<24); //e. P1.28 is GPIO pin (запись ( 11 ) в бит PINMODE0 "для включения подтягивающего резистора") |
igor_v | 21:bc8c1cec3da6 | 125 | LPC_GPIO1->FIODIR |= (1<<28); //e. P1.28 is output (запись ( 1 ) в 5 бит FIODIR выбор P0.5 как выход) |
igor_v | 21:bc8c1cec3da6 | 126 | LPC_GPIO1->FIOCLR |= (1<<28); |
igor_v | 21:bc8c1cec3da6 | 127 | // init_timer(TIME_INTERVAL ); // 10ms |
igor_v | 21:bc8c1cec3da6 | 128 | // enable_timer1(); |
igor_v | 21:bc8c1cec3da6 | 129 | ///иНИциализация подсветки |
igor_v | 21:bc8c1cec3da6 | 130 | LPC_PINCON->PINSEL2 = (0x00<<24); //e. P2.12 is GPIO pin |
igor_v | 21:bc8c1cec3da6 | 131 | LPC_PINCON->PINMODE3 |= (3<<24); //e. P1.28 is GPIO pin (запись ( 11 ) в бит PINMODE0 "для включения подтягивающего резистора") |
igor_v | 21:bc8c1cec3da6 | 132 | LPC_GPIO2->FIODIR |= (1<<12); //e. P1.28 is output (запись ( 1 ) в 5 бит FIODIR выбор P0.5 как выход) |
igor_v | 21:bc8c1cec3da6 | 133 | LPC_GPIO2->FIOCLR |= (1<<12); |
igor_v | 21:bc8c1cec3da6 | 134 | |
igor_v | 0:8ad47e2b6f00 | 135 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
igor_v | 21:bc8c1cec3da6 | 136 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
igor_v | 21:bc8c1cec3da6 | 137 | /* |
igor_v | 21:bc8c1cec3da6 | 138 | //конфигурирование сигнала поджига оторваная нога (поджиг на 80 ноге вместо 81) |
igor_v | 21:bc8c1cec3da6 | 139 | LPC_PINCON->PINSEL0 = (0x00<<10); //e. P0.5 is GPIO pin (запись ( 00 ) в 11:10 бит PISEL0 выбор P0.5 как GPIO) |
igor_v | 21:bc8c1cec3da6 | 140 | LPC_PINCON->PINMODE0 |= (3<<10); //e. P0.5 is GPIO pin (запись ( 11 ) в 11:10 бит PINMODE0 "для включения подтягивающего резистора") |
igor_v | 21:bc8c1cec3da6 | 141 | LPC_GPIO0->FIODIR |= (1<<5); //e. P0.5 is output (запись ( 1 ) в 5 бит FIODIR выбор P0.5 как выход) |
igor_v | 21:bc8c1cec3da6 | 142 | LPC_GPIO0->FIOCLR |= (1<<5); //e. P0.5 is output (запись ( 1 ) в 5 бит CLR устанавливаем на P0.5 низкий уровень сигнала) |
igor_v | 21:bc8c1cec3da6 | 143 | */ |
igor_v | 21:bc8c1cec3da6 | 144 | DMA_Init(); // Инициализация DMA |
igor_v | 21:bc8c1cec3da6 | 145 | FlashDMA_Init(); // Загрузка параметров с флэш |
igor_v | 21:bc8c1cec3da6 | 146 | |
igor_v | 21:bc8c1cec3da6 | 147 | SystemCoreClockUpdate(); // расчет системной частоты для UART. |
igor_v | 21:bc8c1cec3da6 | 148 | UARTInit(); // инициализация UART0 на скорость 38400. |
igor_v | 21:bc8c1cec3da6 | 149 | UART1_Init(); // инициализация UART1 на скорость 38400. |
igor_v | 21:bc8c1cec3da6 | 150 | |
igor_v | 21:bc8c1cec3da6 | 151 | |
igor_v | 21:bc8c1cec3da6 | 152 | DAC_ADC_Exchange_Init(); // инициализация обмена АЦП и ЦАП. |
igor_v | 21:bc8c1cec3da6 | 153 | DACInit(); // инициализация ЦАП. |
igor_v | 21:bc8c1cec3da6 | 154 | SOI_Init(); // Инициализация квадратурного энкодера. |
igor_v | 21:bc8c1cec3da6 | 155 | |
igor_v | 21:bc8c1cec3da6 | 156 | IntLatch_Init(); // инициализация внутренней защелки. |
igor_v | 21:bc8c1cec3da6 | 157 | ExtLatch_Init(); // инициализация внешней защелки. |
igor_v | 0:8ad47e2b6f00 | 158 | |
igor_v | 3:ed8744c5f67a | 159 | //----------------debug------------------------- |
igor_v | 5:02e9f559395c | 160 | //LPC_GPIO2->FIODIR = 0x5C; // P2.0...P2.7 defined as Outputs |
igor_v | 5:02e9f559395c | 161 | //LPC_GPIO2->FIOCLR = 0x5C; // turn off all the LEDs |
igor_v | 3:ed8744c5f67a | 162 | //----------------debug------------------------- |
igor_v | 3:ed8744c5f67a | 163 | |
igor_v | 3:ed8744c5f67a | 164 | |
igor_v | 13:e2a1d18677b8 | 165 | |
igor_v | 21:bc8c1cec3da6 | 166 | LoadFlashParam(FromFLASH); //загрузка параметров. |
igor_v | 21:bc8c1cec3da6 | 167 | UART_DMA_Init(); //инициализация DMA для UART. |
igor_v | 21:bc8c1cec3da6 | 168 | G_Photo_Init(); //инициализация интерфейса I2C для фотодетектора. |
igor_v | 21:bc8c1cec3da6 | 169 | Out_G_photo(60, 60); //запись в буфер мастера принятые от функции данные (60,60) и установка флага старта передачи и занятой шины. |
igor_v | 0:8ad47e2b6f00 | 170 | // WDTInit(); |
igor_v | 0:8ad47e2b6f00 | 171 | |
igor_v | 0:8ad47e2b6f00 | 172 | |
igor_v | 21:bc8c1cec3da6 | 173 | open_all_loops(); //#define open_all_loops() RgConA = 0 (Основной регистр управления устройства (0 - включить, 1 - отключить)). |
igor_v | 21:bc8c1cec3da6 | 174 | Output.Str.HF_reg = Device_blk.Str.HF_min; //HFO output voltage = максивальное напряжение на ГВЧ. |
igor_v | 21:bc8c1cec3da6 | 175 | init_PLC(); //Инициализация СРП(регулировка периметра) |
igor_v | 21:bc8c1cec3da6 | 176 | init_Dither_reg(); //инициализация вибропривода |
igor_v | 21:bc8c1cec3da6 | 177 | RgConB = RATE_VIBRO_1; // дополнительный регистр управления = разность вибросчетчиков после фильтра скольз.среднего(#define RATE_VIBRO_1 0x0001) |
igor_v | 21:bc8c1cec3da6 | 178 | |
igor_v | 5:02e9f559395c | 179 | init_Vibro(); |
igor_v | 5:02e9f559395c | 180 | init_timer(TIME_INTERVAL ); // 10ms |
igor_v | 5:02e9f559395c | 181 | enable_timer1(); |
igor_v | 5:02e9f559395c | 182 | Init_TIM2(); |
igor_v | 5:02e9f559395c | 183 | enable_timer2(); |
igor_v | 5:02e9f559395c | 184 | close_all_loops(); |
igor_v | 0:8ad47e2b6f00 | 185 | |
igor_v | 13:e2a1d18677b8 | 186 | |
igor_v | 5:02e9f559395c | 187 | LPC_GPIO0->FIOCLR = (1<<5); |
igor_v | 5:02e9f559395c | 188 | |
igor_v | 3:ed8744c5f67a | 189 | |
igor_v | 15:f5191a1c3805 | 190 | Event1Hz = 0; |
igor_v | 15:f5191a1c3805 | 191 | Event1K = 0; |
igor_v | 15:f5191a1c3805 | 192 | Event100K = 0; |
igor_v | 15:f5191a1c3805 | 193 | EventVibro = 0; |
igor_v | 15:f5191a1c3805 | 194 | Time1K = 0; |
igor_v | 15:f5191a1c3805 | 195 | Time100K = 0; |
igor_v | 15:f5191a1c3805 | 196 | Time1Hz = 0; |
igor_v | 15:f5191a1c3805 | 197 | Clock1Hz = 0; |
igor_v | 16:18e3fd7b92d0 | 198 | ShiftD = StartShiftD; |
igor_v | 16:18e3fd7b92d0 | 199 | ShiftL = StartShiftL; |
igor_v | 15:f5191a1c3805 | 200 | |
igor_v | 3:ed8744c5f67a | 201 | Pulse_8Point = 0; |
igor_v | 3:ed8744c5f67a | 202 | Pulse_16Point = 0; |
igor_v | 3:ed8744c5f67a | 203 | Pulse_32Point = 0; |
igor_v | 0:8ad47e2b6f00 | 204 | |
igor_v | 3:ed8744c5f67a | 205 | Temp_AMP=0; |
igor_v | 3:ed8744c5f67a | 206 | Temp_ADC_2=0; |
igor_v | 3:ed8744c5f67a | 207 | Temp_ADC_3=0; |
igor_v | 3:ed8744c5f67a | 208 | Temp_ADC_4=0; |
igor_v | 3:ed8744c5f67a | 209 | Temp_ADC_5=0; |
igor_v | 0:8ad47e2b6f00 | 210 | |
igor_v | 3:ed8744c5f67a | 211 | for (y = 0; y < 256; y++ ) { |
igor_v | 5:02e9f559395c | 212 | Buff_16Point[y] = 0xffff; |
igor_v | 5:02e9f559395c | 213 | Buff_8Point[y] = 0xffff; |
igor_v | 5:02e9f559395c | 214 | Buff_32Point[y] = 0xffff; |
igor_v | 21:bc8c1cec3da6 | 215 | Buff_ADC_1[y] = 0; // ампл ацп. |
igor_v | 5:02e9f559395c | 216 | Buff_ADC_2[y] = 0; |
igor_v | 5:02e9f559395c | 217 | Buff_ADC_3[y] = 0; |
igor_v | 5:02e9f559395c | 218 | Buff_ADC_4[y] = 0; |
igor_v | 5:02e9f559395c | 219 | Buff_ADC_5[y] = 0; |
igor_v | 0:8ad47e2b6f00 | 220 | |
igor_v | 3:ed8744c5f67a | 221 | } |
igor_v | 0:8ad47e2b6f00 | 222 | |
igor_v | 0:8ad47e2b6f00 | 223 | |
igor_v | 0:8ad47e2b6f00 | 224 | |
igor_v | 12:74bd0ecf7f83 | 225 | |
igor_v | 16:18e3fd7b92d0 | 226 | WriteCon("\n\r ...GL start programm uart 0.... "); |
igor_v | 15:f5191a1c3805 | 227 | sprintf(Time,"\r\nCompiled: %s %s.",__DATE__, __TIME__ ); //Подготовка даты и времени компиляции |
igor_v | 13:e2a1d18677b8 | 228 | WriteCon(Time); |
igor_v | 11:af609f6dee46 | 229 | |
igor_v | 11:af609f6dee46 | 230 | |
igor_v | 11:af609f6dee46 | 231 | |
igor_v | 21:bc8c1cec3da6 | 232 | do { //основной цикл. |
igor_v | 15:f5191a1c3805 | 233 | Concol (); // Проврка 0 консоли (вход и выход) |
igor_v | 3:ed8744c5f67a | 234 | if (OutBufConCount) OutBufConCount--; |
igor_v | 15:f5191a1c3805 | 235 | |
igor_v | 15:f5191a1c3805 | 236 | if (ReadCon (Time)) { |
igor_v | 16:18e3fd7b92d0 | 237 | if (Time[0] == 'h') { // если ввели буквц h то выдать подсказку. сделанно через принф ОЧЕНЬ плохо в работе не использовать |
igor_v | 15:f5191a1c3805 | 238 | sprintf(Time,"\r\nCompiled: %s %s.",__DATE__, __TIME__ ); //Подготовка даты и времени компиляции |
igor_v | 15:f5191a1c3805 | 239 | WriteCon(Time); |
igor_v | 15:f5191a1c3805 | 240 | sprintf(Time,"--%d.%3.d.%2.d.",Clock1Hz,Time1K,Time100K); //Временно выдачпа временни из трех чисел |
igor_v | 15:f5191a1c3805 | 241 | WriteCon(Time); |
igor_v | 15:f5191a1c3805 | 242 | } |
igor_v | 15:f5191a1c3805 | 243 | } |
igor_v | 15:f5191a1c3805 | 244 | |
igor_v | 15:f5191a1c3805 | 245 | if (Event1Hz) {// событие раз в 1 Гц |
igor_v | 15:f5191a1c3805 | 246 | Event1Hz --; |
igor_v | 15:f5191a1c3805 | 247 | Clock1Hz++; |
igor_v | 16:18e3fd7b92d0 | 248 | |
igor_v | 16:18e3fd7b92d0 | 249 | //============================= блок управления поджигом и подсветкой, сделанно через сдвиг====================== |
igor_v | 16:18e3fd7b92d0 | 250 | if (ShiftD) { //Проверка поджига |
igor_v | 16:18e3fd7b92d0 | 251 | // if (ShiftD & 0x01) |
igor_v | 16:18e3fd7b92d0 | 252 | ShiftD = ShiftD >> 1; |
igor_v | 16:18e3fd7b92d0 | 253 | } |
igor_v | 16:18e3fd7b92d0 | 254 | if (ShiftL) { //Проверка подсветки |
igor_v | 16:18e3fd7b92d0 | 255 | ShiftL = ShiftL >> 1; |
igor_v | 16:18e3fd7b92d0 | 256 | |
igor_v | 16:18e3fd7b92d0 | 257 | } |
igor_v | 16:18e3fd7b92d0 | 258 | |
igor_v | 15:f5191a1c3805 | 259 | } |
igor_v | 15:f5191a1c3805 | 260 | if (Event1K) {// событие раз в 1 кГц |
igor_v | 15:f5191a1c3805 | 261 | Event1K --; |
igor_v | 15:f5191a1c3805 | 262 | Time1K++; |
igor_v | 15:f5191a1c3805 | 263 | if (Time1K == 1000) { |
igor_v | 15:f5191a1c3805 | 264 | Time1K = 0; |
igor_v | 15:f5191a1c3805 | 265 | Event1Hz ++; |
igor_v | 16:18e3fd7b92d0 | 266 | |
igor_v | 15:f5191a1c3805 | 267 | } |
igor_v | 15:f5191a1c3805 | 268 | } |
igor_v | 15:f5191a1c3805 | 269 | if (Event100K) {// событие раз в 100 кГц |
igor_v | 15:f5191a1c3805 | 270 | Event100K --; |
igor_v | 15:f5191a1c3805 | 271 | Time100K++; |
igor_v | 15:f5191a1c3805 | 272 | if (Time100K == 100) { |
igor_v | 15:f5191a1c3805 | 273 | Time100K = 0; |
igor_v | 15:f5191a1c3805 | 274 | Event1K ++; |
igor_v | 15:f5191a1c3805 | 275 | } |
igor_v | 15:f5191a1c3805 | 276 | } |
igor_v | 15:f5191a1c3805 | 277 | if (EventVibro) {// событие от вибр |
igor_v | 15:f5191a1c3805 | 278 | EventVibro --; |
igor_v | 15:f5191a1c3805 | 279 | } |
igor_v | 15:f5191a1c3805 | 280 | |
igor_v | 15:f5191a1c3805 | 281 | |
igor_v | 15:f5191a1c3805 | 282 | |
igor_v | 15:f5191a1c3805 | 283 | |
igor_v | 15:f5191a1c3805 | 284 | // Concol1 (); |
igor_v | 3:ed8744c5f67a | 285 | Read_CMD(); |
igor_v | 3:ed8744c5f67a | 286 | |
igor_v | 3:ed8744c5f67a | 287 | // VibroOut(); |
igor_v | 3:ed8744c5f67a | 288 | |
igor_v | 3:ed8744c5f67a | 289 | if(Time_1kHz>100) { |
igor_v | 3:ed8744c5f67a | 290 | |
igor_v | 3:ed8744c5f67a | 291 | SEC++; |
igor_v | 5:02e9f559395c | 292 | if(Rate_Flag==1 && SEC>500) { |
igor_v | 3:ed8744c5f67a | 293 | SEC-=500; |
igor_v | 12:74bd0ecf7f83 | 294 | // CMD_Rate(); |
igor_v | 3:ed8744c5f67a | 295 | } |
igor_v | 3:ed8744c5f67a | 296 | |
igor_v | 3:ed8744c5f67a | 297 | Time_1kHz-=100; |
igor_v | 3:ed8744c5f67a | 298 | if(LightUpCount) { |
igor_v | 3:ed8744c5f67a | 299 | LightUpCount--; |
igor_v | 3:ed8744c5f67a | 300 | LightUpON |
igor_v | 3:ed8744c5f67a | 301 | } |
igor_v | 0:8ad47e2b6f00 | 302 | |
igor_v | 3:ed8744c5f67a | 303 | else { |
igor_v | 3:ed8744c5f67a | 304 | LightUpOFF; |
igor_v | 3:ed8744c5f67a | 305 | } |
igor_v | 3:ed8744c5f67a | 306 | if(BackLightCount) { |
igor_v | 3:ed8744c5f67a | 307 | BackLightCount--; |
igor_v | 3:ed8744c5f67a | 308 | BackLightON |
igor_v | 3:ed8744c5f67a | 309 | } else { |
igor_v | 3:ed8744c5f67a | 310 | BackLightOFF; |
igor_v | 3:ed8744c5f67a | 311 | } |
igor_v | 3:ed8744c5f67a | 312 | } |
igor_v | 3:ed8744c5f67a | 313 | ButtonLightUP(); |
igor_v | 3:ed8744c5f67a | 314 | //Device_blk.Str. |
igor_v | 15:f5191a1c3805 | 315 | // TakeFromBuff(); |
igor_v | 3:ed8744c5f67a | 316 | |
igor_v | 21:bc8c1cec3da6 | 317 | //отключение поджига. |
igor_v | 21:bc8c1cec3da6 | 318 | |
igor_v | 3:ed8744c5f67a | 319 | // paramV=TakeParam(1); |
igor_v | 3:ed8744c5f67a | 320 | |
igor_v | 3:ed8744c5f67a | 321 | |
igor_v | 15:f5191a1c3805 | 322 | |
igor_v | 21:bc8c1cec3da6 | 323 | if (LPC_PWM1->IR & 0x0001) { // Если в регистре прерываний ШИМ1 (регистр PWM1IR) есть влаг прерывания совпадения счетчика с МАТСН (lim0 ?) то: |
igor_v | 21:bc8c1cec3da6 | 324 | |
igor_v | 16:18e3fd7b92d0 | 325 | /* ResetCS(ADC); //prepare ADC for sampling |
igor_v | 3:ed8744c5f67a | 326 | SetDAC(DAC); |
igor_v | 21:bc8c1cec3da6 | 327 | LPC_GPIO2->FIOSET |= 0x0000004; // turn on the LED |
igor_v | 21:bc8c1cec3da6 | 328 | LPC_GPIO2->FIOSET |= 0x0000004; // turn on the LED |
igor_v | 21:bc8c1cec3da6 | 329 | LPC_GPIO2->FIOSET |= 0x0000004; // turn on the LED |
igor_v | 16:18e3fd7b92d0 | 330 | SetCS(ADC); //start ADC sampling |
igor_v | 3:ed8744c5f67a | 331 | ResetDAC(DAC); //start DAC prepearing for writing |
igor_v | 3:ed8744c5f67a | 332 | */ |
igor_v | 3:ed8744c5f67a | 333 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
igor_v | 0:8ad47e2b6f00 | 334 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
igor_v | 0:8ad47e2b6f00 | 335 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
igor_v | 3:ed8744c5f67a | 336 | secPuls++; |
igor_v | 3:ed8744c5f67a | 337 | tmpSec++; |
igor_v | 3:ed8744c5f67a | 338 | mSec++; |
igor_v | 0:8ad47e2b6f00 | 339 | |
igor_v | 3:ed8744c5f67a | 340 | i1++; |
igor_v | 3:ed8744c5f67a | 341 | if(i1>10000) |
igor_v | 3:ed8744c5f67a | 342 | //if(CountV31>30) |
igor_v | 3:ed8744c5f67a | 343 | { |
igor_v | 15:f5191a1c3805 | 344 | WriteCon("."); |
igor_v | 3:ed8744c5f67a | 345 | i1=0; |
igor_v | 3:ed8744c5f67a | 346 | /* |
igor_v | 3:ed8744c5f67a | 347 | SendToBuffStr("\n\r"); |
igor_v | 3:ed8744c5f67a | 348 | // if (Buff_ADC_1 [y] > 65535)SendToBuffStr(" 0 "); else SendToBuffStr(" 1 "); |
igor_v | 3:ed8744c5f67a | 349 | sprintf (BuffTemp,"<%05d> <%05d> <%05d> <%05d> <%05d>", Temp_AMP>>5,Temp_ADC_2>>5,Temp_ADC_3>>5,Temp_ADC_4>>5,Temp_ADC_5>>5); |
igor_v | 3:ed8744c5f67a | 350 | // sprintf (BuffTemp,"<%07d> <%07d> <%07d> <%07d> <%07d>", Spi.ADC1,Spi.ADC2,Spi.ADC3,Spi.ADC4,Spi.ADC5); |
igor_v | 3:ed8744c5f67a | 351 | SendToBuffStr(BuffTemp); |
igor_v | 3:ed8744c5f67a | 352 | */ |
igor_v | 3:ed8744c5f67a | 353 | /* |
igor_v | 3:ed8744c5f67a | 354 | WriteConByte (Main.T_Vib&0xff00); |
igor_v | 3:ed8744c5f67a | 355 | WriteConByte (Main.T_Vib&0x00ff); |
igor_v | 3:ed8744c5f67a | 356 | WriteConByte (Main.T_Vib); |
igor_v | 3:ed8744c5f67a | 357 | */ |
igor_v | 3:ed8744c5f67a | 358 | /* |
igor_v | 3:ed8744c5f67a | 359 | |
igor_v | 3:ed8744c5f67a | 360 | for (y = 0; y < 32; y++ ) |
igor_v | 3:ed8744c5f67a | 361 | { |
igor_v | 3:ed8744c5f67a | 362 | |
igor_v | 3:ed8744c5f67a | 363 | WriteCon(BuffTemp); |
igor_v | 3:ed8744c5f67a | 364 | } WriteCon("\n\r"); |
igor_v | 0:8ad47e2b6f00 | 365 | |
igor_v | 3:ed8744c5f67a | 366 | */ |
igor_v | 3:ed8744c5f67a | 367 | /* |
igor_v | 3:ed8744c5f67a | 368 | Main.T_Vib=((7680000*16/Main.Frq)*4096); |
igor_v | 3:ed8744c5f67a | 369 | th= Main.T_Vib&0xff00; |
igor_v | 3:ed8744c5f67a | 370 | tt= Main.T_Vib&0x00ff; |
igor_v | 3:ed8744c5f67a | 371 | sprintf(BuffTemp,"<%07d >",( (Main.T_Vib&0xff00))); |
igor_v | 3:ed8744c5f67a | 372 | SendToBuffStr(BuffTemp); |
igor_v | 3:ed8744c5f67a | 373 | |
igor_v | 3:ed8744c5f67a | 374 | sprintf(BuffTemp,"<%07d >",( ( Main.T_Vib&0x00ff))); |
igor_v | 3:ed8744c5f67a | 375 | SendToBuffStr(BuffTemp); |
igor_v | 15:f5191a1c3805 | 376 | |
igor_v | 3:ed8744c5f67a | 377 | CuruAngleOld=CuruAngle;*/ |
igor_v | 3:ed8744c5f67a | 378 | // Spi.ADC1=Spi.ADC1*0.000061; |
igor_v | 3:ed8744c5f67a | 379 | |
igor_v | 3:ed8744c5f67a | 380 | |
igor_v | 3:ed8744c5f67a | 381 | |
igor_v | 3:ed8744c5f67a | 382 | |
igor_v | 3:ed8744c5f67a | 383 | /* |
igor_v | 3:ed8744c5f67a | 384 | |
igor_v | 3:ed8744c5f67a | 385 | sprintf(BuffTemp,"\n\r<%05d><%05d><%05d><%05d><%05d>",Spi.ADC1,Spi.ADC2,Spi.ADC3,Spi.ADC4,Spi.ADC5); |
igor_v | 3:ed8744c5f67a | 386 | SendToBuffStr(BuffTemp); |
igor_v | 3:ed8744c5f67a | 387 | |
igor_v | 3:ed8744c5f67a | 388 | */ |
igor_v | 3:ed8744c5f67a | 389 | |
igor_v | 3:ed8744c5f67a | 390 | /* sprintf(BuffTemp,"<%d>",(FrecTemp)); |
igor_v | 3:ed8744c5f67a | 391 | SendToBuffStr(BuffTemp); |
igor_v | 3:ed8744c5f67a | 392 | for (y = 0; y < 32; y++ ) |
igor_v | 3:ed8744c5f67a | 393 | { |
igor_v | 3:ed8744c5f67a | 394 | sprintf(BuffTemp," <%07d>", (Buff_16PointD [y]-65535)); |
igor_v | 3:ed8744c5f67a | 395 | SendToBuffStr(BuffTemp); |
igor_v | 3:ed8744c5f67a | 396 | } */ |
igor_v | 15:f5191a1c3805 | 397 | |
igor_v | 3:ed8744c5f67a | 398 | } |
igor_v | 3:ed8744c5f67a | 399 | |
igor_v | 3:ed8744c5f67a | 400 | |
igor_v | 3:ed8744c5f67a | 401 | |
igor_v | 3:ed8744c5f67a | 402 | |
igor_v | 0:8ad47e2b6f00 | 403 | |
igor_v | 0:8ad47e2b6f00 | 404 | |
igor_v | 0:8ad47e2b6f00 | 405 | |
igor_v | 0:8ad47e2b6f00 | 406 | |
igor_v | 0:8ad47e2b6f00 | 407 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
igor_v | 0:8ad47e2b6f00 | 408 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
igor_v | 0:8ad47e2b6f00 | 409 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
igor_v | 0:8ad47e2b6f00 | 410 | |
igor_v | 0:8ad47e2b6f00 | 411 | |
igor_v | 0:8ad47e2b6f00 | 412 | |
igor_v | 3:ed8744c5f67a | 413 | |
igor_v | 3:ed8744c5f67a | 414 | LPC_GPIO2->FIOSET |= 0x0000004; // turn on the LED |
igor_v | 3:ed8744c5f67a | 415 | |
igor_v | 0:8ad47e2b6f00 | 416 | |
igor_v | 21:bc8c1cec3da6 | 417 | Curr_Cnt_Vib = LPC_QEI->POS; // записать в переменную Curr_Cnt_Vib текущее положение Энкодера. (текущее количество импульсов) |
igor_v | 21:bc8c1cec3da6 | 418 | Latch_Event(); //определение защелки |
igor_v | 3:ed8744c5f67a | 419 | |
igor_v | 21:bc8c1cec3da6 | 420 | clc_Pulses(); // счетчик импульсов. RATE_REPER_OR_REFMEANDR или RATE_VIBRO_1 |
igor_v | 0:8ad47e2b6f00 | 421 | |
igor_v | 0:8ad47e2b6f00 | 422 | |
igor_v | 21:bc8c1cec3da6 | 423 | //ADC_Input(); // проверка флагов заполнения буфера и четение Thermo1, Thermo2, HF_out в масив Input.ArrayIn[n]. |
igor_v | 21:bc8c1cec3da6 | 424 | //DAC_ADC_Exchange();// проверка флагов заполнения буфера и зпись в ЦАПы. |
igor_v | 21:bc8c1cec3da6 | 425 | ServiceTime();//секундный таймер. |
igor_v | 21:bc8c1cec3da6 | 426 | clc_ThermoSensors();//расчет средней температуры за секунду |
igor_v | 21:bc8c1cec3da6 | 427 | clc_HFO(); //расчет значения для передачи в контур ГВЧ(на цап). |
igor_v | 21:bc8c1cec3da6 | 428 | |
igor_v | 3:ed8744c5f67a | 429 | clc_PLC(); |
igor_v | 3:ed8744c5f67a | 430 | // clc_Dith_regulator(); |
igor_v | 3:ed8744c5f67a | 431 | clc_OutFreq_regulator(); |
igor_v | 3:ed8744c5f67a | 432 | Output.Str.WP_sin = clc_WP_sin(); |
igor_v | 3:ed8744c5f67a | 433 | contrl_GLD(); |
igor_v | 3:ed8744c5f67a | 434 | G_Photo_Exchange(); |
igor_v | 3:ed8744c5f67a | 435 | // Output.Str.T_Vibro = paramV*48; |
igor_v | 0:8ad47e2b6f00 | 436 | |
igor_v | 3:ed8744c5f67a | 437 | |
igor_v | 3:ed8744c5f67a | 438 | Line_1_Rcv(); |
igor_v | 3:ed8744c5f67a | 439 | decode_CMD(); |
igor_v | 3:ed8744c5f67a | 440 | transm_DAT(); |
igor_v | 12:74bd0ecf7f83 | 441 | //îòêëþ÷åíèå ïîäæèãà. |
igor_v | 3:ed8744c5f67a | 442 | |
igor_v | 3:ed8744c5f67a | 443 | |
igor_v | 13:e2a1d18677b8 | 444 | // data_Rdy &= ~RESET_PERIOD; |
igor_v | 0:8ad47e2b6f00 | 445 | |
igor_v | 0:8ad47e2b6f00 | 446 | |
igor_v | 3:ed8744c5f67a | 447 | LPC_PWM1->IR = 0x0001; //e. clear interrupt flag |
igor_v | 13:e2a1d18677b8 | 448 | LPC_GPIO2->FIOCLR |= 0x0000004; // turn off the LED |
igor_v | 0:8ad47e2b6f00 | 449 | |
igor_v | 0:8ad47e2b6f00 | 450 | // WDTFeed(); |
igor_v | 0:8ad47e2b6f00 | 451 | //SPI_Exchange(); |
igor_v | 3:ed8744c5f67a | 452 | |
igor_v | 3:ed8744c5f67a | 453 | } |
igor_v | 3:ed8744c5f67a | 454 | |
igor_v | 3:ed8744c5f67a | 455 | } while ( 1 ); // main infinie loop |
igor_v | 0:8ad47e2b6f00 | 456 | } |
igor_v | 0:8ad47e2b6f00 | 457 | |
igor_v | 0:8ad47e2b6f00 | 458 | /****************************************************************************** |
igor_v | 0:8ad47e2b6f00 | 459 | ** End Of File |
igor_v | 0:8ad47e2b6f00 | 460 | ******************************************************************************/ |
igor_v | 0:8ad47e2b6f00 | 461 | |
igor_v | 0:8ad47e2b6f00 | 462 |