Skip to content

Commit 02832c8

Browse files
philmozelecpower
andauthored
chore: add CPU details to hwdefs files (#7136)
Co-authored-by: elecpower <elecpower@users.noreply.github.com>
1 parent b3d36eb commit 02832c8

63 files changed

Lines changed: 230 additions & 117 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

companion/src/firmwares/boardjson.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,15 @@ const int BoardJson::getCapability(const Board::Capability capability) const
214214
case Board::InputSwitches:
215215
return m_inputCnt.switches;
216216

217+
case Board::IsF4:
218+
return m_hardware.cpu_type == "STM32F4";
219+
220+
case Board::IsH5:
221+
return m_hardware.cpu_type == "STM32H5";
222+
223+
case Board::IsH7:
224+
return m_hardware.cpu_type == "STM32H7";
225+
217226
case Board::JoystickAxes:
218227
return m_inputCnt.flexJoystickAxes;
219228

@@ -1247,6 +1256,8 @@ bool BoardJson::loadFile(Board::Type board, QString hwdefn, InputsTable * inputs
12471256
hardware.has_int_module_support = o.value("has_int_module_support").toInt();
12481257
hardware.sport_max_baudrate = o.value("sport_max_baudrate").toInt();
12491258
hardware.surface = o.value("surface").toInt();
1259+
hardware.cpu = o.value("cpu").toString().toStdString();
1260+
hardware.cpu_type = o.value("cpu_type").toString().toStdString();
12501261
}
12511262

12521263
delete json;
@@ -1290,3 +1301,15 @@ void BoardJson::setSwitchCounts(const SwitchesTable * switches, SwitchCounts & s
12901301
switchCounts.func++;
12911302
}
12921303
}
1304+
1305+
const QString BoardJson::getCapabilityStr(const Board::Capability capability) const
1306+
{
1307+
switch (capability) {
1308+
case Board::CPU:
1309+
return m_hardware.cpu.c_str();
1310+
case Board::CPUType:
1311+
return m_hardware.cpu_type.c_str();
1312+
default:
1313+
return QString();
1314+
}
1315+
}

companion/src/firmwares/boardjson.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ class BoardJson
123123
int has_int_module_support = 0;
124124
int sport_max_baudrate = 0;
125125
int surface = 0;
126+
std::string cpu = "";
127+
std::string cpu_type = "";
126128
};
127129

128130
typedef std::vector<TrimDefn> TrimsTable;
@@ -136,6 +138,7 @@ class BoardJson
136138
bool loadDefinition();
137139

138140
const int getCapability(const Board::Capability capability) const;
141+
const QString getCapabilityStr(const Board::Capability capability) const;
139142
const int getInputsCalibrated() const;
140143

141144
const int getInputIndex(const QString val, Board::LookupValueType lvt) const;

companion/src/firmwares/boards.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1182,3 +1182,8 @@ void Boards::tests()
11821182
{
11831183
qDebug() << "**** Board checks ****";
11841184
}
1185+
1186+
QString Boards::getCapabilityStr(Board::Type board, Board::Capability capability)
1187+
{
1188+
return getBoardJson(board)->getCapabilityStr(capability);
1189+
}

companion/src/firmwares/boards.h

