Skip to content

Commit 53dac52

Browse files
committed
admt: Added regmap debug method
Signed-off-by: John Lloyd Juanillo <[email protected]>
1 parent 17309a8 commit 53dac52

File tree

4 files changed

+44
-13
lines changed

4 files changed

+44
-13
lines changed

plugins/admt/include/admt/admtcontroller.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ class SCOPY_ADMT_EXPORT ADMTController : public QObject
9696
SDP_GPIO_CTRL,
9797
SDP_GPIO0_BUSY,
9898
SDP_COIL_RS,
99+
REGMAP_DUMP,
99100
DEVICE_ATTR_COUNT
100101
};
101102

@@ -172,7 +173,7 @@ class SCOPY_ADMT_EXPORT ADMTController : public QObject
172173

173174
const char* ChannelIds[CHANNEL_COUNT] = { "rot", "angl", "count", "temp" };
174175
const char* DeviceIds[DEVICE_COUNT] = { "admt4000", "tmc5240" };
175-
const char* DeviceAttributes[DEVICE_ATTR_COUNT] = { "page", "sequencer_mode", "angle_filt", "conversion_mode", "h8_ctrl", "sdp_gpio_ctrl", "sdp_gpio0_busy", "sdp_coil_rs" };
176+
const char* DeviceAttributes[DEVICE_ATTR_COUNT] = { "page", "sequencer_mode", "angle_filt", "conversion_mode", "h8_ctrl", "sdp_gpio_ctrl", "sdp_gpio0_busy", "sdp_coil_rs", "regmap_dump" };
176177
const char* MotorAttributes[MOTOR_ATTR_COUNT] = { "amax", "rotate_vmax", "dmax",
177178
"disable", "target_pos", "current_pos",
178179
"ramp_mode" };
@@ -203,6 +204,7 @@ class SCOPY_ADMT_EXPORT ADMTController : public QObject
203204
int getChannelIndex(const char *deviceName, const char *channelName);
204205
double getChannelValue(const char *deviceName, const char *channelName, int bufferSize = 1);
205206
int getDeviceAttributeValue(const char *deviceName, const char *attributeName, double *returnValue);
207+
int getDeviceAttributeValueString(const char *deviceName, const char *attributeName, char *returnValue, size_t byteLength = 512);
206208
int setDeviceAttributeValue(const char *deviceName, const char *attributeName, double writeValue);
207209
QString calibrate(vector<double> PANG, int cycles = 11, int samplesPerCycle = 256);
208210
int writeDeviceRegistry(const char *deviceName, uint32_t address, uint32_t value);

plugins/admt/include/admt/harmoniccalibration.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,8 @@ public Q_SLOTS:
160160
*calibrationMotorCurrentPositionLineEdit,
161161
*AFEDIAG0LineEdit, *AFEDIAG1LineEdit, *AFEDIAG2LineEdit;
162162

163-
QLabel *rotationValueLabel, *angleValueLabel, *countValueLabel, *tempValueLabel,
163+
QLabel *rawAngleValueLabel,
164+
*rotationValueLabel, *angleValueLabel, *countValueLabel, *tempValueLabel,
164165
*motorAmaxValueLabel, *motorRotateVmaxValueLabel, *motorDmaxValueLabel,
165166
*motorDisableValueLabel, *motorTargetPosValueLabel, *motorCurrentPosValueLabel,
166167
*motorRampModeValueLabel,
@@ -371,6 +372,10 @@ public Q_SLOTS:
371372
double convertAccelTimetoAMAX(double accelTime);
372373
double convertAMAXtoAccelTime(double amax);
373374
#pragma endregion
375+
376+
#pragma region Debug Methods
377+
QString readRegmapDumpAttributeValue();
378+
#pragma endregion
374379
};
375380
} // namespace admt
376381
} // namespace scopy

plugins/admt/src/admtcontroller.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,21 @@ int ADMTController::getDeviceAttributeValue(const char *deviceName, const char *
314314
return result;
315315
}
316316

