![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
n
Fork of LG by
Diff: QEI.c
- Revision:
- 1:f2adcae3d304
- Parent:
- 0:8ad47e2b6f00
- Child:
- 21:bc8c1cec3da6
diff -r 8ad47e2b6f00 -r f2adcae3d304 QEI.c --- a/QEI.c Sat Jan 30 13:00:39 2016 +0000 +++ b/QEI.c Sat Jan 30 13:53:19 2016 +0000 @@ -1,13 +1,10 @@ -#include "lpc17xx.h" -#include "QEI.h" -#include "vibro.h" -#include "MTimer.h" +#include "Global.h" int Pulse_midl = 0; int PulseHalf = 0; int CuruAngle = 0; int Dif_QEI; -int FFF=0;//äëÿ çàïëàòêè +int FFF=0;//��� �������� int Pulse_8Point = 0; int Pulse_16Point = 0; @@ -31,21 +28,21 @@ Dif_QEI=0; - Cur_QEI = LPC_QEI->POS & 0xFFFF; // ñ÷èòûâàíèå òåêóùåãî çíà÷åíèÿ ýíêîäåðà. - Dif_QEI = (Cur_QEI - Last_QEI); // ïîëó÷åíèå ïðèðàùåíèÿ.() - Last_QEI = Cur_QEI; // çàïèñü òåêóùåãî çíà÷åíèÿ ýíêîäåðà â ðåãèñòð ïðåäûäóùåãî çíà÷åíèÿ. + Cur_QEI = LPC_QEI->POS & 0xFFFF; // ���������� �������� �������� ��������. + Dif_QEI = (Cur_QEI - Last_QEI); // ��������� ����������.() + Last_QEI = Cur_QEI; // ������ �������� �������� �������� � ������� ����������� ��������. - if (Dif_QEI < -0xfff) Dif_QEI += 0x10000; // îáðàáîòêà ïðîõîäà çíà÷åíèÿ ÷åðåç íîëü - if (Dif_QEI > 0xfff) Dif_QEI -= 0x10000; // îáðàáîòêà ïðîõîäà çíà÷åíèÿ ÷åðåç íîëü + if (Dif_QEI < -0xfff) Dif_QEI += 0x10000; // ��������� ������� �������� ����� ���� + if (Dif_QEI > 0xfff) Dif_QEI -= 0x10000; // ��������� ������� �������� ����� ���� - Buff_1Point[CountV255] = (unsigned int) (Dif_QEI + 0xffff);// íàêîïëåíèå â áóôåð åäåíè÷íûõ çíà÷åíèé ïðèðàùåíèÿ ïî êàæäîìó òàêòó. + Buff_1Point[CountV255] = (unsigned int) (Dif_QEI + 0xffff);// ���������� � ����� ��������� �������� ���������� �� ������� �����. //////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////// - if (LPC_QEI->STAT) //e. "+" direction //r. ñòàëè âðàùàòüñÿ â "+" ñòîðîíó + if (LPC_QEI->STAT) //e. "+" direction //r. ����� ��������� � "+" ������� { Main.Cnt_Mns = Dif_QEI; } @@ -53,28 +50,28 @@ { Main.Cnt_Pls = -Dif_QEI; } - ////////// ???? Çàïëàòêà - ////////// ???? Ïðîáëåìà íà÷àëüíîãî çàïîëíåíèÿ áóôåðîâ + ////////// ???? �������� + ////////// ???? �������� ���������� ���������� ������� ////////////////////////////////////////////////////////////////////////////////////////////// - if(FFF==1) // åñëè ïðîøëî 32 òàêòà âèáðî ïîäâåñà íà÷àòü çàïîëíÿòü îñòàëüíûå áóâåðû. + if(FFF==1) // ���� ������ 32 ����� ����� ������� ������ ��������� ��������� ������. { Pulse_8Point += Buff_1Point[CountV255]; - Pulse_8Point -= Buff_1Point[(CountV255-8) & 0xff]; // çàïîëíåíèå áóôåðà íàêîïëåíûõ ïðèðàùåíèé çà 8 òàêòîâ + Pulse_8Point -= Buff_1Point[(CountV255-8) & 0xff]; // ���������� ������ ���������� ���������� �� 8 ������ Buff_8Point[CountV255] = (unsigned int) (Pulse_8Point + 0xffff); Pulse_16Point += Buff_1Point[CountV255]; - Pulse_16Point -= Buff_1Point[(CountV255-16) & 0xff]; // çàïîëíåíèå áóôåðà íàêîïëåíûõ ïðèðàùåíèé çà 16 òàêòîâ + Pulse_16Point -= Buff_1Point[(CountV255-16) & 0xff]; // ���������� ������ ���������� ���������� �� 16 ������ Buff_16Point[CountV255] = (unsigned int) (Pulse_16Point + 0xffff); Pulse_32Point += Buff_1Point[CountV255]; - Pulse_32Point -= Buff_1Point[(CountV255-32) & 0xff]; // çàïîëíåíèå áóôåðà íàêîïëåíûõ ïðèðàùåíèé çà 32 òàêòîâ + Pulse_32Point -= Buff_1Point[(CountV255-32) & 0xff]; // ���������� ������ ���������� ���������� �� 32 ������ Main.Cnt_Dif = (Pulse_32Point+ 0xffff); Buff_32Point[CountV255] = (unsigned int) (Pulse_32Point + 0xffff); Pulse_16PointD += Buff_1Point[CountV255]; - Pulse_16PointD -= Buff_1Point[(CountV255-16) & 0xff]; // çàïîëíåíèå áóôåðà íàêîïëåíûõ ïðèðàùåíèé çà 16 òàêòîâ Äâîéíûç + Pulse_16PointD -= Buff_1Point[(CountV255-16) & 0xff]; // ���������� ������ ���������� ���������� �� 16 ������ ������� Pulse_16PointD += Buff_1Point[(CountV255-32) & 0xff]; // - Pulse_16PointD -= Buff_1Point[(CountV255-48) & 0xff]; // ç + Pulse_16PointD -= Buff_1Point[(CountV255-48) & 0xff]; // � Buff_16PointD[CountV255] = (unsigned int) (Pulse_16PointD + 0xffff); @@ -104,7 +101,7 @@ } else if(CountV255 == 255) { - FFF=1;//âðåìåííàÿ çàïëàòêà äëÿ ïàóçû ïåðåä çàïîëíåíèåì îñòàëüíûõ áóôåðîâ + FFF=1;//��������� �������� ��� ����� ����� ����������� ��������� ������� for (yy = 0; yy < 256; yy++ ) { Buff_1Point [yy] = 0xffff;