![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
fork
Fork of LG by
Diff: SPI.c
- Revision:
- 109:ee0cff33ad3b
- Parent:
- 105:bd01d8d20fb6
- Child:
- 110:6406b7ac0442
--- a/SPI.c Sat Apr 02 11:15:38 2016 +0000 +++ b/SPI.c Sat Apr 02 13:10:40 2016 +0000 @@ -5,6 +5,9 @@ unsigned int Count_AMP, ADD_AMP, Cur_Amp; int Znak_Amp; +int AD_Regul = 0; + + unsigned int Temp_ADC_2; unsigned int Temp_ADC_3; @@ -71,33 +74,48 @@ // Temp_AMP -= Buff_ADC_5[(CountV255-32) & 0xff]; // заполнение буфера накопленых приращений за 8 тактов // Buff_AMP[CountV255] = (unsigned int) (Temp_AMP); - Temp_AMP += Buff_ADC_5[CountV255]; - Temp_AMP -= Buff_ADC_5[(CountV255-32) & 0xff]; // з - Temp_AMP += Buff_ADC_5[(CountV255-64) & 0xff]; // - Temp_AMP -= Buff_ADC_5[(CountV255-96) & 0xff]; // з - Buff_AMP[CountV255] = (unsigned int) (Temp_AMP); +// Temp_AMP += Buff_ADC_5[CountV255]; +// Temp_AMP -= Buff_ADC_5[(CountV255-32) & 0xff]; // з +// Temp_AMP += Buff_ADC_5[(CountV255-64) & 0xff]; // +// Temp_AMP -= Buff_ADC_5[(CountV255-96) & 0xff]; // з +// Buff_AMP[CountV255] = (unsigned int) (Temp_AMP); - ADD_AMP+=Spi.ADC5; - Count_AMP++; - if(Gyro.RgConA&0x2){ - if(Count_AMP>=(32*32)) + ADD_AMP+=Spi.ADC5; + Count_AMP++; + if(Count_AMP>=(32*32+8)) { Delta = ADD_AMP - Cur_Amp; - if ( Delta > 3000000 ) Spi.DAC_B += 100; - else if ( Delta < (-300000) ) Spi.DAC_B += 100; - else if ((Delta * Znak_Amp) > 0) - { - Spi.DAC_B += 1 ; - Znak_Amp = 1; + + if(Gyro.RgConA&0x2){ + + + + if (Znak_Amp > 10) {Znak_Amp --;} + else if ( Delta > 30000000 ) {AD_Regul += 5000000; Znak_Amp = 5;} + else if ( Delta < (-3000000)) {AD_Regul += 5000000; Znak_Amp = 5;} + else if ((Delta * Znak_Amp) > 0) + { +// Spi.DAC_B += 1 ; + Znak_Amp = 1; + AD_Regul += (Delta * Znak_Amp * 100); + } + else + { +// Spi.DAC_B -= 1; + Znak_Amp = -1; + AD_Regul += (Delta * Znak_Amp * 100); + } + + Spi.DAC_B = (AD_Regul + 0x1fffffff)/65536; + + } - else - { - Spi.DAC_B -= 1; - Znak_Amp = -1; - } + + + Cur_Amp=ADD_AMP; Count_AMP=0; ADD_AMP=0; } - } +