123
Fork of LG by
commandset.c@0:8ad47e2b6f00, 2016-01-30 (annotated)
- Committer:
- igor_v
- Date:
- Sat Jan 30 13:00:39 2016 +0000
- Revision:
- 0:8ad47e2b6f00
- Child:
- 1:f2adcae3d304
2016_01_30;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
igor_v | 0:8ad47e2b6f00 | 1 | #include <string.h> |
igor_v | 0:8ad47e2b6f00 | 2 | #include "commandset.h" |
igor_v | 0:8ad47e2b6f00 | 3 | #include "el_lin.h" |
igor_v | 0:8ad47e2b6f00 | 4 | #include "CyclesSync.h" |
igor_v | 0:8ad47e2b6f00 | 5 | #include "CntrlGLD.h" |
igor_v | 0:8ad47e2b6f00 | 6 | #include "InputOutput.h" |
igor_v | 0:8ad47e2b6f00 | 7 | #include "Parameters.h" |
igor_v | 0:8ad47e2b6f00 | 8 | |
igor_v | 0:8ad47e2b6f00 | 9 | #define COMMAND_DEBUG |
igor_v | 0:8ad47e2b6f00 | 10 | |
igor_v | 0:8ad47e2b6f00 | 11 | //++++++++++++++++debug++++++++++++++++ |
igor_v | 0:8ad47e2b6f00 | 12 | extern uint32_t In_Flag; |
igor_v | 0:8ad47e2b6f00 | 13 | unsigned char BuffTemp1[100]; |
igor_v | 0:8ad47e2b6f00 | 14 | //e. +++++++++++++++++++ variables +++++++++++++++++++++++++++++++++++++++++++ //r. +++++++++++++++++++ ïåðåìåííûå +++++++++++++++++++++++++++++++++++++++++++ |
igor_v | 0:8ad47e2b6f00 | 15 | uint32_t CMD_Mode = 0; //e. operation mode of the device //r. ðåæèì ðàáîòû óñòðîéñòâà |
igor_v | 0:8ad47e2b6f00 | 16 | uint32_t CMD_Code; //e. full code of the last recieved command //r. ïîëíûé êîä ïîñëåäíåé ïðèíÿòîé êîìàíäû |
igor_v | 0:8ad47e2b6f00 | 17 | uint32_t wrk_period; //e. run period in cycles //r. ðàáî÷èé ïåðèîä â öèêëàõ |
igor_v | 0:8ad47e2b6f00 | 18 | uint32_t blt_in_test; |
igor_v | 0:8ad47e2b6f00 | 19 | |
igor_v | 0:8ad47e2b6f00 | 20 | int32_t ScopeMode; //e. mode of display for a control point of an scope //r. ðåæèì îòîáðàæåíèÿ äëÿ êîíòðîëüíîé òî÷êè îñöèëëîãðàôà |
igor_v | 0:8ad47e2b6f00 | 21 | |
igor_v | 0:8ad47e2b6f00 | 22 | |
igor_v | 0:8ad47e2b6f00 | 23 | void SetSpeedPeriod(void) //e.============ procedure of set of rate and periodicity of answer ======== //r.============ ïðîöåäóðà óñòàíîâêè ñêîðîñòè è ïåðèîäè÷íîñòè îòâåòà ======== |
igor_v | 0:8ad47e2b6f00 | 24 | { |
igor_v | 0:8ad47e2b6f00 | 25 | if ((rcv_buf[3] & 0x0080) != 0) //e. is periodic data transmission needed? //r. ïåðèîäè÷åñêàÿ ïåðåäà÷à òðóáóåòñÿ? |
igor_v | 0:8ad47e2b6f00 | 26 | { |
igor_v | 0:8ad47e2b6f00 | 27 | trm_cycl = 1; //e. yes, set present flag //r. äà, óñòàíîâèòü äàííûé ôëàã |
igor_v | 0:8ad47e2b6f00 | 28 | } |
igor_v | 0:8ad47e2b6f00 | 29 | else |
igor_v | 0:8ad47e2b6f00 | 30 | { |
igor_v | 0:8ad47e2b6f00 | 31 | trm_cycl = 0; //e. no, reset present flag //r. íåò, ñáðîñèòü äàííûé ôëàã |
igor_v | 0:8ad47e2b6f00 | 32 | } |
igor_v | 0:8ad47e2b6f00 | 33 | |
igor_v | 0:8ad47e2b6f00 | 34 | SRgR &= 0xffcf; //e. clear the bit of transfer rate //r. î÷èñòêà áèò ñêîðîñòè ïåðåäà÷è |
igor_v | 0:8ad47e2b6f00 | 35 | trm_rate = (rcv_buf[3] >> 1) & 0x0030; |
igor_v | 0:8ad47e2b6f00 | 36 | SRgR |= trm_rate; //e. set present transfer rate //r. óñòàíîâèòü äàííóþ ñêîðîñòü ïåðåäà÷è |
igor_v | 0:8ad47e2b6f00 | 37 | } // SetSpeedPeriod |
igor_v | 0:8ad47e2b6f00 | 38 | |
igor_v | 0:8ad47e2b6f00 | 39 | |
igor_v | 0:8ad47e2b6f00 | 40 | void B_Delta_BINS(void) //r.===ïðîöåäóðà âûäà÷è íàêîïëåííûõ ðàçíîñòåé ñ÷åò÷èêîâ èìïóëüñîâ â ÈÍÑ â ôîðìàòå 14.18 |
igor_v | 0:8ad47e2b6f00 | 41 | { |
igor_v | 0:8ad47e2b6f00 | 42 | Valid_Data = 0; // reset all bits of status word |
igor_v | 0:8ad47e2b6f00 | 43 | |
igor_v | 0:8ad47e2b6f00 | 44 | num_of_par = 2; //e. 2 parameters output //r. âûâîäèòü 2 ïàðàìåòðà |
igor_v | 0:8ad47e2b6f00 | 45 | addr_param[0] = &Output.Str.BINS_dif; //e. set the first parameter address //r. çàäàòü àäðåñ ïåðâîãî ïàðàìåòðà |
igor_v | 0:8ad47e2b6f00 | 46 | addr_param[1] = &Valid_Data; //e. set the second paremeter address //r. çàäàòü àäðåñ âòîðîãî ïàðàìåòðà |
igor_v | 0:8ad47e2b6f00 | 47 | size_param[0] = 4; //e. the length of the 1st parameter is 4 bytes //r. ïàðàìåòð 1 èìåeò äëèíó 4 áàéòà |
igor_v | 0:8ad47e2b6f00 | 48 | size_param[1] = 1; //e. the length of the 2nd parameter is 1 byte (!! - the high byte, instead of low is transmitted) //r. ïàðàìåòð 2 èìååò äëèíó 1 áàéò (!!! ïåðåäàåòñÿ ñòàðøèé áàéò, à íå ìëàäøèé) |
igor_v | 0:8ad47e2b6f00 | 49 | trm_ena = 1; //e. allow operation of the transmitter //r. ðàçðåøèòü ðàáîòó ïåðåäàò÷èêà |
igor_v | 0:8ad47e2b6f00 | 50 | |
igor_v | 0:8ad47e2b6f00 | 51 | } // B_Delta_BINS |
igor_v | 0:8ad47e2b6f00 | 52 | |
igor_v | 0:8ad47e2b6f00 | 53 | void B_Delta_SF(void) //r.=== ïðîöåäóðà äëÿ èçìåðåíèÿ ìàñøòàáíîãî ìíîæèòåëÿ |
igor_v | 0:8ad47e2b6f00 | 54 | { |
igor_v | 0:8ad47e2b6f00 | 55 | //e. time for data transfer has come, we work only with dither counters //r. ïðèøëî âðåìÿ ïåðåäàâàòü äàííûå, ðàáîòàåì òîëüêî ñ âèáðî-ñ÷åò÷èêàìè |
igor_v | 0:8ad47e2b6f00 | 56 | RgConB = RATE_VIBRO_1; //e. set in the additional register of device control the mode of work with dither counters and the filter of moving average //r. óñòàíàâëèâàåì â äîïîëíèòåëüíîì ðåãèñòðå óïðàâëåíèÿ ðåæèì ðàáîòû ñ âèáðîñ÷åò÷èêàìè è ôèëüòðîì ñêîëüçÿùåãî ñðåäíåãî |
igor_v | 0:8ad47e2b6f00 | 57 | |
igor_v | 0:8ad47e2b6f00 | 58 | Valid_Data = 0; // reset all bits of status word |
igor_v | 0:8ad47e2b6f00 | 59 | |
igor_v | 0:8ad47e2b6f00 | 60 | num_of_par = 5;//8; //e. 8 parameters output //r. âûâîäèòü 8 ïàðàìåòðà |
igor_v | 0:8ad47e2b6f00 | 61 | addr_param[0] = &Output.Str.SF_dif; //e. set the first parameter address //r. çàäàòü àäðåñ ïåðâîãî ïàðàìåòðà |
igor_v | 0:8ad47e2b6f00 | 62 | addr_param[1] = &Out_main_cycle_latch; //e. set the second paremeter address //r. çàäàòü àäðåñ âòîðîãî ïàðàìåòðà |
igor_v | 0:8ad47e2b6f00 | 63 | addr_param[2] = &Out_T_latch;//F_ras; |
igor_v | 0:8ad47e2b6f00 | 64 | addr_param[3] = &Output.Str.WP_reg; |
igor_v | 0:8ad47e2b6f00 | 65 | addr_param[4] = &Output.Str.Tmp_Out; |
igor_v | 0:8ad47e2b6f00 | 66 | size_param[0] = 8; //e. the length of the 1st parameter is 4 bytes //r. ïàðàìåòð 1 èìåeò äëèíó 4 áàéòà |
igor_v | 0:8ad47e2b6f00 | 67 | size_param[1] = 4; //e. the length of the 2nd parameter is 1 byte (!! - the high byte, instead of low is transmitted) //r. ïàðàìåòð 2 èìååò äëèíó 1 áàéò (!!! ïåðåäàåòñÿ ñòàðøèé áàéò, à íå ìëàäøèé) |
igor_v | 0:8ad47e2b6f00 | 68 | size_param[2] = 2; |
igor_v | 0:8ad47e2b6f00 | 69 | size_param[3] = 2; |
igor_v | 0:8ad47e2b6f00 | 70 | size_param[4] = 12; |
igor_v | 0:8ad47e2b6f00 | 71 | trm_ena = 1; //e. allow operation of the transmitter //r. ðàçðåøèòü ðàáîòó ïåðåäàò÷èêà |
igor_v | 0:8ad47e2b6f00 | 72 | } // B_Delta_SF |
igor_v | 0:8ad47e2b6f00 | 73 | |
igor_v | 0:8ad47e2b6f00 | 74 | void B_Delta_PS_execution(void) |
igor_v | 0:8ad47e2b6f00 | 75 | { |
igor_v | 0:8ad47e2b6f00 | 76 | static void * paramTable[11] = {&(Output.Str.F_ras) , &(Output.Str.HF_reg), &(Output.Str.T_Vibro), &(Output.Str.L_Vibro), &(Output.Str.WP_reg), &(Output.Str.Tmp_Out[0]), &(Output.Str.Tmp_Out[1]), &(Output.Str.Tmp_Out[2]), &(Output.Str.Tmp_Out[3]), &(Output.Str.Tmp_Out[4]), &(Output.Str.Tmp_Out[5])}; |
igor_v | 0:8ad47e2b6f00 | 77 | static uint32_t val, paramTmpWord; |
igor_v | 0:8ad47e2b6f00 | 78 | static uint32_t * ptr; |
igor_v | 0:8ad47e2b6f00 | 79 | static uint32_t index = 0; |
igor_v | 0:8ad47e2b6f00 | 80 | |
igor_v | 0:8ad47e2b6f00 | 81 | if ((index & 1) == 0) // high byte |
igor_v | 0:8ad47e2b6f00 | 82 | { |
igor_v | 0:8ad47e2b6f00 | 83 | ptr = (uint32_t*)paramTable[index >> 1]; |
igor_v | 0:8ad47e2b6f00 | 84 | val = *ptr; |
igor_v | 0:8ad47e2b6f00 | 85 | paramTmpWord = val >> 8; // move it to low byte of word |
igor_v | 0:8ad47e2b6f00 | 86 | } |
igor_v | 0:8ad47e2b6f00 | 87 | else |
igor_v | 0:8ad47e2b6f00 | 88 | { |
igor_v | 0:8ad47e2b6f00 | 89 | paramTmpWord = val; |
igor_v | 0:8ad47e2b6f00 | 90 | } |
igor_v | 0:8ad47e2b6f00 | 91 | paramTmpWord &= 0xFF; |
igor_v | 0:8ad47e2b6f00 | 92 | paramTmpWord |= index << 8; |
igor_v | 0:8ad47e2b6f00 | 93 | |
igor_v | 0:8ad47e2b6f00 | 94 | Valid_Data = 0; // reset all bits of status word |
igor_v | 0:8ad47e2b6f00 | 95 | |
igor_v | 0:8ad47e2b6f00 | 96 | |
igor_v | 0:8ad47e2b6f00 | 97 | num_of_par = 2; //e. 2 parameters output //r. âûâîäèòü 2 ïàðàìåòðà |
igor_v | 0:8ad47e2b6f00 | 98 | addr_param[0] = &Output.Str.PS_dif; //e. set the first parameter address //r. çàäàòü àäðåñ ïåðâîãî ïàðàìåòðà |
igor_v | 0:8ad47e2b6f00 | 99 | addr_param[1] = ¶mTmpWord; |
igor_v | 0:8ad47e2b6f00 | 100 | size_param[0] = 2; //e. the 1st parameter has 2 bytes length //r. ïàðàìåòð 1 èìåeò äëèíó 2 áàéò |
igor_v | 0:8ad47e2b6f00 | 101 | size_param[1] = 2; //e. the 2nd and 3rd parameters have 1 bytes length//r. ïàðàìåòðû 2,3 èìåþò äëèíó 1 áàéò |
igor_v | 0:8ad47e2b6f00 | 102 | trm_ena = 1; //e. allow operation of the transmitter //r. ðàçðåøèòü ðàáîòó ïåðåäàò÷èêà |
igor_v | 0:8ad47e2b6f00 | 103 | |
igor_v | 0:8ad47e2b6f00 | 104 | index++; |
igor_v | 0:8ad47e2b6f00 | 105 | if (index > 21) |
igor_v | 0:8ad47e2b6f00 | 106 | { |
igor_v | 0:8ad47e2b6f00 | 107 | index = 0; |
igor_v | 0:8ad47e2b6f00 | 108 | } |
igor_v | 0:8ad47e2b6f00 | 109 | } // B_Delta_PS_execution |
igor_v | 0:8ad47e2b6f00 | 110 | |
igor_v | 0:8ad47e2b6f00 | 111 | void M_Mirror(void) //e.---------------- prepare to transmission of the copy of receiving buffer ------------- //r.---------------- ïîäãîòîâêà ïåðåäà÷è êîïèè ïðèåìíîãî áóôåðà ------------- |
igor_v | 0:8ad47e2b6f00 | 112 | { |
igor_v | 0:8ad47e2b6f00 | 113 | num_of_par = 1; //e. 1 parameter output //r. âûâîäèòü 1 ïàðàìåòð |
igor_v | 0:8ad47e2b6f00 | 114 | |
igor_v | 0:8ad47e2b6f00 | 115 | addr_param[0] = &rcv_copy; //e. set the address of the receiving buffer //r. óñòàíîâêà àäðåñà ïðèåìíîãî áóôåðà |
igor_v | 0:8ad47e2b6f00 | 116 | |
igor_v | 0:8ad47e2b6f00 | 117 | //e. multiply the number of copied words on 2, since each //r. óìíîæèòü ÷èñëî ñêîïèðîâàííûõ ñëîâ íà 2, ò.ê. êàæäîå |
igor_v | 0:8ad47e2b6f00 | 118 | //e. will be trasferred in two steps: first zero, and then //r. áóäåò ïåðåäàâàòüñ÷ â äâà ïðèåìà: ñíà÷àëà íóëåâîé, à çàòåì |
igor_v | 0:8ad47e2b6f00 | 119 | size_param[0] = rcv_byt_copy << 1; // multiplay by 2 |
igor_v | 0:8ad47e2b6f00 | 120 | if (size_param[0] >= 64) |
igor_v | 0:8ad47e2b6f00 | 121 | { |
igor_v | 0:8ad47e2b6f00 | 122 | size_param[0] = 64; //e. maximal amount - no more than double length of the copy buffer //r. ìàêñèìàëüíîå êîëè÷åñòâî - íå áîëåå äâîéíîé äëèíû áóôåðà-êîïèè |
igor_v | 0:8ad47e2b6f00 | 123 | } |
igor_v | 0:8ad47e2b6f00 | 124 | trm_rate = 0; //e. set the transfer rate to the 38400 bauds //r. óñòàíîâèòü ñêîðîñòü ïåðåäà÷è 38400 áîä |
igor_v | 0:8ad47e2b6f00 | 125 | trm_cycl = 0; //e. forbid cyclic transmission of the parameter //r. çàïðåòèòü ïåðåäà÷ó ïàðàìåòðà â öèêëå |
igor_v | 0:8ad47e2b6f00 | 126 | trm_ena = 1; //e. allow operation of the transmitter //r. ðàçðåøèòü ðàáîòó ïåðåäàò÷èêà |
igor_v | 0:8ad47e2b6f00 | 127 | } // M_Mirror |
igor_v | 0:8ad47e2b6f00 | 128 | |
igor_v | 0:8ad47e2b6f00 | 129 | void Mk_Ask1(void) //r.----------------- prepare of the standart answer 1 ---------------------- //r.----------------- ïîäãîòîâêà ñòàíäàðòíîãî îòâåòà 1 ---------------------- |
igor_v | 0:8ad47e2b6f00 | 130 | { |
igor_v | 0:8ad47e2b6f00 | 131 | CMD_Code &= 0xff00; //e. clear bits of errors //r. î÷èñòèòü â íåì ïîëå îøèáîê |
igor_v | 0:8ad47e2b6f00 | 132 | num_of_par = 1; //e. total amount parameters in aswer - 1 //r. âñåãî ïàðàìåòðîâ â îòâåòå - 1 |
igor_v | 0:8ad47e2b6f00 | 133 | addr_param[0] = &CMD_Code; //e. and this parameter - returnable command code //r. è ýòîò ïàðàìåòð - âîçâðàùàåìûé êîä êîìàíäû |
igor_v | 0:8ad47e2b6f00 | 134 | size_param[0] = 2; //e. and both its bytes //r. ïðè÷åì îáà åãî áàéòà |
igor_v | 0:8ad47e2b6f00 | 135 | trm_ena = 1; //e. allow operation of the transmitter of the device //r. ðàçðåøèòü ðàáîòó ïåðåäàò÷èêà óñòðîéñòâà |
igor_v | 0:8ad47e2b6f00 | 136 | } // Mk_Ask1 |
igor_v | 0:8ad47e2b6f00 | 137 | |
igor_v | 0:8ad47e2b6f00 | 138 | void Mk_AskDev(void) //r.----------------- answer on a command for device mode set ------------ //r.----------------- Îòâåò íà êîìàíäó óñòàíîâêè ðåæèìà ïðèáîðà ------------ |
igor_v | 0:8ad47e2b6f00 | 139 | { |
igor_v | 0:8ad47e2b6f00 | 140 | num_of_par = 2; //e. 2 parameters output //r. âûâîäèòü äâà ïàðàìåòðà |
igor_v | 0:8ad47e2b6f00 | 141 | addr_param[0] = &Device_Mode; //e. address of the counter mode register (intenal latch, external latch, etc.) //r. àäðåñ ðåãèñòðà ðåæèìà ñ÷åò÷èêîâ (âíóòð., âíåøíÿÿ çàùåëêà è ò.ä.) |
igor_v | 0:8ad47e2b6f00 | 142 | addr_param[1] = &SRgR; //e. address of the mode register of the processor card //r. àäðåñ ðåãèñòðà ðåæèìà ïëàòû ïðîöåññîðà |
igor_v | 0:8ad47e2b6f00 | 143 | size_param[0] = 2; //e. size of the counter mode register - 2 bytes //r. ðàçìåð ðåãèñòðà ðåæèìà ñ÷åò÷èêîâ - 2 áàéòà |
igor_v | 0:8ad47e2b6f00 | 144 | size_param[1] = 2; //e. size of the mode register of the processor card //r. ðàçìåð ðåãèñòðà ðåæèìà ïëàòû ïðîöåññîðà |
igor_v | 0:8ad47e2b6f00 | 145 | trm_cycl = 0; //e. forbid cyclic transmission of the parameter //r. çàïðåòèòü ïåðåäà÷ó ïàðàìåòðà â öèêëå |
igor_v | 0:8ad47e2b6f00 | 146 | trm_ena = 1; //e. allow operation of the transmitter //r. ðàçðåøèòü ðàáîòó ïåðåäàò÷èêà |
igor_v | 0:8ad47e2b6f00 | 147 | } // Mk_AskDev |
igor_v | 0:8ad47e2b6f00 | 148 | |
igor_v | 0:8ad47e2b6f00 | 149 | void GLD_Output(void) //e. ----------- Output modes --------- //r. --------- Ðåæèìû âûâîäà --------- |
igor_v | 0:8ad47e2b6f00 | 150 | { |
igor_v | 0:8ad47e2b6f00 | 151 | if (Latch_Rdy) //latch appeared |
igor_v | 0:8ad47e2b6f00 | 152 | { |
igor_v | 0:8ad47e2b6f00 | 153 | if (trm_cycl) |
igor_v | 0:8ad47e2b6f00 | 154 | trm_ena = 1; //enable packet generation |
igor_v | 0:8ad47e2b6f00 | 155 | |
igor_v | 0:8ad47e2b6f00 | 156 | switch (CMD_Mode) |
igor_v | 0:8ad47e2b6f00 | 157 | { |
igor_v | 0:8ad47e2b6f00 | 158 | case 1: //e. Delta _PS mode |
igor_v | 0:8ad47e2b6f00 | 159 | B_Delta_PS_execution(); |
igor_v | 0:8ad47e2b6f00 | 160 | break; |
igor_v | 0:8ad47e2b6f00 | 161 | |
igor_v | 0:8ad47e2b6f00 | 162 | case 5: |
igor_v | 0:8ad47e2b6f00 | 163 | CMD_Code &= 0xff1f; //e. reset bits of current command code settings of periodicity and transfer rate //r. ñáðîñèòü â òåêóùåì êîäå êîìàíäû áèòû óñòàíîâêè ïåðèîäè÷íîñòè è ñêîðîñòè ïåðåäà÷è |
igor_v | 0:8ad47e2b6f00 | 164 | if (CMD_Code == 0xdd02) //e. is it the Rate2 mode? //r. ýòî ðåæèì Rate2? |
igor_v | 0:8ad47e2b6f00 | 165 | { |
igor_v | 0:8ad47e2b6f00 | 166 | if (data_Rdy & WHOLE_PERIOD) |
igor_v | 0:8ad47e2b6f00 | 167 | { |
igor_v | 0:8ad47e2b6f00 | 168 | trm_ena = 1; |
igor_v | 0:8ad47e2b6f00 | 169 | } |
igor_v | 0:8ad47e2b6f00 | 170 | else |
igor_v | 0:8ad47e2b6f00 | 171 | trm_ena = 0; |
igor_v | 0:8ad47e2b6f00 | 172 | } |
igor_v | 0:8ad47e2b6f00 | 173 | break; |
igor_v | 0:8ad47e2b6f00 | 174 | } |
igor_v | 0:8ad47e2b6f00 | 175 | } |
igor_v | 0:8ad47e2b6f00 | 176 | } // GLD_Delta |
igor_v | 0:8ad47e2b6f00 | 177 | |
igor_v | 0:8ad47e2b6f00 | 178 | |
igor_v | 0:8ad47e2b6f00 | 179 | |
igor_v | 0:8ad47e2b6f00 | 180 | ///// -------- commands ------------------------------------------------------------- |
igor_v | 0:8ad47e2b6f00 | 181 | //e. set main device operation modes: //r. Óñòàíîâêà îñíîâíûõ ðåæèìîâ ðàáîòû ïðèáîðà: |
igor_v | 0:8ad47e2b6f00 | 182 | //e. 1. acions with counters (internal latch, external latch with request over line, //r. 1. ðàáîòà ñî ñ÷åò÷èêàìè (âíóòðåííÿÿ çàùåëêà, âíåøíÿÿ çàùåëêè ñ çàïðîñîì ïî ëèíèè, |
igor_v | 0:8ad47e2b6f00 | 183 | //e. external latch without request over line (instant answer after receiving of external latch pulse)) //r. âíåøíÿÿ çàùåëêà áåç çàïðîñà ïî ëèíèè (îòâåò ñðàçó ïîñëå ïðèõîäà èìïóëüñà âíåøí. çàùåëêè)) |
igor_v | 0:8ad47e2b6f00 | 184 | //e. 2. line receiving/transmission rate //r. 2. ñêîðîñòü ïðèåìà/ïåðåäà÷è ïî ëèíèè |
igor_v | 0:8ad47e2b6f00 | 185 | void B_Dev_Mode(void) |
igor_v | 0:8ad47e2b6f00 | 186 | { |
igor_v | 0:8ad47e2b6f00 | 187 | Device_Mode = rcv_buf[3] & 0x00ff; //e. read the byte of command parameter from the receiver buffer //r. ñ÷èòàòü èç áóôåðà ïðèåìíèêà áàéò ïàðàìåòðà êîìàíäû |
igor_v | 0:8ad47e2b6f00 | 188 | //e. and write it to the counter mode register //r. è çàïèñûâàåì â ðåãèñòð ðåæèìà ñ÷åò÷èêîâ |
igor_v | 0:8ad47e2b6f00 | 189 | trm_cycl = 0; //e. periodic data transmission is not needed //r. ïåðèîäè÷åñêàÿ ïåðåäà÷à îòâåòà íå òðåáóåòñÿ |
igor_v | 0:8ad47e2b6f00 | 190 | Mk_AskDev(); |
igor_v | 0:8ad47e2b6f00 | 191 | } // B_Dev_Mode |
igor_v | 0:8ad47e2b6f00 | 192 | |
igor_v | 0:8ad47e2b6f00 | 193 | void B_BIT_Mode(void) |
igor_v | 0:8ad47e2b6f00 | 194 | { |
igor_v | 0:8ad47e2b6f00 | 195 | uint8_t temp; |
igor_v | 0:8ad47e2b6f00 | 196 | |
igor_v | 0:8ad47e2b6f00 | 197 | temp = rcv_buf[3] & 0x000f & (~((rcv_buf[3] & 0x00f0) >> 4)); |
igor_v | 0:8ad47e2b6f00 | 198 | if (temp == 1) // 1 - const test |
igor_v | 0:8ad47e2b6f00 | 199 | { |
igor_v | 0:8ad47e2b6f00 | 200 | Is_BIT = 1; |
igor_v | 0:8ad47e2b6f00 | 201 | BIT_number = (long)(rcv_buf[4] & 0x00FF) << 24; |
igor_v | 0:8ad47e2b6f00 | 202 | BIT_number |= (long)(rcv_buf[5] & 0x00FF) << 16; |
igor_v | 0:8ad47e2b6f00 | 203 | BIT_number |= (long)(rcv_buf[6] & 0x00FF) << 8; |
igor_v | 0:8ad47e2b6f00 | 204 | BIT_number |= (long)(rcv_buf[7] & 0x00FF); |
igor_v | 0:8ad47e2b6f00 | 205 | } |
igor_v | 0:8ad47e2b6f00 | 206 | else |
igor_v | 0:8ad47e2b6f00 | 207 | { |
igor_v | 0:8ad47e2b6f00 | 208 | Is_BIT = 0; |
igor_v | 0:8ad47e2b6f00 | 209 | } |
igor_v | 0:8ad47e2b6f00 | 210 | trm_cycl = 0; //e. periodic data transmission is not needed //r. ïåðèîäè÷åñêàÿ ïåðåäà÷à îòâåòà íå òðåáóåòñÿ |
igor_v | 0:8ad47e2b6f00 | 211 | Mk_AskDev(); |
igor_v | 0:8ad47e2b6f00 | 212 | } // B_BIT_Mode |
igor_v | 0:8ad47e2b6f00 | 213 | |
igor_v | 0:8ad47e2b6f00 | 214 | void M_Stimul(void) //e. === procedure of output of analog (DAC) and digital (flags) stimuluses //r. === ïðîöåäóðà âûâîäà àíàëîãîâûõ (ÖÀÏ) è äèñêðåòíûõ (ôëàãè) ñòèìóëîâ |
igor_v | 0:8ad47e2b6f00 | 215 | { |
igor_v | 0:8ad47e2b6f00 | 216 | uint32_t chan; |
igor_v | 0:8ad47e2b6f00 | 217 | |
igor_v | 0:8ad47e2b6f00 | 218 | ScopeMode = 4; //e. WP_PHASE_DETECTOR allocate a mode of display for a control point of an scope //r. WP_PHASE_DETECTOR íàçíà÷èòü ðåæèì îòîáðàæåíèÿ äëÿ êîíòðîëüíîé òî÷êè îñöèëëîãðàôà |
igor_v | 0:8ad47e2b6f00 | 219 | |
igor_v | 0:8ad47e2b6f00 | 220 | chan = CMD_Code & 0x0007; //e. extracting the number of stimulus //r. âûäåëåíèå íîìåðà ñòèìóëà |
igor_v | 0:8ad47e2b6f00 | 221 | |
igor_v | 0:8ad47e2b6f00 | 222 | Output.ArrayOut[chan] = (((int)rcv_buf[4] << 8) | (int)rcv_buf[5])-0x8000; |
igor_v | 0:8ad47e2b6f00 | 223 | |
igor_v | 0:8ad47e2b6f00 | 224 | if ((CMD_Code & (1 << 7)) == 0) //e. to estimate: whether the answer is required //r. îöåíèòü: òðåáóåòñÿ ëè îòâåò |
igor_v | 0:8ad47e2b6f00 | 225 | { |
igor_v | 0:8ad47e2b6f00 | 226 | return; //e. if no - return //r. åñëè íåò - âîçâðàò |
igor_v | 0:8ad47e2b6f00 | 227 | } |
igor_v | 0:8ad47e2b6f00 | 228 | Mk_Ask1(); //e. otherwise - answer output //r. èíà÷å - âûäàòü îòâåò |
igor_v | 0:8ad47e2b6f00 | 229 | } // M_Stymul |
igor_v | 0:8ad47e2b6f00 | 230 | |
igor_v | 0:8ad47e2b6f00 | 231 | void M_Status(void) //e. === procedure of initialization of transmission of the device status //r. === ïðîöåäóðà èíèöèàëèçàöèè ïåðåäà÷è ñòàòóñà óñòðîéñòâà |
igor_v | 0:8ad47e2b6f00 | 232 | { |
igor_v | 0:8ad47e2b6f00 | 233 | SetSpeedPeriod(); //e. and set the answer transfer rate and its periodicity //r. è óñòàíîâèòü ñêîðîñòü ïåðåäà÷è îòâåòà è åãî ïåðèîäè÷íîñòü |
igor_v | 0:8ad47e2b6f00 | 234 | |
igor_v | 0:8ad47e2b6f00 | 235 | num_of_par = 2; //e. 2 parameters output //r. âûâîäèòü äâà ïàðàìåòðà |
igor_v | 0:8ad47e2b6f00 | 236 | addr_param[0] = &blt_in_test; //e. the register address of the self-testing result //r. àäðåñ ðåãèñòðà ðåçóëüòàòà ñàìîòåñòèðîâàíèÿ |
igor_v | 0:8ad47e2b6f00 | 237 | addr_param[1] = &ser_num; //e. address of the register of errors of line //r. àäðåñ ðåãèñòðà îøèáîê ëèíèè |
igor_v | 0:8ad47e2b6f00 | 238 | size_param[0] = 2; //e. size of the self-test register - 2 bytes //r. ðàçìåð ðåãèñòðà ñàìîòåñòèðîâàíèÿ - 2 áàéòà |
igor_v | 0:8ad47e2b6f00 | 239 | size_param[1] = 2; //e. size of the register of errors of line //r. ðàçìåð ðåãèñòðà îøèáîê ëèíèè |
igor_v | 0:8ad47e2b6f00 | 240 | |
igor_v | 0:8ad47e2b6f00 | 241 | trm_rate = 0; //e. set the transfer rate to the 38400 bauds //r. óñòàíîâèòü ñêîðîñòü ïåðåäà÷è 38400 áîä |
igor_v | 0:8ad47e2b6f00 | 242 | trm_cycl = 0; //e. forbid cyclic transmission of the parameter //r. çàïðåòèòü ïåðåäà÷ó ïàðàìåòðà â öèêëå |
igor_v | 0:8ad47e2b6f00 | 243 | trm_ena = 1; //e. allow operation of the transmitter //r. ðàçðåøèòü ðàáîòó ïåðåäàò÷èêà |
igor_v | 0:8ad47e2b6f00 | 244 | } // M_Status |
igor_v | 0:8ad47e2b6f00 | 245 | |
igor_v | 0:8ad47e2b6f00 | 246 | void M_Clear(void) //e.---------------- cleaning of the register of errors of line -------------------------- //r.---------------- î÷èñòêà ðåãèñòðà îøèáîê ëèíèè -------------------------- |
igor_v | 0:8ad47e2b6f00 | 247 | { |
igor_v | 0:8ad47e2b6f00 | 248 | line_err = 0; |
igor_v | 0:8ad47e2b6f00 | 249 | } // M_Clear |
igor_v | 0:8ad47e2b6f00 | 250 | |
igor_v | 0:8ad47e2b6f00 | 251 | void M_Tmp_W(void) //e.----------------- write the command to the AD7714 IC ------------------------- //r.----------------- çàïèñü êîìàíäû â ñõåìû AD7714 ------------------------- |
igor_v | 0:8ad47e2b6f00 | 252 | { |
igor_v | 0:8ad47e2b6f00 | 253 | |
igor_v | 0:8ad47e2b6f00 | 254 | Mk_Ask1(); |
igor_v | 0:8ad47e2b6f00 | 255 | } |
igor_v | 0:8ad47e2b6f00 | 256 | |
igor_v | 0:8ad47e2b6f00 | 257 | void M_Tmp_R(void) //e.----------------- read the data from the AD7714 IC -------------------------- //r.----------------- ÷òåíèå äàííûõ èç ñõåì AD7714 -------------------------- |
igor_v | 0:8ad47e2b6f00 | 258 | { |
igor_v | 0:8ad47e2b6f00 | 259 | |
igor_v | 0:8ad47e2b6f00 | 260 | } // M_Tmp_R |
igor_v | 0:8ad47e2b6f00 | 261 | |
igor_v | 0:8ad47e2b6f00 | 262 | void M_ADC_R(void) //e.----------------- read the data from the ADCs ADS1250, ADS8321 --------- //r.----------------- ÷òåíèå äàííûõ èç êàíàëîâ ÀÖÏ ADS1250, ADS8321 --------- |
igor_v | 0:8ad47e2b6f00 | 263 | { |
igor_v | 0:8ad47e2b6f00 | 264 | SetSpeedPeriod(); //e. set the answer transfer rate and its periodicity //r. óñòàíîâèòü ñêîðîñòü ïåðåäà÷è îòâåòà è åãî ïåðèîäè÷íîñòü |
igor_v | 0:8ad47e2b6f00 | 265 | UART_SwitchSpeed(trm_rate); |
igor_v | 0:8ad47e2b6f00 | 266 | |
igor_v | 0:8ad47e2b6f00 | 267 | num_of_par = 4; //e. 4 parameters output //r. âûâîäèòü ÷åòûðå ïàðàìåòðà |
igor_v | 0:8ad47e2b6f00 | 268 | addr_param[0] = 0; //e. //r. <!-- èñïîëüçîâàëèñü äëÿ ÄÓÏ, òåïåðü íå èñïîëüçóþòñÿ |
igor_v | 0:8ad47e2b6f00 | 269 | addr_param[1] = 0; //e. //r. --> |
igor_v | 0:8ad47e2b6f00 | 270 | addr_param[2] = 0; |
igor_v | 0:8ad47e2b6f00 | 271 | addr_param[3] = &(Input.StrIn.HF_out); //e. set the 4th parameter address _HF_out //r. çàäàòü àäðåñ ÷åòâåðòîãî ïàðàìåòðà _HF_out |
igor_v | 0:8ad47e2b6f00 | 272 | size_param[0] = 2; //e. size of the parameters - 2 bytes //r. ðàçìåð ïàðàìåòðîâ - 2 áàéòà |
igor_v | 0:8ad47e2b6f00 | 273 | size_param[1] = 2; |
igor_v | 0:8ad47e2b6f00 | 274 | size_param[2] = 2; |
igor_v | 0:8ad47e2b6f00 | 275 | size_param[3] = 2; |
igor_v | 0:8ad47e2b6f00 | 276 | trm_ena = 1; //e. allow operation of the transmitter //r. ðàçðåøèòü ðàáîòó ïåðåäàò÷èêà |
igor_v | 0:8ad47e2b6f00 | 277 | } // M_ADC_R |
igor_v | 0:8ad47e2b6f00 | 278 | |
igor_v | 0:8ad47e2b6f00 | 279 | void M_Cnt_R(void) //r.----------------- read the counters of the Elio5 card -------------------------- //r.----------------- ÷òåíèå ñ÷åò÷èêîâ ïëàòû Elio5 -------------------------- |
igor_v | 0:8ad47e2b6f00 | 280 | { |
igor_v | 0:8ad47e2b6f00 | 281 | SetSpeedPeriod(); //e. set the answer transfer rate and its periodicity //r. óñòàíîâèòü ñêîðîñòü ïåðåäà÷è îòâåòà è åãî ïåðèîäè÷íîñòü |
igor_v | 0:8ad47e2b6f00 | 282 | UART_SwitchSpeed(trm_rate); |
igor_v | 0:8ad47e2b6f00 | 283 | num_of_par = 2; //e. 2 parameters output //r. âûâîäèòü äâà ïàðàìåòðà |
igor_v | 0:8ad47e2b6f00 | 284 | |
igor_v | 0:8ad47e2b6f00 | 285 | addr_param[0] = &(Output.Str.Cnt_Pls); //e. set the first parameter address //r. çàäàòü àäðåñ ïåðâîãî ïàðàìåòðà |
igor_v | 0:8ad47e2b6f00 | 286 | addr_param[1] = &(Output.Str.Cnt_Mns); //e. set the second paremeter address //r. çàäàòü àäðåñ âòîðîãî ïàðàìåòðà |
igor_v | 0:8ad47e2b6f00 | 287 | size_param[0] = 2; //e. size of the parameters - 2 bytes //r. ðàçìåð ïàðàìåòðîâ - 2 áàéòà |
igor_v | 0:8ad47e2b6f00 | 288 | size_param[1] = 2; |
igor_v | 0:8ad47e2b6f00 | 289 | trm_ena = 1; //e. allow operation of the transmitter //r. ðàçðåøèòü ðàáîòó ïåðåäàò÷èêà |
igor_v | 0:8ad47e2b6f00 | 290 | } // M_Cnt_R |
igor_v | 0:8ad47e2b6f00 | 291 | |
igor_v | 0:8ad47e2b6f00 | 292 | /*void M_e5r_W(void) //r.----------------- write to the mode register of the Elio5 card ------------------ //r.----------------- çàïèñü â ðåãèñòð ðåæèìà ïëàòû Elio5 ------------------ |
igor_v | 0:8ad47e2b6f00 | 293 | { |
igor_v | 0:8ad47e2b6f00 | 294 | //e. read the byte of command parameter from the receiver buffer //r. ñ÷èòàòü èç áóôåðà ïðèåìíèêà áàéò ïàðàìåòðà êîìàíäû |
igor_v | 0:8ad47e2b6f00 | 295 | //e. and write it to the card mode register and its copy //r. è çàïèñàòü åãî â ðåãèñòð ðåæèìà ïëàòû è â åãî êîïèþ |
igor_v | 0:8ad47e2b6f00 | 296 | #if !defined COMMAND_DEBUG |
igor_v | 0:8ad47e2b6f00 | 297 | Copy_e5_RgR = rcv_buf[3]; |
igor_v | 0:8ad47e2b6f00 | 298 | io_space_write(E5_RGR, Copy_e5_RgR); |
igor_v | 0:8ad47e2b6f00 | 299 | #endif |
igor_v | 0:8ad47e2b6f00 | 300 | trm_cycl = 0; //e. periodic data transmission is not needed //r. ïåðèîäè÷åñêàÿ ïåðåäà÷à îòâåòà íå òðåáóåòñÿ |
igor_v | 0:8ad47e2b6f00 | 301 | Mk_Ask1(); |
igor_v | 0:8ad47e2b6f00 | 302 | } // M_e5r_W */ |
igor_v | 0:8ad47e2b6f00 | 303 | /* |
igor_v | 0:8ad47e2b6f00 | 304 | void M_e5rA_W(void) //e.----- write to the 1st additional mode register of the Elio5 card ---------- //r.----- çàïèñü â 1-ûé äîïîëíèòåëüíûé ðåãèñòð ðåæèìà ïëàòû Elio5 ---------- |
igor_v | 0:8ad47e2b6f00 | 305 | { |
igor_v | 0:8ad47e2b6f00 | 306 | //e. this command is used for switching a signal on which data counters are latched: //r. ýòà êîìàíäà èñïîëüçóåòñÿ äëÿ ïåðåêëþ÷åíèÿ ñèãíàëà, ïî êîòîðîìó çàùåëêèâàþòñÿ |
igor_v | 0:8ad47e2b6f00 | 307 | //e. on the Reper signal or on Sign Meander //r. èíôîðìàöèîííûå ñ÷åò÷èêè: ëèáî ïî Reper`ó ëèáî ïî RefMeandr`ó |
igor_v | 0:8ad47e2b6f00 | 308 | |
igor_v | 0:8ad47e2b6f00 | 309 | //e. read the byte of command parameter from the receiver buffer //r. ñ÷èòàòü èç áóôåðà ïðèåìíèêà áàéò ïàðàìåòðà êîìàíäû |
igor_v | 0:8ad47e2b6f00 | 310 | //e. and write it to the card mode register and its copy //r. è çàïèñàòü åãî â ðåãèñòð ðåæèìà ïëàòû è â åãî êîïèþ |
igor_v | 0:8ad47e2b6f00 | 311 | Copy_e5_RgRA = rcv_buf[3]; |
igor_v | 0:8ad47e2b6f00 | 312 | //??? Device_Mode = Copy_e5_RgRA; //e. and write it to the counter mode register //r. è çàïèñûâàåì â ðåãèñòð ðåæèìà ñ÷åò÷èêîâ |
igor_v | 0:8ad47e2b6f00 | 313 | #if !defined COMMAND_DEBUG |
igor_v | 0:8ad47e2b6f00 | 314 | io_space_write(E5_RGRA, Copy_e5_RgRA); |
igor_v | 0:8ad47e2b6f00 | 315 | #endif |
igor_v | 0:8ad47e2b6f00 | 316 | trm_cycl = 0; //e. periodic data transmission is not needed //r. ïåðèîäè÷åñêàÿ ïåðåäà÷à îòâåòà íå òðåáóåòñÿ |
igor_v | 0:8ad47e2b6f00 | 317 | Mk_Ask1(); |
igor_v | 0:8ad47e2b6f00 | 318 | } // M_e5rA_W */ |
igor_v | 0:8ad47e2b6f00 | 319 | |
igor_v | 0:8ad47e2b6f00 | 320 | void M_Ctl_R(void) //r.----------------- reading the control register of the device ----------------- //r.----------------- ÷òåíèå ðåãèñòðà óïðàâëåíèÿ óñòðîéñòâà ----------------- |
igor_v | 0:8ad47e2b6f00 | 321 | { |
igor_v | 0:8ad47e2b6f00 | 322 | num_of_par = 2; //e. 2 parameters transfer //r. ïåðåäàâàòü 2 ïàðàìåòðà |
igor_v | 0:8ad47e2b6f00 | 323 | addr_param[0] = &CMD_Code; //e. the first parameter in answer - returned command code //r. ïåðâûé ïàðàìåòð â îòâåòå - âîçâðàùàåìûé êîä êîìàíäû |
igor_v | 0:8ad47e2b6f00 | 324 | size_param[0] = 2; |
igor_v | 0:8ad47e2b6f00 | 325 | size_param[1] = 2; //e. two bytes also have control registers //r. äâà áàéòà èìåþò òàêæå è ðåãèñòðû óïðàâëåíèÿ |
igor_v | 0:8ad47e2b6f00 | 326 | if ((rcv_buf[3] & (1 << 4)) == 0) //e. is main control register needed? //r. òðåáóåòñÿ îñíîâíîé ðåãèñòð óïðàâëåíèÿ? |
igor_v | 0:8ad47e2b6f00 | 327 | { |
igor_v | 0:8ad47e2b6f00 | 328 | addr_param[1] = &RgConA; //e. yes //r. äà |
igor_v | 0:8ad47e2b6f00 | 329 | } |
igor_v | 0:8ad47e2b6f00 | 330 | else |
igor_v | 0:8ad47e2b6f00 | 331 | { |
igor_v | 0:8ad47e2b6f00 | 332 | addr_param[1] = &RgConB; //e. otherwise - load the address of the addititonal register //r. èíà÷å - çàãðóçèòü àäðåñ äîïîëíèòåëüíîãî ðåãèñòðà |
igor_v | 0:8ad47e2b6f00 | 333 | } |
igor_v | 0:8ad47e2b6f00 | 334 | CMD_Code &= 0xff10; //e. clear in it bit of errors and byte number //r. ñáðîñèòü â íåì ïîëÿ îøèáîê è íîìåðà áèòà |
igor_v | 0:8ad47e2b6f00 | 335 | trm_ena = 1; //e. allow operation of the transmitter of line //r. ðàçðåøèòü ðàáîòó ïåðåäàò÷èêà ëèíèè |
igor_v | 0:8ad47e2b6f00 | 336 | } // M_Ctl_R |
igor_v | 0:8ad47e2b6f00 | 337 | |
igor_v | 0:8ad47e2b6f00 | 338 | void M_Ctl_M(void) //r.----------------- modification of the control register of the device ------------ //r.----------------- ìîäèôèêàöèÿ ðåãèñòðà óïðàâëåíèÿ óñòðîéñòâà ------------ |
igor_v | 0:8ad47e2b6f00 | 339 | { |
igor_v | 0:8ad47e2b6f00 | 340 | uint32_t * ptr; |
igor_v | 0:8ad47e2b6f00 | 341 | uint32_t bit_numb; |
igor_v | 0:8ad47e2b6f00 | 342 | |
igor_v | 0:8ad47e2b6f00 | 343 | num_of_par = 2; //e. 2 parameters transfer //r. ïåðåäàâàòü 2 ïàðàìåòðà |
igor_v | 0:8ad47e2b6f00 | 344 | addr_param[0] = &CMD_Code; //e. the first parameter in answer - returned command code //r. ïåðâûé ïàðàìåòð â îòâåòå - âîçâðàùàåìûé êîä êîìàíäû |
igor_v | 0:8ad47e2b6f00 | 345 | size_param[0] = 2; |
igor_v | 0:8ad47e2b6f00 | 346 | size_param[1] = 2; //e. two bytes also have control registers //r. äâà áàéòà èìåþò òàêæå è ðåãèñòðû óïðàâëåíèÿ |
igor_v | 0:8ad47e2b6f00 | 347 | if ((CMD_Code & (1 << 4)) == 0) //e. is main control register needed? //r. òðåáóåòñÿ îñíîâíîé ðåãèñòð óïðàâëåíèÿ? |
igor_v | 0:8ad47e2b6f00 | 348 | { |
igor_v | 0:8ad47e2b6f00 | 349 | ptr = &RgConA; //e. yes //r. äà |
igor_v | 0:8ad47e2b6f00 | 350 | } |
igor_v | 0:8ad47e2b6f00 | 351 | else |
igor_v | 0:8ad47e2b6f00 | 352 | { |
igor_v | 0:8ad47e2b6f00 | 353 | ptr = &RgConB; //e. otherwise - load the address of the addititonal register //r. èíà÷å - çàãðóçèòü àäðåñ äîïîëíèòåëüíîãî ðåãèñòðà |
igor_v | 0:8ad47e2b6f00 | 354 | } |
igor_v | 0:8ad47e2b6f00 | 355 | addr_param[1] = ptr; //e. the second parameter in answer - modified register //r. âòîðîé ïàðàìåòð â îòâåòå - ìîäèôèöèðîâàííûé ðåãèñòð |
igor_v | 0:8ad47e2b6f00 | 356 | |
igor_v | 0:8ad47e2b6f00 | 357 | bit_numb = CMD_Code & 0x000f; //e. extract the number of the changeable bit //r. âûäåëèòü íîìåð èçìåíÿåìîãî áèòà |
igor_v | 0:8ad47e2b6f00 | 358 | if ((CMD_Code & (1 << 7)) == 0) // Is clear bit |
igor_v | 0:8ad47e2b6f00 | 359 | { |
igor_v | 0:8ad47e2b6f00 | 360 | *ptr &= ~(1 << bit_numb); // yes, clear bit |
igor_v | 0:8ad47e2b6f00 | 361 | } |
igor_v | 0:8ad47e2b6f00 | 362 | else |
igor_v | 0:8ad47e2b6f00 | 363 | { |
igor_v | 0:8ad47e2b6f00 | 364 | *ptr |= 1 << bit_numb; // no, set bit |
igor_v | 0:8ad47e2b6f00 | 365 | } |
igor_v | 0:8ad47e2b6f00 | 366 | |
igor_v | 0:8ad47e2b6f00 | 367 | CMD_Code &= 0xff10; //e. clear in command bit of errors and byte number //r. ñáðîñèòü â êîìàíäå ïîëÿ îøèáîê è íîìåðà áèòà |
igor_v | 0:8ad47e2b6f00 | 368 | trm_cycl = 0; //e. forbid cyclic transmission of the parameter //r. çàïðåòèòü ïåðåäà÷ó ïàðàìåòðà â öèêëå |
igor_v | 0:8ad47e2b6f00 | 369 | trm_ena = 1; //e. allow operation of the transmitter of line //r. ðàçðåøèòü ðàáîòó ïåðåäàò÷èêà ëèíèè |
igor_v | 0:8ad47e2b6f00 | 370 | } // M_Ctl_M |
igor_v | 0:8ad47e2b6f00 | 371 | |
igor_v | 0:8ad47e2b6f00 | 372 | void M_Flg_R(void) //e.------------ reading the register of input flags --------------------------- //r.------------ ÷òåíèå ðåãèñòðà âõîäíûõ ôëàãîâ --------------------------- |
igor_v | 0:8ad47e2b6f00 | 373 | { |
igor_v | 0:8ad47e2b6f00 | 374 | |
igor_v | 0:8ad47e2b6f00 | 375 | num_of_par = 1; //e. 1 parameter output //r. âûâîäèòü îäèí ïàðàìåòð |
igor_v | 0:8ad47e2b6f00 | 376 | addr_param[0] = &In_Flag; //e. the address of the flag register copy //r. àäðåñ êîïèè ðåãèñòðà ôëàãîâ |
igor_v | 0:8ad47e2b6f00 | 377 | size_param[0] = 2; //e. size of the buffer - 2 bytes //r. ðàçìåð áóôåðà - 2 áàéòà |
igor_v | 0:8ad47e2b6f00 | 378 | trm_ena = 1; //e. allow operation of the transmitter //r. ðàçðåøèòü ðàáîòó ïåðåäàò÷èêà |
igor_v | 0:8ad47e2b6f00 | 379 | |
igor_v | 0:8ad47e2b6f00 | 380 | } // M_Flg_R |
igor_v | 0:8ad47e2b6f00 | 381 | |
igor_v | 0:8ad47e2b6f00 | 382 | void M_Vib_W(void) //r.------------ set the oscillation period of the dither drive ----------------- //r.------------ óñòàíîâêà ïåðèîäà êîëåáàíèé âèáðîïðèâîäà ----------------- |
igor_v | 0:8ad47e2b6f00 | 383 | { |
igor_v | 0:8ad47e2b6f00 | 384 | ScopeMode = 1; //e. VB_PHASE_DETECTOR allocate a mode of display for a control point of an scope //r. VB_PHASE_DETECTOR íàçíà÷èòü ðåæèì îòîáðàæåíèÿ äëÿ êîíòðîëüíîé òî÷êè îñöèëëîãðàôà |
igor_v | 0:8ad47e2b6f00 | 385 | |
igor_v | 0:8ad47e2b6f00 | 386 | Output.Str.T_Vibro = (rcv_buf[4] << 8) | (rcv_buf[5] & 0xFF); //e. new variable of the period //r. íîâàÿ ïåðåìåííàÿ ïåðèîäà |
igor_v | 0:8ad47e2b6f00 | 387 | /* sprintf(BuffTemp1, "\n\r F = %d ", Output.Str.T_Vibro); |
igor_v | 0:8ad47e2b6f00 | 388 | SendToBuff(BuffTemp1,15);*/ |
igor_v | 0:8ad47e2b6f00 | 389 | Output.Str.L_Vibro= (rcv_buf[6] << 8) | (rcv_buf[7] & 0xFF); //e. new variable of the pulse width //r. íîâàÿ ïåðåìåííàÿ äëèòåëüíîñòè èìïóëüñîâ |
igor_v | 0:8ad47e2b6f00 | 390 | /*sprintf(BuffTemp1, "\n\r L = %d ", Output.Str.L_Vibro); |
igor_v | 0:8ad47e2b6f00 | 391 | SendToBuff(BuffTemp1,15);*/ |
igor_v | 0:8ad47e2b6f00 | 392 | VibroDither_Set(); //e. and output its value to period registers on card //r. âûâåñòè åå çíà÷åíèå â ðåãèñòðû ïåðèîäà íà ïëàòå |
igor_v | 0:8ad47e2b6f00 | 393 | |
igor_v | 0:8ad47e2b6f00 | 394 | trm_cycl = 0; //e. periodic data transmission is not needed //r. ïåðèîäè÷åñêàÿ ïåðåäà÷à îòâåòà íå òðåáóåòñÿ |
igor_v | 0:8ad47e2b6f00 | 395 | Mk_Ask1(); |
igor_v | 0:8ad47e2b6f00 | 396 | } // M_Vib_W |
igor_v | 0:8ad47e2b6f00 | 397 | |
igor_v | 0:8ad47e2b6f00 | 398 | void M_Gph_W(void) //e.------------ set the gain factor of photodetector channels ------------------- //r.------------ óñòàíîâêà óñèëåíèÿ êàíàëîâ ôîòîïðèåìíèêà ------------------- |
igor_v | 0:8ad47e2b6f00 | 399 | { |
igor_v | 0:8ad47e2b6f00 | 400 | Device_blk.Str.Gain_Ph_A = rcv_buf[4]; //e. read from the receiver buffer the value of the gain factor of the A channel //r. ñ÷èòàòü èç áóôåðà ïðèåìíèêà çíà÷åíèå óñèëåíèÿ êàíàëà À |
igor_v | 0:8ad47e2b6f00 | 401 | Device_blk.Str.Gain_Ph_B = rcv_buf[5]; //e. read from the receiver buffer the value of the gain factor of the B channel //r. ñ÷èòàòü èç áóôåðà ïðèåìíèêà çíà÷åíèå óñèëåíèÿ êàíàëà  |
igor_v | 0:8ad47e2b6f00 | 402 | |
igor_v | 0:8ad47e2b6f00 | 403 | Out_G_photo(Device_blk.Str.Gain_Ph_A, Device_blk.Str.Gain_Ph_B); //e. display these values to digital potentiometers //r. âûâåñòè ýòè çíà÷åíèÿ â öèôðîâûå ïîòåíöèîìåòðû |
igor_v | 0:8ad47e2b6f00 | 404 | |
igor_v | 0:8ad47e2b6f00 | 405 | trm_cycl = 0; //e. periodic data transmission is not needed //r. ïåðèîäè÷åñêàÿ ïåðåäà÷à îòâåòà íå òðåáóåòñÿ |
igor_v | 0:8ad47e2b6f00 | 406 | Mk_Ask1(); |
igor_v | 0:8ad47e2b6f00 | 407 | } // M_Gph_W |
igor_v | 0:8ad47e2b6f00 | 408 | |
igor_v | 0:8ad47e2b6f00 | 409 | void M_Rate(void) //e.------------ start of transfer of the M_Rate parameters stack ------------------- //r.------------ çàïóñê ïåðåäà÷è íàáîðà ïàðàìåòðîâ M_Rate ------------------- |
igor_v | 0:8ad47e2b6f00 | 410 | { |
igor_v | 0:8ad47e2b6f00 | 411 | uint8_t mode; |
igor_v | 0:8ad47e2b6f00 | 412 | |
igor_v | 0:8ad47e2b6f00 | 413 | SetSpeedPeriod(); //e. set the answer transfer rate and its periodicity //r. óñòàíîâèòü ñêîðîñòü ïåðåäà÷è îòâåòà è åãî ïåðèîäè÷íîñòü |
igor_v | 0:8ad47e2b6f00 | 414 | UART_SwitchSpeed(trm_rate); |
igor_v | 0:8ad47e2b6f00 | 415 | |
igor_v | 0:8ad47e2b6f00 | 416 | mode = rcv_buf[3] & 0x001f; //e. extract number of the parameters stack in the command //r. âûäåëèòü íîìåð íàáîðà ïàðàìåòðîâ â êîìàíäå |
igor_v | 0:8ad47e2b6f00 | 417 | |
igor_v | 0:8ad47e2b6f00 | 418 | switch (mode) { |
igor_v | 0:8ad47e2b6f00 | 419 | case 1: //e. it is the Rate stack //r. ýòî íàáîð Rate |
igor_v | 0:8ad47e2b6f00 | 420 | RgConB = RATE_REPER_OR_REFMEANDR; //e. counter latch every vibro period |
igor_v | 0:8ad47e2b6f00 | 421 | SwitchRefMeandInt(RATE_REPER_OR_REFMEANDR); //e. enable reference meander interrupt |
igor_v | 0:8ad47e2b6f00 | 422 | |
igor_v | 0:8ad47e2b6f00 | 423 | wrk_period = 12500000; //e. load needed length of working period 1 ñ.//r. çàãðóçèòü òðåáóåìóþ äëèòåëüíîñòü ðàáî÷åãî ïåðèîäà 1 ñ. |
igor_v | 0:8ad47e2b6f00 | 424 | num_of_par = 14; //e. 9 parameters or groups of parameters output //r. âûâîäèòü 9 ïàðàìåòðîâ èëè ãðóïï ïàðàìåòðîâ |
igor_v | 0:8ad47e2b6f00 | 425 | |
igor_v | 0:8ad47e2b6f00 | 426 | Valid_Data = 0; // reset all bits of status word |
igor_v | 0:8ad47e2b6f00 | 427 | |
igor_v | 0:8ad47e2b6f00 | 428 | addr_param[0] = &(Output.Str.Cnt_Pls); //e. set the address of the 1st parameter in the 1st group //r. çàäàòü àäðåñ ïåðâîãî ïàðàìåòðà â 1-îé ãðóïïå |
igor_v | 0:8ad47e2b6f00 | 429 | addr_param[1] = &(Output.Str.Cnt_Mns); //e. set the address of the 1st parameter in the 2nd group //r. çàäàòü àäðåñ ïåðâîãî ïàðàìåòðà â 2-îé ãðóïïå |
igor_v | 0:8ad47e2b6f00 | 430 | addr_param[2] = &(Output.Str.Cnt_Dif); //e. set the address of the 1st parameter in the 3rd group //r. çàäàòü àäðåñ ïåðâîãî ïàðàìåòðà â 3-îé ãðóïïå |
igor_v | 0:8ad47e2b6f00 | 431 | addr_param[3] = &(Output.Str.F_ras); //e. set the address of the _F_ras parameter in the 4th group //r. çàäàòü àäðåñ ïàðàìåòðà _F_ras âî 4-îé ãðóïïå |
igor_v | 0:8ad47e2b6f00 | 432 | addr_param[4] = &(Output.Str.HF_reg); //e. set the address of the _HF_reg parameter in the 5th group //r. çàäàòü àäðåñ ïàðàìåòðà _HF_reg â 5-åé ãðóïïå |
igor_v | 0:8ad47e2b6f00 | 433 | addr_param[5] = &(Output.Str.HF_dif); //e. set the address of the _HF_dif parameter in the 6th group //r. çàäàòü àäðåñ ïàðàìåòðà _HF_dif â 6-îé ãðóïïå |
igor_v | 0:8ad47e2b6f00 | 434 | addr_param[6] = &(Output.Str.T_Vibro); //e. parameter _T_Vibro //r. ïàðàìåòð _T_Vibro |
igor_v | 0:8ad47e2b6f00 | 435 | addr_param[7] = &(Output.Str.T_VB_pll); //e. parameter _T_VB_pll //r.ïàðàìåòðâ _T_VB_pll |
igor_v | 0:8ad47e2b6f00 | 436 | addr_param[8] = &(Output.Str.L_Vibro); //e. parameter _L_Vibro //r. ïàðàìåòð _L_Vibro |
igor_v | 0:8ad47e2b6f00 | 437 | addr_param[9] = &(Input.StrIn.HF_out); //e. set the address of the _RI_reg parameter in the 8th group //r. çàäàòü àäðåñ ïàðàìåòðà _RI_reg â 8-îé ãðóïïå |
igor_v | 0:8ad47e2b6f00 | 438 | addr_param[10] = &(Output.Str.WP_reg); //e. parameters: _WP_reg, _WP_pll //r. ïàðàìåòðîâ _WP_reg, _WP_pll |
igor_v | 0:8ad47e2b6f00 | 439 | addr_param[11] = &(Output.Str.WP_pll); //e. parameters: _WP_reg, _WP_pll //r. ïàðàìåòðîâ _WP_reg, _WP_pll |
igor_v | 0:8ad47e2b6f00 | 440 | addr_param[12] = &(Output.Str.Tmp_Out); //e. set the address of the temperature sensors array //r. çàäàòü àäðåñ ìàññèâà äàò÷èêîâ òåìïåðàòóðû |
igor_v | 0:8ad47e2b6f00 | 441 | addr_param[13] = &(Output.Str.WP_scope1); //e. reserved //r. çàðåçåðâèðîâàíî äëÿ äàëüíåéøèõ ïðèìåíåíèé |
igor_v | 0:8ad47e2b6f00 | 442 | |
igor_v | 0:8ad47e2b6f00 | 443 | size_param[0] = 2; //e. groups 1-6, 8-10 consists of one parameter ... //r. ãðóïïû 1-6, 8-10 ñîäåðæàò ïî îäíîìó ïàðàìåòðó |
igor_v | 0:8ad47e2b6f00 | 444 | size_param[1] = 2; //e. and have 2 bytes length each //r. è èìåþò äëèíó 2 áàéòà êàæäàÿ |
igor_v | 0:8ad47e2b6f00 | 445 | size_param[2] = 2; |
igor_v | 0:8ad47e2b6f00 | 446 | size_param[3] = 2; |
igor_v | 0:8ad47e2b6f00 | 447 | size_param[4] = 2; |
igor_v | 0:8ad47e2b6f00 | 448 | size_param[5] = 2; |
igor_v | 0:8ad47e2b6f00 | 449 | size_param[6] = 2; |
igor_v | 0:8ad47e2b6f00 | 450 | size_param[7] = 2; |
igor_v | 0:8ad47e2b6f00 | 451 | size_param[8] = 2; |
igor_v | 0:8ad47e2b6f00 | 452 | size_param[9] = 2; |
igor_v | 0:8ad47e2b6f00 | 453 | size_param[10] = 2; |
igor_v | 0:8ad47e2b6f00 | 454 | size_param[11] = 2; |
igor_v | 0:8ad47e2b6f00 | 455 | |
igor_v | 0:8ad47e2b6f00 | 456 | size_param[13] = 4; //e. the 11th group parameters has length of 4 bytes //r. 11-z ãðóïïà ïàðàìåòðîâ èìååò äëèíó 4 áàéòà |
igor_v | 0:8ad47e2b6f00 | 457 | |
igor_v | 0:8ad47e2b6f00 | 458 | size_param[12] = 12; //e. format o the GLD array of temperatures - 12 bytes //r. ôîðìàò ìàññèâà òåìïåðàòóð ÃËÄ - 12 áàéò |
igor_v | 0:8ad47e2b6f00 | 459 | |
igor_v | 0:8ad47e2b6f00 | 460 | trm_ena = 1; //e. allow operation of the transmitter //r. ðàçðåøèòü ðàáîòó ïåðåäàò÷èêà |
igor_v | 0:8ad47e2b6f00 | 461 | break; |
igor_v | 0:8ad47e2b6f00 | 462 | |
igor_v | 0:8ad47e2b6f00 | 463 | case 2: //e. it is the Rate2 stack //r. ýòî íàáîð Rate2 |
igor_v | 0:8ad47e2b6f00 | 464 | RgConB = RATE_REPER_OR_REFMEANDR; |
igor_v | 0:8ad47e2b6f00 | 465 | SwitchRefMeandInt(RATE_REPER_OR_REFMEANDR); //e. enable interrupt from ref. meander |
igor_v | 0:8ad47e2b6f00 | 466 | wrk_period = 0; //e. frequency of output = fvibro //r. ÷àñòîòà âûâîäà ðàâíà ÷àñòîòå ÂÏ |
igor_v | 0:8ad47e2b6f00 | 467 | |
igor_v | 0:8ad47e2b6f00 | 468 | num_of_par = 2; //e. 2 parameters output //r. âûâîäèòü 2 ïàðàìåòðà |
igor_v | 0:8ad47e2b6f00 | 469 | |
igor_v | 0:8ad47e2b6f00 | 470 | addr_param[0] = &(Output.Str.Cnt_Pls); //e. set the first parameter address //r. çàäàòü àäðåñ ïåðâîãî ïàðàìåòðà |
igor_v | 0:8ad47e2b6f00 | 471 | addr_param[1] = &(Output.Str.Cnt_Mns); //e. and the 2nd //r. è âòîðîãî |
igor_v | 0:8ad47e2b6f00 | 472 | size_param[0] = 2; //e. parameters has 2 bytes length //r. ïàðàìåòðû èìååò äëèíó 2 áàéòà |
igor_v | 0:8ad47e2b6f00 | 473 | size_param[1] = 2; |
igor_v | 0:8ad47e2b6f00 | 474 | trm_ena = 1; //e. allow operation of the transmitter //r. ðàçðåøèòü ðàáîòó ïåðåäàò÷èêà |
igor_v | 0:8ad47e2b6f00 | 475 | break; |
igor_v | 0:8ad47e2b6f00 | 476 | |
igor_v | 0:8ad47e2b6f00 | 477 | case 3: //e. it is the Rate3 stack //r. ýòî íàáîð Rate3 |
igor_v | 0:8ad47e2b6f00 | 478 | |
igor_v | 0:8ad47e2b6f00 | 479 | wrk_period = 2500; //e. frequency of output = 10000 Hz //r. n=1, ÷àñòîòà âûâîäà = 10000 Hz |
igor_v | 0:8ad47e2b6f00 | 480 | num_of_par = 2; //e. 2 parameters output //r. âûâîäèòü 2 ïàðàìåòðà |
igor_v | 0:8ad47e2b6f00 | 481 | |
igor_v | 0:8ad47e2b6f00 | 482 | addr_param[0] = &(Output.Str.WP_scope1); //e. set the addresses of output parameters //r. çàäàòü àäðåñà âûâîäèìûõ ïàðàìåòðîâ |
igor_v | 0:8ad47e2b6f00 | 483 | addr_param[1] = &(Output.Str.WP_scope2); |
igor_v | 0:8ad47e2b6f00 | 484 | size_param[0] = 2; //e. all parameters has 2 bytes length //r. âñå ïàðàìåòðû èìåþò äëèíó 2 áàéòà |
igor_v | 0:8ad47e2b6f00 | 485 | size_param[1] = 2; |
igor_v | 0:8ad47e2b6f00 | 486 | trm_ena = 1; //e. allow operation of the transmitter //r. ðàçðåøèòü ðàáîòó ïåðåäàò÷èêà |
igor_v | 0:8ad47e2b6f00 | 487 | break; |
igor_v | 0:8ad47e2b6f00 | 488 | |
igor_v | 0:8ad47e2b6f00 | 489 | case 4: //e. it is the Rate4 stack //r. ýòî íàáîð Rate4 |
igor_v | 0:8ad47e2b6f00 | 490 | wrk_period = 20000; //e. correspond to output frequency 1.25 kHz //r. ñîîòâåñòâóåò ÷àñòîòå âûâîäà 1.25 kHz |
igor_v | 0:8ad47e2b6f00 | 491 | num_of_par = 4; //e. 4 parameters output //r. âûâîäèòü 4 ïàðàìåòðà |
igor_v | 0:8ad47e2b6f00 | 492 | |
igor_v | 0:8ad47e2b6f00 | 493 | //e. set the addresses of output parameters //r. çàäàòü àäðåñà âûâîäèìûõ ïàðàìåòðîâ |
igor_v | 0:8ad47e2b6f00 | 494 | // --- raw data array of numbers --- |
igor_v | 0:8ad47e2b6f00 | 495 | // addr_param[0] = &Dif_Curr_Array; |
igor_v | 0:8ad47e2b6f00 | 496 | // --- filtered array of numbers --- |
igor_v | 0:8ad47e2b6f00 | 497 | // addr_param[1] = &Dif_Filt_Array; |
igor_v | 0:8ad47e2b6f00 | 498 | // --------------------------------- |
igor_v | 0:8ad47e2b6f00 | 499 | addr_param[2] = &(Output.Str.HF_reg); //e. HFO regulator //r. íàïðÿæåíèå ÃÂ× |
igor_v | 0:8ad47e2b6f00 | 500 | addr_param[3] = &(Output.Str.WP_reg); //e. CPLC heater regulator //r. íàïðÿæåíèå íàãðåâàòåëÿ |
igor_v | 0:8ad47e2b6f00 | 501 | size_param[0] = 16; |
igor_v | 0:8ad47e2b6f00 | 502 | size_param[1] = 32; |
igor_v | 0:8ad47e2b6f00 | 503 | size_param[2] = 2; |
igor_v | 0:8ad47e2b6f00 | 504 | size_param[3] = 2; |
igor_v | 0:8ad47e2b6f00 | 505 | trm_ena = 1; //e. allow operation of the transmitter //r. ðàçðåøèòü ðàáîòó ïåðåäàò÷èêà |
igor_v | 0:8ad47e2b6f00 | 506 | break; |
igor_v | 0:8ad47e2b6f00 | 507 | case 7: |
igor_v | 0:8ad47e2b6f00 | 508 | wrk_period = 20000; //e. correspond to output frequency 1250 Hz //r. ñîîòâåñòâóåò ÷àñòîòå âûâîäà 1.25 kHz |
igor_v | 0:8ad47e2b6f00 | 509 | num_of_par = 5; //e. 4 parameters output //r. âûâîäèòü 5 ïàðàìåòðà |
igor_v | 0:8ad47e2b6f00 | 510 | |
igor_v | 0:8ad47e2b6f00 | 511 | //e. set the addresses of output parameters //r. çàäàòü àäðåñà âûâîäèìûõ ïàðàìåòðîâ |
igor_v | 0:8ad47e2b6f00 | 512 | // --- raw data array of PLC phase --- |
igor_v | 0:8ad47e2b6f00 | 513 | addr_param[0] = &(Output.Str.WP_Phase_Det_Array); |
igor_v | 0:8ad47e2b6f00 | 514 | // --- filtered array of reference sin--- |
igor_v | 0:8ad47e2b6f00 | 515 | addr_param[1] = &(Output.Str.WP_sin_Array); |
igor_v | 0:8ad47e2b6f00 | 516 | // --------------------------------- |
igor_v | 0:8ad47e2b6f00 | 517 | addr_param[2] = &(Output.Str.WP_reg); //e. CPLC heater regulator //r. íàïðÿæåíèå íàãðåâàòåëÿ |
igor_v | 0:8ad47e2b6f00 | 518 | addr_param[3] = &(Output.Str.WP_pll); //e. CPLC phase //r. ôàçà |
igor_v | 0:8ad47e2b6f00 | 519 | addr_param[4] = &(Output.Str.HF_reg); //e. set the address of the _HF_reg parameter in the 5th group //r. çàäàòü àäðåñ ïàðàìåòðà _HF_reg â 5-åé ãðóïïå |
igor_v | 0:8ad47e2b6f00 | 520 | size_param[0] = 16; |
igor_v | 0:8ad47e2b6f00 | 521 | size_param[1] = 16; |
igor_v | 0:8ad47e2b6f00 | 522 | size_param[2] = 2; |
igor_v | 0:8ad47e2b6f00 | 523 | size_param[3] = 2; |
igor_v | 0:8ad47e2b6f00 | 524 | size_param[4] = 2; |
igor_v | 0:8ad47e2b6f00 | 525 | trm_ena = 1; //e. allow operation of the transmitter //r. ðàçðåøèòü ðàáîòó ïåðåäàò÷èêà |
igor_v | 0:8ad47e2b6f00 | 526 | break; |
igor_v | 0:8ad47e2b6f00 | 527 | } |
igor_v | 0:8ad47e2b6f00 | 528 | SetIntLatch(wrk_period); |
igor_v | 0:8ad47e2b6f00 | 529 | } // M_Rate |
igor_v | 0:8ad47e2b6f00 | 530 | |
igor_v | 0:8ad47e2b6f00 | 531 | void M_Reset(void) |
igor_v | 0:8ad47e2b6f00 | 532 | { |
igor_v | 0:8ad47e2b6f00 | 533 | while(1); |
igor_v | 0:8ad47e2b6f00 | 534 | } // will not achieve |
igor_v | 0:8ad47e2b6f00 | 535 | |
igor_v | 0:8ad47e2b6f00 | 536 | void M_Param_R(void) //e. ------------ read the parameter of the GLD from the data memory ---------------------- //r.------------ ÷òåíèå ïàðàìåòðà GLD èç ïàìÿòè äàííûõ ---------------------- |
igor_v | 0:8ad47e2b6f00 | 537 | { |
igor_v | 0:8ad47e2b6f00 | 538 | num_of_par = 1; //e. 1 parameter output //r. âûâîäèòü îäèí ïàðàìåòð |
igor_v | 0:8ad47e2b6f00 | 539 | addr_param[0] = (void *)(&Device_blk.Str.My_Addres + rcv_buf[3]); //e. address of the needed parameter in the block //r. àäðåñ òðåáóåìîãî ïàðàìåòðà â áëîêå |
igor_v | 0:8ad47e2b6f00 | 540 | size_param[0] = 2; //e. size of the buffer - 2 bytes //r. ðàçìåð áóôåðà - 2 áàéòà |
igor_v | 0:8ad47e2b6f00 | 541 | |
igor_v | 0:8ad47e2b6f00 | 542 | trm_ena = 1; //e. allow operation of the transmitter //r. ðàçðåøèòü ðàáîòó ïåðåäàò÷èêà |
igor_v | 0:8ad47e2b6f00 | 543 | } // M_Param_R |
igor_v | 0:8ad47e2b6f00 | 544 | |
igor_v | 0:8ad47e2b6f00 | 545 | void M_Param_W(void) //e.------------ write the parameter of the GLD from the data memory ----------------------- //r.------------ çàïèñü ïàðàìåòðà GLD â ïàìÿòü äàííûõ ----------------------- |
igor_v | 0:8ad47e2b6f00 | 546 | { |
igor_v | 0:8ad47e2b6f00 | 547 | int * ptr; |
igor_v | 0:8ad47e2b6f00 | 548 | |
igor_v | 0:8ad47e2b6f00 | 549 | ScopeMode = 0; //e. VB_DELAY_MEANDER allocate a mode of display for a control point of an scope //r. VB_DELAY_MEANDER íàçíà÷èòü ðåæèì îòîáðàæåíèÿ äëÿ êîíòðîëüíîé òî÷êè îñöèëëîãðàôà |
igor_v | 0:8ad47e2b6f00 | 550 | |
igor_v | 0:8ad47e2b6f00 | 551 | ptr = (int *)&Device_blk.Str.My_Addres; // pointer to Parameters block |
igor_v | 0:8ad47e2b6f00 | 552 | ptr += rcv_buf[3]; // calculate offset |
igor_v | 0:8ad47e2b6f00 | 553 | *ptr = (rcv_buf[4] << 8) | (rcv_buf[5] & 0xFF); // write new parameter value |
igor_v | 0:8ad47e2b6f00 | 554 | |
igor_v | 0:8ad47e2b6f00 | 555 | trm_cycl = 0; //e. periodic data transmission is not needed //r. ïåðèîäè÷åñêàÿ ïåðåäà÷à îòâåòà íå òðåáóåòñÿ |
igor_v | 0:8ad47e2b6f00 | 556 | Mk_Ask1(); |
igor_v | 0:8ad47e2b6f00 | 557 | } // M_Param_W |
igor_v | 0:8ad47e2b6f00 | 558 | |
igor_v | 0:8ad47e2b6f00 | 559 | void M_LdPar_F() //e.============ procedure for load the GLD parameters from the flash-memory =========== //r.============ ïðîöåäóðà çàãðóçêè ïàðàìåòðîâ ÃËÄ èç ôëýø-ïàìÿòè =========== |
igor_v | 0:8ad47e2b6f00 | 560 | { |
igor_v | 0:8ad47e2b6f00 | 561 | |
igor_v | 0:8ad47e2b6f00 | 562 | LoadFlashParam(FromFLASH); //e. load the GLD parameters from the flash-memory //r. çàãðóçèòü ïàðàìåòðû ÃËÄ èç ôäýø-ïàìÿòè |
igor_v | 0:8ad47e2b6f00 | 563 | blt_in_test = ((uint32_t)FIRMWARE_VER << 8) | (Device_blk.Str.Device_SerialNumber & 0x00FF); |
igor_v | 0:8ad47e2b6f00 | 564 | // Init_software(); |
igor_v | 0:8ad47e2b6f00 | 565 | |
igor_v | 0:8ad47e2b6f00 | 566 | trm_cycl = 0; //e. periodic data transmission is not needed //r. ïåðèîäè÷åñêàÿ ïåðåäà÷à îòâåòà íå òðåáóåòñÿ |
igor_v | 0:8ad47e2b6f00 | 567 | Mk_Ask1(); |
igor_v | 0:8ad47e2b6f00 | 568 | } // M_LdPar_F |
igor_v | 0:8ad47e2b6f00 | 569 | |
igor_v | 0:8ad47e2b6f00 | 570 | void M_LdPar_D(void) //e.============ procedure for set parameters of the GLD by default ============ //r.============ ïðîöåäóðà óñòàíîâêè ïàðàìåòðîâ ÃËÄ ïî óìîë÷àíèþ ============ |
igor_v | 0:8ad47e2b6f00 | 571 | { |
igor_v | 0:8ad47e2b6f00 | 572 | #if !defined COMMAND_DEBUG |
igor_v | 0:8ad47e2b6f00 | 573 | LoadFlashParam(ByDefault); //e. define parameters of the GLD by default //r. îïðåäåëèòü ïàðàìåòðû ÃËÄ ïî óìîë÷àíèþ (default) |
igor_v | 0:8ad47e2b6f00 | 574 | Init_software(); |
igor_v | 0:8ad47e2b6f00 | 575 | #endif |
igor_v | 0:8ad47e2b6f00 | 576 | trm_cycl = 0; //e. periodic data transmission is not needed //r. ïåðèîäè÷åñêàÿ ïåðåäà÷à îòâåòà íå òðåáóåòñÿ |
igor_v | 0:8ad47e2b6f00 | 577 | Mk_Ask1(); |
igor_v | 0:8ad47e2b6f00 | 578 | } // M_LdPar_D |
igor_v | 0:8ad47e2b6f00 | 579 | |
igor_v | 0:8ad47e2b6f00 | 580 | void M_Start(void) //e.============ initialization of the GLD switch on ================================= //r.============ èíèöèàëèçàöèÿ çàïóñêà ÃËÄ ================================= |
igor_v | 0:8ad47e2b6f00 | 581 | { |
igor_v | 0:8ad47e2b6f00 | 582 | start_Rq = 1; //e. set the flag of the GLD switch on request //r. óñòàíîâèòü ôëàã çàïðîñà ñòàðòà ÃËÄ |
igor_v | 0:8ad47e2b6f00 | 583 | trm_cycl = 0; //e. periodic data transmission is not needed //r. ïåðèîäè÷åñêàÿ ïåðåäà÷à îòâåòà íå òðåáóåòñÿ |
igor_v | 0:8ad47e2b6f00 | 584 | Mk_Ask1(); |
igor_v | 0:8ad47e2b6f00 | 585 | } // M_Start |
igor_v | 0:8ad47e2b6f00 | 586 | |
igor_v | 0:8ad47e2b6f00 | 587 | void M_Stop(void) //e.============ initialization of the GLD switch off ============================== //r.============ èíèöèàëèçàöèÿ âûêëþ÷åíèÿ ÃËÄ ============================== |
igor_v | 0:8ad47e2b6f00 | 588 | { |
igor_v | 0:8ad47e2b6f00 | 589 | stop_Rq = 1; //e. set the flag of the GLD switch off request //r. óñòàíîâèòü ôëàã çàïðîñà âûêëþ÷åíèÿ ÃËÄ |
igor_v | 0:8ad47e2b6f00 | 590 | trm_cycl = 0; //e. periodic data transmission is not needed //r. ïåðèîäè÷åñêàÿ ïåðåäà÷à îòâåòà íå òðåáóåòñÿ |
igor_v | 0:8ad47e2b6f00 | 591 | Mk_Ask1(); |
igor_v | 0:8ad47e2b6f00 | 592 | } // M_Stop |
igor_v | 0:8ad47e2b6f00 | 593 | |
igor_v | 0:8ad47e2b6f00 | 594 | void M_Pulse(void) //e.============ generetion of the light-up pulse ========================= //r.============ ãåíåðàöèÿ èìïóëüñà çàïóñêà ëàçåðà ========================= |
igor_v | 0:8ad47e2b6f00 | 595 | { |
igor_v | 0:8ad47e2b6f00 | 596 | pulse_Rq = 1; //e. set the flag of the GLD switch on request //r. óñòàíîâèòü ôëàã çàïðîñà ñòàðòà ÃËÄ |
igor_v | 0:8ad47e2b6f00 | 597 | trm_cycl = 0; //e. periodic data transmission is not needed //r. ïåðèîäè÷åñêàÿ ïåðåäà÷à îòâåòà íå òðåáóåòñÿ |
igor_v | 0:8ad47e2b6f00 | 598 | Mk_Ask1(); |
igor_v | 0:8ad47e2b6f00 | 599 | } // M_Pulse |
igor_v | 0:8ad47e2b6f00 | 600 | |
igor_v | 0:8ad47e2b6f00 | 601 | void B_Rate(void) //e. === procedure of device operation in a mode of continuous output of raw data //r. === ïðîöåäóðà ðàáîòû ïðèáîðà â ðåæèìå íåïðåðûâíîé âûäà÷è "ñûðûõ" äàííûõ |
igor_v | 0:8ad47e2b6f00 | 602 | { |
igor_v | 0:8ad47e2b6f00 | 603 | } // B_Rate |
igor_v | 0:8ad47e2b6f00 | 604 | |
igor_v | 0:8ad47e2b6f00 | 605 | void B_Delta(void) //e. === procedure not used //r. === ïðîöåäóðà íå èñïîëüçóåòñÿ |
igor_v | 0:8ad47e2b6f00 | 606 | { |
igor_v | 0:8ad47e2b6f00 | 607 | } // B_Delta |
igor_v | 0:8ad47e2b6f00 | 608 | |
igor_v | 0:8ad47e2b6f00 | 609 | void D_Period_W(void) //e. === set the period of the angle increase output //r. === óñòàíîâêà ïåðèîäà âûäà÷è ïðèðàùåíèÿ óãëà |
igor_v | 0:8ad47e2b6f00 | 610 | { |
igor_v | 0:8ad47e2b6f00 | 611 | } // D_Period_W |
igor_v | 0:8ad47e2b6f00 | 612 | |
igor_v | 0:8ad47e2b6f00 | 613 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
igor_v | 0:8ad47e2b6f00 | 614 | void exec_CMD(void) //e. === the final decoding and command execution procedure //r. === ïðîöåäóðà îêîí÷àòåëüíîé äåøèôðàöèè è èñïîëíåíèÿ êîìàíäû |
igor_v | 0:8ad47e2b6f00 | 615 | { |
igor_v | 0:8ad47e2b6f00 | 616 | uint32_t wcode; |
igor_v | 0:8ad47e2b6f00 | 617 | |
igor_v | 0:8ad47e2b6f00 | 618 | rx_buf_copy = 1; //e. initialization of the flag of copying of receiving buffer //r. ïðåäóñòàíîâ ôëàãà êîïèðîâàíèÿ ïðèåìíîãî áóôåðà |
igor_v | 0:8ad47e2b6f00 | 619 | |
igor_v | 0:8ad47e2b6f00 | 620 | wcode = (rcv_buf[2] & 0xFF) << 8; |
igor_v | 0:8ad47e2b6f00 | 621 | CMD_Code = wcode | (rcv_buf[3] & 0xFF); //e. save it in the memory for echo-transmission //r. ñîõðàíèòü åãî â ïàìÿòè äëÿ îáðàòíîé ïåðåäà÷è |
igor_v | 0:8ad47e2b6f00 | 622 | |
igor_v | 0:8ad47e2b6f00 | 623 | if (wcode == CMD_RATE) //e. is it Rate command? //r. ýòî êîìàíäà Rate? |
igor_v | 0:8ad47e2b6f00 | 624 | { |
igor_v | 0:8ad47e2b6f00 | 625 | B_Rate(); |
igor_v | 0:8ad47e2b6f00 | 626 | return; |
igor_v | 0:8ad47e2b6f00 | 627 | } |
igor_v | 0:8ad47e2b6f00 | 628 | else if (wcode == CMD_DEV_MODE) //e. is it the Device_Mode command? //r. ýòî êîìàíäà óñòàíîâêè ðåæèìà ïðèáîðà? |
igor_v | 0:8ad47e2b6f00 | 629 | { |
igor_v | 0:8ad47e2b6f00 | 630 | CMD_Mode = 3; |
igor_v | 0:8ad47e2b6f00 | 631 | B_Dev_Mode(); |
igor_v | 0:8ad47e2b6f00 | 632 | return; |
igor_v | 0:8ad47e2b6f00 | 633 | } |
igor_v | 0:8ad47e2b6f00 | 634 | else if (wcode == CMD_DELTA_BINS) //e. is it the B_DeltaBINS command (command of request for data transfer to the navigation system)? //r. ýòî êîìàíäà çàïðîñà ïåðåäà÷è äàííûõ â íàâèã.ñèñòåìó? |
igor_v | 0:8ad47e2b6f00 | 635 | { |
igor_v | 0:8ad47e2b6f00 | 636 | RgConB = RATE_VIBRO_1; //e. set in the additional register of device control the mode of work with dither counters and the filter of moving average //r. óñòàíàâëèâàåì â äîïîëíèòåëüíîì ðåãèñòðå óïðàâëåíèÿ ðåæèì ðàáîòû ñ âèáðîñ÷åò÷èêàìè è ôèëüòðîì ñêîëüçÿùåãî ñðåäíåãî |
igor_v | 0:8ad47e2b6f00 | 637 | SetSpeedPeriod(); |
igor_v | 0:8ad47e2b6f00 | 638 | UART_SwitchSpeed(trm_rate); |
igor_v | 0:8ad47e2b6f00 | 639 | CMD_Mode = 4; |
igor_v | 0:8ad47e2b6f00 | 640 | B_Delta_BINS(); |
igor_v | 0:8ad47e2b6f00 | 641 | return; |
igor_v | 0:8ad47e2b6f00 | 642 | } |
igor_v | 0:8ad47e2b6f00 | 643 | else if (wcode == CMD_DELTA_PS) //e. is it the B_DeltaPS command (command of request for data transfer to the uPC)? //r. ýòî êîìàíäà çàïðîñà ïåðåäà÷è äàííûõ â MkPC? |
igor_v | 0:8ad47e2b6f00 | 644 | { |
igor_v | 0:8ad47e2b6f00 | 645 | SetSpeedPeriod(); //e. and set the answer transfer rate and its periodicity //r. è óñòàíîâèòü ñêîðîñòü ïåðåäà÷è îòâåòà è åãî ïåðèîäè÷íîñòü (_trm_cycl) |
igor_v | 0:8ad47e2b6f00 | 646 | UART_SwitchSpeed(trm_rate); |
igor_v | 0:8ad47e2b6f00 | 647 | if (Device_Mode < 4) //e. work with internal latch |
igor_v | 0:8ad47e2b6f00 | 648 | Device_Mode = DM_INT_LATCH_DELTA_PS; |
igor_v | 0:8ad47e2b6f00 | 649 | else |
igor_v | 0:8ad47e2b6f00 | 650 | Device_Mode = DM_EXT_LATCH_DELTA_PS_PULSE; |
igor_v | 0:8ad47e2b6f00 | 651 | CMD_Mode = 1; |
igor_v | 0:8ad47e2b6f00 | 652 | // B_Delta_PS(); |
igor_v | 0:8ad47e2b6f00 | 653 | return; |
igor_v | 0:8ad47e2b6f00 | 654 | } |
igor_v | 0:8ad47e2b6f00 | 655 | else if (wcode == CMD_DELTA_SF) // is it the B_DeltaSF command? |
igor_v | 0:8ad47e2b6f00 | 656 | { |
igor_v | 0:8ad47e2b6f00 | 657 | SetSpeedPeriod(); //e. and set the answer transfer rate and its periodicity //r. è óñòàíîâèòü ñêîðîñòü ïåðåäà÷è îòâåòà è åãî ïåðèîäè÷íîñòü (_trm_cycl) |
igor_v | 0:8ad47e2b6f00 | 658 | CMD_Mode = 7; |
igor_v | 0:8ad47e2b6f00 | 659 | if ((rcv_buf[3] & 0x0001) != 0) //e.reset of accumulated number is disabled //r. ñáðîñ íàêîïëåííîãî ìåæäó çàùåëêàìè ÷èñëà çàïðåùåí |
igor_v | 0:8ad47e2b6f00 | 660 | Ext_Latch_ResetEnable = 0; |
igor_v | 0:8ad47e2b6f00 | 661 | else |
igor_v | 0:8ad47e2b6f00 | 662 | Ext_Latch_ResetEnable = 1; |
igor_v | 0:8ad47e2b6f00 | 663 | B_Delta_SF(); |
igor_v | 0:8ad47e2b6f00 | 664 | return; |
igor_v | 0:8ad47e2b6f00 | 665 | } |
igor_v | 0:8ad47e2b6f00 | 666 | else if (wcode == CMD_BIT_MODE) //e. is this the BIT mode command? //r. ýòî êîìàíäà òåñòèðîâàíèÿ? |
igor_v | 0:8ad47e2b6f00 | 667 | { |
igor_v | 0:8ad47e2b6f00 | 668 | CMD_Mode = 6; //e. set the value of the Delta mode//r. óñòàíîâèòü çíà÷åíèå ðåæèìà Delta |
igor_v | 0:8ad47e2b6f00 | 669 | B_BIT_Mode(); |
igor_v | 0:8ad47e2b6f00 | 670 | return; |
igor_v | 0:8ad47e2b6f00 | 671 | } |
igor_v | 0:8ad47e2b6f00 | 672 | else if (wcode == CMD_DELTA) //e. is this the B_Delta command? //r. ýòî êîìàíäà B_Delta? |
igor_v | 0:8ad47e2b6f00 | 673 | { |
igor_v | 0:8ad47e2b6f00 | 674 | CMD_Mode = 2; //e. set the value of the Delta mode//r. óñòàíîâèòü çíà÷åíèå ðåæèìà Delta |
igor_v | 0:8ad47e2b6f00 | 675 | B_Delta(); //e. output calculated value of angle increase //r. âûâîäèòü âû÷èñëåííîå çíà÷åíèå ïðèðàùåíèÿ óãëà |
igor_v | 0:8ad47e2b6f00 | 676 | return; |
igor_v | 0:8ad47e2b6f00 | 677 | } |
igor_v | 0:8ad47e2b6f00 | 678 | else if (CMD_Code == CMD_MAINT) //e. is this the Maintenance mode command? //r. ýòî êîìàíäà Maintenance mode? |
igor_v | 0:8ad47e2b6f00 | 679 | { |
igor_v | 0:8ad47e2b6f00 | 680 | if (!RgConB) |
igor_v | 0:8ad47e2b6f00 | 681 | { |
igor_v | 0:8ad47e2b6f00 | 682 | RgConB = RATE_VIBRO_1; |
igor_v | 0:8ad47e2b6f00 | 683 | SwitchRefMeandInt(RATE_VIBRO_1); //e. disable interrupt from referense meander |
igor_v | 0:8ad47e2b6f00 | 684 | } |
igor_v | 0:8ad47e2b6f00 | 685 | CMD_Mode = 5; //e. yes, switch on present mode //r. äà, âêëþ÷èòü äàííûé ðåæèì |
igor_v | 0:8ad47e2b6f00 | 686 | M_Status(); //e. output the status stack of registers //r. âûâåñòè ñòàòóñíûé íàáîð ðåãèñòðîâ |
igor_v | 0:8ad47e2b6f00 | 687 | if (Device_Mode != DM_INT_10KHZ_LATCH) //e. mode of internal latch 10 kHz //r. ðåæèì âíóòðåííåé çàùåëêè 10 êÃö |
igor_v | 0:8ad47e2b6f00 | 688 | { |
igor_v | 0:8ad47e2b6f00 | 689 | Device_Mode = DM_INT_10KHZ_LATCH; |
igor_v | 0:8ad47e2b6f00 | 690 | trm_ena = 0; |
igor_v | 0:8ad47e2b6f00 | 691 | } |
igor_v | 0:8ad47e2b6f00 | 692 | else |
igor_v | 0:8ad47e2b6f00 | 693 | UART_SwitchSpeed(trm_rate); |
igor_v | 0:8ad47e2b6f00 | 694 | return; |
igor_v | 0:8ad47e2b6f00 | 695 | } |
igor_v | 0:8ad47e2b6f00 | 696 | else if (wcode == SUBCMD_M_RESET) //e. is this subcommand for modification of the device control register? //r. ýòî ïîäêîìàíäà ìîäèôèêàöèè ðåãèñòðà óïðàâëåíèÿ ó-âà? |
igor_v | 0:8ad47e2b6f00 | 697 | { |
igor_v | 0:8ad47e2b6f00 | 698 | // Mk_AskDev(); |
igor_v | 0:8ad47e2b6f00 | 699 | M_Reset(); |
igor_v | 0:8ad47e2b6f00 | 700 | return; |
igor_v | 0:8ad47e2b6f00 | 701 | } |
igor_v | 0:8ad47e2b6f00 | 702 | else // subcommand analyse |
igor_v | 0:8ad47e2b6f00 | 703 | { |
igor_v | 0:8ad47e2b6f00 | 704 | if (CMD_Mode == 2) //e. is this the 2(Delta) mode? //r. ýòî ðåæèì 2? (Delta) |
igor_v | 0:8ad47e2b6f00 | 705 | { |
igor_v | 0:8ad47e2b6f00 | 706 | if (CMD_Code == CMD_D_PERIOD_W) //e. the Delta mode, check the subcommand ... //r. ðåæèì DElta, ïðîâåðèòü ïîäêîìàíäó çàãðóçêè ïåðèîäà |
igor_v | 0:8ad47e2b6f00 | 707 | { |
igor_v | 0:8ad47e2b6f00 | 708 | D_Period_W(); //e. otherwise - set the data transfer period //r. èíà÷å óñòàíîâèòèü ïåðèîä âûäà÷è äàííûõ |
igor_v | 0:8ad47e2b6f00 | 709 | return; |
igor_v | 0:8ad47e2b6f00 | 710 | } |
igor_v | 0:8ad47e2b6f00 | 711 | else |
igor_v | 0:8ad47e2b6f00 | 712 | { |
igor_v | 0:8ad47e2b6f00 | 713 | line_sts = line_sts | CODE_ERR; // invalid command code |
igor_v | 0:8ad47e2b6f00 | 714 | return; |
igor_v | 0:8ad47e2b6f00 | 715 | } |
igor_v | 0:8ad47e2b6f00 | 716 | } |
igor_v | 0:8ad47e2b6f00 | 717 | else if (CMD_Mode == 5) //e. check the 5 mode (Maintenance) //r. ïðîâåðêà ðåæèìà 5 (Maintenance) |
igor_v | 0:8ad47e2b6f00 | 718 | { |
igor_v | 0:8ad47e2b6f00 | 719 | if (CMD_Code == SUBCMD_M_CLEAR) //e. is this subcommand of cleaning of the error register? //r. ýòî ïîäêîìàíäà î÷èñòêè ðåãèñòðà îøèáîê ëèíèè? |
igor_v | 0:8ad47e2b6f00 | 720 | { |
igor_v | 0:8ad47e2b6f00 | 721 | M_Clear(); //e. yes, cleaning the error register //r. äà, î÷èñòêà ðåãèñòðà îøèáîê |
igor_v | 0:8ad47e2b6f00 | 722 | M_Status(); //e. preparing for trabsfer of the device status //r. ïîäãîòîâêà ïåðåäà÷è ñòàòóñà óñòðîéñòâà |
igor_v | 0:8ad47e2b6f00 | 723 | UART_SwitchSpeed(trm_rate); |
igor_v | 0:8ad47e2b6f00 | 724 | return; |
igor_v | 0:8ad47e2b6f00 | 725 | } |
igor_v | 0:8ad47e2b6f00 | 726 | else if (CMD_Code == SUBCMD_M_MIRR) //e. is this subcommand of return of previous command? //r. ýòî ïîäêîìàíäà âîçâðàòà ïðåäûäóùåé êîìàíäû? |
igor_v | 0:8ad47e2b6f00 | 727 | { |
igor_v | 0:8ad47e2b6f00 | 728 | rx_buf_copy = 0; //e. yes, forbid copying of command on saving previous //r. äà, çàïðåòèòü êîïèðîâàíèå êîìàíäû äëÿ ñîõðàíåíèÿ ïðåäûäóùåé |
igor_v | 0:8ad47e2b6f00 | 729 | M_Mirror(); //e. prepare transfer of the receiving buffer copy //r. ïîäãîòîâèòü ïåðåäà÷ó êîïèè ïðèåìíîãî áóôåðà |
igor_v | 0:8ad47e2b6f00 | 730 | return; |
igor_v | 0:8ad47e2b6f00 | 731 | } |
igor_v | 0:8ad47e2b6f00 | 732 | /* else if (wcode == SUBCMD_M_TMP_W) //e. is this subcommand for writing instructions to the AD7714? //r. ýòî ïîäêîìàíäà çàïèñè èíñòðóêöèé â AD7714? |
igor_v | 0:8ad47e2b6f00 | 733 | { |
igor_v | 0:8ad47e2b6f00 | 734 | // M_Tmp_W(); //e. yes, procedure call of write of the command //r. äà, âûçîâ ïðîöåäóðû çàïèñè êîìàíäû |
igor_v | 0:8ad47e2b6f00 | 735 | return; |
igor_v | 0:8ad47e2b6f00 | 736 | } */ |
igor_v | 0:8ad47e2b6f00 | 737 | else if (wcode == SUBCMD_M_TMP_R) //e. is this subcommand for data read from the AD7714? //r. ýòî ïîäêîìàíäà ÷òåíèÿ äàííûõ èç AD7714? |
igor_v | 0:8ad47e2b6f00 | 738 | { |
igor_v | 0:8ad47e2b6f00 | 739 | M_Tmp_R(); //r. yes, call the procedure for data read //e. äà, âûçîâ ïðîöåäóðû ÷òåíèÿ äàííûõ |
igor_v | 0:8ad47e2b6f00 | 740 | return; |
igor_v | 0:8ad47e2b6f00 | 741 | } |
igor_v | 0:8ad47e2b6f00 | 742 | /* else if (wcode == SUBCMD_M_E5R_W) //e. is this subcommand for write to the mode register? //r. ýòî ïîäêîìàíäà çàïèñè â ðåãèñòð ðåæèìà? |
igor_v | 0:8ad47e2b6f00 | 743 | { |
igor_v | 0:8ad47e2b6f00 | 744 | M_e5r_W(); //e. yes, write data to the mode register of the Elio5 card //r. äà, çàïèñàòü äàííûå â ðåãèñòð ðåæèìà ïëàòû Elio5 |
igor_v | 0:8ad47e2b6f00 | 745 | return; |
igor_v | 0:8ad47e2b6f00 | 746 | } |
igor_v | 0:8ad47e2b6f00 | 747 | else if (wcode == SUBCMD_M_E5RA_W) //e. is this subcommand for write to the mode register? //r. ýòî ïîäêîìàíäà çàïèñè â ðåãèñòð ðåæèìà? |
igor_v | 0:8ad47e2b6f00 | 748 | { |
igor_v | 0:8ad47e2b6f00 | 749 | M_e5rA_W(); //e. yes, write data to the mode register of the Elio5 card //r. äà, çàïèñàòü äàííûå â ðåãèñòð ðåæèìà ïëàòû Elio5 |
igor_v | 0:8ad47e2b6f00 | 750 | return; |
igor_v | 0:8ad47e2b6f00 | 751 | } */ |
igor_v | 0:8ad47e2b6f00 | 752 | else if (wcode == SUBCMD_M_ADC_R) //e. is t the subcommand for data read from ADCs ADS1250 and ADS8321 ? //r. ýòî ïîäêîìàíäà ÷òåíèÿ äàííûõ èç ÀÖÏ ADS1250 è ADS8321? |
igor_v | 0:8ad47e2b6f00 | 753 | { |
igor_v | 0:8ad47e2b6f00 | 754 | M_ADC_R(); //e. read of ADC channels //r. ÷òåíèå êàíàëîâ ÀÖÏ |
igor_v | 0:8ad47e2b6f00 | 755 | return; |
igor_v | 0:8ad47e2b6f00 | 756 | } |
igor_v | 0:8ad47e2b6f00 | 757 | else if (wcode == SUBCMD_M_CNT_R) //e. is this subcommand of data read from pulse counters? //r. ýòî ïîäêîìàíäà ÷òåíèÿ äàííûõ èç ñ÷åò÷èêîâ èìïóëüñîâ? |
igor_v | 0:8ad47e2b6f00 | 758 | { |
igor_v | 0:8ad47e2b6f00 | 759 | M_Cnt_R(); //e. read of counters //r. ÷òåíèå ñ÷åò÷èêîâ |
igor_v | 0:8ad47e2b6f00 | 760 | return; |
igor_v | 0:8ad47e2b6f00 | 761 | } |
igor_v | 0:8ad47e2b6f00 | 762 | else if (wcode == SUBCMD_M_FLG_R) //e. is it the command of data read about input flags? //r. ýòî ïîäêîìàíäà ÷òåíèÿ äàííûõ î âõîäíûõ ôëàãàõ? |
igor_v | 0:8ad47e2b6f00 | 763 | { |
igor_v | 0:8ad47e2b6f00 | 764 | M_Flg_R(); //e. read the input flags //r. ÷èòàòü âõîäíûå ôëàãè |
igor_v | 0:8ad47e2b6f00 | 765 | return; |
igor_v | 0:8ad47e2b6f00 | 766 | } |
igor_v | 0:8ad47e2b6f00 | 767 | else if (wcode == SUBCMD_M_VIB_W) //e. is this subcommand for load the dither drive period? //r. ýòî ïîäêîìàíäà çàãðóçêè ïåðèîäà âèáðîïðèâîäà? |
igor_v | 0:8ad47e2b6f00 | 768 | { |
igor_v | 0:8ad47e2b6f00 | 769 | M_Vib_W(); //e. set the new value of the period //r. óñòàíîâèòü íîâîå çíà÷åíèå ïåðèîäà |
igor_v | 0:8ad47e2b6f00 | 770 | return; |
igor_v | 0:8ad47e2b6f00 | 771 | } |
igor_v | 0:8ad47e2b6f00 | 772 | else if (wcode == SUBCMD_M_GPH_W) //e. is this subcommand for set the gain factor of photodetector channels? //r. ýòî ïîäêîìàíäà óñòàíîâêè óñèëåíèÿ êàíàëîâ ôîòîïðèåìíèêà ? |
igor_v | 0:8ad47e2b6f00 | 773 | { |
igor_v | 0:8ad47e2b6f00 | 774 | M_Gph_W(); //e. set the new values of gain factor //r. óñòàíîâèòü íîâûå çíà÷åíèÿ óñèëåíèÿ |
igor_v | 0:8ad47e2b6f00 | 775 | return; |
igor_v | 0:8ad47e2b6f00 | 776 | } |
igor_v | 0:8ad47e2b6f00 | 777 | else if (wcode == SUBCMD_M_STIMUL) //e. is this subcommand for set the values of the DACs and flags? //r. ýòî ïîäêîìàíäà óñòàíîâêè çíà÷åíèÿ ÖÀÏîâ è ôäàãîâ ? |
igor_v | 0:8ad47e2b6f00 | 778 | { |
igor_v | 0:8ad47e2b6f00 | 779 | M_Stimul(); //e. set the new values //r. óñòàíîâèòü íîâûå çíà÷åíèÿ |
igor_v | 0:8ad47e2b6f00 | 780 | return; |
igor_v | 0:8ad47e2b6f00 | 781 | } |
igor_v | 0:8ad47e2b6f00 | 782 | else if (wcode == SUBCMD_M_RATE) //e. is this subcommand for set the M_Rate output stack //r. ýòî ïîäêîìàíäà óñòàíîâêè âûäà÷è íàáîðà M_Rate ? |
igor_v | 0:8ad47e2b6f00 | 783 | { |
igor_v | 0:8ad47e2b6f00 | 784 | M_Rate(); //e. switch on the M_Rate data transfer //r. âêëþ÷èòü ïåðåäà÷ó äàííûõ M_Rate |
igor_v | 0:8ad47e2b6f00 | 785 | return; |
igor_v | 0:8ad47e2b6f00 | 786 | } |
igor_v | 0:8ad47e2b6f00 | 787 | else if (wcode == SUBCMD_M_PARAM_W) //e. is this subcommand for write the new value of the GLD parameter ... //r. ýòî ïîäêîìàíäà çàïèñè íîâîãî çíà÷åíèÿ ïàðàìåòðà GLD |
igor_v | 0:8ad47e2b6f00 | 788 | { |
igor_v | 0:8ad47e2b6f00 | 789 | M_Param_W(); //e. write the new value of the parameter //r. çàïèñàòü íîâîå çíà÷åíèå ïàðàìåòðà |
igor_v | 0:8ad47e2b6f00 | 790 | return; |
igor_v | 0:8ad47e2b6f00 | 791 | } |
igor_v | 0:8ad47e2b6f00 | 792 | else if (wcode == SUBCMD_M_PARAM_R) //e. is this subcommand for read the value of the GLD parameter? //r. ýòî ïîäêîìàíäà ÷òåíèÿ çíà÷åíèÿ ïàðàìåòðà GLD? |
igor_v | 0:8ad47e2b6f00 | 793 | { |
igor_v | 0:8ad47e2b6f00 | 794 | M_Param_R(); //e. read the value from the data memory //r. ñ÷èòàòü çíà÷åíèå ïàðàìåòðà èç ïàìÿòè äàíûõ |
igor_v | 0:8ad47e2b6f00 | 795 | return; |
igor_v | 0:8ad47e2b6f00 | 796 | } |
igor_v | 0:8ad47e2b6f00 | 797 | else if (CMD_Code == SUBCMD_M_LDPAR_F) //e. is this subcommand for load GLD parameters ... //r. ýòî ïîäêîìàíäà çàãðóçêè ïàðàìåòðîâ GLD |
igor_v | 0:8ad47e2b6f00 | 798 | { |
igor_v | 0:8ad47e2b6f00 | 799 | M_LdPar_F(); //e. start the loading of parameters //r. çàïóñòèòü çàãðóçêó ïàðàìåòðîâ |
igor_v | 0:8ad47e2b6f00 | 800 | return; |
igor_v | 0:8ad47e2b6f00 | 801 | } |
igor_v | 0:8ad47e2b6f00 | 802 | else if (CMD_Code == SUBCMD_M_LDPAR_D) //e. is this subcommand for direct setting of the GLD parameters ... //r. ýòî ïîäêîìàíäà ïðÿìîãî íàçíà÷åíèÿ ïàðàìåòðîâ GLD |
igor_v | 0:8ad47e2b6f00 | 803 | { |
igor_v | 0:8ad47e2b6f00 | 804 | M_LdPar_D(); //e. read the value of the parameter from the data memory //r. ñ÷èòàòü çíà÷åíèå ïàðàìåòðà èç ïàìÿòè äàíûõ |
igor_v | 0:8ad47e2b6f00 | 805 | return; |
igor_v | 0:8ad47e2b6f00 | 806 | } |
igor_v | 0:8ad47e2b6f00 | 807 | else if (CMD_Code == SUBCMD_M_START) //e. is this subcommand for GLD starting? //r. ýòî ïîäêîìàíäà çàïóñêà GLD? |
igor_v | 0:8ad47e2b6f00 | 808 | { |
igor_v | 0:8ad47e2b6f00 | 809 | M_Start(); //e. call the procedure of start //r. çàïóñòèòü ïðîöåäóðó ñòàðòà |
igor_v | 0:8ad47e2b6f00 | 810 | return; |
igor_v | 0:8ad47e2b6f00 | 811 | } |
igor_v | 0:8ad47e2b6f00 | 812 | else if (CMD_Code == SUBCMD_M_PULSE) //e. is this subcommand for GLD starting? //r. ýòî ïîäêîìàíäà çàïóñêà GLD? |
igor_v | 0:8ad47e2b6f00 | 813 | { |
igor_v | 0:8ad47e2b6f00 | 814 | M_Pulse(); //e. call light-up function //r. âûäàòü èìïóëüñ ïîäæèãà |
igor_v | 0:8ad47e2b6f00 | 815 | return; |
igor_v | 0:8ad47e2b6f00 | 816 | } |
igor_v | 0:8ad47e2b6f00 | 817 | else if (CMD_Code == SUBCMD_M_STOP) //e. is this subcommand for GLD switch off? //r. ýòî ïîäêîìàíäà âûêëþ÷åíèÿ GLD? |
igor_v | 0:8ad47e2b6f00 | 818 | { |
igor_v | 0:8ad47e2b6f00 | 819 | M_Stop(); //e. otherwise- switch off all regulators and stop device //r. âûêëþ÷èòü âñå êîíòóðû è îñòàíîâèòü ïðèáîð |
igor_v | 0:8ad47e2b6f00 | 820 | return; |
igor_v | 0:8ad47e2b6f00 | 821 | } |
igor_v | 0:8ad47e2b6f00 | 822 | else if (wcode == SUBCMD_M_CTL_R) //e. is this subcommand for read the device control register? //r. ýòî ïîäêîìàíäà ÷òåíèÿ ðåãèñòðà óïðàâëåíèÿ ó-âà? |
igor_v | 0:8ad47e2b6f00 | 823 | { |
igor_v | 0:8ad47e2b6f00 | 824 | M_Ctl_R(); |
igor_v | 0:8ad47e2b6f00 | 825 | return; |
igor_v | 0:8ad47e2b6f00 | 826 | } |
igor_v | 0:8ad47e2b6f00 | 827 | else if (wcode == SUBCMD_M_CTL_M) //e. is this subcommand for modification of the device control register? //r. ýòî ïîäêîìàíäà ìîäèôèêàöèè ðåãèñòðà óïðàâëåíèÿ ó-âà? |
igor_v | 0:8ad47e2b6f00 | 828 | { |
igor_v | 0:8ad47e2b6f00 | 829 | M_Ctl_M(); |
igor_v | 0:8ad47e2b6f00 | 830 | return; |
igor_v | 0:8ad47e2b6f00 | 831 | } |
igor_v | 0:8ad47e2b6f00 | 832 | /* else if (wcode == SUBCMD_M_RESET) //e. is this subcommand for modification of the device control register? //r. ýòî ïîäêîìàíäà ìîäèôèêàöèè ðåãèñòðà óïðàâëåíèÿ ó-âà? |
igor_v | 0:8ad47e2b6f00 | 833 | { |
igor_v | 0:8ad47e2b6f00 | 834 | M_Reset(); |
igor_v | 0:8ad47e2b6f00 | 835 | return; |
igor_v | 0:8ad47e2b6f00 | 836 | }*/ |
igor_v | 0:8ad47e2b6f00 | 837 | else |
igor_v | 0:8ad47e2b6f00 | 838 | { |
igor_v | 0:8ad47e2b6f00 | 839 | line_sts = line_sts | MODE_ERR; // mode error |
igor_v | 0:8ad47e2b6f00 | 840 | return; |
igor_v | 0:8ad47e2b6f00 | 841 | } |
igor_v | 0:8ad47e2b6f00 | 842 | } |
igor_v | 0:8ad47e2b6f00 | 843 | } |
igor_v | 0:8ad47e2b6f00 | 844 | } // exec_CMD |
igor_v | 0:8ad47e2b6f00 | 845 | |
igor_v | 0:8ad47e2b6f00 | 846 | void decode_CMD(void) |
igor_v | 0:8ad47e2b6f00 | 847 | { |
igor_v | 0:8ad47e2b6f00 | 848 | int size; |
igor_v | 0:8ad47e2b6f00 | 849 | |
igor_v | 0:8ad47e2b6f00 | 850 | if (!rcv_Rdy) //e. is data in receive buffer? //r. â ïðèåìíîì áóôåðå åñòü èíôîðìàöèÿ? |
igor_v | 0:8ad47e2b6f00 | 851 | { |
igor_v | 0:8ad47e2b6f00 | 852 | return; //e. if no, stop processing //r. åñëè íåò, çàêîí÷èòü îáðàáîòêó |
igor_v | 0:8ad47e2b6f00 | 853 | } |
igor_v | 0:8ad47e2b6f00 | 854 | |
igor_v | 0:8ad47e2b6f00 | 855 | if (!line_sts) //e. Whether there were errors of receiving of start-bit? //r. áûëè ëè îøèáêè ïðèåìà ñòàðò-áèòà ? |
igor_v | 0:8ad47e2b6f00 | 856 | { |
igor_v | 0:8ad47e2b6f00 | 857 | //e. there were not errors of receiving of bytes, check the device address //r. îøèáîê ïðèåìà áàéòîâ íå áûëî, ïðîâåðèòü àäðåñ îáðàùåíèÿ |
igor_v | 0:8ad47e2b6f00 | 858 | //Is_Brodcast_Req = 0; //e. reset the flag of broadcasting request //r. ñáðîñèòü ôëàã øèðîêîâåùàòåëüíîãî çàïðîñà |
igor_v | 0:8ad47e2b6f00 | 859 | if (rcv_buf[1] != Device_blk.Str.My_Addres) |
igor_v | 0:8ad47e2b6f00 | 860 | { |
igor_v | 0:8ad47e2b6f00 | 861 | if (rcv_buf[1] != BROADCAST_ADDRESS) |
igor_v | 0:8ad47e2b6f00 | 862 | { |
igor_v | 0:8ad47e2b6f00 | 863 | goto end; |
igor_v | 0:8ad47e2b6f00 | 864 | } |
igor_v | 0:8ad47e2b6f00 | 865 | } |
igor_v | 0:8ad47e2b6f00 | 866 | |
igor_v | 0:8ad47e2b6f00 | 867 | if (rcv_buf[0] == COMMAND_PREFIX) |
igor_v | 0:8ad47e2b6f00 | 868 | { //e. there is new command in the receiver buffer, stop the transfer //r. â áóôåðå ïðèåìíèêà åñòü íîâàÿ êîìàíäà, ïðåêðàòèòü ïåðåäà÷ó |
igor_v | 0:8ad47e2b6f00 | 869 | trm_ena = 0; //e. reset the flag of transmission allowing //r. ñáðîñèòü ôëàã ðàçðåøåíèÿ ïåðåäà÷è |
igor_v | 0:8ad47e2b6f00 | 870 | |
igor_v | 0:8ad47e2b6f00 | 871 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
igor_v | 0:8ad47e2b6f00 | 872 | |
igor_v | 0:8ad47e2b6f00 | 873 | exec_CMD(); // øåé êîìàíäû |
igor_v | 0:8ad47e2b6f00 | 874 | |
igor_v | 0:8ad47e2b6f00 | 875 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
igor_v | 0:8ad47e2b6f00 | 876 | |
igor_v | 0:8ad47e2b6f00 | 877 | |
igor_v | 0:8ad47e2b6f00 | 878 | //e. check up presence of errors in operation of this procedure //r. ïðîâåðèòü, íàëè÷èå îøèáîê â ðàáîòå äàííîé ïîöåäóðû |
igor_v | 0:8ad47e2b6f00 | 879 | //e. did is the "unknown code of a command" or "parameters were set incorrectly" error? //r. áûëà îøèáêà "íåèçâåñòíûé êîä êîìàíäû" èëè "íåâåðíî çàäàííûå ïàðàìåòðû"? |
igor_v | 0:8ad47e2b6f00 | 880 | if ( ((line_sts & CODE_ERR) == CODE_ERR) || ((line_sts & PARAM_ERR) == PARAM_ERR) ) |
igor_v | 0:8ad47e2b6f00 | 881 | { |
igor_v | 0:8ad47e2b6f00 | 882 | line_err = line_sts; //e. set error bits in the error register of the line //r. óñòàíîâèòü áèòû îøèáîê â ðåãèñòðå îøèáîê ëèíèè |
igor_v | 0:8ad47e2b6f00 | 883 | } |
igor_v | 0:8ad47e2b6f00 | 884 | } |
igor_v | 0:8ad47e2b6f00 | 885 | else |
igor_v | 0:8ad47e2b6f00 | 886 | { |
igor_v | 0:8ad47e2b6f00 | 887 | line_err = line_sts | NO_CMD_ERR; // äîáàâëåíèå îøèáêè â ðåãèñòð îøèáîê |
igor_v | 0:8ad47e2b6f00 | 888 | } |
igor_v | 0:8ad47e2b6f00 | 889 | |
igor_v | 0:8ad47e2b6f00 | 890 | } |
igor_v | 0:8ad47e2b6f00 | 891 | else |
igor_v | 0:8ad47e2b6f00 | 892 | { |
igor_v | 0:8ad47e2b6f00 | 893 | line_err = line_sts; |
igor_v | 0:8ad47e2b6f00 | 894 | } |
igor_v | 0:8ad47e2b6f00 | 895 | end: |
igor_v | 0:8ad47e2b6f00 | 896 | if (rx_buf_copy) //e. is copying of present received packet needed? //r. òðåáóåòñÿ êîïèðîâàíèå äàííîãî ïðèíÿòîãî ïàêåòà? |
igor_v | 0:8ad47e2b6f00 | 897 | { |
igor_v | 0:8ad47e2b6f00 | 898 | size = rcv_num_byt; |
igor_v | 0:8ad47e2b6f00 | 899 | rcv_byt_copy = rcv_num_byt; //e. save the size of copy //r. çàïîìíèòü ðàçìåð êîïèè |
igor_v | 0:8ad47e2b6f00 | 900 | if (rcv_num_byt > sizeof(rcv_buf)) //e. compare the size of receiving buffer with amount of received bytes //r. êîïèðîâàíèå òðåáóåòñÿ, ñðàâíèòü ðàçìåð ïðèåìíîãî áóôåðà ñ ÷èñëîì ïðèíÿòûõ áàéò |
igor_v | 0:8ad47e2b6f00 | 901 | { |
igor_v | 0:8ad47e2b6f00 | 902 | size = sizeof(rcv_buf); |
igor_v | 0:8ad47e2b6f00 | 903 | } |
igor_v | 0:8ad47e2b6f00 | 904 | memcpy(rcv_copy, rcv_buf, size); //e. copy of received amount of bytes, but no more than buffer size //r. êîïèðîâàòü ïðèíÿòîå ÷èñëî áàéò, íî íå áîëåå ðàçìåðà áóôåðà |
igor_v | 0:8ad47e2b6f00 | 905 | } |
igor_v | 0:8ad47e2b6f00 | 906 | rx_buf_copy = 0; //e. reset the flag of necessity of copying of receiving buffer //r. ñáðîñèòü ôëàã íåîáõîäèìîñòè êîïèðîâàíèÿ ïðèåìíîãî áóôåðà |
igor_v | 0:8ad47e2b6f00 | 907 | |
igor_v | 0:8ad47e2b6f00 | 908 | do |
igor_v | 0:8ad47e2b6f00 | 909 | rcv_buf[--rcv_num_byt] = 0; |
igor_v | 0:8ad47e2b6f00 | 910 | while(rcv_num_byt); |
igor_v | 0:8ad47e2b6f00 | 911 | rcv_num_byt_old = rcv_num_byt; |
igor_v | 0:8ad47e2b6f00 | 912 | line_sts = 0; //e. reset the line status register //r. ñáðîñèòü ðåãèñòð ñòàòóñà ëèíèè |
igor_v | 0:8ad47e2b6f00 | 913 | rcv_Rdy = 0; //e. allow further data reception //r. ðàçðåøèòü äàëüíåéøèé ïðèåì äàííûõ |
igor_v | 0:8ad47e2b6f00 | 914 | } // decode_CMD |
igor_v | 0:8ad47e2b6f00 | 915 | |
igor_v | 0:8ad47e2b6f00 | 916 |