317+
int ADMTController::getDeviceAttributeValueString(const char *deviceName, const char *attributeName, char *returnValue, size_t byteLength)
318+
{
319+
if(!m_iioCtx) { return -1; }
320+
int result = -1;
321+
int deviceCount = iio_context_get_devices_count(m_iioCtx);
322+
if(deviceCount == 0) { return result; }
323+
iio_device *iioDevice = iio_context_find_device(m_iioCtx, deviceName);
324+
if(iioDevice == NULL) { return result; }
325+
const char* hasAttr = iio_device_find_attr(iioDevice, attributeName);
326+
if(hasAttr == NULL) { return result; }
327+
result = iio_device_attr_read(iioDevice, attributeName, returnValue, byteLength);
328+
329+
return result;
330+
}
331+
317332
/** @brief Set the attribute value of a device
318333
* @param deviceName A pointer to the device name
319334
* @param attributeName A NULL-terminated string corresponding to the name of the

plugins/admt/src/harmoniccalibration.cpp

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -295,15 +295,10 @@ ToolTemplate* HarmonicCalibration::createAcquisitionWidget()
295295
countWidget->contentLayout()->addWidget(countSection);
296296
tempWidget->contentLayout()->addWidget(tempSection);
297297

298-
rotationValueLabel = new QLabel(rotationSection);
299-
angleValueLabel = new QLabel(angleSection);
300-
countValueLabel = new QLabel(countSection);
301-
tempValueLabel = new QLabel(tempSection);
302-
303-
rotationValueLabel->setText("--.--°");
304-
angleValueLabel->setText("--.--°");
305-
countValueLabel->setText("--");
306-
tempValueLabel->setText("--.-- °C");
298+
rotationValueLabel = new QLabel("--.--°", rotationSection);
299+
angleValueLabel = new QLabel("--.--°", angleSection);
300+
countValueLabel = new QLabel("--", countSection);
301+
tempValueLabel = new QLabel("--.-- °C", tempSection);
307302

308303
rotationSection->contentLayout()->addWidget(rotationValueLabel);
309304
angleSection->contentLayout()->addWidget(angleValueLabel);
@@ -2079,8 +2074,8 @@ bool HarmonicCalibration::updateChannelValues(){
20792074
void HarmonicCalibration::updateCountValue(){
20802075
uint32_t *absAngleRegValue = new uint32_t;
20812076
bool success = false;
2082-
if(m_admtController->writeDeviceRegistry(m_admtController->getDeviceId(ADMTController::Device::ADMT4000), m_admtController->getConfigurationRegister(ADMTController::ConfigurationRegister::CNVPAGE), 0x0000) != -1){
2083-
if(m_admtController->readDeviceRegistry(m_admtController->getDeviceId(ADMTController::Device::ADMT4000), m_admtController->getSensorRegister(ADMTController::SensorRegister::ABSANGLE), absAngleRegValue) != -1){
2077+
if(m_admtController->writeDeviceRegistry(m_admtController->getDeviceId(ADMTController::Device::ADMT4000), m_admtController->getConfigurationRegister(ADMTController::ConfigurationRegister::CNVPAGE), 0x0000) == 0){
2078+
if(m_admtController->readDeviceRegistry(m_admtController->getDeviceId(ADMTController::Device::ADMT4000), m_admtController->getSensorRegister(ADMTController::SensorRegister::ABSANGLE), absAngleRegValue) == 0){
20842079
count = m_admtController->getAbsAngleTurnCount(static_cast<uint16_t>(*absAngleRegValue));
20852080
success = true;
20862081
}
@@ -3826,4 +3821,18 @@ double HarmonicCalibration::convertAMAXtoAccelTime(double amax)
38263821
{
38273822
return ((rotate_vmax * 131072) / (amax * motorfCLK));
38283823
}
3824+
#pragma endregion
3825+
3826+
#pragma region Debug Methods
3827+
QString HarmonicCalibration::readRegmapDumpAttributeValue()
3828+
{
3829+
QString output = "";
3830+
char value[1024];
3831+
int result = -1;
3832+
result = m_admtController->getDeviceAttributeValueString(m_admtController->getDeviceId(ADMTController::Device::ADMT4000),
3833+
m_admtController->getDeviceAttribute(ADMTController::DeviceAttribute::REGMAP_DUMP),
3834+
value, 1024);
3835+
output = QString(value);
3836+
return output;
3837+
}
38293838
#pragma endregion

0 commit comments

Comments
 (0)