Show exported peripheral symbols in peripheral tab
MODIFY
src/io/ioledmatrix.cpp
src/io/ioledmatrix.cpp
@@ -64,7 +64,7 @@ void IOLedMatrix::updateLEDRegs() {
m_extraSymbols.clear();
m_extraSymbols.push_back(IOSymbol{"WIDTH", width});
- m_extraSymbols.push_back(IOSymbol{"HEIGHT", width});
+ m_extraSymbols.push_back(IOSymbol{"HEIGHT", height});
m_regDescs.clear();
m_regDescs.resize(nLEDs);

MODIFY
src/io/iomanager.cpp
src/io/iomanager.cpp
@@ -115,22 +115,22 @@ void IOManager::refreshMemoryMap() {
updateSymbols();
}
-std::map<QString, uint32_t> IOManager::assemblerSymbolsForPeriph(IOBase* peripheral) const {
+std::vector<std::pair<QString, uint32_t>> IOManager::assemblerSymbolsForPeriph(IOBase* peripheral) const {
const QString& periphName = cName(peripheral->name());
- std::map<QString, uint32_t> symbols;
+ std::vector<std::pair<QString, uint32_t>> symbols;
const auto& periphInfo = m_peripherals.at(peripheral);
- symbols[periphName + "_BASE"] = periphInfo.startAddr;
- symbols[periphName + "_SIZE"] = periphInfo.size;
+ symbols.push_back({periphName + "_BASE", periphInfo.startAddr});
+ symbols.push_back({periphName + "_SIZE", periphInfo.size});
for (const auto& reg : peripheral->registers()) {
if (reg.exported) {
- symbols[periphName + "_" + cName(reg.name)] = reg.address + periphInfo.startAddr;
+ symbols.push_back({periphName + "_" + cName(reg.name), reg.address + periphInfo.startAddr});
}
}
if (auto* extraSymbols = peripheral->extraSymbols()) {
for (const auto& extraSymbol : *extraSymbols) {
- symbols[periphName + "_" + cName(extraSymbol.name)] = extraSymbol.value;
+ symbols.push_back({periphName + "_" + cName(extraSymbol.name), extraSymbol.value});
}
}

MODIFY
src/io/iomanager.h
src/io/iomanager.h
@@ -41,6 +41,7 @@ public:
* @returns as cSymbols, but as a map which can be directly loaded into the assembler.
*/
std::map<QString, uint32_t> assemblerSymbols() const { return m_assemblerSymbols; }
+ std::vector<std::pair<QString, uint32_t>> assemblerSymbolsForPeriph(IOBase* peripheral) const;
signals:
void memoryMapChanged();
@@ -48,7 +49,6 @@ signals:
private:
IOManager();
- std::map<QString, uint32_t> assemblerSymbolsForPeriph(IOBase* peripheral) const;
/**
* @brief updateSymbols

MODIFY
src/ioperipheraltab.cpp
src/ioperipheraltab.cpp
#include "ioperipheraltab.h"
#include "ui_ioperipheraltab.h"
+#include "editor/csyntaxhighlighter.h"
#include "io/iobase.h"
+#include "io/iomanager.h"
#include "io/periphparammodel.h"
#include "io/registermapmodel.h"
@@ -20,6 +22,17 @@ IOPeripheralTab::IOPeripheralTab(QWidget* parent, IOBase* peripheral)
m_ui->parameterView->horizontalHeader()->setStretchLastSection(true);
m_ui->parameterView->resizeColumnsToContents();
m_ui->parameterView->setItemDelegateForColumn(PeriphParamModel::Value, new PeriphParamDelegate(this));
+
+ updateExportsInfo();
+}
+
+void IOPeripheralTab::updateExportsInfo() {
+ auto symbols = IOManager::get().assemblerSymbolsForPeriph(m_peripheral);
+ for (const auto& symbol : symbols) {
+ m_ui->exports->appendPlainText("#define " + symbol.first + " " + "(0x" + QString::number(symbol.second, 16) +
+ ")");
+ }
+ CSyntaxHighlighter(m_ui->exports->document()).rehighlight();
}
IOPeripheralTab::~IOPeripheralTab() {

MODIFY
src/ioperipheraltab.h
src/ioperipheraltab.h
@@ -16,6 +16,8 @@ public:
~IOPeripheralTab();
private:
+ void updateExportsInfo();
+
Ui::IOPeripheralTab* m_ui;
IOBase* m_peripheral = nullptr;

MODIFY
src/ioperipheraltab.ui
src/ioperipheraltab.ui
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
- <string>Code example</string>
+ <string>Exports</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<property name="leftMargin">
<number>0</number>
</property>
<item row="0" column="0">
- <widget class="QPlainTextEdit" name="codeExample">
+ <widget class="QPlainTextEdit" name="exports">
<property name="readOnly">
<bool>true</bool>
</property>

Show exported peripheral symbols in peripheral tab