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
+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);