feat: Check MCU type at start (#3272)

* Check MCU type

* MCU check

* MCU check

* chore: Change capitalisation
This commit is contained in:
3djc
2023-03-13 16:13:01 +10:00
committed by GitHub
parent 2ea804877f
commit 16a7f0498d
2 changed files with 24 additions and 4 deletions
@@ -270,10 +270,7 @@ void menuRadioVersion(event_t event)
coord_t y = MENU_HEADER_HEIGHT + 2;
lcdDrawText(FW, y, vers_stamp, SMLSIZE);
y += 5 * (FH - 1);
y += 2;
y += 5 * (FH - 1) + 2;
#if defined(PCBTARANIS)
lcdDrawText(INDENT_WIDTH, y, BUTTON(TR_FIRMWARE_OPTIONS), menuVerticalPosition == ITEM_RADIO_FIRMWARE_OPTIONS ? INVERS : 0);
+23
View File
@@ -140,6 +140,27 @@ static void readKeysAndTrims()
}
}
void checkValidMCU(void)
{
// Checks the radio MCU type matches intended firmware type
uint32_t idcode = DBGMCU->IDCODE & 0xFFF;
#if defined(STM32F205xx)
#define TARGET_IDCODE 0x411
#elif defined(STM32F407xx)
#define TARGET_IDCODE 0x413
#elif defined(STM32F429xx)
#define TARGET_IDCODE 0x419
#else
// Ensure new radio get registered :)
#define TARGET_IDCODE 0x0
#endif
if(idcode != TARGET_IDCODE) {
runFatalErrorScreen("Wrong MCU");
}
}
void per10ms()
{
g_tmr10ms++;
@@ -1668,6 +1689,8 @@ int main()
boardInit();
pulsesInit();
checkValidMCU();
#if defined(PCBHORUS)
if (!IS_FIRMWARE_COMPATIBLE_WITH_BOARD()) {
runFatalErrorScreen(STR_WRONG_PCBREV);