123

Dependencies:   mbed

Fork of LG by igor Apu

Committer:
Diletant
Date:
Sun Jul 03 13:40:48 2016 +0000
Revision:
177:672ef279c8e0
Parent:
174:0f86eedd511c
Device&... update. Some Ask_Gld functionality. Not final!!!

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Diletant 161:efd949e8d536 1 #include "Device.h"
Diletant 161:efd949e8d536 2
Diletant 161:efd949e8d536 3 extern Device device;
Diletant 161:efd949e8d536 4 extern HashParam hashParamTable[HASH_PARAM_COUNT];
Diletant 161:efd949e8d536 5 extern HashFunc hashFuncTable[HASH_FUNC_COUNT];
Diletant 161:efd949e8d536 6
Diletant 167:bedc0a9d559a 7 void InitUserProtocolEncoderDefaultSettings(void) {
Diletant 167:bedc0a9d559a 8 }
Diletant 167:bedc0a9d559a 9
Diletant 167:bedc0a9d559a 10 void InitUserProtocolEncoderState(void) {
Diletant 161:efd949e8d536 11 device.user.encoder.error = 0;
Diletant 161:efd949e8d536 12 device.user.encoder.count = 0;
Diletant 161:efd949e8d536 13 device.user.encoder.CRC = 0;
Diletant 161:efd949e8d536 14 }
Diletant 161:efd949e8d536 15
Diletant 167:bedc0a9d559a 16 void DeviceStartUserProtocolEncoder(void) {
Diletant 167:bedc0a9d559a 17 }
Diletant 167:bedc0a9d559a 18
Diletant 161:efd949e8d536 19 //Next to LineDecode(), PinDecode()
Diletant 177:672ef279c8e0 20 void userEncodeResponse(void) {
Diletant 161:efd949e8d536 21 if (device.user.response.enabled) {
Diletant 161:efd949e8d536 22 if ((device.user.response.type == RESPONSE_PERIODIC) && (!device.user.response.triggered)) return;
Diletant 161:efd949e8d536 23
Diletant 161:efd949e8d536 24 switch(device.user.response.code){
Diletant 177:672ef279c8e0 25 case DEV_MODE: EncodeDeviceMode(); break;
Diletant 177:672ef279c8e0 26 case DELTA_BINS: EncodeDeltaBINS(); break;
Diletant 177:672ef279c8e0 27 case DELTA_PS: EncodeDeltaPS(); break;
Diletant 177:672ef279c8e0 28 case DELTA_SF: EncodeDeltaSF(); break;
Diletant 177:672ef279c8e0 29 case BIT_MODE: EncodeDeviceMode(); break; //Same response as DEV_MODE
Diletant 177:672ef279c8e0 30 case MAINTENANCE: EncodeMainMode(); break;
Diletant 177:672ef279c8e0 31 case M0_RATE_1: EncodeMRate(); break;
Diletant 177:672ef279c8e0 32 case M0_CTL_R: EncodeMCtlR(); break;
Diletant 177:672ef279c8e0 33 case M0_CTL_A_M: EncodeMCtlAM(); break;
Diletant 177:672ef279c8e0 34 case M0_CTL_B_M: EncodeMCtlBM(); break;
Diletant 177:672ef279c8e0 35 case M0_CNT_R: EncodeMCntR(); break;
Diletant 161:efd949e8d536 36 case M0_GPH_W: EncodeStart(); EncodeAddress(); Encode8(M0_GPH_W >> 8); Encode8(0); EncodeCRC(); break;
Diletant 161:efd949e8d536 37 case H_PARAM8_W:
Diletant 161:efd949e8d536 38 case H_PARAM8_R:
Diletant 161:efd949e8d536 39 case H_PARAM16_W:
Diletant 161:efd949e8d536 40 case H_PARAM16_R:
Diletant 161:efd949e8d536 41 case H_PARAM32_W:
Diletant 161:efd949e8d536 42 case H_PARAM32_R:
Diletant 161:efd949e8d536 43 case H_BYTES_W:
Diletant 161:efd949e8d536 44 case H_BYTES_R:
Diletant 161:efd949e8d536 45 case FLASH_READ_ALL:
Diletant 161:efd949e8d536 46 case FLASH_WRITE_ALL:
Diletant 161:efd949e8d536 47 EncodeStart(); EncodeAddress(); Encode16(device.user.response.code); EncodeMessage(); if (device.user.response.message == 0) EncodeParameters(); EncodeCRC();
Diletant 161:efd949e8d536 48 break;
Diletant 161:efd949e8d536 49 default: EncodeFail();
Diletant 161:efd949e8d536 50 }
Diletant 161:efd949e8d536 51 }
Diletant 161:efd949e8d536 52 }
Diletant 161:efd949e8d536 53
Diletant 161:efd949e8d536 54 void Encode8(uint8_t param){
Diletant 161:efd949e8d536 55 device.user.response.buffer.data[device.user.response.buffer.count] = param;
Diletant 161:efd949e8d536 56 device.user.response.buffer.count += 1;
Diletant 161:efd949e8d536 57
Diletant 177:672ef279c8e0 58 //sprintf(device.service.buffer,"- %2x\r\n", param); WriteConcole(); //Development message
Diletant 161:efd949e8d536 59 }
Diletant 161:efd949e8d536 60
Diletant 161:efd949e8d536 61 void Encode16(uint16_t param) {
Diletant 161:efd949e8d536 62 Encode8((param >> 8) & 0xff);
Diletant 161:efd949e8d536 63 Encode8(param & 0xff);
Diletant 161:efd949e8d536 64 }
Diletant 161:efd949e8d536 65
Diletant 161:efd949e8d536 66 void EncodeStart(void) {
Diletant 161:efd949e8d536 67 device.user.response.ready = 0; //Disable transmission
Diletant 161:efd949e8d536 68 device.user.response.buffer.count = 0; //Clear buffer
Diletant 161:efd949e8d536 69 Encode8(0xdd); //Write response header code
Diletant 161:efd949e8d536 70 }
Diletant 161:efd949e8d536 71
Diletant 161:efd949e8d536 72 void EncodeEnd(void) {
Diletant 161:efd949e8d536 73 device.user.response.enabled = 0; //Disable response overwrite
Diletant 161:efd949e8d536 74 device.user.response.ready = 1; //Enable transmission
Diletant 161:efd949e8d536 75 device.user.response.buffer.position = 0; //Reset transmitter
Diletant 161:efd949e8d536 76 }
Diletant 161:efd949e8d536 77
Diletant 161:efd949e8d536 78 void EncodeFail(void) {
Diletant 161:efd949e8d536 79 device.user.response.buffer.count = 0; //Clear buffer
Diletant 161:efd949e8d536 80 device.user.response.enabled = 0; //Disable response overwrite
Diletant 161:efd949e8d536 81 }
Diletant 161:efd949e8d536 82
Diletant 161:efd949e8d536 83 void EncodeAddress(void) {
Diletant 161:efd949e8d536 84 Encode8(device.user.address);
Diletant 161:efd949e8d536 85 }
Diletant 161:efd949e8d536 86
Diletant 177:672ef279c8e0 87 //TODO: EncodePacket(uint16_t length) - auto reset packet index
Diletant 177:672ef279c8e0 88 void EncodePacket(void) {
Diletant 177:672ef279c8e0 89 Encode8(device.user.response.packet);
Diletant 177:672ef279c8e0 90 device.user.response.packet++;
Diletant 177:672ef279c8e0 91 }
Diletant 177:672ef279c8e0 92
Diletant 161:efd949e8d536 93 void EncodeMessage(void) {
Diletant 161:efd949e8d536 94 Encode16(device.user.response.message);
Diletant 161:efd949e8d536 95 }
Diletant 161:efd949e8d536 96
Diletant 161:efd949e8d536 97 void EncodeParameters(void) {
Diletant 161:efd949e8d536 98 for (uint8_t i = 0; i < device.user.response.parametersCount; i++){
Diletant 161:efd949e8d536 99 uint8_t * b = (uint8_t *)device.user.response.parameters[i].ref;
Diletant 161:efd949e8d536 100 for (uint8_t j = 0; j < device.user.response.parameters[i].size; j++){
Diletant 161:efd949e8d536 101 Encode8(*b); b++;
Diletant 161:efd949e8d536 102 }
Diletant 161:efd949e8d536 103 }
Diletant 161:efd949e8d536 104 }
Diletant 161:efd949e8d536 105
Diletant 161:efd949e8d536 106 void EncodeCRC(void) {
Diletant 161:efd949e8d536 107 int16_t crc = 0;
Diletant 161:efd949e8d536 108 for (int i = 2; i < device.user.response.buffer.count; i++) crc += device.user.response.buffer.data[i];
Diletant 161:efd949e8d536 109 Encode16(crc);
Diletant 161:efd949e8d536 110 EncodeEnd();
Diletant 161:efd949e8d536 111 }
Diletant 161:efd949e8d536 112
Diletant 161:efd949e8d536 113 void EncodeDeviceMode(void) {
Diletant 177:672ef279c8e0 114 EncodeStart();
Diletant 177:672ef279c8e0 115 EncodeAddress();
Diletant 177:672ef279c8e0 116 EncodeDeviceMode();
Diletant 177:672ef279c8e0 117
Diletant 177:672ef279c8e0 118 uint8_t mode = 0;
Diletant 177:672ef279c8e0 119 if (device.counters.latch.state.enabled) {
Diletant 177:672ef279c8e0 120 //External latch mode
Diletant 177:672ef279c8e0 121 if ((device.counters.latch.state.signal == 0) && (device.counters.latch.state.format == 0))
Diletant 177:672ef279c8e0 122 //DM_EXT_LATCH_DELTA_PS_LINE
Diletant 177:672ef279c8e0 123 mode = 3;
Diletant 177:672ef279c8e0 124 else if ((device.counters.latch.state.signal == 1) && (device.counters.latch.state.format == 0))
Diletant 177:672ef279c8e0 125 //DM_EXT_LATCH_DELTA_PS_PULSE
Diletant 177:672ef279c8e0 126 mode = 4;
Diletant 177:672ef279c8e0 127 else if ((device.counters.latch.state.signal == 0) && (device.counters.latch.state.format == 1))
Diletant 177:672ef279c8e0 128 //DM_EXT_LATCH_DELTA_BINS_LINE
Diletant 177:672ef279c8e0 129 mode = 5;
Diletant 177:672ef279c8e0 130 else if ((device.counters.latch.state.signal == 1) && (device.counters.latch.state.format == 1))
Diletant 177:672ef279c8e0 131 //DM_EXT_LATCH_DELTA_BINS_PULSE
Diletant 177:672ef279c8e0 132 mode = 6;
Diletant 177:672ef279c8e0 133 } else {
Diletant 177:672ef279c8e0 134 //Internal latch mode
Diletant 177:672ef279c8e0 135 if (device.counters.rate.state.source == 0) {
Diletant 177:672ef279c8e0 136 //DM_INT_SIGN_MEANDER_LATCH
Diletant 177:672ef279c8e0 137 mode = 2;
Diletant 177:672ef279c8e0 138 } else {
Diletant 177:672ef279c8e0 139 //DM_INT_10KHZ_LATCH
Diletant 177:672ef279c8e0 140 mode = 1;
Diletant 177:672ef279c8e0 141 }
Diletant 177:672ef279c8e0 142 }
Diletant 161:efd949e8d536 143 Encode8(mode);
Diletant 177:672ef279c8e0 144
Diletant 177:672ef279c8e0 145 //Encode SysRgR
Diletant 177:672ef279c8e0 146 // Unused 3 bits: => xxxxx000
Diletant 177:672ef279c8e0 147 // Hardware: transmitter rate = receiver rate => xxxx1000
Diletant 177:672ef279c8e0 148 // Sending response, so transmitter enabled, no case => 1xxx1000
Diletant 177:672ef279c8e0 149 // Request received, so receiver enabled, no case => 11xx1000
Diletant 177:672ef279c8e0 150 switch (device.user.response.rate) {
Diletant 177:672ef279c8e0 151 case 38400: Encode8(0xc8); break; //11001000
Diletant 177:672ef279c8e0 152 case 115200: Encode8(0xd8); break; //11011000
Diletant 177:672ef279c8e0 153 case 460800: Encode8(0xe8); break; //11101000
Diletant 177:672ef279c8e0 154 case 921600: Encode8(0xf8); break; //11111000
Diletant 177:672ef279c8e0 155 }
Diletant 177:672ef279c8e0 156
Diletant 177:672ef279c8e0 157 EncodeCRC();
Diletant 161:efd949e8d536 158 }
Diletant 161:efd949e8d536 159
Diletant 177:672ef279c8e0 160 void EncodeDeltaPS(void) {
Diletant 177:672ef279c8e0 161 //TODO: RESPONSE_DELAYED/RESPONSE_PERIODIC
Diletant 161:efd949e8d536 162
Diletant 177:672ef279c8e0 163 EncodeStart();
Diletant 177:672ef279c8e0 164 EncodeAddress();
Diletant 177:672ef279c8e0 165 //Encode angle counts
Diletant 177:672ef279c8e0 166 Encode16(0);//TODO: PSdiff
Diletant 177:672ef279c8e0 167 //Prepare parameter
Diletant 177:672ef279c8e0 168 uint8_t param;
Diletant 177:672ef279c8e0 169 switch (device.user.response.packet) {
Diletant 177:672ef279c8e0 170 //High byte of output frequency
Diletant 177:672ef279c8e0 171 case 0: break;
Diletant 177:672ef279c8e0 172 //Lo byte of output frequency
Diletant 177:672ef279c8e0 173 case 1: break;
Diletant 177:672ef279c8e0 174 //Hi byte of ISACS output
Diletant 177:672ef279c8e0 175 case 2: break;
Diletant 177:672ef279c8e0 176 //Lo byte of ISACS output
Diletant 177:672ef279c8e0 177 case 3: break;
Diletant 177:672ef279c8e0 178 //Hi byte of dither period
Diletant 177:672ef279c8e0 179 case 4: break;
Diletant 177:672ef279c8e0 180 //Lo byte of dither period
Diletant 177:672ef279c8e0 181 case 5: break;
Diletant 177:672ef279c8e0 182 //Hi byte of dither pulse width
Diletant 177:672ef279c8e0 183 case 6: break;
Diletant 177:672ef279c8e0 184 //Hi byte of dither pulse width
Diletant 177:672ef279c8e0 185 case 7: break;
Diletant 177:672ef279c8e0 186 //Hi byte of PLCS output
Diletant 177:672ef279c8e0 187 case 8: param = ((uint16_t)device.controller.SSP.out[1]) >> 8; break;
Diletant 177:672ef279c8e0 188 //Lo byte of PLCS output
Diletant 177:672ef279c8e0 189 case 9: param = (((uint16_t)device.controller.SSP.out[1])) & 0xff; break;
Diletant 177:672ef279c8e0 190 //Unused
Diletant 177:672ef279c8e0 191 case 10: param = 0; break;
Diletant 177:672ef279c8e0 192 //Unused
Diletant 177:672ef279c8e0 193 case 11: param = 0; break;
Diletant 177:672ef279c8e0 194 //Unused
Diletant 177:672ef279c8e0 195 case 12: param = 0; break;
Diletant 177:672ef279c8e0 196 //Unused
Diletant 177:672ef279c8e0 197 case 13: param = 0; break;
Diletant 177:672ef279c8e0 198 //Hi byte of CCS current[0]
Diletant 177:672ef279c8e0 199 case 14: param = ((uint16_t)device.ccs.current[0].state.raw) >> 8; break;
Diletant 177:672ef279c8e0 200 //Lo byte of CCS current[0]
Diletant 177:672ef279c8e0 201 case 15: param = (((uint16_t)device.ccs.current[0].state.raw)) & 0xff; break;
Diletant 177:672ef279c8e0 202 //Hi byte of CCS current[1]
Diletant 177:672ef279c8e0 203 case 16: param = ((uint16_t)device.ccs.current[1].state.raw) >> 8; break;
Diletant 177:672ef279c8e0 204 //Lo byte of CCS current[1]
Diletant 177:672ef279c8e0 205 case 17: param = (((uint16_t)device.ccs.current[1].state.raw)) & 0xff; break;
Diletant 177:672ef279c8e0 206 //Hi byte of TSS gradient
Diletant 177:672ef279c8e0 207 case 18: param = ((uint16_t)device.tss.gradient.state.raw) >> 8; break;
Diletant 177:672ef279c8e0 208 //Lo byte of TSS gradient
Diletant 177:672ef279c8e0 209 case 19: param = (((uint16_t)device.tss.gradient.state.raw)) & 0xff; break;
Diletant 177:672ef279c8e0 210 //Hi byte of TSS temperature
Diletant 177:672ef279c8e0 211 case 20: param = ((uint16_t)device.tss.temperature.state.raw) >> 8; break;
Diletant 177:672ef279c8e0 212 //Lo byte of TSS temperature
Diletant 177:672ef279c8e0 213 case 21: param = (((uint16_t)device.tss.temperature.state.raw)) & 0xff; break;
Diletant 177:672ef279c8e0 214 }
Diletant 177:672ef279c8e0 215 //Encode packet index
Diletant 177:672ef279c8e0 216 EncodePacket();
Diletant 177:672ef279c8e0 217 //Reset packet index
Diletant 177:672ef279c8e0 218 if (device.user.response.packet > 21) device.user.response.packet = 0;
Diletant 177:672ef279c8e0 219 //Encode parameter
Diletant 177:672ef279c8e0 220 Encode8(param);
Diletant 177:672ef279c8e0 221 //Finish encoding
Diletant 177:672ef279c8e0 222 EncodeCRC();
Diletant 161:efd949e8d536 223 }
Diletant 161:efd949e8d536 224
Diletant 177:672ef279c8e0 225 void EncodeDeltaBINS(void) {
Diletant 177:672ef279c8e0 226 EncodeStart();
Diletant 177:672ef279c8e0 227 EncodeAddress();
Diletant 177:672ef279c8e0 228 Encode16(0); Encode16(0); //TODO: BINSDiff_32
Diletant 177:672ef279c8e0 229 Encode8(0); //Data ok
Diletant 177:672ef279c8e0 230 EncodeCRC();
Diletant 177:672ef279c8e0 231 }
Diletant 177:672ef279c8e0 232
Diletant 177:672ef279c8e0 233 void EncodeDeltaSF(void) {
Diletant 177:672ef279c8e0 234 //TODO
Diletant 161:efd949e8d536 235 }
Diletant 161:efd949e8d536 236
Diletant 177:672ef279c8e0 237 //Deprecated
Diletant 177:672ef279c8e0 238 //Usage: Ask_Gld "Maintenance" button
Diletant 177:672ef279c8e0 239 //Usage: Ask_Gld "x" button
Diletant 177:672ef279c8e0 240 void EncodeMainMode(void) {
Diletant 177:672ef279c8e0 241 EncodeStart();
Diletant 177:672ef279c8e0 242 EncodeAddress();
Diletant 177:672ef279c8e0 243 Encode8(0); //Version - 0: use extended command to get version
Diletant 177:672ef279c8e0 244 Encode8(0); //Serial number - 0: use extended command to get serial number
Diletant 177:672ef279c8e0 245 EncodeMessage();
Diletant 177:672ef279c8e0 246 EncodeCRC();
Diletant 177:672ef279c8e0 247 }
Diletant 177:672ef279c8e0 248
Diletant 177:672ef279c8e0 249 void EncodeMCntR(void) {
Diletant 177:672ef279c8e0 250 EncodeStart();
Diletant 177:672ef279c8e0 251 EncodeAddress();
Diletant 177:672ef279c8e0 252 Encode16((int16_t)device.counters.meander.state.a);
Diletant 177:672ef279c8e0 253 Encode16((int16_t)device.counters.meander.state.b);
Diletant 177:672ef279c8e0 254 EncodeCRC();
Diletant 174:0f86eedd511c 255 }
Diletant 174:0f86eedd511c 256
Diletant 174:0f86eedd511c 257 void EncodeMRate(void) {
Diletant 174:0f86eedd511c 258 EncodeStart();
Diletant 174:0f86eedd511c 259 EncodeAddress();
Diletant 177:672ef279c8e0 260 //Encode positive meander latched counter data
Diletant 174:0f86eedd511c 261 Encode16((int16_t)device.counters.meander.state.a);
Diletant 177:672ef279c8e0 262 //Encode negative meander latched counter data
Diletant 174:0f86eedd511c 263 Encode16((int16_t)device.counters.meander.state.b);
Diletant 177:672ef279c8e0 264 //Encode accumulated meander latched counters difference
Diletant 177:672ef279c8e0 265 uint32_t angle = device.counters.meander.state.angle[0] + device.counters.meander.state.angle[1] >> 1;
Diletant 177:672ef279c8e0 266 device.counters.meander.state.angle[0] = 0;
Diletant 177:672ef279c8e0 267 //device.counters.meander.state.angle[1] -= device.counters.meander.state.angle[1] >> 1;//?
Diletant 177:672ef279c8e0 268 Encode16((int16_t)angle);
Diletant 177:672ef279c8e0 269 //Encode output frequency
Diletant 177:672ef279c8e0 270 Encode16((uint16_t)(device.counters.dither.state.amplitude >> 1));
Diletant 177:672ef279c8e0 271 //Encode ISACS output
Diletant 177:672ef279c8e0 272 Encode16((uint16_t)device.controller.SSP.out[0]);
Diletant 177:672ef279c8e0 273 //Encode ISACS error
Diletant 177:672ef279c8e0 274 Encode16((int16_t)device.isacs.regulator.state.error);
Diletant 177:672ef279c8e0 275 //Encode dither period
Diletant 177:672ef279c8e0 276 Encode16((uint16_t)((7680000*16/(device.dither.frequency.state.frequency>>12))));
Diletant 177:672ef279c8e0 277 //Encode dither phase detector output
Diletant 177:672ef279c8e0 278 Encode16((int16_t)(device.dither.detector.state.phase));
Diletant 177:672ef279c8e0 279 //Encode dither pulse width
Diletant 177:672ef279c8e0 280 Encode16((int16_t)(((7680000 * 2 * device.dither.pulse.state.width >> 8) >> 8) * 8/(device.dither.frequency.state.frequency>>12)));
Diletant 177:672ef279c8e0 281 //Encode unused
Diletant 177:672ef279c8e0 282 Encode16(0);
Diletant 177:672ef279c8e0 283 //Encode PLCS output
Diletant 177:672ef279c8e0 284 Encode16((uint16_t)device.controller.SSP.out[1]);
Diletant 177:672ef279c8e0 285 //Encode PLCS error
Diletant 177:672ef279c8e0 286 Encode16((int16_t)device.plcs.regulator.state.error);
Diletant 177:672ef279c8e0 287 //Encode unused
Diletant 177:672ef279c8e0 288 Encode16(0); //T0
Diletant 177:672ef279c8e0 289 //Encode unused
Diletant 177:672ef279c8e0 290 Encode16(0); //T1
Diletant 177:672ef279c8e0 291 //Encode CCS data
Diletant 177:672ef279c8e0 292 Encode16((int16_t)device.ccs.current[0].state.raw); //T2
Diletant 177:672ef279c8e0 293 Encode16((int16_t)device.ccs.current[1].state.raw); //T3
Diletant 177:672ef279c8e0 294 //Encode TSS data
Diletant 177:672ef279c8e0 295 Encode16((int16_t)device.tss.gradient.state.raw); //T4
Diletant 177:672ef279c8e0 296 Encode16((int16_t)device.tss.temperature.state.raw); //T5
Diletant 177:672ef279c8e0 297 //Encode unused
Diletant 177:672ef279c8e0 298 Encode16(0);
Diletant 177:672ef279c8e0 299 //Encode unused
Diletant 177:672ef279c8e0 300 Encode16(0);
Diletant 177:672ef279c8e0 301 //Finish encoding
Diletant 177:672ef279c8e0 302 EncodeCRC();
Diletant 177:672ef279c8e0 303 }
Diletant 177:672ef279c8e0 304
Diletant 177:672ef279c8e0 305 //Deprecated
Diletant 177:672ef279c8e0 306 void EncodeMCtlR(void) {
Diletant 177:672ef279c8e0 307 EncodeStart();
Diletant 177:672ef279c8e0 308 EncodeAddress();
Diletant 177:672ef279c8e0 309 Encode8(device.user.response.code >> 8);
Diletant 177:672ef279c8e0 310 if (device.user.response.code & 0x10 == 0){
Diletant 177:672ef279c8e0 311 Encode8(0); //Encode error status and RgConA attribute (clear register RgConB bit)
Diletant 177:672ef279c8e0 312 //Prepare RgConA
Diletant 177:672ef279c8e0 313 uint16_t param = 0;
Diletant 177:672ef279c8e0 314 if (device.dither.frequency.state.enabled) param |= 1 << 6;
Diletant 177:672ef279c8e0 315 if (device.dither.amplitude.state.enabled) param |= 1 << 5;
Diletant 177:672ef279c8e0 316 if (device.sequencer.sampler.state.enabled) param |= 1 << 4;
Diletant 177:672ef279c8e0 317 if (device.plcs.regulator.state.enabled) param |= 1 << 3;
Diletant 177:672ef279c8e0 318 if (device.isacs.regulator.state.enabled) param |= 1 << 1;
Diletant 177:672ef279c8e0 319 Encode16(param); //Encode RgConA
Diletant 177:672ef279c8e0 320 } else {
Diletant 177:672ef279c8e0 321 Encode8(0x10); //Encode error status and RgConB attribute (set register RgConB bit)
Diletant 177:672ef279c8e0 322 Encode16(device.counters.rate.state.source); //Encode RgConB
Diletant 177:672ef279c8e0 323 }
Diletant 177:672ef279c8e0 324 //Finish encoding
Diletant 177:672ef279c8e0 325 EncodeCRC();
Diletant 177:672ef279c8e0 326 }
Diletant 177:672ef279c8e0 327
Diletant 177:672ef279c8e0 328 //Deprecated
Diletant 177:672ef279c8e0 329 void EncodeMCtlAM(void) {
Diletant 177:672ef279c8e0 330 EncodeStart();
Diletant 177:672ef279c8e0 331 EncodeAddress();
Diletant 177:672ef279c8e0 332 Encode8(device.user.response.code >> 8);
Diletant 174:0f86eedd511c 333 //TODO:
Diletant 177:672ef279c8e0 334 Encode8(0x10); Encode8(0);Encode8(0); //Encode RgConA content
Diletant 177:672ef279c8e0 335 //Finish encoding
Diletant 177:672ef279c8e0 336 EncodeCRC();
Diletant 177:672ef279c8e0 337 }
Diletant 177:672ef279c8e0 338
Diletant 177:672ef279c8e0 339 //Usage: Ask_Gld "Maintenance" button
Diletant 177:672ef279c8e0 340 void EncodeMCtlBM(void) {
Diletant 177:672ef279c8e0 341 EncodeStart();
Diletant 177:672ef279c8e0 342 EncodeAddress();
Diletant 177:672ef279c8e0 343 Encode8(device.user.response.code >> 8);
Diletant 177:672ef279c8e0 344 //TODO:
Diletant 177:672ef279c8e0 345 Encode8(0); Encode8(0);Encode8(0); //Encode RgConB content
Diletant 177:672ef279c8e0 346 //Finish encoding
Diletant 177:672ef279c8e0 347 EncodeCRC();
Diletant 177:672ef279c8e0 348 }
Diletant 177:672ef279c8e0 349
Diletant 177:672ef279c8e0 350 void EncodeMParamR(void) {
Diletant 177:672ef279c8e0 351 EncodeStart();
Diletant 177:672ef279c8e0 352 EncodeAddress();
Diletant 177:672ef279c8e0 353 EncodeMessage();
Diletant 177:672ef279c8e0 354 EncodeCRC();
Diletant 177:672ef279c8e0 355 }
Diletant 177:672ef279c8e0 356
Diletant 177:672ef279c8e0 357 void EncodeMParamW(void) {
Diletant 177:672ef279c8e0 358 EncodeStart();
Diletant 177:672ef279c8e0 359 EncodeAddress();
Diletant 177:672ef279c8e0 360 EncodeMessage();
Diletant 174:0f86eedd511c 361 EncodeCRC();
Diletant 161:efd949e8d536 362 }