mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-25 01:18:38 -05:00
LimeSDR: detect Lime hardware type. Interface with GPIO only for SPI and USB type
This commit is contained in:
parent
83b66eb6f1
commit
f3b75ead00
2
debian/changelog
vendored
2
debian/changelog
vendored
@ -4,7 +4,7 @@ sdrangel (4.3.1-1) unstable; urgency=medium
|
||||
* SoapySDR support: 250 ms minimum timeout
|
||||
* LimeSDR REST API: support GPIO
|
||||
|
||||
-- Edouard Griffiths, F4EXB <f4exb06@gmail.com> Sun, 02 Dec 2018 21:14:18 +0100
|
||||
-- Edouard Griffiths, F4EXB <f4exb06@gmail.com> Fri, 30 Nov 2018 21:14:18 +0100
|
||||
|
||||
sdrangel (4.3.0-1) unstable; urgency=medium
|
||||
|
||||
|
@ -19,7 +19,9 @@
|
||||
|
||||
bool DeviceLimeSDRParams::open(lms_info_str_t deviceStr)
|
||||
{
|
||||
qDebug("DeviceLimeSDRParams::open: serial: %s", (const char *) deviceStr);
|
||||
getHardwareType((const char *) deviceStr);
|
||||
|
||||
qDebug("DeviceLimeSDRParams::open: serial: %s type: %d", (const char *) deviceStr, (int) m_type);
|
||||
|
||||
if (LMS_Open(&m_dev, deviceStr, 0) < 0)
|
||||
{
|
||||
@ -105,3 +107,18 @@ void DeviceLimeSDRParams::close()
|
||||
}
|
||||
}
|
||||
|
||||
void DeviceLimeSDRParams::getHardwareType(const char *device_str)
|
||||
{
|
||||
QString deviceStr(device_str);
|
||||
|
||||
if (deviceStr.contains(QString("LimeSDR Mini"))) {
|
||||
m_type = LimeMini;
|
||||
} else if (deviceStr.contains(QString("LimeSDR-USB"))) {
|
||||
m_type = LimeUSB;
|
||||
} else if (deviceStr.contains(QString("media=SPI"))) {
|
||||
m_type = LimeSPI;
|
||||
} else {
|
||||
m_type = LimeUndefined;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -30,6 +30,14 @@
|
||||
*/
|
||||
struct DEVICES_API DeviceLimeSDRParams
|
||||
{
|
||||
enum LimeType
|
||||
{
|
||||
LimeSPI,
|
||||
LimeMini,
|
||||
LimeUSB,
|
||||
LimeUndefined
|
||||
};
|
||||
|
||||
lms_device_t *m_dev; //!< device handle
|
||||
uint32_t m_nbRxChannels; //!< number of Rx channels (normally 2, we'll see if we really use it...)
|
||||
uint32_t m_nbTxChannels; //!< number of Tx channels (normally 2, we'll see if we really use it...)
|
||||
@ -44,6 +52,7 @@ struct DEVICES_API DeviceLimeSDRParams
|
||||
int m_log2OvSRTx; //!< log2 of Tx oversampling (0..5)
|
||||
float m_rxFrequency; //!< Rx frequency
|
||||
float m_txFrequency; //!< Tx frequency
|
||||
LimeType m_type; //!< Hardware type
|
||||
|
||||
DeviceLimeSDRParams() :
|
||||
m_dev(0),
|
||||
@ -53,7 +62,8 @@ struct DEVICES_API DeviceLimeSDRParams
|
||||
m_log2OvSRRx(0),
|
||||
m_log2OvSRTx(0),
|
||||
m_rxFrequency(1e6),
|
||||
m_txFrequency(1e6)
|
||||
m_txFrequency(1e6),
|
||||
m_type(LimeUndefined)
|
||||
{
|
||||
m_lpfRangeRx.max = 0.0f;
|
||||
m_lpfRangeRx.min = 0.0f;
|
||||
@ -90,6 +100,9 @@ struct DEVICES_API DeviceLimeSDRParams
|
||||
~DeviceLimeSDRParams()
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
void getHardwareType(const char *device_str);
|
||||
};
|
||||
|
||||
#endif /* DEVICES_LIMESDR_DEVICELIMESDRPARAM_H_ */
|
||||
|
@ -658,15 +658,19 @@ bool LimeSDROutput::handleMessage(const Message& message)
|
||||
uint8_t gpioPins = 0;
|
||||
|
||||
if (m_deviceShared.m_deviceParams->getDevice() && (LMS_GetChipTemperature(m_deviceShared.m_deviceParams->getDevice(), 0, &temp) != 0)) {
|
||||
qWarning("LimeSDROutput::handleMessage: MsgGetDeviceInfo: cannot get temperature");
|
||||
qDebug("LimeSDROutput::handleMessage: MsgGetDeviceInfo: cannot get temperature");
|
||||
}
|
||||
|
||||
if (m_deviceShared.m_deviceParams->getDevice() && (LMS_GPIORead(m_deviceShared.m_deviceParams->getDevice(), &gpioPins, 1) != 0)) {
|
||||
qWarning("LimeSDROutput::handleMessage: MsgGetDeviceInfo: cannot get GPIO pins values");
|
||||
if ((m_deviceShared.m_deviceParams->m_type != DeviceLimeSDRParams::LimeMini)
|
||||
&& (m_deviceShared.m_deviceParams->m_type != DeviceLimeSDRParams::LimeUndefined))
|
||||
{
|
||||
if (m_deviceShared.m_deviceParams->getDevice() && (LMS_GPIORead(m_deviceShared.m_deviceParams->getDevice(), &gpioPins, 1) != 0)) {
|
||||
qDebug("LimeSDROutput::handleMessage: MsgGetDeviceInfo: cannot get GPIO pins values");
|
||||
}
|
||||
}
|
||||
|
||||
// send to oneself
|
||||
if (getMessageQueueToGUI())
|
||||
if (getMessageQueueToGUI())
|
||||
{
|
||||
DeviceLimeSDRShared::MsgReportDeviceInfo *report = DeviceLimeSDRShared::MsgReportDeviceInfo::create(temp, gpioPins);
|
||||
getMessageQueueToGUI()->push(report);
|
||||
@ -929,29 +933,33 @@ bool LimeSDROutput::applySettings(const LimeSDROutputSettings& settings, bool fo
|
||||
}
|
||||
}
|
||||
|
||||
if ((m_settings.m_gpioDir != settings.m_gpioDir) || force)
|
||||
if ((m_deviceShared.m_deviceParams->m_type != DeviceLimeSDRParams::LimeMini)
|
||||
&& (m_deviceShared.m_deviceParams->m_type != DeviceLimeSDRParams::LimeUndefined))
|
||||
{
|
||||
if (LMS_GPIODirWrite(m_deviceShared.m_deviceParams->getDevice(), &settings.m_gpioDir, 1) != 0)
|
||||
if ((m_settings.m_gpioDir != settings.m_gpioDir) || force)
|
||||
{
|
||||
qCritical("LimeSDROutput::applySettings: could not set GPIO directions to %u", settings.m_gpioDir);
|
||||
if (LMS_GPIODirWrite(m_deviceShared.m_deviceParams->getDevice(), &settings.m_gpioDir, 1) != 0)
|
||||
{
|
||||
qCritical("LimeSDROutput::applySettings: could not set GPIO directions to %u", settings.m_gpioDir);
|
||||
}
|
||||
else
|
||||
{
|
||||
forwardGPIOChange = true;
|
||||
qDebug("LimeSDROutput::applySettings: GPIO directions set to %u", settings.m_gpioDir);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
forwardGPIOChange = true;
|
||||
qDebug("LimeSDROutput::applySettings: GPIO directions set to %u", settings.m_gpioDir);
|
||||
}
|
||||
}
|
||||
|
||||
if ((m_settings.m_gpioPins != settings.m_gpioPins) || force)
|
||||
{
|
||||
if (LMS_GPIOWrite(m_deviceShared.m_deviceParams->getDevice(), &settings.m_gpioPins, 1) != 0)
|
||||
if ((m_settings.m_gpioPins != settings.m_gpioPins) || force)
|
||||
{
|
||||
qCritical("LimeSDROutput::applySettings: could not set GPIO pins to %u", settings.m_gpioPins);
|
||||
}
|
||||
else
|
||||
{
|
||||
forwardGPIOChange = true;
|
||||
qDebug("LimeSDROutput::applySettings: GPIO pins set to %u", settings.m_gpioPins);
|
||||
if (LMS_GPIOWrite(m_deviceShared.m_deviceParams->getDevice(), &settings.m_gpioPins, 1) != 0)
|
||||
{
|
||||
qCritical("LimeSDROutput::applySettings: could not set GPIO pins to %u", settings.m_gpioPins);
|
||||
}
|
||||
else
|
||||
{
|
||||
forwardGPIOChange = true;
|
||||
qDebug("LimeSDROutput::applySettings: GPIO pins set to %u", settings.m_gpioPins);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -244,7 +244,7 @@ bool LimeSDROutputGUI::handleMessage(const Message& message)
|
||||
{
|
||||
DeviceLimeSDRShared::MsgReportDeviceInfo& report = (DeviceLimeSDRShared::MsgReportDeviceInfo&) message;
|
||||
ui->temperatureText->setText(tr("%1C").arg(QString::number(report.getTemperature(), 'f', 0)));
|
||||
ui->gpioText->setText(tr("%1").arg(report.getGPIOPins(), 2, 16, QChar('0')));
|
||||
ui->gpioText->setText(tr("%1").arg(report.getGPIOPins(), 2, 16, QChar('0')).toUpper());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -671,18 +671,22 @@ bool LimeSDRInput::handleMessage(const Message& message)
|
||||
else if (MsgGetDeviceInfo::match(message))
|
||||
{
|
||||
double temp = 0.0;
|
||||
uint8_t gpioPins = 0;
|
||||
uint8_t gpioPins = 0;
|
||||
|
||||
if (m_deviceShared.m_deviceParams->getDevice() && (LMS_GetChipTemperature(m_deviceShared.m_deviceParams->getDevice(), 0, &temp) != 0)) {
|
||||
qWarning("LimeSDRInput::handleMessage: MsgGetDeviceInfo: cannot get temperature");
|
||||
qDebug("LimeSDRInput::handleMessage: MsgGetDeviceInfo: cannot get temperature");
|
||||
}
|
||||
|
||||
if (m_deviceShared.m_deviceParams->getDevice() && (LMS_GPIORead(m_deviceShared.m_deviceParams->getDevice(), &gpioPins, 1) != 0)) {
|
||||
qWarning("LimeSDROutput::handleMessage: MsgGetDeviceInfo: cannot get GPIO pins values");
|
||||
if ((m_deviceShared.m_deviceParams->m_type != DeviceLimeSDRParams::LimeMini)
|
||||
&& (m_deviceShared.m_deviceParams->m_type != DeviceLimeSDRParams::LimeUndefined))
|
||||
{
|
||||
if (m_deviceShared.m_deviceParams->getDevice() && (LMS_GPIORead(m_deviceShared.m_deviceParams->getDevice(), &gpioPins, 1) != 0)) {
|
||||
qDebug("LimeSDROutput::handleMessage: MsgGetDeviceInfo: cannot get GPIO pins values");
|
||||
}
|
||||
}
|
||||
|
||||
// send to oneself
|
||||
if (m_deviceAPI->getSampleSourceGUIMessageQueue())
|
||||
if (m_deviceAPI->getSampleSourceGUIMessageQueue())
|
||||
{
|
||||
DeviceLimeSDRShared::MsgReportDeviceInfo *report = DeviceLimeSDRShared::MsgReportDeviceInfo::create(temp, gpioPins);
|
||||
m_deviceAPI->getSampleSourceGUIMessageQueue()->push(report);
|
||||
@ -1106,29 +1110,33 @@ bool LimeSDRInput::applySettings(const LimeSDRInputSettings& settings, bool forc
|
||||
}
|
||||
}
|
||||
|
||||
if ((m_settings.m_gpioDir != settings.m_gpioDir) || force)
|
||||
if ((m_deviceShared.m_deviceParams->m_type != DeviceLimeSDRParams::LimeMini)
|
||||
&& (m_deviceShared.m_deviceParams->m_type != DeviceLimeSDRParams::LimeUndefined))
|
||||
{
|
||||
if (LMS_GPIODirWrite(m_deviceShared.m_deviceParams->getDevice(), &settings.m_gpioDir, 1) != 0)
|
||||
if ((m_settings.m_gpioDir != settings.m_gpioDir) || force)
|
||||
{
|
||||
qCritical("LimeSDROutput::applySettings: could not set GPIO directions to %u", settings.m_gpioDir);
|
||||
if (LMS_GPIODirWrite(m_deviceShared.m_deviceParams->getDevice(), &settings.m_gpioDir, 1) != 0)
|
||||
{
|
||||
qCritical("LimeSDROutput::applySettings: could not set GPIO directions to %u", settings.m_gpioDir);
|
||||
}
|
||||
else
|
||||
{
|
||||
forwardGPIOChange = true;
|
||||
qDebug("LimeSDROutput::applySettings: GPIO directions set to %u", settings.m_gpioDir);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
forwardGPIOChange = true;
|
||||
qDebug("LimeSDROutput::applySettings: GPIO directions set to %u", settings.m_gpioDir);
|
||||
}
|
||||
}
|
||||
|
||||
if ((m_settings.m_gpioPins != settings.m_gpioPins) || force)
|
||||
{
|
||||
if (LMS_GPIOWrite(m_deviceShared.m_deviceParams->getDevice(), &settings.m_gpioPins, 1) != 0)
|
||||
if ((m_settings.m_gpioPins != settings.m_gpioPins) || force)
|
||||
{
|
||||
qCritical("LimeSDROutput::applySettings: could not set GPIO pins to %u", settings.m_gpioPins);
|
||||
}
|
||||
else
|
||||
{
|
||||
forwardGPIOChange = true;
|
||||
qDebug("LimeSDROutput::applySettings: GPIO pins set to %u", settings.m_gpioPins);
|
||||
if (LMS_GPIOWrite(m_deviceShared.m_deviceParams->getDevice(), &settings.m_gpioPins, 1) != 0)
|
||||
{
|
||||
qCritical("LimeSDROutput::applySettings: could not set GPIO pins to %u", settings.m_gpioPins);
|
||||
}
|
||||
else
|
||||
{
|
||||
forwardGPIOChange = true;
|
||||
qDebug("LimeSDROutput::applySettings: GPIO pins set to %u", settings.m_gpioPins);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -226,7 +226,7 @@ bool LimeSDRInputGUI::handleMessage(const Message& message)
|
||||
{
|
||||
DeviceLimeSDRShared::MsgReportDeviceInfo& report = (DeviceLimeSDRShared::MsgReportDeviceInfo&) message;
|
||||
ui->temperatureText->setText(tr("%1C").arg(QString::number(report.getTemperature(), 'f', 0)));
|
||||
ui->gpioText->setText(tr("%1").arg(report.getGPIOPins(), 2, 16, QChar('0')));
|
||||
ui->gpioText->setText(tr("%1").arg(report.getGPIOPins(), 2, 16, QChar('0')).toUpper());
|
||||
return true;
|
||||
}
|
||||
else if (LimeSDRInput::MsgStartStop::match(message))
|
||||
|
Loading…
Reference in New Issue
Block a user