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