Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of LG by
commandset.c@1:f2adcae3d304, 2016-01-30 (annotated)
- Committer:
- igor_v
- Date:
- Sat Jan 30 13:53:19 2016 +0000
- Revision:
- 1:f2adcae3d304
- Parent:
- 0:8ad47e2b6f00
- Child:
- 21:bc8c1cec3da6
123
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
igor_v | 1:f2adcae3d304 | 1 | |
igor_v | 1:f2adcae3d304 | 2 | |
igor_v | 1:f2adcae3d304 | 3 | |
igor_v | 0:8ad47e2b6f00 | 4 | #include <string.h> |
igor_v | 1:f2adcae3d304 | 5 | |
igor_v | 1:f2adcae3d304 | 6 | |
igor_v | 1:f2adcae3d304 | 7 | #include "Global.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 | 1:f2adcae3d304 | 14 | //e. +++++++++++++++++++ variables +++++++++++++++++++++++++++++++++++++++++++ //r. +++++++++++++++++++ ���������� +++++++++++++++++++++++++++++++++++++++++++ |
igor_v | 1:f2adcae3d304 | 15 | uint32_t CMD_Mode = 0; //e. operation mode of the device //r. ����� ������ ���������� |
igor_v | 1:f2adcae3d304 | 16 | uint32_t CMD_Code; //e. full code of the last recieved command //r. ������ ��� ��������� �������� ������� |
igor_v | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 23 | void SetSpeedPeriod(void) //e.============ procedure of set of rate and periodicity of answer ======== //r.============ ��������� ��������� �������� � ������������� ������ ======== |
igor_v | 0:8ad47e2b6f00 | 24 | { |
igor_v | 1:f2adcae3d304 | 25 | if ((rcv_buf[3] & 0x0080) != 0) //e. is periodic data transmission needed? //r. ������������� �������� ���������? |
igor_v | 0:8ad47e2b6f00 | 26 | { |
igor_v | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 31 | trm_cycl = 0; //e. no, reset present flag //r. ���, �������� ������ ���� |
igor_v | 0:8ad47e2b6f00 | 32 | } |
igor_v | 0:8ad47e2b6f00 | 33 | |
igor_v | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 44 | num_of_par = 2; //e. 2 parameters output //r. �������� 2 ��������� |
igor_v | 1:f2adcae3d304 | 45 | addr_param[0] = &Output.Str.BINS_dif; //e. set the first parameter address //r. ������ ����� ������� ��������� |
igor_v | 1:f2adcae3d304 | 46 | addr_param[1] = &Valid_Data; //e. set the second paremeter address //r. ������ ����� ������� ��������� |
igor_v | 1:f2adcae3d304 | 47 | size_param[0] = 4; //e. the length of the 1st parameter is 4 bytes //r. �������� 1 ���e� ����� 4 ����� |
igor_v | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 53 | void B_Delta_SF(void) //r.=== ��������� ��� ��������� ����������� ��������� |
igor_v | 0:8ad47e2b6f00 | 54 | { |
igor_v | 1:f2adcae3d304 | 55 | //e. time for data transfer has come, we work only with dither counters //r. ������ ����� ���������� ������, �������� ������ � �����-���������� |
igor_v | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 60 | num_of_par = 5;//8; //e. 8 parameters output //r. �������� 8 ��������� |
igor_v | 1:f2adcae3d304 | 61 | addr_param[0] = &Output.Str.SF_dif; //e. set the first parameter address //r. ������ ����� ������� ��������� |
igor_v | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 66 | size_param[0] = 8; //e. the length of the 1st parameter is 4 bytes //r. �������� 1 ���e� ����� 4 ����� |
igor_v | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 97 | num_of_par = 2; //e. 2 parameters output //r. �������� 2 ��������� |
igor_v | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 100 | size_param[0] = 2; //e. the 1st parameter has 2 bytes length //r. �������� 1 ���e� ����� 2 ���� |
igor_v | 1:f2adcae3d304 | 101 | size_param[1] = 2; //e. the 2nd and 3rd parameters have 1 bytes length//r. ��������� 2,3 ����� ����� 1 ���� |
igor_v | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 111 | void M_Mirror(void) //e.---------------- prepare to transmission of the copy of receiving buffer ------------- //r.---------------- ���������� �������� ����� ��������� ������ ------------- |
igor_v | 0:8ad47e2b6f00 | 112 | { |
igor_v | 1:f2adcae3d304 | 113 | num_of_par = 1; //e. 1 parameter output //r. �������� 1 �������� |
igor_v | 0:8ad47e2b6f00 | 114 | |
igor_v | 1:f2adcae3d304 | 115 | addr_param[0] = &rcv_copy; //e. set the address of the receiving buffer //r. ��������� ������ ��������� ������ |
igor_v | 0:8ad47e2b6f00 | 116 | |
igor_v | 1:f2adcae3d304 | 117 | //e. multiply the number of copied words on 2, since each //r. �������� ����� ������������� ���� �� 2, �.�. ������ |
igor_v | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 124 | trm_rate = 0; //e. set the transfer rate to the 38400 bauds //r. ���������� �������� �������� 38400 ��� |
igor_v | 1:f2adcae3d304 | 125 | trm_cycl = 0; //e. forbid cyclic transmission of the parameter //r. ��������� �������� ��������� � ����� |
igor_v | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 129 | void Mk_Ask1(void) //r.----------------- prepare of the standart answer 1 ---------------------- //r.----------------- ���������� ������������ ������ 1 ---------------------- |
igor_v | 0:8ad47e2b6f00 | 130 | { |
igor_v | 1:f2adcae3d304 | 131 | CMD_Code &= 0xff00; //e. clear bits of errors //r. �������� � ��� ���� ������ |
igor_v | 1:f2adcae3d304 | 132 | num_of_par = 1; //e. total amount parameters in aswer - 1 //r. ����� ���������� � ������ - 1 |
igor_v | 1:f2adcae3d304 | 133 | addr_param[0] = &CMD_Code; //e. and this parameter - returnable command code //r. � ���� �������� - ������������ ��� ������� |
igor_v | 1:f2adcae3d304 | 134 | size_param[0] = 2; //e. and both its bytes //r. ������ ��� ��� ����� |
igor_v | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 138 | void Mk_AskDev(void) //r.----------------- answer on a command for device mode set ------------ //r.----------------- ����� �� ������� ��������� ������ ������� ------------ |
igor_v | 0:8ad47e2b6f00 | 139 | { |
igor_v | 1:f2adcae3d304 | 140 | num_of_par = 2; //e. 2 parameters output //r. �������� ��� ��������� |
igor_v | 1:f2adcae3d304 | 141 | addr_param[0] = &Device_Mode; //e. address of the counter mode register (intenal latch, external latch, etc.) //r. ����� �������� ������ ��������� (�����., ������� ������� � �.�.) |
igor_v | 1:f2adcae3d304 | 142 | addr_param[1] = &SRgR; //e. address of the mode register of the processor card //r. ����� �������� ������ ����� ���������� |
igor_v | 1:f2adcae3d304 | 143 | size_param[0] = 2; //e. size of the counter mode register - 2 bytes //r. ������ �������� ������ ��������� - 2 ����� |
igor_v | 1:f2adcae3d304 | 144 | size_param[1] = 2; //e. size of the mode register of the processor card //r. ������ �������� ������ ����� ���������� |
igor_v | 1:f2adcae3d304 | 145 | trm_cycl = 0; //e. forbid cyclic transmission of the parameter //r. ��������� �������� ��������� � ����� |
igor_v | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 163 | CMD_Code &= 0xff1f; //e. reset bits of current command code settings of periodicity and transfer rate //r. �������� � ������� ���� ������� ���� ��������� ������������� � �������� �������� |
igor_v | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 181 | //e. set main device operation modes: //r. ��������� �������� ������� ������ �������: |
igor_v | 1:f2adcae3d304 | 182 | //e. 1. acions with counters (internal latch, external latch with request over line, //r. 1. ������ �� ���������� (���������� �������, ������� ������� � �������� �� �����, |
igor_v | 1:f2adcae3d304 | 183 | //e. external latch without request over line (instant answer after receiving of external latch pulse)) //r. ������� ������� ��� ������� �� ����� (����� ����� ����� ������� �������� �����. �������)) |
igor_v | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 187 | Device_Mode = rcv_buf[3] & 0x00ff; //e. read the byte of command parameter from the receiver buffer //r. ������� �� ������ ��������� ���� ��������� ������� |
igor_v | 1:f2adcae3d304 | 188 | //e. and write it to the counter mode register //r. � ���������� � ������� ������ ��������� |
igor_v | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 224 | if ((CMD_Code & (1 << 7)) == 0) //e. to estimate: whether the answer is required //r. �������: ��������� �� ����� |
igor_v | 0:8ad47e2b6f00 | 225 | { |
igor_v | 1:f2adcae3d304 | 226 | return; //e. if no - return //r. ���� ��� - ������� |
igor_v | 0:8ad47e2b6f00 | 227 | } |
igor_v | 1:f2adcae3d304 | 228 | Mk_Ask1(); //e. otherwise - answer output //r. ����� - ������ ����� |
igor_v | 0:8ad47e2b6f00 | 229 | } // M_Stymul |
igor_v | 0:8ad47e2b6f00 | 230 | |
igor_v | 1:f2adcae3d304 | 231 | void M_Status(void) //e. === procedure of initialization of transmission of the device status //r. === ��������� ������������� �������� ������� ���������� |
igor_v | 0:8ad47e2b6f00 | 232 | { |
igor_v | 1:f2adcae3d304 | 233 | SetSpeedPeriod(); //e. and set the answer transfer rate and its periodicity //r. � ���������� �������� �������� ������ � ��� ������������� |
igor_v | 0:8ad47e2b6f00 | 234 | |
igor_v | 1:f2adcae3d304 | 235 | num_of_par = 2; //e. 2 parameters output //r. �������� ��� ��������� |
igor_v | 1:f2adcae3d304 | 236 | addr_param[0] = &blt_in_test; //e. the register address of the self-testing result //r. ����� �������� ���������� ���������������� |
igor_v | 1:f2adcae3d304 | 237 | addr_param[1] = &ser_num; //e. address of the register of errors of line //r. ����� �������� ������ ����� |
igor_v | 1:f2adcae3d304 | 238 | size_param[0] = 2; //e. size of the self-test register - 2 bytes //r. ������ �������� ���������������� - 2 ����� |
igor_v | 1:f2adcae3d304 | 239 | size_param[1] = 2; //e. size of the register of errors of line //r. ������ �������� ������ ����� |
igor_v | 0:8ad47e2b6f00 | 240 | |
igor_v | 1:f2adcae3d304 | 241 | trm_rate = 0; //e. set the transfer rate to the 38400 bauds //r. ���������� �������� �������� 38400 ��� |
igor_v | 1:f2adcae3d304 | 242 | trm_cycl = 0; //e. forbid cyclic transmission of the parameter //r. ��������� �������� ��������� � ����� |
igor_v | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 267 | num_of_par = 4; //e. 4 parameters output //r. �������� ������ ��������� |
igor_v | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 271 | addr_param[3] = &(Input.StrIn.HF_out); //e. set the 4th parameter address _HF_out //r. ������ ����� ���������� ��������� _HF_out |
igor_v | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 279 | void M_Cnt_R(void) //r.----------------- read the counters of the Elio5 card -------------------------- //r.----------------- ������ ��������� ����� Elio5 -------------------------- |
igor_v | 0:8ad47e2b6f00 | 280 | { |
igor_v | 1:f2adcae3d304 | 281 | SetSpeedPeriod(); //e. set the answer transfer rate and its periodicity //r. ���������� �������� �������� ������ � ��� ������������� |
igor_v | 0:8ad47e2b6f00 | 282 | UART_SwitchSpeed(trm_rate); |
igor_v | 1:f2adcae3d304 | 283 | num_of_par = 2; //e. 2 parameters output //r. �������� ��� ��������� |
igor_v | 0:8ad47e2b6f00 | 284 | |
igor_v | 1:f2adcae3d304 | 285 | addr_param[0] = &(Output.Str.Cnt_Pls); //e. set the first parameter address //r. ������ ����� ������� ��������� |
igor_v | 1:f2adcae3d304 | 286 | addr_param[1] = &(Output.Str.Cnt_Mns); //e. set the second paremeter address //r. ������ ����� ������� ��������� |
igor_v | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 294 | //e. read the byte of command parameter from the receiver buffer //r. ������� �� ������ ��������� ���� ��������� ������� |
igor_v | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 306 | //e. this command is used for switching a signal on which data counters are latched: //r. ��� ������� ������������ ��� ������������ �������, �� �������� ������������� |
igor_v | 1:f2adcae3d304 | 307 | //e. on the Reper signal or on Sign Meander //r. �������������� ��������: ���� �� Reper`� ���� �� RefMeandr`� |
igor_v | 0:8ad47e2b6f00 | 308 | |
igor_v | 1:f2adcae3d304 | 309 | //e. read the byte of command parameter from the receiver buffer //r. ������� �� ������ ��������� ���� ��������� ������� |
igor_v | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 320 | void M_Ctl_R(void) //r.----------------- reading the control register of the device ----------------- //r.----------------- ������ �������� ���������� ���������� ----------------- |
igor_v | 0:8ad47e2b6f00 | 321 | { |
igor_v | 1:f2adcae3d304 | 322 | num_of_par = 2; //e. 2 parameters transfer //r. ���������� 2 ��������� |
igor_v | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 325 | size_param[1] = 2; //e. two bytes also have control registers //r. ��� ����� ����� ����� � �������� ���������� |
igor_v | 1:f2adcae3d304 | 326 | if ((rcv_buf[3] & (1 << 4)) == 0) //e. is main control register needed? //r. ��������� �������� ������� ����������? |
igor_v | 0:8ad47e2b6f00 | 327 | { |
igor_v | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 332 | addr_param[1] = &RgConB; //e. otherwise - load the address of the addititonal register //r. ����� - ��������� ����� ��������������� �������� |
igor_v | 0:8ad47e2b6f00 | 333 | } |
igor_v | 1:f2adcae3d304 | 334 | CMD_Code &= 0xff10; //e. clear in it bit of errors and byte number //r. �������� � ��� ���� ������ � ������ ���� |
igor_v | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 343 | num_of_par = 2; //e. 2 parameters transfer //r. ���������� 2 ��������� |
igor_v | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 346 | size_param[1] = 2; //e. two bytes also have control registers //r. ��� ����� ����� ����� � �������� ���������� |
igor_v | 1:f2adcae3d304 | 347 | if ((CMD_Code & (1 << 4)) == 0) //e. is main control register needed? //r. ��������� �������� ������� ����������? |
igor_v | 0:8ad47e2b6f00 | 348 | { |
igor_v | 1:f2adcae3d304 | 349 | ptr = &RgConA; //e. yes //r. �� |
igor_v | 0:8ad47e2b6f00 | 350 | } |
igor_v | 0:8ad47e2b6f00 | 351 | else |
igor_v | 0:8ad47e2b6f00 | 352 | { |
igor_v | 1:f2adcae3d304 | 353 | ptr = &RgConB; //e. otherwise - load the address of the addititonal register //r. ����� - ��������� ����� ��������������� �������� |
igor_v | 0:8ad47e2b6f00 | 354 | } |
igor_v | 1:f2adcae3d304 | 355 | addr_param[1] = ptr; //e. the second parameter in answer - modified register //r. ������ �������� � ������ - ���������������� ������� |
igor_v | 0:8ad47e2b6f00 | 356 | |
igor_v | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 367 | CMD_Code &= 0xff10; //e. clear in command bit of errors and byte number //r. �������� � ������� ���� ������ � ������ ���� |
igor_v | 1:f2adcae3d304 | 368 | trm_cycl = 0; //e. forbid cyclic transmission of the parameter //r. ��������� �������� ��������� � ����� |
igor_v | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 375 | num_of_par = 1; //e. 1 parameter output //r. �������� ���� �������� |
igor_v | 1:f2adcae3d304 | 376 | addr_param[0] = &In_Flag; //e. the address of the flag register copy //r. ����� ����� �������� ������ |
igor_v | 1:f2adcae3d304 | 377 | size_param[0] = 2; //e. size of the buffer - 2 bytes //r. ������ ������ - 2 ����� |
igor_v | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 382 | void M_Vib_W(void) //r.------------ set the oscillation period of the dither drive ----------------- //r.------------ ��������� ������� ��������� ������������ ----------------- |
igor_v | 0:8ad47e2b6f00 | 383 | { |
igor_v | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 392 | VibroDither_Set(); //e. and output its value to period registers on card //r. ������� �� �������� � �������� ������� �� ����� |
igor_v | 0:8ad47e2b6f00 | 393 | |
igor_v | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 398 | void M_Gph_W(void) //e.------------ set the gain factor of photodetector channels ------------------- //r.------------ ��������� �������� ������� ������������� ------------------- |
igor_v | 0:8ad47e2b6f00 | 399 | { |
igor_v | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 423 | wrk_period = 12500000; //e. load needed length of working period 1 �.//r. ��������� ��������� ������������ �������� ������� 1 �. |
igor_v | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 428 | addr_param[0] = &(Output.Str.Cnt_Pls); //e. set the address of the 1st parameter in the 1st group //r. ������ ����� ������� ��������� � 1-�� ������ |
igor_v | 1:f2adcae3d304 | 429 | addr_param[1] = &(Output.Str.Cnt_Mns); //e. set the address of the 1st parameter in the 2nd group //r. ������ ����� ������� ��������� � 2-�� ������ |
igor_v | 1:f2adcae3d304 | 430 | addr_param[2] = &(Output.Str.Cnt_Dif); //e. set the address of the 1st parameter in the 3rd group //r. ������ ����� ������� ��������� � 3-�� ������ |
igor_v | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 434 | addr_param[6] = &(Output.Str.T_Vibro); //e. parameter _T_Vibro //r. �������� _T_Vibro |
igor_v | 1:f2adcae3d304 | 435 | addr_param[7] = &(Output.Str.T_VB_pll); //e. parameter _T_VB_pll //r.��������� _T_VB_pll |
igor_v | 1:f2adcae3d304 | 436 | addr_param[8] = &(Output.Str.L_Vibro); //e. parameter _L_Vibro //r. �������� _L_Vibro |
igor_v | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 438 | addr_param[10] = &(Output.Str.WP_reg); //e. parameters: _WP_reg, _WP_pll //r. ���������� _WP_reg, _WP_pll |
igor_v | 1:f2adcae3d304 | 439 | addr_param[11] = &(Output.Str.WP_pll); //e. parameters: _WP_reg, _WP_pll //r. ���������� _WP_reg, _WP_pll |
igor_v | 1:f2adcae3d304 | 440 | addr_param[12] = &(Output.Str.Tmp_Out); //e. set the address of the temperature sensors array //r. ������ ����� ������� �������� ����������� |
igor_v | 1:f2adcae3d304 | 441 | addr_param[13] = &(Output.Str.WP_scope1); //e. reserved //r. ��������������� ��� ���������� ���������� |
igor_v | 0:8ad47e2b6f00 | 442 | |
igor_v | 1:f2adcae3d304 | 443 | size_param[0] = 2; //e. groups 1-6, 8-10 consists of one parameter ... //r. ������ 1-6, 8-10 �������� �� ������ ��������� |
igor_v | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 458 | size_param[12] = 12; //e. format o the GLD array of temperatures - 12 bytes //r. ������ ������� ���������� ��� - 12 ���� |
igor_v | 0:8ad47e2b6f00 | 459 | |
igor_v | 1:f2adcae3d304 | 460 | trm_ena = 1; //e. allow operation of the transmitter //r. ��������� ������ ����������� |
igor_v | 0:8ad47e2b6f00 | 461 | break; |
igor_v | 0:8ad47e2b6f00 | 462 | |
igor_v | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 466 | wrk_period = 0; //e. frequency of output = fvibro //r. ������� ������ ����� ������� �� |
igor_v | 0:8ad47e2b6f00 | 467 | |
igor_v | 1:f2adcae3d304 | 468 | num_of_par = 2; //e. 2 parameters output //r. �������� 2 ��������� |
igor_v | 0:8ad47e2b6f00 | 469 | |
igor_v | 1:f2adcae3d304 | 470 | addr_param[0] = &(Output.Str.Cnt_Pls); //e. set the first parameter address //r. ������ ����� ������� ��������� |
igor_v | 1:f2adcae3d304 | 471 | addr_param[1] = &(Output.Str.Cnt_Mns); //e. and the 2nd //r. � ������� |
igor_v | 1:f2adcae3d304 | 472 | size_param[0] = 2; //e. parameters has 2 bytes length //r. ��������� ����� ����� 2 ����� |
igor_v | 0:8ad47e2b6f00 | 473 | size_param[1] = 2; |
igor_v | 1:f2adcae3d304 | 474 | trm_ena = 1; //e. allow operation of the transmitter //r. ��������� ������ ����������� |
igor_v | 0:8ad47e2b6f00 | 475 | break; |
igor_v | 0:8ad47e2b6f00 | 476 | |
igor_v | 1:f2adcae3d304 | 477 | case 3: //e. it is the Rate3 stack //r. ��� ����� Rate3 |
igor_v | 0:8ad47e2b6f00 | 478 | |
igor_v | 1:f2adcae3d304 | 479 | wrk_period = 2500; //e. frequency of output = 10000 Hz //r. n=1, ������� ������ = 10000 Hz |
igor_v | 1:f2adcae3d304 | 480 | num_of_par = 2; //e. 2 parameters output //r. �������� 2 ��������� |
igor_v | 0:8ad47e2b6f00 | 481 | |
igor_v | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 486 | trm_ena = 1; //e. allow operation of the transmitter //r. ��������� ������ ����������� |
igor_v | 0:8ad47e2b6f00 | 487 | break; |
igor_v | 0:8ad47e2b6f00 | 488 | |
igor_v | 1:f2adcae3d304 | 489 | case 4: //e. it is the Rate4 stack //r. ��� ����� Rate4 |
igor_v | 1:f2adcae3d304 | 490 | wrk_period = 20000; //e. correspond to output frequency 1.25 kHz //r. ������������ ������� ������ 1.25 kHz |
igor_v | 1:f2adcae3d304 | 491 | num_of_par = 4; //e. 4 parameters output //r. �������� 4 ��������� |
igor_v | 0:8ad47e2b6f00 | 492 | |
igor_v | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 499 | addr_param[2] = &(Output.Str.HF_reg); //e. HFO regulator //r. ���������� ��� |
igor_v | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 508 | wrk_period = 20000; //e. correspond to output frequency 1250 Hz //r. ������������ ������� ������ 1.25 kHz |
igor_v | 1:f2adcae3d304 | 509 | num_of_par = 5; //e. 4 parameters output //r. �������� 5 ��������� |
igor_v | 0:8ad47e2b6f00 | 510 | |
igor_v | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 517 | addr_param[2] = &(Output.Str.WP_reg); //e. CPLC heater regulator //r. ���������� ����������� |
igor_v | 1:f2adcae3d304 | 518 | addr_param[3] = &(Output.Str.WP_pll); //e. CPLC phase //r. ���� |
igor_v | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 538 | num_of_par = 1; //e. 1 parameter output //r. �������� ���� �������� |
igor_v | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 540 | size_param[0] = 2; //e. size of the buffer - 2 bytes //r. ������ ������ - 2 ����� |
igor_v | 0:8ad47e2b6f00 | 541 | |
igor_v | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 580 | void M_Start(void) //e.============ initialization of the GLD switch on ================================= //r.============ ������������� ������� ��� ================================= |
igor_v | 0:8ad47e2b6f00 | 581 | { |
igor_v | 1:f2adcae3d304 | 582 | start_Rq = 1; //e. set the flag of the GLD switch on request //r. ���������� ���� ������� ������ ��� |
igor_v | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 587 | void M_Stop(void) //e.============ initialization of the GLD switch off ============================== //r.============ ������������� ���������� ��� ============================== |
igor_v | 0:8ad47e2b6f00 | 588 | { |
igor_v | 1:f2adcae3d304 | 589 | stop_Rq = 1; //e. set the flag of the GLD switch off request //r. ���������� ���� ������� ���������� ��� |
igor_v | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 594 | void M_Pulse(void) //e.============ generetion of the light-up pulse ========================= //r.============ ��������� �������� ������� ������ ========================= |
igor_v | 0:8ad47e2b6f00 | 595 | { |
igor_v | 1:f2adcae3d304 | 596 | pulse_Rq = 1; //e. set the flag of the GLD switch on request //r. ���������� ���� ������� ������ ��� |
igor_v | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 666 | else if (wcode == CMD_BIT_MODE) //e. is this the BIT mode command? //r. ��� ������� ������������? |
igor_v | 0:8ad47e2b6f00 | 667 | { |
igor_v | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 672 | else if (wcode == CMD_DELTA) //e. is this the B_Delta command? //r. ��� ������� B_Delta? |
igor_v | 0:8ad47e2b6f00 | 673 | { |
igor_v | 1:f2adcae3d304 | 674 | CMD_Mode = 2; //e. set the value of the Delta mode//r. ���������� �������� ������ Delta |
igor_v | 1:f2adcae3d304 | 675 | B_Delta(); //e. output calculated value of angle increase //r. �������� ����������� �������� ���������� ���� |
igor_v | 0:8ad47e2b6f00 | 676 | return; |
igor_v | 0:8ad47e2b6f00 | 677 | } |
igor_v | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 685 | CMD_Mode = 5; //e. yes, switch on present mode //r. ��, �������� ������ ����� |
igor_v | 1:f2adcae3d304 | 686 | M_Status(); //e. output the status stack of registers //r. ������� ��������� ����� ��������� |
igor_v | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 704 | if (CMD_Mode == 2) //e. is this the 2(Delta) mode? //r. ��� ����� 2? (Delta) |
igor_v | 0:8ad47e2b6f00 | 705 | { |
igor_v | 1:f2adcae3d304 | 706 | if (CMD_Code == CMD_D_PERIOD_W) //e. the Delta mode, check the subcommand ... //r. ����� DElta, ��������� ���������� �������� ������� |
igor_v | 0:8ad47e2b6f00 | 707 | { |
igor_v | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 717 | else if (CMD_Mode == 5) //e. check the 5 mode (Maintenance) //r. �������� ������ 5 (Maintenance) |
igor_v | 0:8ad47e2b6f00 | 718 | { |
igor_v | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 721 | M_Clear(); //e. yes, cleaning the error register //r. ��, ������� �������� ������ |
igor_v | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 728 | rx_buf_copy = 0; //e. yes, forbid copying of command on saving previous //r. ��, ��������� ����������� ������� ��� ���������� ���������� |
igor_v | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 754 | M_ADC_R(); //e. read of ADC channels //r. ������ ������� ��� |
igor_v | 0:8ad47e2b6f00 | 755 | return; |
igor_v | 0:8ad47e2b6f00 | 756 | } |
igor_v | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 759 | M_Cnt_R(); //e. read of counters //r. ������ ��������� |
igor_v | 0:8ad47e2b6f00 | 760 | return; |
igor_v | 0:8ad47e2b6f00 | 761 | } |
igor_v | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 764 | M_Flg_R(); //e. read the input flags //r. ������ ������� ����� |
igor_v | 0:8ad47e2b6f00 | 765 | return; |
igor_v | 0:8ad47e2b6f00 | 766 | } |
igor_v | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 779 | M_Stimul(); //e. set the new values //r. ���������� ����� �������� |
igor_v | 0:8ad47e2b6f00 | 780 | return; |
igor_v | 0:8ad47e2b6f00 | 781 | } |
igor_v | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 799 | M_LdPar_F(); //e. start the loading of parameters //r. ��������� �������� ���������� |
igor_v | 0:8ad47e2b6f00 | 800 | return; |
igor_v | 0:8ad47e2b6f00 | 801 | } |
igor_v | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 807 | else if (CMD_Code == SUBCMD_M_START) //e. is this subcommand for GLD starting? //r. ��� ���������� ������� GLD? |
igor_v | 0:8ad47e2b6f00 | 808 | { |
igor_v | 1:f2adcae3d304 | 809 | M_Start(); //e. call the procedure of start //r. ��������� ��������� ������ |
igor_v | 0:8ad47e2b6f00 | 810 | return; |
igor_v | 0:8ad47e2b6f00 | 811 | } |
igor_v | 1:f2adcae3d304 | 812 | else if (CMD_Code == SUBCMD_M_PULSE) //e. is this subcommand for GLD starting? //r. ��� ���������� ������� GLD? |
igor_v | 0:8ad47e2b6f00 | 813 | { |
igor_v | 1:f2adcae3d304 | 814 | M_Pulse(); //e. call light-up function //r. ������ ������� ������� |
igor_v | 0:8ad47e2b6f00 | 815 | return; |
igor_v | 0:8ad47e2b6f00 | 816 | } |
igor_v | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 850 | if (!rcv_Rdy) //e. is data in receive buffer? //r. � �������� ������ ���� ����������? |
igor_v | 0:8ad47e2b6f00 | 851 | { |
igor_v | 1:f2adcae3d304 | 852 | return; //e. if no, stop processing //r. ���� ���, ��������� ��������� |
igor_v | 0:8ad47e2b6f00 | 853 | } |
igor_v | 0:8ad47e2b6f00 | 854 | |
igor_v | 1:f2adcae3d304 | 855 | if (!line_sts) //e. Whether there were errors of receiving of start-bit? //r. ���� �� ������ ������ �����-���� ? |
igor_v | 0:8ad47e2b6f00 | 856 | { |
igor_v | 1:f2adcae3d304 | 857 | //e. there were not errors of receiving of bytes, check the device address //r. ������ ������ ������ �� ����, ��������� ����� ��������� |
igor_v | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 868 | { //e. there is new command in the receiver buffer, stop the transfer //r. � ������ ��������� ���� ����� �������, ���������� �������� |
igor_v | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 878 | //e. check up presence of errors in operation of this procedure //r. ���������, ������� ������ � ������ ������ �������� |
igor_v | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 899 | rcv_byt_copy = rcv_num_byt; //e. save the size of copy //r. ��������� ������ ����� |
igor_v | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 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 | 1:f2adcae3d304 | 912 | line_sts = 0; //e. reset the line status register //r. �������� ������� ������� ����� |
igor_v | 1:f2adcae3d304 | 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 |