Lines changed: 7 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,8 @@ namespace Board {
213213
enum Capability {
214214
Air,
215215
BacklightLevelMin,
216+
CPU,
217+
CPUType,
216218
FlexInputs,
217219
FlexSwitches,
218220
FunctionSwitchColors,
@@ -241,6 +243,9 @@ namespace Board {
241243
HasVCPSerialMode,
242244
Inputs,
243245
InputSwitches,
246+
IsF4,
247+
IsH5,
248+
IsH7,
244249
JoystickAxes,
245250
Joysticks,
246251
Keys,
@@ -401,12 +406,14 @@ class Boards
401406
const int getEEpromSize() const { return getEEpromSize(m_boardType); }
402407
const int getFlashSize() const { return getFlashSize(m_boardType); }
403408
const int getCapability(Board::Capability capability) const { return getCapability(m_boardType, capability); }
409+
const QString getCapabilityStr(Board::Capability capability) const { return getCapabilityStr(m_boardType, capability); }
404410
const bool isBoardCompatible(Board::Type board2) const { return isBoardCompatible(m_boardType, board2); }
405411

406412
static uint32_t getFourCC(Board::Type board);
407413
static int getEEpromSize(Board::Type board);
408414
static int getFlashSize(Board::Type board);
409415
static int getCapability(Board::Type board, Board::Capability capability);
416+
static QString getCapabilityStr(Board::Type board, Board::Capability capability);
410417
static QString getAxisName(int index);
411418
static bool isBoardCompatible(Board::Type board1, Board::Type board2);
412419
static QString getBoardName(Board::Type board);
@@ -816,17 +823,6 @@ inline bool IS_FAMILY_HORUS_OR_T16(Board::Type board)
816823
IS_FLYSKY_PA01(board)/*generally*/ || IS_FLYSKY_NB4P(board)/*generally*/;
817824
}
818825

819-
inline bool IS_STM32(Board::Type board)
820-
{
821-
return IS_TARANIS(board) || IS_FAMILY_HORUS_OR_T16(board) ||
822-
IS_FLYSKY_NV14(board) || IS_FLYSKY_EL18(board) || IS_FAMILY_PL18(board) || IS_FLYSKY_ST16(board);
823-
}
824-
825-
inline bool IS_ARM(Board::Type board)
826-
{
827-
return IS_STM32(board);
828-
}
829-
830826
inline bool HAS_LARGE_LCD(Board::Type board)
831827
{
832828
return IS_FAMILY_HORUS_OR_T16(board) || IS_TARANIS_X9(board);
@@ -854,27 +850,3 @@ inline bool IS_ACCESS_RADIO(Board::Type board, const QString & id)
854850
return IS_ACCESS_RADIO(board) ||
855851
(IS_FAMILY_HORUS_OR_T16(board) && id.contains("internalaccess"));
856852
}
857-
858-
inline bool HAS_EEPROM_YAML(Board::Type board)
859-
{
860-
return IS_FAMILY_HORUS_OR_T16(board);
861-
}
862-
863-
inline bool IS_STM32H5(Board::Type board)
864-
{
865-
return false;
866-
}
867-
868-
inline bool IS_STM32H7(Board::Type board)
869-
{
870-
return IS_FLYSKY_PA01(board) ||
871-
IS_FLYSKY_ST16(board) ||
872-
IS_JUMPER_T15PRO(board) ||
873-
IS_RADIOMASTER_TX15(board) ||
874-
IS_RADIOMASTER_TX16SMK3(board);
875-
}
876-
877-
inline bool IS_STM32F2F4(Board::Type board)
878-
{
879-
return (!IS_STM32H5(board) && !IS_STM32H7(board));
880-
}

companion/src/firmwares/edgetx/yaml_modeldata.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1509,7 +1509,7 @@ bool convert<ModelData>::decode(const Node& node, ModelData& rhs)
15091509
}
15101510

15111511
// v2.12 CRSF limit external module to 3.75M for older boards
1512-
if (IS_STM32F2F4(board) &&
1512+
if (Boards::getCapability((Board::Type)board, Board::IsF4) &&
15131513
rhs.moduleData[1].protocol == PULSES_CROSSFIRE &&
15141514
rhs.moduleData[1].crsf.telemetryBaudrate > 4)
15151515
rhs.moduleData[1].crsf.telemetryBaudrate = 4;

companion/src/firmwares/moduledata.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,8 @@ AbstractStaticItemModel * ModuleData::telemetryBaudrateItemModel(unsigned int pr
611611
for (int i = 0; i < moduleBaudratesList.size(); i++) {
612612
// CRSF limit external module to 3.75M for older boards
613613
if (protocol == PULSES_CROSSFIRE && moduleIdx == 1 &&
614-
IS_STM32F2F4((Board::Type)board) && i > 4) break;
614+
Boards::getCapability((Board::Type)board, Board::IsF4) &&
615+
i > 4) break;
615616

616617
if (protocol == PULSES_GHOST && i >= 2) break;
617618
mdl->appendToItemList(moduleBaudratesList.at(i), i);

companion/src/firmwares/opentx/opentxinterface.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ int OpenTxFirmware::getCapability(::Capability capability)
7676
case GlobalFunctions:
7777
return CPN_MAX_SPECIAL_FUNCTIONS;
7878
case Gvars:
79-
return id.contains("nogvars") ? 0 : (IS_STM32H7(board) || IS_STM32H5(board) ? CPN_MAX_GVARS : 9);
79+
return id.contains("nogvars") ? 0 : (Boards::getCapability((Board::Type)board, Board::IsF4) ? 9 : CPN_MAX_GVARS);
8080
case GvarsName:
8181
return 3;
8282
case Haptic: // TODO remove with X9D
@@ -189,7 +189,7 @@ int OpenTxFirmware::getCapability(::Capability capability)
189189
case SafetyChannelCustomFunction:
190190
return id.contains("nooverridech") ? 0 : 1;
191191
case Sensors:
192-
if (IS_STM32H7(board))
192+
if (Boards::getCapability((Board::Type)board, Board::IsH7))
193193
return CPN_MAX_SENSORS;
194194
else if (IS_FAMILY_HORUS_OR_T16(board) || IS_TARANIS_X9(board))
195195
return 60;

companion/src/generaledit/generalsetup.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,7 @@ ui(new Ui::GeneralSetup)
9494
ui->gpsFormatCB->setCurrentIndex(generalSettings.gpsFormat);
9595
ui->timezoneLE->setTime((generalSettings.timezone * 3600) + (generalSettings.timezoneMinutes/*quarter hours*/ * 15 * 60));
9696
ui->adjustRTC->setChecked(generalSettings.adjustRTC);
97-
98-
if (IS_STM32(board)) {
99-
ui->usbModeCB->setCurrentIndex(generalSettings.usbMode);
100-
}
101-
else {
102-
ui->usbModeLabel->hide();
103-
ui->usbModeCB->hide();
104-
}
97+
ui->usbModeCB->setCurrentIndex(generalSettings.usbMode);
10598

10699
if (IS_FLYSKY_EL18(board) || IS_FLYSKY_NV14(board) || IS_FAMILY_PL18(board)) {
107100
ui->hatsModeCB->setModel(panelFilteredModels->getItemModel(FIM_HATSMODE));

companion/src/modeledit/customfunctions.cpp

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -85,26 +85,22 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData * model,
8585
}
8686
}
8787

88-
if (IS_STM32(firmware->getBoard())) {
89-
scriptsSet = getFilesSet(g.profile[g.id()].sdPath() + "/SCRIPTS/FUNCTIONS", QStringList() << "*.lua", firmware->getCapability(VoicesMaxLength));
90-
for (int i = 0; i < fswCapability; i++) {
91-
if (functions[i].func == FuncPlayScript) {
92-
QString temp = functions[i].paramarm;
93-
if (!temp.isEmpty()) {
94-
scriptsSet.insert(temp);
95-
}
88+
scriptsSet = getFilesSet(g.profile[g.id()].sdPath() + "/SCRIPTS/FUNCTIONS", QStringList() << "*.lua", firmware->getCapability(VoicesMaxLength));
89+
for (int i = 0; i < fswCapability; i++) {
90+
if (functions[i].func == FuncPlayScript) {
91+
QString temp = functions[i].paramarm;
92+
if (!temp.isEmpty()) {
93+
scriptsSet.insert(temp);
9694
}
9795
}
9896
}
9997

100-
if (IS_STM32(firmware->getBoard())) {
101-
scriptsSetRGB = getFilesSet(g.profile[g.id()].sdPath() + "/SCRIPTS/RGBLED", QStringList() << "*.lua", firmware->getCapability(VoicesMaxLength));
102-
for (int i = 0; i < fswCapability; i++) {
103-
if (functions[i].func == FuncRGBLed) {
104-
QString temp = functions[i].paramarm;
105-
if (!temp.isEmpty()) {
106-
scriptsSetRGB.insert(temp);
107-
}
98+
scriptsSetRGB = getFilesSet(g.profile[g.id()].sdPath() + "/SCRIPTS/RGBLED", QStringList() << "*.lua", firmware->getCapability(VoicesMaxLength));
99+
for (int i = 0; i < fswCapability; i++) {
100+
if (functions[i].func == FuncRGBLed) {
101+
QString temp = functions[i].paramarm;
102+
if (!temp.isEmpty()) {
103+
scriptsSetRGB.insert(temp);
108104
}
109105
}
110106
}

radio/src/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,10 @@ string(CONCAT RADIO_NAME "RADIO_" ${RADIO_NAME})
116116
add_definitions(-D${RADIO_NAME})
117117
set(${RADIO_NAME} YES)
118118

119+
add_definitions(
120+
-DCPU_TYPE=${CPU_TYPE} -DCPU_TYPE_FULL=${CPU_TYPE_FULL}
121+
)
122+
119123
set(HW_DESC_JSON ${FLAVOUR}.json)
120124
AddHardwareDefTarget(${HW_DESC_JSON})
121125

0 commit comments

Comments
 (0)