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