only reboot one controller at a time

This commit is contained in:
Matthew Kennedy 2023-11-11 21:36:57 -08:00
parent a4eb0f7e74
commit 0bbc32104d
2 changed files with 10 additions and 6 deletions

View File

@ -111,7 +111,7 @@ Configuration* GetConfiguration()
auto sel1 = readSelPin(ID_SEL1_PORT, ID_SEL1_PIN);
auto sel2 = readSelPin(ID_SEL2_PORT, ID_SEL2_PIN);
// See https://github.com/mck1117/wideband/issues/11
// See https://github.com/mck1117/wideband/issues/11 to explain this madness
switch (3 * sel1 + sel2) {
case 0: c.CanIndexOffset = 2; break;
case 1: c.CanIndexOffset = 0; break;

View File

@ -94,14 +94,18 @@ void CanRxThread(void*)
}
}
// If it's a bootloader entry request, reboot to the bootloader!
else if (frame.DLC == 0 && frame.EID == WB_BL_ENTER)
else if (frame.DLC == 1 && frame.EID == WB_BL_ENTER)
{
SendAck();
// If 0xFF (force update all) or our ID, reset to bootloader, otherwise ignore
if (frame.data8[0] == 0xFF || frame.data8[0] == GetConfiguration()->CanIndexOffset)
{
SendAck();
// Let the message get out before we reset the chip
chThdSleep(50);
// Let the message get out before we reset the chip
chThdSleep(50);
NVIC_SystemReset();
NVIC_SystemReset();
}
}
// Check if it's an "index set" message
else if (frame.DLC == 1 && frame.EID == WB_MSG_SET_INDEX)