[avr] add comments to commands
This commit is contained in:
parent
b641230fc8
commit
e282a750de
|
@ -226,20 +226,17 @@ void ctrlDecode(void)
|
||||||
ctrlAddToTxBuffer(cmd[1]);
|
ctrlAddToTxBuffer(cmd[1]);
|
||||||
|
|
||||||
switch (cmd[0]) {
|
switch (cmd[0]) {
|
||||||
case 'g':
|
case 'g': /* get */
|
||||||
ctrlCmdGet(cmd[1]);
|
ctrlCmdGet(cmd[1]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 's':
|
case 's': /* set */
|
||||||
ctrlCmdSet(cmd[1]);
|
ctrlCmdSet(cmd[1]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'c':
|
case 'c': /* commit */
|
||||||
if (cmd[1] == 't') ctrlCmdCommit();
|
if (cmd[1] == 't') ctrlCmdCommit();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
|
||||||
ctrlAddToTxBuffer('z');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
crc = ctrlCalcCrc8(&ctrlTxBuffer);
|
crc = ctrlCalcCrc8(&ctrlTxBuffer);
|
||||||
|
@ -257,23 +254,23 @@ void ctrlCmdGet(uint8_t cmd)
|
||||||
uint32_t tmp32, tmp32_bis;
|
uint32_t tmp32, tmp32_bis;
|
||||||
|
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case 'h':
|
case 'h': /* hardware {major,minor} version */
|
||||||
ctrlWriteShortToTxBuffer(version.hw_major);
|
ctrlWriteShortToTxBuffer(version.hw_major);
|
||||||
ctrlWriteCharToTxBuffer(version.hw_minor);
|
ctrlWriteCharToTxBuffer(version.hw_minor);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 's':
|
case 's': /* software {major,minor} version */
|
||||||
ctrlWriteCharToTxBuffer(version.sw_major);
|
ctrlWriteCharToTxBuffer(version.sw_major);
|
||||||
ctrlWriteCharToTxBuffer(version.sw_minor);
|
ctrlWriteCharToTxBuffer(version.sw_minor);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'p':
|
case 'p': /* phy-to-logical mapping */
|
||||||
for (i = 0 ; i < MAX_SENSORS; i++) {
|
for (i = 0 ; i < MAX_SENSORS; i++) {
|
||||||
ctrlWriteCharToTxBuffer(phy_to_log[i]);
|
ctrlWriteCharToTxBuffer(phy_to_log[i]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'c':
|
case 'c': /* sensor counter value */
|
||||||
ctrlReadCharFromRxBuffer(&i);
|
ctrlReadCharFromRxBuffer(&i);
|
||||||
|
|
||||||
cli();
|
cli();
|
||||||
|
@ -283,20 +280,20 @@ void ctrlCmdGet(uint8_t cmd)
|
||||||
ctrlWriteLongToTxBuffer(tmp32);
|
ctrlWriteLongToTxBuffer(tmp32);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'm':
|
case 'm': /* sensor meterconstant */
|
||||||
ctrlReadCharFromRxBuffer(&i);
|
ctrlReadCharFromRxBuffer(&i);
|
||||||
ctrlWriteShortToTxBuffer(sensor[i].meterconst);
|
ctrlWriteShortToTxBuffer(sensor[i].meterconst);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'w':
|
case 'w': /* watchdog counter */
|
||||||
ctrlWriteShortToTxBuffer(event.wdt);
|
ctrlWriteShortToTxBuffer(event.wdt);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'b':
|
case 'b': /* brown-out counter */
|
||||||
ctrlWriteShortToTxBuffer(event.brown_out);
|
ctrlWriteShortToTxBuffer(event.brown_out);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'd':
|
case 'd': /* delta: all changes since last gd */
|
||||||
for (i = 0 ; i < MAX_SENSORS; i++) {
|
for (i = 0 ; i < MAX_SENSORS; i++) {
|
||||||
if (state[i].flags & (STATE_PULSE | STATE_POWER)) {
|
if (state[i].flags & (STATE_PULSE | STATE_POWER)) {
|
||||||
ctrlWriteCharToTxBuffer(i);
|
ctrlWriteCharToTxBuffer(i);
|
||||||
|
@ -313,9 +310,6 @@ void ctrlCmdGet(uint8_t cmd)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
|
||||||
ctrlAddToTxBuffer('z');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -326,7 +320,7 @@ void ctrlCmdSet(uint8_t cmd)
|
||||||
uint32_t tmp32 = 0;
|
uint32_t tmp32 = 0;
|
||||||
|
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case 'h':
|
case 'h': /* hardware {major,minor} version */
|
||||||
ctrlReadShortFromRxBuffer(&tmp16);
|
ctrlReadShortFromRxBuffer(&tmp16);
|
||||||
ctrlReadCharFromRxBuffer(&tmp8);
|
ctrlReadCharFromRxBuffer(&tmp8);
|
||||||
|
|
||||||
|
@ -336,7 +330,7 @@ void ctrlCmdSet(uint8_t cmd)
|
||||||
sei();
|
sei();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 's':
|
case 's': /* software {major,minor} version */
|
||||||
ctrlReadCharFromRxBuffer(&tmp8);
|
ctrlReadCharFromRxBuffer(&tmp8);
|
||||||
ctrlReadCharFromRxBuffer(&tmp8_bis);
|
ctrlReadCharFromRxBuffer(&tmp8_bis);
|
||||||
|
|
||||||
|
@ -345,7 +339,7 @@ void ctrlCmdSet(uint8_t cmd)
|
||||||
version.sw_minor = tmp8_bis;
|
version.sw_minor = tmp8_bis;
|
||||||
sei();
|
sei();
|
||||||
|
|
||||||
case 'p':
|
case 'p': /* phy-to-logical mapping */
|
||||||
for (i = 0 ; i < MAX_SENSORS; i++) {
|
for (i = 0 ; i < MAX_SENSORS; i++) {
|
||||||
ctrlReadCharFromRxBuffer(&tmp8);
|
ctrlReadCharFromRxBuffer(&tmp8);
|
||||||
|
|
||||||
|
@ -355,7 +349,7 @@ void ctrlCmdSet(uint8_t cmd)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'c':
|
case 'c': /* sensor counter value */
|
||||||
ctrlReadCharFromRxBuffer(&i);
|
ctrlReadCharFromRxBuffer(&i);
|
||||||
ctrlReadLongFromRxBuffer(&tmp32);
|
ctrlReadLongFromRxBuffer(&tmp32);
|
||||||
|
|
||||||
|
@ -364,7 +358,7 @@ void ctrlCmdSet(uint8_t cmd)
|
||||||
sei();
|
sei();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'm':
|
case 'm': /* sensor meterconstant */
|
||||||
ctrlReadCharFromRxBuffer(&i);
|
ctrlReadCharFromRxBuffer(&i);
|
||||||
ctrlReadShortFromRxBuffer(&tmp16);
|
ctrlReadShortFromRxBuffer(&tmp16);
|
||||||
|
|
||||||
|
@ -373,7 +367,7 @@ void ctrlCmdSet(uint8_t cmd)
|
||||||
sei();
|
sei();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'w':
|
case 'w': /* watchdog counter */
|
||||||
ctrlReadShortFromRxBuffer(&tmp16);
|
ctrlReadShortFromRxBuffer(&tmp16);
|
||||||
|
|
||||||
cli();
|
cli();
|
||||||
|
@ -381,16 +375,13 @@ void ctrlCmdSet(uint8_t cmd)
|
||||||
sei();
|
sei();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'b':
|
case 'b': /* brown-out counter */
|
||||||
ctrlReadShortFromRxBuffer(&tmp16);
|
ctrlReadShortFromRxBuffer(&tmp16);
|
||||||
|
|
||||||
cli();
|
cli();
|
||||||
event.brown_out = tmp16;
|
event.brown_out = tmp16;
|
||||||
sei();
|
sei();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
|
||||||
ctrlAddToTxBuffer('z');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue