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