![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
n
Fork of LG by
main.c@0:8ad47e2b6f00, 2016-01-30 (annotated)
- Committer:
- igor_v
- Date:
- Sat Jan 30 13:00:39 2016 +0000
- Revision:
- 0:8ad47e2b6f00
- Child:
- 3:ed8744c5f67a
2016_01_30;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
igor_v | 0:8ad47e2b6f00 | 1 | |
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 | 0:8ad47e2b6f00 | 13 | ** Descriptions: |
igor_v | 0:8ad47e2b6f00 | 14 | **-------------------------------------------------------------------------------------------------------- |
igor_v | 0:8ad47e2b6f00 | 15 | *********************************************************************************************************/ |
igor_v | 0:8ad47e2b6f00 | 16 | |
igor_v | 0:8ad47e2b6f00 | 17 | |
igor_v | 0:8ad47e2b6f00 | 18 | |
igor_v | 0:8ad47e2b6f00 | 19 | #include "Global.h" |
igor_v | 0:8ad47e2b6f00 | 20 | |
igor_v | 0:8ad47e2b6f00 | 21 | |
igor_v | 0:8ad47e2b6f00 | 22 | |
igor_v | 0:8ad47e2b6f00 | 23 | //#include <math.h> |
igor_v | 0:8ad47e2b6f00 | 24 | |
igor_v | 0:8ad47e2b6f00 | 25 | |
igor_v | 0:8ad47e2b6f00 | 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 | 0:8ad47e2b6f00 | 33 | |
igor_v | 0:8ad47e2b6f00 | 34 | int i1 =0; |
igor_v | 0:8ad47e2b6f00 | 35 | //extern unsigned int Buff_QEI[256]; |
igor_v | 0:8ad47e2b6f00 | 36 | volatile unsigned int IRQ_Counter=0; |
igor_v | 0:8ad47e2b6f00 | 37 | volatile uint32_t timer1_counter = 0; |
igor_v | 0:8ad47e2b6f00 | 38 | int temp111=0,temp=0; |
igor_v | 0:8ad47e2b6f00 | 39 | int y = 0; |
igor_v | 0:8ad47e2b6f00 | 40 | int CuruAngleOld=0; |
igor_v | 0:8ad47e2b6f00 | 41 | unsigned int LightUpCount,BackLightCount,secPuls,CountBI,CmmandIn,tt,th; |
igor_v | 0:8ad47e2b6f00 | 42 | |
igor_v | 0:8ad47e2b6f00 | 43 | |
igor_v | 0:8ad47e2b6f00 | 44 | unsigned int paramV; |
igor_v | 0:8ad47e2b6f00 | 45 | |
igor_v | 0:8ad47e2b6f00 | 46 | |
igor_v | 0:8ad47e2b6f00 | 47 | |
igor_v | 0:8ad47e2b6f00 | 48 | |
igor_v | 0:8ad47e2b6f00 | 49 | void Led_init() |
igor_v | 0:8ad47e2b6f00 | 50 | { |
igor_v | 0:8ad47e2b6f00 | 51 | LPC_PINCON->PINSEL0 = (0x00<<28); |
igor_v | 0:8ad47e2b6f00 | 52 | LPC_GPIO1->FIODIR = (0x1<<30); |
igor_v | 0:8ad47e2b6f00 | 53 | LPC_PINCON->PINMODE0 = (0x3<<28); |
igor_v | 0:8ad47e2b6f00 | 54 | // LPC_GPIO1->FIOSET = (0x0<<30); |
igor_v | 0:8ad47e2b6f00 | 55 | // LPC_GPIO0->FIOSET = (1<<4); |
igor_v | 0:8ad47e2b6f00 | 56 | } |
igor_v | 0:8ad47e2b6f00 | 57 | int flag=0, TIME=0,t=0, Sec=0,tmpSec=0,SEC=0, mSec=0; |
igor_v | 0:8ad47e2b6f00 | 58 | int tempsec=0; |
igor_v | 0:8ad47e2b6f00 | 59 | float DACF, K_DAC; |
igor_v | 0:8ad47e2b6f00 | 60 | void Led_Blink() |
igor_v | 0:8ad47e2b6f00 | 61 | { |
igor_v | 0:8ad47e2b6f00 | 62 | |
igor_v | 0:8ad47e2b6f00 | 63 | if (flag == 0) |
igor_v | 0:8ad47e2b6f00 | 64 | { |
igor_v | 0:8ad47e2b6f00 | 65 | LPC_GPIO1->FIOSET = (0x1<<30); |
igor_v | 0:8ad47e2b6f00 | 66 | flag=1; |
igor_v | 0:8ad47e2b6f00 | 67 | } |
igor_v | 0:8ad47e2b6f00 | 68 | else |
igor_v | 0:8ad47e2b6f00 | 69 | { |
igor_v | 0:8ad47e2b6f00 | 70 | flag =0; |
igor_v | 0:8ad47e2b6f00 | 71 | LPC_GPIO1->FIOCLR = (0x01<<30); |
igor_v | 0:8ad47e2b6f00 | 72 | } |
igor_v | 0:8ad47e2b6f00 | 73 | } |
igor_v | 0:8ad47e2b6f00 | 74 | |
igor_v | 0:8ad47e2b6f00 | 75 | long LED_TEMP=0; |
igor_v | 0:8ad47e2b6f00 | 76 | |
igor_v | 0:8ad47e2b6f00 | 77 | |
igor_v | 0:8ad47e2b6f00 | 78 | |
igor_v | 0:8ad47e2b6f00 | 79 | int main (void) |
igor_v | 0:8ad47e2b6f00 | 80 | { |
igor_v | 0:8ad47e2b6f00 | 81 | |
igor_v | 0:8ad47e2b6f00 | 82 | { |
igor_v | 0:8ad47e2b6f00 | 83 | K_DAC=65535.0/(65535.0+(deltaDAC+deltaDAC/2)); |
igor_v | 0:8ad47e2b6f00 | 84 | K_DAC=0.8; |
igor_v | 0:8ad47e2b6f00 | 85 | Main.Firmware_Version=0x15; |
igor_v | 0:8ad47e2b6f00 | 86 | Main.GLD_Serial = 0x20; |
igor_v | 0:8ad47e2b6f00 | 87 | Main.My_Addres=0; |
igor_v | 0:8ad47e2b6f00 | 88 | LightUpCount=1000; |
igor_v | 0:8ad47e2b6f00 | 89 | BackLightCount=5000; |
igor_v | 0:8ad47e2b6f00 | 90 | secPuls=0; |
igor_v | 0:8ad47e2b6f00 | 91 | Pulse_midl = 0; |
igor_v | 0:8ad47e2b6f00 | 92 | PulseHalf = 0; |
igor_v | 0:8ad47e2b6f00 | 93 | CuruAngle = 0; |
igor_v | 0:8ad47e2b6f00 | 94 | Spi.DAC_A=0x7fff; |
igor_v | 0:8ad47e2b6f00 | 95 | Spi.DAC_B=0x7fff; |
igor_v | 0:8ad47e2b6f00 | 96 | //������������� |
igor_v | 0:8ad47e2b6f00 | 97 | SystemInit(); // ������������� ������� |
igor_v | 0:8ad47e2b6f00 | 98 | Led_init(); |
igor_v | 0:8ad47e2b6f00 | 99 | |
igor_v | 0:8ad47e2b6f00 | 100 | ///* |
igor_v | 0:8ad47e2b6f00 | 101 | //���������������� ������� ������� |
igor_v | 0:8ad47e2b6f00 | 102 | LPC_PINCON->PINSEL0 &= ~(3<<8); //e. P0.4 is GPIO pin (������ ( 00 ) � 9:8 ��� PISEL0 ����� P0.4 ��� GPIO) |
igor_v | 0:8ad47e2b6f00 | 103 | LPC_PINCON->PINMODE0 |= (3<<8); //e. P0.4 is GPIO pin (������ ( 11 ) � 9:8 ��� PINMODE0 "��� ��������� �������������� ���������") |
igor_v | 0:8ad47e2b6f00 | 104 | LPC_GPIO0->FIODIR |= (1<<4); //e. P0.4 is output (������ ( 1 ) � 5 ��� FIODIR ����� P0.4 ��� �����) |
igor_v | 0:8ad47e2b6f00 | 105 | LightUpON //e. P0.4 is output (������ ( 1 ) � 5 ��� CLR ������������� �� P0.4 ������ ������� �������) |
igor_v | 0:8ad47e2b6f00 | 106 | /* |
igor_v | 0:8ad47e2b6f00 | 107 | LPC_PINCON->PINSEL0 &= ~(3<<10); //e. P0.4 is GPIO pin (������ ( 00 ) � 9:8 ��� PISEL0 ����� P0.4 ��� GPIO) |
igor_v | 0:8ad47e2b6f00 | 108 | LPC_PINCON->PINMODE0 |= (3<<10); //e. P0.4 is GPIO pin (������ ( 11 ) � 9:8 ��� PINMODE0 "��� ��������� �������������� ���������") |
igor_v | 0:8ad47e2b6f00 | 109 | LPC_GPIO0->FIODIR |= (1<<5); //e. P0.4 is output (������ ( 1 ) � 5 ��� FIODIR ����� P0.4 ��� �����) |
igor_v | 0:8ad47e2b6f00 | 110 | LPC_GPIO0->FIOCLR |= (1<<5); //e. P0.4 is output (������ ( 1 ) � 5 ��� CLR ������������� �� P0.4 ������ ������� �������)*/ |
igor_v | 0:8ad47e2b6f00 | 111 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
igor_v | 0:8ad47e2b6f00 | 112 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
igor_v | 0:8ad47e2b6f00 | 113 | |
igor_v | 0:8ad47e2b6f00 | 114 | LPC_PINCON->PINSEL3 = (0x00<<18); //e. P1.25 is GPIO pin |
igor_v | 0:8ad47e2b6f00 | 115 | LPC_PINCON->PINMODE3 |= (3<<18); //e. P1.25 (��������e �������������� ���������") |
igor_v | 0:8ad47e2b6f00 | 116 | LPC_GPIO1->FIODIR |= (1<<25); //e. P0.5 is output (������ ( 1 ) � 5 ��� FIODIR ����� P0.5 ��� �����) |
igor_v | 0:8ad47e2b6f00 | 117 | LPC_GPIO1->FIOCLR |= (1<<25); |
igor_v | 0:8ad47e2b6f00 | 118 | |
igor_v | 0:8ad47e2b6f00 | 119 | |
igor_v | 0:8ad47e2b6f00 | 120 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
igor_v | 0:8ad47e2b6f00 | 121 | |
igor_v | 0:8ad47e2b6f00 | 122 | LPC_PINCON->PINSEL3 = (0x00<<24); //e. P1.28 is GPIO pin |
igor_v | 0:8ad47e2b6f00 | 123 | LPC_PINCON->PINMODE3 |= (3<<24); //e. P1.28 is GPIO pin (������ ( 11 ) � ��� PINMODE0 "��� ��������� �������������� ���������") |
igor_v | 0:8ad47e2b6f00 | 124 | LPC_GPIO1->FIODIR |= (1<<28); //e. P1.28 is output (������ ( 1 ) � 5 ��� FIODIR ����� P0.5 ��� �����) |
igor_v | 0:8ad47e2b6f00 | 125 | LPC_GPIO1->FIOCLR |= (1<<28); |
igor_v | 0:8ad47e2b6f00 | 126 | // init_timer(TIME_INTERVAL ); // 10ms |
igor_v | 0:8ad47e2b6f00 | 127 | // enable_timer1(); |
igor_v | 0:8ad47e2b6f00 | 128 | ///������������� ��������� |
igor_v | 0:8ad47e2b6f00 | 129 | LPC_PINCON->PINSEL2 = (0x00<<24); //e. P2.12 is GPIO pin |
igor_v | 0:8ad47e2b6f00 | 130 | LPC_PINCON->PINMODE3 |= (3<<24); //e. P1.28 is GPIO pin (������ ( 11 ) � ��� PINMODE0 "��� ��������� �������������� ���������") |
igor_v | 0:8ad47e2b6f00 | 131 | LPC_GPIO2->FIODIR |= (1<<12); //e. P1.28 is output (������ ( 1 ) � 5 ��� FIODIR ����� P0.5 ��� �����) |
igor_v | 0:8ad47e2b6f00 | 132 | LPC_GPIO2->FIOCLR |= (1<<12); |
igor_v | 0:8ad47e2b6f00 | 133 | |
igor_v | 0:8ad47e2b6f00 | 134 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
igor_v | 0:8ad47e2b6f00 | 135 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
igor_v | 0:8ad47e2b6f00 | 136 | /* |
igor_v | 0:8ad47e2b6f00 | 137 | //���������������� ������� ������� ��������� ���� (������ �� 80 ���� ������ 81) |
igor_v | 0:8ad47e2b6f00 | 138 | LPC_PINCON->PINSEL0 = (0x00<<10); //e. P0.5 is GPIO pin (������ ( 00 ) � 11:10 ��� PISEL0 ����� P0.5 ��� GPIO) |
igor_v | 0:8ad47e2b6f00 | 139 | LPC_PINCON->PINMODE0 |= (3<<10); //e. P0.5 is GPIO pin (������ ( 11 ) � 11:10 ��� PINMODE0 "��� ��������� �������������� ���������") |
igor_v | 0:8ad47e2b6f00 | 140 | LPC_GPIO0->FIODIR |= (1<<5); //e. P0.5 is output (������ ( 1 ) � 5 ��� FIODIR ����� P0.5 ��� �����) |
igor_v | 0:8ad47e2b6f00 | 141 | LPC_GPIO0->FIOCLR |= (1<<5); //e. P0.5 is output (������ ( 1 ) � 5 ��� CLR ������������� �� P0.5 ������ ������� �������) |
igor_v | 0:8ad47e2b6f00 | 142 | */ |
igor_v | 0:8ad47e2b6f00 | 143 | DMA_Init(); // ������������� DMA |
igor_v | 0:8ad47e2b6f00 | 144 | FlashDMA_Init(); // �������� ���������� � ���� |
igor_v | 0:8ad47e2b6f00 | 145 | |
igor_v | 0:8ad47e2b6f00 | 146 | SystemCoreClockUpdate(); // ������ ��������� ������� ��� UART. |
igor_v | 0:8ad47e2b6f00 | 147 | UARTInit(); // ������������� UART0 �� �������� 38400. |
igor_v | 0:8ad47e2b6f00 | 148 | UART1_Init(); // ������������� UART1 �� �������� 38400. |
igor_v | 0:8ad47e2b6f00 | 149 | |
igor_v | 0:8ad47e2b6f00 | 150 | |
igor_v | 0:8ad47e2b6f00 | 151 | DAC_ADC_Exchange_Init(); // ������������� ������ ��� � ���. |
igor_v | 0:8ad47e2b6f00 | 152 | DACInit(); // ������������� ���. |
igor_v | 0:8ad47e2b6f00 | 153 | SOI_Init(); // ������������� ������������� ��������. |
igor_v | 0:8ad47e2b6f00 | 154 | |
igor_v | 0:8ad47e2b6f00 | 155 | IntLatch_Init(); // ������������� ���������� �������. |
igor_v | 0:8ad47e2b6f00 | 156 | ExtLatch_Init(); // ������������� ������� �������. |
igor_v | 0:8ad47e2b6f00 | 157 | |
igor_v | 0:8ad47e2b6f00 | 158 | //----------------debug------------------------- |
igor_v | 0:8ad47e2b6f00 | 159 | //LPC_GPIO2->FIODIR = 0x5C; // P2.0...P2.7 defined as Outputs |
igor_v | 0:8ad47e2b6f00 | 160 | //LPC_GPIO2->FIOCLR = 0x5C; // turn off all the LEDs |
igor_v | 0:8ad47e2b6f00 | 161 | //----------------debug------------------------- |
igor_v | 0:8ad47e2b6f00 | 162 | |
igor_v | 0:8ad47e2b6f00 | 163 | |
igor_v | 0:8ad47e2b6f00 | 164 | LoadFlashParam(FromFLASH); //�������� ����������. |
igor_v | 0:8ad47e2b6f00 | 165 | UART_DMA_Init(); //������������� DMA ��� UART. |
igor_v | 0:8ad47e2b6f00 | 166 | G_Photo_Init(); //������������� ���������� I2C ��� �������������. |
igor_v | 0:8ad47e2b6f00 | 167 | Out_G_photo(60, 60); //������ � ����� ������� �������� �� ������� ������ (60,60) � ��������� ����� ������ �������� � ������� ����. |
igor_v | 0:8ad47e2b6f00 | 168 | // WDTInit(); |
igor_v | 0:8ad47e2b6f00 | 169 | |
igor_v | 0:8ad47e2b6f00 | 170 | |
igor_v | 0:8ad47e2b6f00 | 171 | open_all_loops(); //#define open_all_loops() RgConA = 0 (�������� ������� ���������� ���������� (0 - ��������, 1 - ���������)). |
igor_v | 0:8ad47e2b6f00 | 172 | Output.Str.HF_reg = Device_blk.Str.HF_min; //HFO output voltage = ������������ ���������� �� ���. |
igor_v | 0:8ad47e2b6f00 | 173 | init_PLC(); //������������� ���(����������� ���������) |
igor_v | 0:8ad47e2b6f00 | 174 | init_Dither_reg(); //������������� ������������ |
igor_v | 0:8ad47e2b6f00 | 175 | RgConB = RATE_VIBRO_1; // �������������� ������� ���������� = �������� �������������� ����� ������� ������.��������(#define RATE_VIBRO_1 0x0001) |
igor_v | 0:8ad47e2b6f00 | 176 | init_Vibro(); |
igor_v | 0:8ad47e2b6f00 | 177 | init_timer(TIME_INTERVAL ); // 10ms |
igor_v | 0:8ad47e2b6f00 | 178 | enable_timer1(); |
igor_v | 0:8ad47e2b6f00 | 179 | Init_TIM2(); |
igor_v | 0:8ad47e2b6f00 | 180 | enable_timer2(); |
igor_v | 0:8ad47e2b6f00 | 181 | close_all_loops(); |
igor_v | 0:8ad47e2b6f00 | 182 | |
igor_v | 0:8ad47e2b6f00 | 183 | LPC_GPIO0->FIOCLR = (1<<5); |
igor_v | 0:8ad47e2b6f00 | 184 | } |
igor_v | 0:8ad47e2b6f00 | 185 | |
igor_v | 0:8ad47e2b6f00 | 186 | |
igor_v | 0:8ad47e2b6f00 | 187 | Pulse_8Point = 0; |
igor_v | 0:8ad47e2b6f00 | 188 | Pulse_16Point = 0; |
igor_v | 0:8ad47e2b6f00 | 189 | Pulse_32Point = 0; |
igor_v | 0:8ad47e2b6f00 | 190 | |
igor_v | 0:8ad47e2b6f00 | 191 | Temp_AMP=0; |
igor_v | 0:8ad47e2b6f00 | 192 | Temp_ADC_2=0; |
igor_v | 0:8ad47e2b6f00 | 193 | Temp_ADC_3=0; |
igor_v | 0:8ad47e2b6f00 | 194 | Temp_ADC_4=0; |
igor_v | 0:8ad47e2b6f00 | 195 | Temp_ADC_5=0; |
igor_v | 0:8ad47e2b6f00 | 196 | |
igor_v | 0:8ad47e2b6f00 | 197 | |
igor_v | 0:8ad47e2b6f00 | 198 | |
igor_v | 0:8ad47e2b6f00 | 199 | for (y = 0; y < 256; y++ ) |
igor_v | 0:8ad47e2b6f00 | 200 | { |
igor_v | 0:8ad47e2b6f00 | 201 | Buff_16Point [y] = 0xffff; |
igor_v | 0:8ad47e2b6f00 | 202 | Buff_8Point [y] = 0xffff; |
igor_v | 0:8ad47e2b6f00 | 203 | Buff_32Point [y] = 0xffff; |
igor_v | 0:8ad47e2b6f00 | 204 | Buff_ADC_1 [y] = 0;// ���� ���. |
igor_v | 0:8ad47e2b6f00 | 205 | Buff_ADC_2 [y] = 0; |
igor_v | 0:8ad47e2b6f00 | 206 | Buff_ADC_3 [y] = 0; |
igor_v | 0:8ad47e2b6f00 | 207 | Buff_ADC_4 [y] = 0; |
igor_v | 0:8ad47e2b6f00 | 208 | Buff_ADC_5 [y] = 0; |
igor_v | 0:8ad47e2b6f00 | 209 | |
igor_v | 0:8ad47e2b6f00 | 210 | } |
igor_v | 0:8ad47e2b6f00 | 211 | |
igor_v | 0:8ad47e2b6f00 | 212 | |
igor_v | 0:8ad47e2b6f00 | 213 | |
igor_v | 0:8ad47e2b6f00 | 214 | SendToBuffStr ("\n\r ....... "); |
igor_v | 0:8ad47e2b6f00 | 215 | OutBufConCount =0; |
igor_v | 0:8ad47e2b6f00 | 216 | WriteCon("\n\r ...WriteCon1.... "); |
igor_v | 0:8ad47e2b6f00 | 217 | do //�������� ����. |
igor_v | 0:8ad47e2b6f00 | 218 | { |
igor_v | 0:8ad47e2b6f00 | 219 | |
igor_v | 0:8ad47e2b6f00 | 220 | |
igor_v | 0:8ad47e2b6f00 | 221 | if (OutBufConCount) OutBufConCount--; |
igor_v | 0:8ad47e2b6f00 | 222 | Concol (); |
igor_v | 0:8ad47e2b6f00 | 223 | // Concol1 (); |
igor_v | 0:8ad47e2b6f00 | 224 | Read_CMD(); |
igor_v | 0:8ad47e2b6f00 | 225 | |
igor_v | 0:8ad47e2b6f00 | 226 | // VibroOut(); |
igor_v | 0:8ad47e2b6f00 | 227 | |
igor_v | 0:8ad47e2b6f00 | 228 | |
igor_v | 0:8ad47e2b6f00 | 229 | if(Time_1kHz>100) |
igor_v | 0:8ad47e2b6f00 | 230 | { |
igor_v | 0:8ad47e2b6f00 | 231 | |
igor_v | 0:8ad47e2b6f00 | 232 | SEC++; |
igor_v | 0:8ad47e2b6f00 | 233 | if(Rate_Flag==1&&SEC>500) |
igor_v | 0:8ad47e2b6f00 | 234 | { |
igor_v | 0:8ad47e2b6f00 | 235 | SEC-=500; |
igor_v | 0:8ad47e2b6f00 | 236 | CMD_Rate(); |
igor_v | 0:8ad47e2b6f00 | 237 | } |
igor_v | 0:8ad47e2b6f00 | 238 | |
igor_v | 0:8ad47e2b6f00 | 239 | Time_1kHz-=100; |
igor_v | 0:8ad47e2b6f00 | 240 | if(LightUpCount){LightUpCount--;LightUpON} |
igor_v | 0:8ad47e2b6f00 | 241 | |
igor_v | 0:8ad47e2b6f00 | 242 | else |
igor_v | 0:8ad47e2b6f00 | 243 | { |
igor_v | 0:8ad47e2b6f00 | 244 | LightUpOFF; |
igor_v | 0:8ad47e2b6f00 | 245 | } |
igor_v | 0:8ad47e2b6f00 | 246 | if(BackLightCount){BackLightCount--;BackLightON} |
igor_v | 0:8ad47e2b6f00 | 247 | else |
igor_v | 0:8ad47e2b6f00 | 248 | { |
igor_v | 0:8ad47e2b6f00 | 249 | BackLightOFF; |
igor_v | 0:8ad47e2b6f00 | 250 | } |
igor_v | 0:8ad47e2b6f00 | 251 | } |
igor_v | 0:8ad47e2b6f00 | 252 | ButtonLightUP(); |
igor_v | 0:8ad47e2b6f00 | 253 | //Device_blk.Str. |
igor_v | 0:8ad47e2b6f00 | 254 | TakeFromBuff(); |
igor_v | 0:8ad47e2b6f00 | 255 | |
igor_v | 0:8ad47e2b6f00 | 256 | //���������� �������. |
igor_v | 0:8ad47e2b6f00 | 257 | |
igor_v | 0:8ad47e2b6f00 | 258 | // paramV=TakeParam(1); |
igor_v | 0:8ad47e2b6f00 | 259 | |
igor_v | 0:8ad47e2b6f00 | 260 | |
igor_v | 0:8ad47e2b6f00 | 261 | |
igor_v | 0:8ad47e2b6f00 | 262 | |
igor_v | 0:8ad47e2b6f00 | 263 | |
igor_v | 0:8ad47e2b6f00 | 264 | if (LPC_PWM1->IR & 0x0001) // ���� � �������� ���������� ���1 (������� PWM1IR) ���� ���� ���������� ���������� �������� � ����� (lim0 ?) ��: |
igor_v | 0:8ad47e2b6f00 | 265 | { |
igor_v | 0:8ad47e2b6f00 | 266 | /* ResetCS(ADC); //prepare ADC for sampling |
igor_v | 0:8ad47e2b6f00 | 267 | SetDAC(DAC); |
igor_v | 0:8ad47e2b6f00 | 268 | LPC_GPIO2->FIOSET |= 0x0000004; // turn on the LED |
igor_v | 0:8ad47e2b6f00 | 269 | LPC_GPIO2->FIOSET |= 0x0000004; // turn on the LED |
igor_v | 0:8ad47e2b6f00 | 270 | LPC_GPIO2->FIOSET |= 0x0000004; // turn on the LED |
igor_v | 0:8ad47e2b6f00 | 271 | SetCS(ADC); //start ADC sampling |
igor_v | 0:8ad47e2b6f00 | 272 | ResetDAC(DAC); //start DAC prepearing for writing |
igor_v | 0:8ad47e2b6f00 | 273 | |
igor_v | 0:8ad47e2b6f00 | 274 | */ |
igor_v | 0:8ad47e2b6f00 | 275 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
igor_v | 0:8ad47e2b6f00 | 276 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
igor_v | 0:8ad47e2b6f00 | 277 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
igor_v | 0:8ad47e2b6f00 | 278 | |
igor_v | 0:8ad47e2b6f00 | 279 | |
igor_v | 0:8ad47e2b6f00 | 280 | secPuls++; |
igor_v | 0:8ad47e2b6f00 | 281 | tmpSec++; |
igor_v | 0:8ad47e2b6f00 | 282 | mSec++; |
igor_v | 0:8ad47e2b6f00 | 283 | |
igor_v | 0:8ad47e2b6f00 | 284 | i1++; |
igor_v | 0:8ad47e2b6f00 | 285 | if(i1>10000) |
igor_v | 0:8ad47e2b6f00 | 286 | //if(CountV31>30) |
igor_v | 0:8ad47e2b6f00 | 287 | { |
igor_v | 0:8ad47e2b6f00 | 288 | i1=0; |
igor_v | 0:8ad47e2b6f00 | 289 | /* |
igor_v | 0:8ad47e2b6f00 | 290 | SendToBuffStr("\n\r"); |
igor_v | 0:8ad47e2b6f00 | 291 | // if (Buff_ADC_1 [y] > 65535)SendToBuffStr(" 0 "); else SendToBuffStr(" 1 "); |
igor_v | 0:8ad47e2b6f00 | 292 | 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 | 0:8ad47e2b6f00 | 293 | // sprintf (BuffTemp,"<%07d> <%07d> <%07d> <%07d> <%07d>", Spi.ADC1,Spi.ADC2,Spi.ADC3,Spi.ADC4,Spi.ADC5); |
igor_v | 0:8ad47e2b6f00 | 294 | SendToBuffStr(BuffTemp); |
igor_v | 0:8ad47e2b6f00 | 295 | */ |
igor_v | 0:8ad47e2b6f00 | 296 | /* |
igor_v | 0:8ad47e2b6f00 | 297 | WriteConByte (Main.T_Vib&0xff00); |
igor_v | 0:8ad47e2b6f00 | 298 | WriteConByte (Main.T_Vib&0x00ff); |
igor_v | 0:8ad47e2b6f00 | 299 | WriteConByte (Main.T_Vib); |
igor_v | 0:8ad47e2b6f00 | 300 | */ |
igor_v | 0:8ad47e2b6f00 | 301 | /* |
igor_v | 0:8ad47e2b6f00 | 302 | |
igor_v | 0:8ad47e2b6f00 | 303 | for (y = 0; y < 32; y++ ) |
igor_v | 0:8ad47e2b6f00 | 304 | { |
igor_v | 0:8ad47e2b6f00 | 305 | |
igor_v | 0:8ad47e2b6f00 | 306 | WriteCon(BuffTemp); |
igor_v | 0:8ad47e2b6f00 | 307 | } WriteCon("\n\r"); |
igor_v | 0:8ad47e2b6f00 | 308 | |
igor_v | 0:8ad47e2b6f00 | 309 | */ |
igor_v | 0:8ad47e2b6f00 | 310 | /* |
igor_v | 0:8ad47e2b6f00 | 311 | Main.T_Vib=((7680000*16/Main.Frq)*4096); |
igor_v | 0:8ad47e2b6f00 | 312 | th= Main.T_Vib&0xff00; |
igor_v | 0:8ad47e2b6f00 | 313 | tt= Main.T_Vib&0x00ff; |
igor_v | 0:8ad47e2b6f00 | 314 | sprintf(BuffTemp,"<%07d >",( (Main.T_Vib&0xff00))); |
igor_v | 0:8ad47e2b6f00 | 315 | SendToBuffStr(BuffTemp); |
igor_v | 0:8ad47e2b6f00 | 316 | |
igor_v | 0:8ad47e2b6f00 | 317 | sprintf(BuffTemp,"<%07d >",( ( Main.T_Vib&0x00ff))); |
igor_v | 0:8ad47e2b6f00 | 318 | SendToBuffStr(BuffTemp); |
igor_v | 0:8ad47e2b6f00 | 319 | /* |
igor_v | 0:8ad47e2b6f00 | 320 | CuruAngleOld=CuruAngle;*/ |
igor_v | 0:8ad47e2b6f00 | 321 | // Spi.ADC1=Spi.ADC1*0.000061; |
igor_v | 0:8ad47e2b6f00 | 322 | |
igor_v | 0:8ad47e2b6f00 | 323 | |
igor_v | 0:8ad47e2b6f00 | 324 | |
igor_v | 0:8ad47e2b6f00 | 325 | |
igor_v | 0:8ad47e2b6f00 | 326 | /* |
igor_v | 0:8ad47e2b6f00 | 327 | |
igor_v | 0:8ad47e2b6f00 | 328 | sprintf(BuffTemp,"\n\r<%05d><%05d><%05d><%05d><%05d>",Spi.ADC1,Spi.ADC2,Spi.ADC3,Spi.ADC4,Spi.ADC5); |
igor_v | 0:8ad47e2b6f00 | 329 | SendToBuffStr(BuffTemp); |
igor_v | 0:8ad47e2b6f00 | 330 | |
igor_v | 0:8ad47e2b6f00 | 331 | */ |
igor_v | 0:8ad47e2b6f00 | 332 | |
igor_v | 0:8ad47e2b6f00 | 333 | /* sprintf(BuffTemp,"<%d>",(FrecTemp)); |
igor_v | 0:8ad47e2b6f00 | 334 | SendToBuffStr(BuffTemp); |
igor_v | 0:8ad47e2b6f00 | 335 | for (y = 0; y < 32; y++ ) |
igor_v | 0:8ad47e2b6f00 | 336 | { |
igor_v | 0:8ad47e2b6f00 | 337 | sprintf(BuffTemp," <%07d>", (Buff_16PointD [y]-65535)); |
igor_v | 0:8ad47e2b6f00 | 338 | SendToBuffStr(BuffTemp); |
igor_v | 0:8ad47e2b6f00 | 339 | } */ |
igor_v | 0:8ad47e2b6f00 | 340 | } |
igor_v | 0:8ad47e2b6f00 | 341 | |
igor_v | 0:8ad47e2b6f00 | 342 | |
igor_v | 0:8ad47e2b6f00 | 343 | |
igor_v | 0:8ad47e2b6f00 | 344 | |
igor_v | 0:8ad47e2b6f00 | 345 | |
igor_v | 0:8ad47e2b6f00 | 346 | |
igor_v | 0:8ad47e2b6f00 | 347 | |
igor_v | 0:8ad47e2b6f00 | 348 | |
igor_v | 0:8ad47e2b6f00 | 349 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
igor_v | 0:8ad47e2b6f00 | 350 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
igor_v | 0:8ad47e2b6f00 | 351 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
igor_v | 0:8ad47e2b6f00 | 352 | |
igor_v | 0:8ad47e2b6f00 | 353 | |
igor_v | 0:8ad47e2b6f00 | 354 | |
igor_v | 0:8ad47e2b6f00 | 355 | |
igor_v | 0:8ad47e2b6f00 | 356 | LPC_GPIO2->FIOSET |= 0x0000004; // turn on the LED |
igor_v | 0:8ad47e2b6f00 | 357 | |
igor_v | 0:8ad47e2b6f00 | 358 | |
igor_v | 0:8ad47e2b6f00 | 359 | Curr_Cnt_Vib = LPC_QEI->POS; // �������� � ���������� Curr_Cnt_Vib ������� ��������� ��������. (������� ���������� ���������) |
igor_v | 0:8ad47e2b6f00 | 360 | Latch_Event(); //����������� ������� |
igor_v | 0:8ad47e2b6f00 | 361 | |
igor_v | 0:8ad47e2b6f00 | 362 | clc_Pulses(); // ������� ���������. RATE_REPER_OR_REFMEANDR ��� RATE_VIBRO_1 |
igor_v | 0:8ad47e2b6f00 | 363 | |
igor_v | 0:8ad47e2b6f00 | 364 | |
igor_v | 0:8ad47e2b6f00 | 365 | //ADC_Input(); // �������� ������ ���������� ������ � ������� Thermo1, Thermo2, HF_out � ����� Input.ArrayIn[n]. |
igor_v | 0:8ad47e2b6f00 | 366 | //DAC_ADC_Exchange();// �������� ������ ���������� ������ � ����� � ����. |
igor_v | 0:8ad47e2b6f00 | 367 | ServiceTime();//��������� ������. |
igor_v | 0:8ad47e2b6f00 | 368 | clc_ThermoSensors();//������ ������� ����������� �� ������� |
igor_v | 0:8ad47e2b6f00 | 369 | clc_HFO(); //������ �������� ��� �������� � ������ ���(�� ���). |
igor_v | 0:8ad47e2b6f00 | 370 | clc_PLC(); |
igor_v | 0:8ad47e2b6f00 | 371 | // clc_Dith_regulator(); |
igor_v | 0:8ad47e2b6f00 | 372 | clc_OutFreq_regulator(); |
igor_v | 0:8ad47e2b6f00 | 373 | Output.Str.WP_sin = clc_WP_sin(); |
igor_v | 0:8ad47e2b6f00 | 374 | contrl_GLD(); |
igor_v | 0:8ad47e2b6f00 | 375 | G_Photo_Exchange(); |
igor_v | 0:8ad47e2b6f00 | 376 | // Output.Str.T_Vibro = paramV*48; |
igor_v | 0:8ad47e2b6f00 | 377 | |
igor_v | 0:8ad47e2b6f00 | 378 | |
igor_v | 0:8ad47e2b6f00 | 379 | Line_1_Rcv(); |
igor_v | 0:8ad47e2b6f00 | 380 | decode_CMD(); |
igor_v | 0:8ad47e2b6f00 | 381 | transm_DAT(); |
igor_v | 0:8ad47e2b6f00 | 382 | |
igor_v | 0:8ad47e2b6f00 | 383 | |
igor_v | 0:8ad47e2b6f00 | 384 | // data_Rdy &= ~RESET_PERIOD; |
igor_v | 0:8ad47e2b6f00 | 385 | |
igor_v | 0:8ad47e2b6f00 | 386 | |
igor_v | 0:8ad47e2b6f00 | 387 | LPC_PWM1->IR = 0x0001; //e. clear interrupt flag |
igor_v | 0:8ad47e2b6f00 | 388 | |
igor_v | 0:8ad47e2b6f00 | 389 | |
igor_v | 0:8ad47e2b6f00 | 390 | |
igor_v | 0:8ad47e2b6f00 | 391 | LPC_GPIO2->FIOCLR |= 0x0000004; // turn off the LED |
igor_v | 0:8ad47e2b6f00 | 392 | // WDTFeed(); |
igor_v | 0:8ad47e2b6f00 | 393 | |
igor_v | 0:8ad47e2b6f00 | 394 | |
igor_v | 0:8ad47e2b6f00 | 395 | //SPI_Exchange(); |
igor_v | 0:8ad47e2b6f00 | 396 | |
igor_v | 0:8ad47e2b6f00 | 397 | } |
igor_v | 0:8ad47e2b6f00 | 398 | |
igor_v | 0:8ad47e2b6f00 | 399 | } while ( 1 ); // main infinie loop |
igor_v | 0:8ad47e2b6f00 | 400 | } |
igor_v | 0:8ad47e2b6f00 | 401 | |
igor_v | 0:8ad47e2b6f00 | 402 | /****************************************************************************** |
igor_v | 0:8ad47e2b6f00 | 403 | ** End Of File |
igor_v | 0:8ad47e2b6f00 | 404 | ******************************************************************************/ |
igor_v | 0:8ad47e2b6f00 | 405 | |
igor_v | 0:8ad47e2b6f00 | 406 |