FwUpdate: battery gate skipped on USB power (VBUS)
This commit is contained in:
1 parent
daaf0c2267
commit
3cb3a458ce
1 file changed
+11
-7
@@ -78,14 +78,14 @@ struct Huff {
|
|||||||
};
|
};
|
||||||
|
|
||||||
RAMDATA static uint16_t lbase[29] = { 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27,
|
RAMDATA static uint16_t lbase[29] = { 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27,
|
||||||
31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258 };
|
31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258 };
|
||||||
RAMDATA static uint16_t lext[29] = { 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2,
|
RAMDATA static uint16_t lext[29] = { 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2,
|
||||||
2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0 };
|
2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0 };
|
||||||
RAMDATA static uint16_t dbase[30] = { 1, 2, 3, 4, 5, 7, 9, 13, 17, 25,
|
RAMDATA static uint16_t dbase[30] = { 1, 2, 3, 4, 5, 7, 9, 13, 17, 25,
|
||||||
33, 49, 65, 97, 129, 193, 257, 385, 513, 769,
|
33, 49, 65, 97, 129, 193, 257, 385, 513, 769,
|
||||||
1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577 };
|
1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577 };
|
||||||
RAMDATA static uint16_t dext[30] = { 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6,
|
RAMDATA static uint16_t dext[30] = { 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6,
|
||||||
6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13 };
|
6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13 };
|
||||||
RAMDATA static uint8_t clorder[19] = { 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 };
|
RAMDATA static uint8_t clorder[19] = { 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 };
|
||||||
static Huff g_lencode, g_distcode; // .bss is RAM; static so the stack stays small
|
static Huff g_lencode, g_distcode; // .bss is RAM; static so the stack stays small
|
||||||
static int16_t g_lengths[320];
|
static int16_t g_lengths[320];
|
||||||
@@ -656,7 +656,11 @@ void FwUpdate::cmdApply(uint32_t sender_timestamp, const char *arg, char *reply)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
uint16_t mv = battMinMv();
|
uint16_t mv = battMinMv();
|
||||||
if (!force) {
|
// USB VBUS present: the copy cannot run out of power, and a board without
|
||||||
|
// a cell reads only ~3.7 V on VBAT (x4 on the bench), so the gate would
|
||||||
|
// refuse a perfectly safe apply.
|
||||||
|
bool ext = _board.isExternalPowered();
|
||||||
|
if (!force && !ext) {
|
||||||
if (mv < 2000) {
|
if (mv < 2000) {
|
||||||
sprintf(reply, "ERR: battery unknown (%umV), fw apply force (local)", mv);
|
sprintf(reply, "ERR: battery unknown (%umV), fw apply force (local)", mv);
|
||||||
return;
|
return;
|
||||||
@@ -667,7 +671,7 @@ void FwUpdate::cmdApply(uint32_t sender_timestamp, const char *arg, char *reply)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
_apply_at = millis() + 2000; // let the reply go out first
|
_apply_at = millis() + 2000; // let the reply go out first
|
||||||
sprintf(reply, "OK applying %s in 2 s (batt %umV), back in ~20 s", _version, mv);
|
sprintf(reply, "OK applying %s in 2 s (batt %umV%s), back in ~20 s", _version, mv, ext ? ", USB" : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
void FwUpdate::loop() {
|
void FwUpdate::loop() {
|
||||||
|
|||||||
Reference in new issue
Block a user