![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
fork
Fork of LG by
Diff: Command.c
- Revision:
- 205:775d54fdf646
- Parent:
- 197:7a05523bf588
- Child:
- 206:00341a03e05c
--- a/Command.c Fri Nov 25 06:22:37 2016 +0000 +++ b/Command.c Mon Dec 19 14:08:31 2016 +0000 @@ -16,7 +16,7 @@ int ttemp; int OLDDAC=0; - +int rr = 123; unsigned int pDestT ; GyroParam *Flash; ///////////////flah and boot/////////// @@ -41,38 +41,109 @@ } } - +/* void WriteFlash(void) { - - NVIC_DisableIRQ(TIMER1_IRQn); - NVIC_DisableIRQ(TIMER2_IRQn); - NVIC_DisableIRQ(TIMER3_IRQn); - NVIC_DisableIRQ(EINT3_IRQn); - + SystemInitDef(); WriteCon("\r\n Start Prepare Sectors"); - if(u32IAP_PrepareSectors(18, 21) == IAP_STA_CMD_SUCCESS) + if(u32IAP_PrepareSectors(5, 5) == IAP_STA_CMD_SUCCESS) { WriteCon("\r\nPrepare Sectors OK"); WriteCon("\r\n Start Erase"); u32IAP_EraseSectors(IMG_START_SECTOR, IMG_END_SECTOR); WriteCon("\r\n AND Erase"); } - else WriteCon("\r\nPrepare Sectors ERROR"); + else WriteCon("\r\nPrepare Sectors ERROR "); SystemInit1(); Gyro.FlashMod = 0; } - + */ + void EraseFlash(void) + { + Gyro.FlashMod = 0; + rr = u32IAP_PrepareSectors(8, 10); + sprintf((Time)," dffddfd <%07d> ",rr); + WriteCon(Time); + + rr = u32IAP_EraseSectors(8, 10); + sprintf((Time)," dffddfd <%07d> ",rr); + WriteCon(Time); + } + + void WriteFlash(void) + + { Gyro.FlashMod = 0; + + //SystemInitDef(); + NVIC_DisableIRQ(TIMER1_IRQn); + NVIC_DisableIRQ(TIMER2_IRQn); + NVIC_DisableIRQ(TIMER3_IRQn); + NVIC_DisableIRQ(EINT3_IRQn); + + unsigned int start_address = (unsigned int) & GyroP; + sprintf((Time)," dffddfd <%07d> ",&rr); + WriteCon(Time); + ////unsigned int address=0x0003000; + rr = u32IAP_PrepareSectors(8, 10); + sprintf((Time)," dffddfd <%07d> ",rr); + WriteCon(Time); + + rr = u32IAP_EraseSectors(8, 10); + sprintf((Time)," dffddfd <%07d> ",rr); + WriteCon(Time); + + rr = u32IAP_PrepareSectors(8, 10); + sprintf((Time)," dffddfd <%07d> ",rr); + WriteCon(Time); + + /// SystemInitDef(); + rr = u32IAP_CopyRAMToFlash(0x0009000, &GyroP , 1024); + sprintf((Time)," dffddfd <%07d> ",rr); + WriteCon(Time); + // SystemInit1(); // Инициализация контроллера: установка тактовых частот + //SystemCoreClockUpdate1(); // расчет тактовой частоты процессора перед инициализацией UART - 103MHz + + NVIC_EnableIRQ(TIMER1_IRQn); + NVIC_EnableIRQ(TIMER2_IRQn); + NVIC_EnableIRQ(TIMER3_IRQn); + NVIC_EnableIRQ(EINT3_IRQn); + + } void ReadFlash ( void) { + NVIC_DisableIRQ(TIMER1_IRQn); + NVIC_DisableIRQ(TIMER2_IRQn); + NVIC_DisableIRQ(TIMER3_IRQn); + NVIC_DisableIRQ(EINT3_IRQn); Gyro.FlashMod = 0; WriteCon("\r\n Pirivet Flash"); - pDestT= (unsigned int) (0x10000); + + pDestT= (unsigned int) (0x9000); Flash = (GyroParam*) pDestT; GyroP = *(Flash); - sprintf((Time)," dffddfd <%07d> ", GyroP.Str.K_WP_rst_heating); - WriteCon(Time); + + NVIC_EnableIRQ(TIMER1_IRQn); + NVIC_EnableIRQ(TIMER2_IRQn); + NVIC_EnableIRQ(TIMER3_IRQn); + NVIC_EnableIRQ(EINT3_IRQn); + //char table = (char*)your_address; + /* sprintf((Time)," dffddfd <%07d> ",GyroP.Array[10]); + WriteCon(Time);*/ + + + /*int address = flash_size() - SECTOR_SIZE; //Write in last sector + + int *data = (int*)address; + printf("Starting\r\n"); + // erase_sector(address); do not erase the previous content + // int numbers[10] = {0, 1, 10, 100, 1000, 10000, 1000000, 10000000, 100000000, 1000000000}; + // program_flash(address, (char*)&numbers, 40); //dont overwrite the previous data + printf("Resulting flash: \r\n"); + for (int i = 0; i<10; i++) + printf("%d\r\n", data[i]); //display the non volatile data + + printf("Done\r\n\n");*/ } ///////////////end flah and boot/////////// void M_RateA(void) @@ -83,7 +154,7 @@ case 3: if(Gyro.Event_500Hz ) CMD_Delta_PS(); break; case 4: if(Gyro.EXT_Latch ) CMD_Delta_PS(); break; case 5: if(Gyro.Event_500Hz ) CMD_Delta_Bins(); break; - case 6: if(Gyro.B_Delta_EventEXT ) CMD_B_Delta(); break; + case 6: if(Gyro.EXT_Latch ) CMD_B_Delta(); break; case 7: if(Gyro.Event_500Hz ) CMD_B_Delta(); break; } } @@ -104,6 +175,8 @@ Check(BuffTemp, 6); WriteConN (BuffTemp,6); + /*sprintf((Time),"READ Param = <%07d> GyroP.Array[NP] = <%07d> NP= <%07d> Gyro.CaunPlus+Gyro.CaunMin-5000 <%07d> \r\n",Param, GyroP.Array[NP], NP, GyroP.Str.PLC_Lern); + WriteCon(Time);*/ } void CMD_M_Param_W(void) { @@ -120,10 +193,12 @@ BuffTemp[0] = Gyro.SOC_Out; BuffTemp[1] = Gyro.My_Addres; BuffTemp[2] = Gyro.CMD_In; - BuffTemp[3] = 0x00;//старший байт требуемого параметра + BuffTemp[3] = (GyroP.Array[NP]>> 8) & 0xff;//старший байт требуемого параметра Check(BuffTemp, 6); WriteConN (BuffTemp,6); + /* sprintf((Time),"READ Param = <%07d> GyroP.Array[NP] = <%07d> NP= <%07d> GyroP.Str.PLC_Lern = <%07d> \r\n",Param, GyroP.Array[NP], NP, GyroP.Str.PLC_Lern); + WriteCon(Time);*/ } void CMD_Maintenance(void) { @@ -141,9 +216,8 @@ } void CMD_B_Delta(void) { - //Gyro.B_Delta_Event500=0; Gyro.Event_500Hz=0; - Gyro.B_Delta_EventEXT=0; + Gyro.EXT_Latch=0; unsigned int Temp; BuffTemp[ 0] = Gyro.SOC_Out; BuffTemp[ 1] = Gyro.My_Addres; @@ -160,7 +234,6 @@ void CMD_Delta_Bins(void) { Gyro.Event_500Hz=0; - //Gyro.Delta_Bins_Event500=0; unsigned int Temp; BuffTemp[ 0] = Gyro.SOC_Out; BuffTemp[ 1] = Gyro.My_Addres; @@ -178,7 +251,6 @@ } void CMD_Delta_PS(void) { - //Gyro.Delta500_Event=0; Gyro.EXT_Latch=0; Gyro.Event_500Hz=0; unsigned int Temp; @@ -423,7 +495,7 @@ BuffTemp[22] = (Temp >> 8) & 0xff; BuffTemp[23] = (Temp >> 0) & 0xff; - Temp = Gyro.PLC_Delta >> 16; + Temp =0x0;// Gyro.PLC_Delta >> 16; BuffTemp[24] = (Temp >> 8) & 0xff; BuffTemp[25] = (Temp >> 0) & 0xff;// @@ -590,7 +662,7 @@ void Gph_W() { - Gyro.flagGph_W=3; + //Gyro.flagGph_W=3; Out_G_photo(BuffTemp[4],BuffTemp[5]); } @@ -749,25 +821,6 @@ } - - - - - - - - - - - - - - - - - - - void TechLog(void) { if (ReadCon (Time)) { @@ -776,205 +829,13 @@ //////////////////////Выбор FlashMod/////////////////////////// //////////////////////////////////////////////////////////////// - if (Time[0] == 'B') - { - // sprintf((Time),"<%015d>\r\n", ModArray[7]); - WriteCon(Time);} + if (Time[0] == 'B') Gyro.FlashMod=1; if (Time[0] == 'W') {Gyro.FlashMod=2;} if (Time[0] == 'R') {Gyro.FlashMod=3;} + if (Time[0] == 'E') {Gyro.FlashMod=4;} /////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////// - if (Time[0] == 'H') { // если ввели буквц h то выдать подсказку. сделанно через принф ОЧЕНЬ плохо в работе не использовать - sprintf(Time,"\r\nCompiled: %s %s.",__DATE__, __TIME__ ); //Подготовка даты и времени компиляции - WriteCon(Time); - sprintf(Time,"--%d.%3.d.%2.d.",Time1Hz,Time1K,Time100K); //Временно выдачпа временни из трех чисел - WriteCon(Time); - } - if (Time[0] == 'D') { - Gyro.Discharg = StartDischarg; - } - if (Time[0] == 'L') { - Gyro.BackLight = StartBackLight; - } - if (Time[0] == 'F') { // выдача технологическая - sprintf(Time,"\r\n"); - WriteCon(Time); - sprintf((Time)," <%015d>", Gyro.CuruAngle); - WriteCon(Time); - } - if (Time[0] == 'q') { // внешняя защелка - Gyro.EXT_Latch=1; - } - if (Time[0] == '1') { // выдача технологическая - sprintf(Time,"\r\n"); - WriteCon(Time); - for (int i = 0; i < 32; i++ )sprintf((Time + i * 9)," <%05d> ",Buff_1Point[i]); - WriteCon(Time); - } - if (Time[0] == '2') { // выдача технологическая - sprintf(Time,"\r\n"); - WriteCon(Time); - for (int i = 0; i < 32; i++ )sprintf((Time + i * 9)," <%05d> ", Buff_32Point[CountV31]); - WriteCon(Time); - } - if (Time[0] == '3') { // выдача технологическая - sprintf(Time,"\r\n"); - WriteCon(Time); - for (int i = 0; i < 32; i++ )sprintf((Time + i * 9)," <%05d> ", Buff_16Point[i]); - WriteCon(Time); - } - if (Time[0] == '4') { // выдача технологическая - sprintf(Time,"\r\n"); - WriteCon(Time); - for (int i = 0; i < 32; i++ )sprintf((Time + i * 9)," <%07d> ", Buff_8Point[i]); - WriteCon(Time); - sprintf(Time,"\r\n"); - WriteCon(Time); - for (int i = 0; i < 32; i++ )sprintf((Time + i * 9)," <%07d> ", Buff_16PointD[i]); - WriteCon(Time); - sprintf(Time,"\r\n"); - WriteCon(Time); - sprintf(Time,"\r\n"); - WriteCon(Time); - for (int i = 0; i < 32; i++ )sprintf((Time + i * 9)," <%07d> ", Buff_32Point[i]); - WriteCon(Time); - sprintf(Time,"\r\n"); - WriteCon(Time); - sprintf(Time,"\r\n"); - WriteCon(Time); - for (int i = 0; i < 32; i++ )sprintf((Time + i * 9)," <%07d> ", Buff_Restored_sin[i]); - WriteCon(Time); - sprintf(Time,"\r\n\r\n\r\n"); - WriteCon(Time); - } - if (Time[0] == 'z'){ // выдача технологичес6кая - - sprintf(Time,"\r\n"); - WriteCon(Time); - - for (int i = 0; i < 32; i++ ) - { - ttemp+=(Buff_Restored_sin[i]); - } - sprintf((Time)," %d ",ttemp); - WriteCon(Time); - - for (int i = 0; i < 32; i++ ) - { - ttemp += Buff_64Point[i]; - } - sprintf((Time)," %d ",ttemp); - WriteCon(Time); - - for (int i = 0; i < 32; i++ ) - { - ttemp += Buff_32Point[i]; - } - sprintf((Time)," %d ",ttemp); - WriteCon(Time); - - for (int i = 0; i < 32; i++ ) - { - ttemp += Buff_16Point[i]; - } - sprintf((Time)," %d ",ttemp); - WriteCon(Time); - - for (int i = 0; i < 32; i++ ) - { - ttemp += Buff_16PointD[i]; - } - sprintf((Time)," %d ",ttemp); - WriteCon(Time); - - for (int i = 0; i < 32; i++ ) - { - ttemp += Buff_8Point[i]; - } - sprintf((Time)," %d ",ttemp); - WriteCon(Time); - - for (int i = 0; i < 32; i++ ) - { - ttemp += Buff_1Point[i]; - } - sprintf((Time)," %d ",ttemp); - WriteCon(Time); - } - if (Time[0] == '6') { // выдача технологическая - sprintf(Time,"\r\n"); - WriteCon(Time); - for (int i = 0; i < 32; i++ ) - { - sprintf((Time + i * 9)," <%07d>", (Buff_Restored_Mod[i]>>20)); - } - WriteCon(Time); - } - /* if (Time[0] == '7') { // выдача технологическая - sprintf(Time,"\r\n"); - WriteCon(Time); - - for (int i = 0; i < 32; i++ )sprintf((Time + i * 13)," <%010d>", (BuffADC_64Point[i+32]>>10)); - WriteCon(Time); - } */ - /*for (int i = 32; i < 64; i++ )sprintf((Time + i *8)," <%05d> ",Buff_ADC_5[i]); - WriteCon(Time);*/ - /* - sprintf(Time,"\r\n"); - WriteCon(Time); - for (int i = 0; i < 64; i++ )sprintf((Time + i * 9)," <%05d> ",BuffADC_16Point[i]>>16); - WriteCon(Time); - sprintf(Time,"\r\n"); - WriteCon(Time); - for (int i = 0; i < 64; i++ )sprintf((Time + i * 14)," <%010d> ",BuffADC_32Point[i]); - WriteCon(Time); - sprintf(Time,"\r\n"); - WriteCon(Time); - for (int i = 0; i < 64; i++ )sprintf((Time + i * 14)," <%010d> ",BuffADC_64Point[i]>>16); - WriteCon(Time); - sprintf(Time,"\r\n"); - WriteCon(Time); - for (int i = 0; i < 64; i++ )sprintf((Time + i * 14)," <%010d> ",BuffADC_32PointD[i]); - WriteCon(Time); - sprintf(Time,"\r\n"); - WriteCon(Time); - sprintf(Time,"\r\n"); - WriteCon(Time); - - */ - - - /* if (Time[0] == 'm') { // выдача технологическая - sprintf(Time,"\r\n"); - WriteCon(Time); - for (int i = 0; i < 64; i++ )sprintf((Time + i * 10)," <%010d> ", ModArray[i]); - WriteCon(Time); - }*/ - if (Time[0] == '9') { // выдача технологическая - sprintf(Time,"\r\n"); - WriteCon(Time); - for (int i = 0; i < 32; i++ )sprintf((Time)," <%07d> ",Gyro.Frq); - WriteCon(Time); - } - /*if (Time[0] == 'p') { // выдача технологическая - sprintf(Time,"\r\n"); - WriteCon(Time); - for (int i = 0; i < 32; i++ )sprintf((Time)," <%07d> ",Gyro.MaxAmp); - WriteCon(Time); - }*/ - if (Time[0] == 'x') { // выдача технологическая - sprintf(Time,"\r\n"); - WriteCon(Time); - sprintf((Time)," Gyro.MaxAmp = <%07d> Gyro.CaunPlus = <%07d> Gyro.CaunMin= <%07d> Gyro.CaunPlus+Gyro.CaunMin-5000 <%07d> ",Gyro.MaxAmp, Gyro.CaunPlus, Gyro.CaunMin, ((Gyro.CaunPlus + Gyro.CaunMin)-5000)); - WriteCon(Time); - } - if (Time[0] == 'm') { // выдача технологическая - sprintf(Time,"\r\n"); - WriteCon(Time); - sprintf((Time),"PLC_Delta <%07d> ", Gyro.PLC_Delta); WriteCon(Time); - sprintf((Time),"PLC_DeltaADD <%07d> ", Gyro.PLC_DeltaADD); WriteCon(Time); - } if (Time[0] == 'V') { // выдача технологическая Spi.DAC_B += 200; /* sprintf(Time,"%d\r\n", Spi.DAC_B); @@ -984,62 +845,24 @@ Spi.DAC_B -= 200; /* sprintf(Time,"%d\r\n", Spi.DAC_B); WriteCon(Time);*/ - } - + } if (Time[0] == 'w') TypeMod=2; if (Time[0] == 'a') TypeMod=1; if (Time[0] == 's') TypeMod=0; //////////////////////////////////////////////////////////////////////////////// - /*Запись лога регулировки частоты*/ - if (Time[0] == 'y') Gyro.flag=1; //включит передачу - if (Time[0] == 'u') Gyro.flag=0; //LPC_TIM1->MR0+1000 вносим помеху - if (Time[0] == 'i') {Gyro.flag=2; } //LPC_TIM1->MR0 убираем помеху - if (Time[0] == 'o') Gyro.flag=3; //Отключить передачу - if (Time[0] == 'p') Gyro.LogHZ = 1; //Отключить передачу - if (Time[0] == 'l') Gyro.LogHZ = 0; //Отключить передачу - //////////////////////////////////////////////////////////////////////////////////// /*Запись лога регулировки периметра*/ if (Time[0] == 'g') Gyro.LogPLC=1; if(OLDDAC) Spi.DAC_B=OLDDAC; //включит передачу if (Time[0] == 'h') {Gyro.LogPLC=2; Spi.DAC_B=19000; Gyro.PLC_Error2Mode = 1400; OLDDAC=Spi.DAC_B; Spi.DAC_B=19000;} //десперсионка if (Time[0] == 'j') Gyro.LogPLC=0; if(OLDDAC) Spi.DAC_B=OLDDAC; //регулировка без выдачиж - if (Time[0] == 'b') Gyro.StrayPLC_flag = 3; //LPC_TIM1->MR0-1000 вносим помеху - - if (Time[0] == 'n') Gyro.StrayPLC_flag = 2; //LPC_TIM1->MR0+2500 большая помеха. + if (Time[0] == 'k') Gyro.LogPLC = 0; //Отключить передачу - if (Time[0] == 'd') {Gyro.ModJump = 1; } //прыжок на воду + - if (Time[0] == 'f') {Gyro.ModJump = 2; } //прыжок на воду - - //if (Time[0] == 'z') {Gyro.ModJump = 3; Spi.DAC_B = 0x3a98; } //прообежать по всем модам. + ////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////выдача частоты в терминал длля записи лога/////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////G=1,K=0 в терменале - /* if((Gyro.LogHZ == 1)&&(Gyro.Event_500Hz==1)) //Запись для Ориджина. - { - Gyro.Event_500Hz=0; - sprintf((Time),"%d \r\n",Gyro.MaxAmp); - WriteCon(Time); - } - - */ - if (Time[0] == '8') { // выдача технологическая - sprintf(Time,"\r\n"); - WriteCon(Time); - for (int i = 0; i < 32; i++ ) - { - ttemp=(Buff_AMP64P[i]-(Buff_AMP[i])); - if (ttemp < 0) WriteCon("1"); else WriteCon("0"); - } - } - if (Time[0] == 'q') { // выдача технологическая - sprintf(Time,"\r\n"); - WriteCon(Time); - for (int i = 0; i < 32; i++ ) - { - ttemp=(Buff_Restored_sin[i]); - if (ttemp < 0) WriteCon("1"); else WriteCon("0"); - } - } + if (Gyro.PLC_Error2Mode) { // выдача технологическая // sprintf(Time,"\r\nPLC_Error2Mode"); WriteCon(Time);