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