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