mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-05-24 03:02:29 -04:00
XTRX input: set global gain (auto) a la LimeSuite
This commit is contained in:
parent
cf953496b9
commit
ecaa7f61b0
@ -1,11 +1,13 @@
|
|||||||
project(xtrxdevice)
|
project(xtrxdevice)
|
||||||
|
|
||||||
set(xtrxdevice_SOURCES
|
set(xtrxdevice_SOURCES
|
||||||
|
devicextrx.cpp
|
||||||
devicextrxparam.cpp
|
devicextrxparam.cpp
|
||||||
devicextrxshared.cpp
|
devicextrxshared.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
set(xtrxdevice_HEADERS
|
set(xtrxdevice_HEADERS
|
||||||
|
devicextrx.h
|
||||||
devicextrxparam.h
|
devicextrxparam.h
|
||||||
devicextrxshared.h
|
devicextrxshared.h
|
||||||
)
|
)
|
||||||
|
49
devices/xtrx/devicextrx.cpp
Normal file
49
devices/xtrx/devicextrx.cpp
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Copyright (C) 2018 Edouard Griffiths, F4EXB //
|
||||||
|
// //
|
||||||
|
// This program is free software; you can redistribute it and/or modify //
|
||||||
|
// it under the terms of the GNU General Public License as published by //
|
||||||
|
// the Free Software Foundation as version 3 of the License, or //
|
||||||
|
// //
|
||||||
|
// This program is distributed in the hope that it will be useful, //
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||||
|
// GNU General Public License V3 for more details. //
|
||||||
|
// //
|
||||||
|
// You should have received a copy of the GNU General Public License //
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "devicextrx.h"
|
||||||
|
|
||||||
|
const uint32_t DeviceXTRX::m_lnaTbl[m_nbGains] = {
|
||||||
|
0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5,
|
||||||
|
5, 5, 6, 6, 6, 7, 7, 7, 8, 9, 10, 11, 11, 11, 11, 11,
|
||||||
|
11, 11, 11, 11, 11, 11, 11, 11, 12, 13, 14, 14, 14, 14, 14, 14,
|
||||||
|
14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
|
||||||
|
14, 14, 14, 14, 14, 14, 14, 14, 14, 14
|
||||||
|
};
|
||||||
|
|
||||||
|
const uint32_t DeviceXTRX::m_pgaTbl[m_nbGains] = {
|
||||||
|
0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0,
|
||||||
|
1, 2, 0, 1, 2, 0, 1, 2, 0, 0, 0, 0, 1, 2, 3, 4,
|
||||||
|
5, 6, 7, 8, 9, 10, 11, 12, 12, 12, 12, 4, 5, 6, 7, 8,
|
||||||
|
9, 10, 11, 12, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
|
||||||
|
22, 23, 24, 25, 26, 27, 28, 29, 30, 31
|
||||||
|
};
|
||||||
|
|
||||||
|
void DeviceXTRX::getAutoGains(uint32_t autoGain, uint32_t& lnaGain, uint32_t& tiaGain, uint32_t& pgaGain)
|
||||||
|
{
|
||||||
|
uint32_t value = autoGain + 12 > 73 ? 73 : autoGain + 12;
|
||||||
|
|
||||||
|
if (value > 51) {
|
||||||
|
tiaGain = 2;
|
||||||
|
} else if (value > 42) {
|
||||||
|
tiaGain = 1;
|
||||||
|
} else {
|
||||||
|
tiaGain = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
lnaGain = m_lnaTbl[value];
|
||||||
|
pgaGain = m_pgaTbl[value];
|
||||||
|
}
|
37
devices/xtrx/devicextrx.h
Normal file
37
devices/xtrx/devicextrx.h
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Copyright (C) 2018 Edouard Griffiths, F4EXB //
|
||||||
|
// //
|
||||||
|
// This program is free software; you can redistribute it and/or modify //
|
||||||
|
// it under the terms of the GNU General Public License as published by //
|
||||||
|
// the Free Software Foundation as version 3 of the License, or //
|
||||||
|
// //
|
||||||
|
// This program is distributed in the hope that it will be useful, //
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||||
|
// GNU General Public License V3 for more details. //
|
||||||
|
// //
|
||||||
|
// You should have received a copy of the GNU General Public License //
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifndef DEVICES_XTRX_DEVICEXTRX_H_
|
||||||
|
#define DEVICES_XTRX_DEVICEXTRX_H_
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include "export.h"
|
||||||
|
|
||||||
|
class DEVICES_API DeviceXTRX
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static void getAutoGains(uint32_t autoGain, uint32_t& lnaGain, uint32_t& tiaGain, uint32_t& pgaGain);
|
||||||
|
static const uint32_t m_nbGains = 74;
|
||||||
|
|
||||||
|
private:
|
||||||
|
static const uint32_t m_lnaTbl[m_nbGains];
|
||||||
|
static const uint32_t m_pgaTbl[m_nbGains];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* DEVICES_XTRX_DEVICEXTRX_H_ */
|
@ -29,6 +29,7 @@
|
|||||||
#include "xtrxinputthread.h"
|
#include "xtrxinputthread.h"
|
||||||
#include "xtrx/devicextrxparam.h"
|
#include "xtrx/devicextrxparam.h"
|
||||||
#include "xtrx/devicextrxshared.h"
|
#include "xtrx/devicextrxshared.h"
|
||||||
|
#include "xtrx/devicextrx.h"
|
||||||
|
|
||||||
MESSAGE_CLASS_DEFINITION(XTRXInput::MsgConfigureXTRX, Message)
|
MESSAGE_CLASS_DEFINITION(XTRXInput::MsgConfigureXTRX, Message)
|
||||||
MESSAGE_CLASS_DEFINITION(XTRXInput::MsgGetStreamInfo, Message)
|
MESSAGE_CLASS_DEFINITION(XTRXInput::MsgGetStreamInfo, Message)
|
||||||
@ -653,21 +654,15 @@ static double tia_to_db(unsigned idx)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void XTRXInput::apply_gain_auto(double gain)
|
void XTRXInput::apply_gain_auto(uint32_t gain)
|
||||||
{
|
{
|
||||||
if (xtrx_set_gain(m_deviceShared.m_deviceParams->getDevice(),
|
uint32_t lna, tia, pga;
|
||||||
XTRX_CH_AB /*m_deviceShared.m_channel*/,
|
|
||||||
XTRX_RX_LNA_GAIN,
|
DeviceXTRX::getAutoGains(gain, lna, tia, pga);
|
||||||
gain,
|
|
||||||
NULL) < 0)
|
apply_gain_lna(lna);
|
||||||
{
|
apply_gain_tia(tia_to_db(tia));
|
||||||
qDebug("XTRXInput::applySettings: xtrx_set_gain(auto) failed");
|
apply_gain_pga(pga);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//doCalibration = true;
|
|
||||||
qDebug() << "XTRXInput::applySettings: Gain (auto) set to " << gain;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void XTRXInput::apply_gain_lna(double gain)
|
void XTRXInput::apply_gain_lna(double gain)
|
||||||
|
@ -194,7 +194,7 @@ public:
|
|||||||
void getLPRange(float& minF, float& maxF, float& stepF) const;
|
void getLPRange(float& minF, float& maxF, float& stepF) const;
|
||||||
uint32_t getHWLog2Decim() const;
|
uint32_t getHWLog2Decim() const;
|
||||||
|
|
||||||
void apply_gain_auto(double gain);
|
void apply_gain_auto(uint32_t gain);
|
||||||
void apply_gain_lna(double gain);
|
void apply_gain_lna(double gain);
|
||||||
void apply_gain_tia(double gain);
|
void apply_gain_tia(double gain);
|
||||||
void apply_gain_pga(double gain);
|
void apply_gain_pga(double gain);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user