mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-14 20:10:18 +03:00
Merge pull request #9479 from mikeller/detect_stm32H743_revisions
Detect revisions of the STM32H743.
This commit is contained in:
commit
e67555db7f
6 changed files with 97 additions and 48 deletions
|
@ -36,3 +36,43 @@
|
||||||
#ifdef USE_CLI_DEBUG_PRINT
|
#ifdef USE_CLI_DEBUG_PRINT
|
||||||
#warning Do not use USE_CLI_DEBUG_PRINT for production builds.
|
#warning Do not use USE_CLI_DEBUG_PRINT for production builds.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
mcuTypeId_e getMcuTypeId(void)
|
||||||
|
{
|
||||||
|
#if defined(SIMULATOR_BUILD)
|
||||||
|
return MCU_TYPE_SIMULATOR;
|
||||||
|
#elif defined(STM32F1)
|
||||||
|
return MCU_TYPE_F103;
|
||||||
|
#elif defined(STM32F3)
|
||||||
|
return MCU_TYPE_F303;
|
||||||
|
#elif defined(STM32F40_41xxx)
|
||||||
|
return MCU_TYPE_F40X;
|
||||||
|
#elif defined(STM32F411xE)
|
||||||
|
return MCU_TYPE_F411;
|
||||||
|
#elif defined(STM32F446xx)
|
||||||
|
return MCU_TYPE_F446;
|
||||||
|
#elif defined(STM32F722xx)
|
||||||
|
return MCU_TYPE_F722;
|
||||||
|
#elif defined(STM32F745xx)
|
||||||
|
return MCU_TYPE_F745;
|
||||||
|
#elif defined(STM32F746xx)
|
||||||
|
return MCU_TYPE_F746;
|
||||||
|
#elif defined(STM32F765xx)
|
||||||
|
return MCU_TYPE_F765;
|
||||||
|
#elif defined(STM32H750xx)
|
||||||
|
return MCU_TYPE_H750;
|
||||||
|
#elif defined(STM32H743xx)
|
||||||
|
switch (HAL_GetREVID()) {
|
||||||
|
case REV_ID_Y:
|
||||||
|
return MCU_TYPE_H743_REV_Y;
|
||||||
|
case REV_ID_X:
|
||||||
|
return MCU_TYPE_H743_REV_X;
|
||||||
|
case REV_ID_V:
|
||||||
|
return MCU_TYPE_H743_REV_V;
|
||||||
|
default:
|
||||||
|
return MCU_TYPE_H743_REV_UNKNOWN;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
return MCU_TYPE_UNKNOWN;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
|
@ -37,3 +37,27 @@
|
||||||
#define REQUIRE_CC_ARM_PRINTF_SUPPORT
|
#define REQUIRE_CC_ARM_PRINTF_SUPPORT
|
||||||
#define REQUIRE_PRINTF_LONG_SUPPORT
|
#define REQUIRE_PRINTF_LONG_SUPPORT
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// MCU type IDs.
|
||||||
|
// IDs are permanent as they have a dependency to configurator through MSP reporting
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
MCU_TYPE_SIMULATOR = 0,
|
||||||
|
MCU_TYPE_F103,
|
||||||
|
MCU_TYPE_F303,
|
||||||
|
MCU_TYPE_F40X,
|
||||||
|
MCU_TYPE_F411,
|
||||||
|
MCU_TYPE_F446,
|
||||||
|
MCU_TYPE_F722,
|
||||||
|
MCU_TYPE_F745,
|
||||||
|
MCU_TYPE_F746,
|
||||||
|
MCU_TYPE_F765,
|
||||||
|
MCU_TYPE_H750,
|
||||||
|
MCU_TYPE_H743_REV_UNKNOWN,
|
||||||
|
MCU_TYPE_H743_REV_Y,
|
||||||
|
MCU_TYPE_H743_REV_X,
|
||||||
|
MCU_TYPE_H743_REV_V,
|
||||||
|
MCU_TYPE_UNKNOWN = 255,
|
||||||
|
} mcuTypeId_e;
|
||||||
|
|
||||||
|
mcuTypeId_e getMcuTypeId(void);
|
||||||
|
|
|
@ -269,6 +269,25 @@ static const char * const *sensorHardwareNames[] = {
|
||||||
};
|
};
|
||||||
#endif // USE_SENSOR_NAMES
|
#endif // USE_SENSOR_NAMES
|
||||||
|
|
||||||
|
// Needs to be aligned with mcuTypeId_e
|
||||||
|
static const char *mcuTypeNames[] = {
|
||||||
|
"SIMULATOR",
|
||||||
|
"F103",
|
||||||
|
"F303",
|
||||||
|
"F40X",
|
||||||
|
"F411",
|
||||||
|
"F446",
|
||||||
|
"F722",
|
||||||
|
"F745",
|
||||||
|
"F746",
|
||||||
|
"F765",
|
||||||
|
"H750",
|
||||||
|
"H743 (Rev Unknown)",
|
||||||
|
"H743 (Rev.Y)",
|
||||||
|
"H743 (Rev.X)",
|
||||||
|
"H743 (Rev.V)",
|
||||||
|
};
|
||||||
|
|
||||||
typedef enum dumpFlags_e {
|
typedef enum dumpFlags_e {
|
||||||
DUMP_MASTER = (1 << 0),
|
DUMP_MASTER = (1 << 0),
|
||||||
DUMP_PROFILE = (1 << 1),
|
DUMP_PROFILE = (1 << 1),
|
||||||
|
@ -289,7 +308,7 @@ typedef enum {
|
||||||
REBOOT_TARGET_BOOTLOADER_FLASH,
|
REBOOT_TARGET_BOOTLOADER_FLASH,
|
||||||
} rebootTarget_e;
|
} rebootTarget_e;
|
||||||
|
|
||||||
typedef struct serialPassthroughPort_e {
|
typedef struct serialPassthroughPort_s {
|
||||||
int id;
|
int id;
|
||||||
uint32_t baud;
|
uint32_t baud;
|
||||||
unsigned mode;
|
unsigned mode;
|
||||||
|
@ -4537,13 +4556,22 @@ STATIC_UNIT_TESTED void cliSet(char *cmdline)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *getMcuTypeById(mcuTypeId_e id)
|
||||||
|
{
|
||||||
|
if (id < MCU_TYPE_UNKNOWN) {
|
||||||
|
return mcuTypeNames[id];
|
||||||
|
} else {
|
||||||
|
return "UNKNOWN";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void cliStatus(char *cmdline)
|
static void cliStatus(char *cmdline)
|
||||||
{
|
{
|
||||||
UNUSED(cmdline);
|
UNUSED(cmdline);
|
||||||
|
|
||||||
// MCU type, clock, vrefint, core temperature
|
// MCU type, clock, vrefint, core temperature
|
||||||
|
|
||||||
cliPrintf("MCU %s Clock=%dMHz", MCU_TYPE_NAME, (SystemCoreClock / 1000000));
|
cliPrintf("MCU %s Clock=%dMHz", getMcuTypeById(getMcuTypeId()), (SystemCoreClock / 1000000));
|
||||||
|
|
||||||
#ifdef STM32F4
|
#ifdef STM32F4
|
||||||
// Only F4 is capable of switching between HSE/HSI (for now)
|
// Only F4 is capable of switching between HSE/HSI (for now)
|
||||||
|
|
|
@ -656,7 +656,7 @@ static bool mspCommonProcessOutCommand(int16_t cmdMSP, sbuf_t *dst, mspPostProce
|
||||||
sbufWriteData(dst, &emptySignature, sizeof(emptySignature));
|
sbufWriteData(dst, &emptySignature, sizeof(emptySignature));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
sbufWriteU8(dst, MCU_TYPE_ID);
|
sbufWriteU8(dst, getMcuTypeId());
|
||||||
|
|
||||||
// Added in API version 1.42
|
// Added in API version 1.42
|
||||||
sbufWriteU8(dst, systemConfig()->configurationState);
|
sbufWriteU8(dst, systemConfig()->configurationState);
|
||||||
|
|
|
@ -129,50 +129,6 @@
|
||||||
#error "Invalid chipset specified. Update platform.h"
|
#error "Invalid chipset specified. Update platform.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// MCU type names and IDs.
|
|
||||||
// IDs are permanent as it has dependency to configurator through MSP reporting
|
|
||||||
|
|
||||||
#if defined(SIMULATOR_BUILD)
|
|
||||||
#define MCU_TYPE_ID 0
|
|
||||||
#define MCU_TYPE_NAME "SIMULATOR"
|
|
||||||
#elif defined(STM32F1)
|
|
||||||
#define MCU_TYPE_ID 1
|
|
||||||
#define MCU_TYPE_NAME "F103"
|
|
||||||
#elif defined(STM32F3)
|
|
||||||
#define MCU_TYPE_ID 2
|
|
||||||
#define MCU_TYPE_NAME "F303"
|
|
||||||
#elif defined(STM32F40_41xxx)
|
|
||||||
#define MCU_TYPE_ID 3
|
|
||||||
#define MCU_TYPE_NAME "F40X"
|
|
||||||
#elif defined(STM32F411xE)
|
|
||||||
#define MCU_TYPE_ID 4
|
|
||||||
#define MCU_TYPE_NAME "F411"
|
|
||||||
#elif defined(STM32F446xx)
|
|
||||||
#define MCU_TYPE_ID 5
|
|
||||||
#define MCU_TYPE_NAME "F446"
|
|
||||||
#elif defined(STM32F722xx)
|
|
||||||
#define MCU_TYPE_ID 6
|
|
||||||
#define MCU_TYPE_NAME "F722"
|
|
||||||
#elif defined(STM32F745xx)
|
|
||||||
#define MCU_TYPE_ID 7
|
|
||||||
#define MCU_TYPE_NAME "F745"
|
|
||||||
#elif defined(STM32F746xx)
|
|
||||||
#define MCU_TYPE_ID 8
|
|
||||||
#define MCU_TYPE_NAME "F746"
|
|
||||||
#elif defined(STM32F765xx)
|
|
||||||
#define MCU_TYPE_ID 9
|
|
||||||
#define MCU_TYPE_NAME "F765"
|
|
||||||
#elif defined(STM32H750xx)
|
|
||||||
#define MCU_TYPE_ID 10
|
|
||||||
#define MCU_TYPE_NAME "H750"
|
|
||||||
#elif defined(STM32H743xx)
|
|
||||||
#define MCU_TYPE_ID 11
|
|
||||||
#define MCU_TYPE_NAME "H743"
|
|
||||||
#else
|
|
||||||
#define MCU_TYPE_ID 255
|
|
||||||
#define MCU_TYPE_NAME "Unknown MCU"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "target/common_pre.h"
|
#include "target/common_pre.h"
|
||||||
#include "target.h"
|
#include "target.h"
|
||||||
#include "target/common_deprecated_post.h"
|
#include "target/common_deprecated_post.h"
|
||||||
|
|
|
@ -358,4 +358,5 @@ bool isModeActivationConditionConfigured(const modeActivationCondition_t *, cons
|
||||||
|
|
||||||
void delay(uint32_t) {}
|
void delay(uint32_t) {}
|
||||||
displayPort_t *osdGetDisplayPort(osdDisplayPortDevice_e *) { return NULL; }
|
displayPort_t *osdGetDisplayPort(osdDisplayPortDevice_e *) { return NULL; }
|
||||||
|
mcuTypeId_e getMcuTypeId(void) { return MCU_TYPE_UNKNOWN; }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue