n

Dependencies:   mbed

Fork of LG by igor Apu

Revision:
5:02e9f559395c
Parent:
4:c0bab7b13f3a
Child:
6:6c5cd8c615cc
--- a/main.c	Sun Jan 31 21:14:07 2016 +0000
+++ b/main.c	Sun Jan 31 21:36:19 2016 +0000
@@ -66,109 +66,109 @@
 long LED_TEMP=0;
 int main (void)
 {
-    {
-        K_DAC=65535.0/(65535.0+(deltaDAC+deltaDAC/2));
-        K_DAC=0.8;
-        Main.Firmware_Version=0x15;
-        Main.GLD_Serial = 0x20;
-        Main.My_Addres=0;
-        LightUpCount=1000;
-        BackLightCount=5000;
-        secPuls=0;
-        Pulse_midl = 0;
-        PulseHalf = 0;
-        CuruAngle = 0;
-        Spi.DAC_A=0x7fff;
-        Spi.DAC_B=0x7fff;
-        //�������������
-        SystemInit();  // ������������� �������
-        Led_init();
+    K_DAC=65535.0/(65535.0+(deltaDAC+deltaDAC/2));
+    K_DAC=0.8;
 
-        ///*
-        //���������������� ������� �������
-        LPC_PINCON->PINSEL0 &= ~(3<<8);		//e. P0.4 is GPIO pin (������ ( 00 ) � 9:8 ��� PISEL0    ����� P0.4 ��� GPIO)
-        LPC_PINCON->PINMODE0 |= (3<<8);		//e. P0.4 is GPIO pin (������ ( 11 ) � 9:8 ��� PINMODE0  "��� ��������� �������������� ���������")
-        LPC_GPIO0->FIODIR   |= (1<<4);		//e. P0.4 is output   (������ ( 1 ) �  5  ��� FIODIR    ����� P0.4 ��� �����)
-        LightUpON		//e. P0.4 is output   (������ ( 1 ) �  5  ��� CLR       ������������� �� P0.4 ������ ������� �������)
-        /*
-        LPC_PINCON->PINSEL0 &= ~(3<<10);		//e. P0.4 is GPIO pin (������ ( 00 ) � 9:8 ��� PISEL0    ����� P0.4 ��� GPIO)
-        LPC_PINCON->PINMODE0 |= (3<<10);		//e. P0.4 is GPIO pin (������ ( 11 ) � 9:8 ��� PINMODE0  "��� ��������� �������������� ���������")
-        LPC_GPIO0->FIODIR   |= (1<<5);		//e. P0.4 is output   (������ ( 1 ) �  5  ��� FIODIR    ����� P0.4 ��� �����)
-        LPC_GPIO0->FIOCLR   |= (1<<5);		//e. P0.4 is output   (������ ( 1 ) �  5  ��� CLR       ������������� �� P0.4 ������ ������� �������)*/
+    Main.Firmware_Version=0x15;
+    Main.GLD_Serial = 0x20;
+    Main.My_Addres=0;
+    LightUpCount=1000;
+    BackLightCount=5000;
+    secPuls=0;
+    Pulse_midl = 0;
+    PulseHalf = 0;
+    CuruAngle = 0;
+    Spi.DAC_A=0x7fff;
+    Spi.DAC_B=0x7fff;
+    //�������������
+    SystemInit();  // ������������� �������
+    Led_init();
+
+    ///*
+    //���������������� ������� �������
+    LPC_PINCON->PINSEL0 &= ~(3<<8);		//e. P0.4 is GPIO pin (������ ( 00 ) � 9:8 ��� PISEL0    ����� P0.4 ��� GPIO)
+    LPC_PINCON->PINMODE0 |= (3<<8);		//e. P0.4 is GPIO pin (������ ( 11 ) � 9:8 ��� PINMODE0  "��� ��������� �������������� ���������")
+    LPC_GPIO0->FIODIR   |= (1<<4);		//e. P0.4 is output   (������ ( 1 ) �  5  ��� FIODIR    ����� P0.4 ��� �����)
+    LightUpON		//e. P0.4 is output   (������ ( 1 ) �  5  ��� CLR       ������������� �� P0.4 ������ ������� �������)
+    /*
+    LPC_PINCON->PINSEL0 &= ~(3<<10);		//e. P0.4 is GPIO pin (������ ( 00 ) � 9:8 ��� PISEL0    ����� P0.4 ��� GPIO)
+    LPC_PINCON->PINMODE0 |= (3<<10);		//e. P0.4 is GPIO pin (������ ( 11 ) � 9:8 ��� PINMODE0  "��� ��������� �������������� ���������")
+    LPC_GPIO0->FIODIR   |= (1<<5);		//e. P0.4 is output   (������ ( 1 ) �  5  ��� FIODIR    ����� P0.4 ��� �����)
+    LPC_GPIO0->FIOCLR   |= (1<<5);		//e. P0.4 is output   (������ ( 1 ) �  5  ��� CLR       ������������� �� P0.4 ������ ������� �������)*/
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
-        LPC_PINCON->PINSEL3   = (0x00<<18);		//e. P1.25 is GPIO pin
-        LPC_PINCON->PINMODE3 |= (3<<18);		//e. P1.25  (��������e �������������� ���������")
-        LPC_GPIO1->FIODIR    |= (1<<25);		//e. P0.5 is output   (������ ( 1 ) �  5  ��� FIODIR    ����� P0.5 ��� �����)
-        LPC_GPIO1->FIOCLR    |= (1<<25);
+    LPC_PINCON->PINSEL3   = (0x00<<18);		//e. P1.25 is GPIO pin
+    LPC_PINCON->PINMODE3 |= (3<<18);		//e. P1.25  (��������e �������������� ���������")
+    LPC_GPIO1->FIODIR    |= (1<<25);		//e. P0.5 is output   (������ ( 1 ) �  5  ��� FIODIR    ����� P0.5 ��� �����)
+    LPC_GPIO1->FIOCLR    |= (1<<25);
 
 
 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
-        LPC_PINCON->PINSEL3   = (0x00<<24);		//e. P1.28 is GPIO pin
-        LPC_PINCON->PINMODE3 |= (3<<24);		//e. P1.28 is GPIO pin (������ ( 11 ) � ��� PINMODE0  "��� ��������� �������������� ���������")
-        LPC_GPIO1->FIODIR    |= (1<<28);		//e. P1.28 is output   (������ ( 1 ) �  5  ��� FIODIR    ����� P0.5 ��� �����)
-        LPC_GPIO1->FIOCLR    |= (1<<28);
+    LPC_PINCON->PINSEL3   = (0x00<<24);		//e. P1.28 is GPIO pin
+    LPC_PINCON->PINMODE3 |= (3<<24);		//e. P1.28 is GPIO pin (������ ( 11 ) � ��� PINMODE0  "��� ��������� �������������� ���������")
+    LPC_GPIO1->FIODIR    |= (1<<28);		//e. P1.28 is output   (������ ( 1 ) �  5  ��� FIODIR    ����� P0.5 ��� �����)
+    LPC_GPIO1->FIOCLR    |= (1<<28);
 //  init_timer(TIME_INTERVAL ); // 10ms
 // enable_timer1();
 ///������������� ���������
-        LPC_PINCON->PINSEL2   = (0x00<<24);		//e. P2.12 is GPIO pin
-        LPC_PINCON->PINMODE3 |= (3<<24);		//e. P1.28 is GPIO pin (������ ( 11 ) � ��� PINMODE0  "��� ��������� �������������� ���������")
-        LPC_GPIO2->FIODIR    |= (1<<12);		//e. P1.28 is output   (������ ( 1 ) �  5  ��� FIODIR    ����� P0.5 ��� �����)
-        LPC_GPIO2->FIOCLR    |= (1<<12);
+    LPC_PINCON->PINSEL2   = (0x00<<24);		//e. P2.12 is GPIO pin
+    LPC_PINCON->PINMODE3 |= (3<<24);		//e. P1.28 is GPIO pin (������ ( 11 ) � ��� PINMODE0  "��� ��������� �������������� ���������")
+    LPC_GPIO2->FIODIR    |= (1<<12);		//e. P1.28 is output   (������ ( 1 ) �  5  ��� FIODIR    ����� P0.5 ��� �����)
+    LPC_GPIO2->FIOCLR    |= (1<<12);
 
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-        /*
-          //���������������� ������� ������� ��������� ���� (������ �� 80 ���� ������ 81)
-          LPC_PINCON->PINSEL0   = (0x00<<10);		//e. P0.5 is GPIO pin (������ ( 00 ) � 11:10 ��� PISEL0    ����� P0.5 ��� GPIO)
-          LPC_PINCON->PINMODE0 |= (3<<10);		//e. P0.5 is GPIO pin (������ ( 11 ) � 11:10 ��� PINMODE0  "��� ��������� �������������� ���������")
-          LPC_GPIO0->FIODIR    |= (1<<5);		//e. P0.5 is output   (������ ( 1 ) �  5  ��� FIODIR    ����� P0.5 ��� �����)
-          LPC_GPIO0->FIOCLR    |= (1<<5);		//e. P0.5 is output   (������ ( 1 ) �  5  ��� CLR       ������������� �� P0.5 ������ ������� �������)
-        	*/
-        DMA_Init();           // ������������� DMA
-        FlashDMA_Init(); 			// �������� ���������� � ����
+    /*
+      //���������������� ������� ������� ��������� ���� (������ �� 80 ���� ������ 81)
+      LPC_PINCON->PINSEL0   = (0x00<<10);		//e. P0.5 is GPIO pin (������ ( 00 ) � 11:10 ��� PISEL0    ����� P0.5 ��� GPIO)
+      LPC_PINCON->PINMODE0 |= (3<<10);		//e. P0.5 is GPIO pin (������ ( 11 ) � 11:10 ��� PINMODE0  "��� ��������� �������������� ���������")
+      LPC_GPIO0->FIODIR    |= (1<<5);		//e. P0.5 is output   (������ ( 1 ) �  5  ��� FIODIR    ����� P0.5 ��� �����)
+      LPC_GPIO0->FIOCLR    |= (1<<5);		//e. P0.5 is output   (������ ( 1 ) �  5  ��� CLR       ������������� �� P0.5 ������ ������� �������)
+    	*/
+    DMA_Init();           // ������������� DMA
+    FlashDMA_Init(); 			// �������� ���������� � ����
 
-        SystemCoreClockUpdate();  // ������ ��������� ������� ��� UART.
-        UARTInit();				        // �������������  UART0 �� �������� 38400.
-        UART1_Init();             // �������������  UART1 �� �������� 38400.
+    SystemCoreClockUpdate();  // ������ ��������� ������� ��� UART.
+    UARTInit();				        // �������������  UART0 �� �������� 38400.
+    UART1_Init();             // �������������  UART1 �� �������� 38400.
 
 
-        DAC_ADC_Exchange_Init();  // �������������  ������ ��� � ���.
-        DACInit();                // ������������� ���.
-        SOI_Init(); 			      	// ������������� ������������� ��������.
+    DAC_ADC_Exchange_Init();  // �������������  ������ ��� � ���.
+    DACInit();                // ������������� ���.
+    SOI_Init(); 			      	// ������������� ������������� ��������.
 
-        IntLatch_Init();			// ������������� ���������� �������.
-        ExtLatch_Init();			// ������������� ������� �������.
+    IntLatch_Init();			// ������������� ���������� �������.
+    ExtLatch_Init();			// ������������� ������� �������.
 
 //----------------debug-------------------------
-        //LPC_GPIO2->FIODIR = 0x5C;		// P2.0...P2.7 defined as Outputs
-        //LPC_GPIO2->FIOCLR = 0x5C;		// turn off all the LEDs
+    //LPC_GPIO2->FIODIR = 0x5C;		// P2.0...P2.7 defined as Outputs
+    //LPC_GPIO2->FIOCLR = 0x5C;		// turn off all the LEDs
 //----------------debug-------------------------
 
 
-        LoadFlashParam(FromFLASH); 	//�������� ����������.
-        UART_DMA_Init();			    	//������������� DMA ��� UART.
-        G_Photo_Init();				      //������������� ���������� I2C ��� �������������.
-        Out_G_photo(60, 60);        //������ � ����� ������� �������� �� ������� ������ (60,60) � ��������� ����� ������ �������� � ������� ����.
+    LoadFlashParam(FromFLASH); 	//�������� ����������.
+    UART_DMA_Init();			    	//������������� DMA ��� UART.
+    G_Photo_Init();				      //������������� ���������� I2C ��� �������������.
+    Out_G_photo(60, 60);        //������ � ����� ������� �������� �� ������� ������ (60,60) � ��������� ����� ������ �������� � ������� ����.
 //  WDTInit();
 
 
-        open_all_loops();                          //#define open_all_loops()			RgConA   = 0	(�������� ������� ���������� ���������� (0 - ��������, 1 - ���������)).
-        Output.Str.HF_reg = Device_blk.Str.HF_min; //HFO output voltage = ������������ ���������� �� ���.
-        init_PLC();                                //������������� ���(����������� ���������)
-        init_Dither_reg();                         //������������� ������������
-        RgConB = RATE_VIBRO_1; // �������������� ������� ���������� = �������� �������������� ����� ������� ������.��������(#define RATE_VIBRO_1	0x0001)
-        init_Vibro();
-        init_timer(TIME_INTERVAL ); // 10ms
-        enable_timer1();
-        Init_TIM2();
-        enable_timer2();
-        close_all_loops();
+    open_all_loops();                          //#define open_all_loops()			RgConA   = 0	(�������� ������� ���������� ���������� (0 - ��������, 1 - ���������)).
+    Output.Str.HF_reg = Device_blk.Str.HF_min; //HFO output voltage = ������������ ���������� �� ���.
+    init_PLC();                                //������������� ���(����������� ���������)
+    init_Dither_reg();                         //������������� ������������
+    RgConB = RATE_VIBRO_1; // �������������� ������� ���������� = �������� �������������� ����� ������� ������.��������(#define RATE_VIBRO_1	0x0001)
+    init_Vibro();
+    init_timer(TIME_INTERVAL ); // 10ms
+    enable_timer1();
+    Init_TIM2();
+    enable_timer2();
+    close_all_loops();
 
-        LPC_GPIO0->FIOCLR = (1<<5);
-    }
+    LPC_GPIO0->FIOCLR = (1<<5);
+
 
 
     Pulse_8Point = 0;
@@ -184,25 +184,24 @@
 
 
     for (y = 0; y < 256; y++ ) {
-        Buff_16Point [y] = 0xffff;
-        Buff_8Point [y] = 0xffff;
-        Buff_32Point [y] = 0xffff;
-        Buff_ADC_1	[y] = 0;// ���� ���.
-        Buff_ADC_2	[y] = 0;
-        Buff_ADC_3	[y] = 0;
-        Buff_ADC_4	[y] = 0;
-        Buff_ADC_5	[y] = 0;
+        Buff_16Point[y] 	= 0xffff;
+        Buff_8Point[y] 		= 0xffff;
+        Buff_32Point[y] 	= 0xffff;
+        Buff_ADC_1[y] 		= 0;					// ���� ���.
+        Buff_ADC_2[y] 		= 0;
+        Buff_ADC_3[y] 		= 0;
+        Buff_ADC_4[y] 		= 0;
+        Buff_ADC_5[y] 		= 0;
 
     }
 
 
 
     SendToBuffStr ("\n\r ....... ");
-    OutBufConCount =0;
+    OutBufConCount = 0;
     WriteCon("\n\r ...WriteCon1.... ");
+
     do { //�������� ����.
-
-
         if (OutBufConCount)  OutBufConCount--;
         Concol ();
 //   Concol1 ();
@@ -214,7 +213,7 @@
         if(Time_1kHz>100) {
 
             SEC++;
-            if(Rate_Flag==1&&SEC>500) {
+            if(Rate_Flag==1 && SEC>500) {
                 SEC-=500;
                 CMD_Rate();
             }