Detect revisions of the STM32H743.

This commit is contained in:
mikeller 2020-02-14 01:16:46 +13:00
parent 7ed29f455a
commit 214d378e82
6 changed files with 97 additions and 48 deletions

View File

@ -36,3 +36,43 @@
#ifdef USE_CLI_DEBUG_PRINT
#warning Do not use USE_CLI_DEBUG_PRINT for production builds.
#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
}

View File

@ -37,3 +37,27 @@
#define REQUIRE_CC_ARM_PRINTF_SUPPORT
#define REQUIRE_PRINTF_LONG_SUPPORT
#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);

View File

@ -258,7 +258,7 @@ static const rxFailsafeChannelMode_e rxFailsafeModesTable[RX_FAILSAFE_TYPE_COUNT
#if defined(USE_SENSOR_NAMES)
// sync this with sensors_e
static const char * const sensorTypeNames[] = {
static const char *const sensorTypeNames[] = {
"GYRO", "ACC", "BARO", "MAG", "RANGEFINDER", "GPS", "GPS+MAG", NULL
};
@ -269,6 +269,25 @@ static const char * const *sensorHardwareNames[] = {
};
#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 {
DUMP_MASTER = (1 << 0),
DUMP_PROFILE = (1 << 1),
@ -289,7 +308,7 @@ typedef enum {
REBOOT_TARGET_BOOTLOADER_FLASH,
} rebootTarget_e;
typedef struct serialPassthroughPort_e {
typedef struct serialPassthroughPort_s {
int id;
uint32_t baud;
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)
{
UNUSED(cmdline);
// 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
// Only F4 is capable of switching between HSE/HSI (for now)

View File

@ -656,7 +656,7 @@ static bool mspCommonProcessOutCommand(int16_t cmdMSP, sbuf_t *dst, mspPostProce
sbufWriteData(dst, &emptySignature, sizeof(emptySignature));
#endif
sbufWriteU8(dst, MCU_TYPE_ID);
sbufWriteU8(dst, getMcuTypeId());
// Added in API version 1.42
sbufWriteU8(dst, systemConfig()->configurationState);

View File

@ -129,50 +129,6 @@
#error "Invalid chipset specified. Update platform.h"
#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.h"
#include "target/common_deprecated_post.h"

View File

@ -358,4 +358,5 @@ bool isModeActivationConditionConfigured(const modeActivationCondition_t *, cons
void delay(uint32_t) {}
displayPort_t *osdGetDisplayPort(osdDisplayPortDevice_e *) { return NULL; }
mcuTypeId_e getMcuTypeId(void) { return MCU_TYPE_UNKNOWN; }
}