mirror of https://github.com/g4klx/MMDVM.git
Add an optional TX DC offset.
This commit is contained in:
parent
58966406da
commit
fbd9c4d18b
7
IO.cpp
7
IO.cpp
|
@ -48,6 +48,7 @@ m_dstarTXLevel(128 * 128),
|
||||||
m_dmrTXLevel(128 * 128),
|
m_dmrTXLevel(128 * 128),
|
||||||
m_ysfTXLevel(128 * 128),
|
m_ysfTXLevel(128 * 128),
|
||||||
m_p25TXLevel(128 * 128),
|
m_p25TXLevel(128 * 128),
|
||||||
|
m_txDCOffset(DC_OFFSET),
|
||||||
m_ledCount(0U),
|
m_ledCount(0U),
|
||||||
m_ledValue(true),
|
m_ledValue(true),
|
||||||
m_detect(false),
|
m_detect(false),
|
||||||
|
@ -246,7 +247,7 @@ void CIO::write(MMDVM_STATE mode, q15_t* samples, uint16_t length, const uint8_t
|
||||||
for (uint16_t i = 0U; i < length; i++) {
|
for (uint16_t i = 0U; i < length; i++) {
|
||||||
q31_t res1 = samples[i] * txLevel;
|
q31_t res1 = samples[i] * txLevel;
|
||||||
q15_t res2 = q15_t(__SSAT((res1 >> 15), 16));
|
q15_t res2 = q15_t(__SSAT((res1 >> 15), 16));
|
||||||
uint16_t res3 = uint16_t(res2 + DC_OFFSET);
|
uint16_t res3 = uint16_t(res2 + m_txDCOffset);
|
||||||
|
|
||||||
// Detect DAC overflow
|
// Detect DAC overflow
|
||||||
if (res3 > 4095U)
|
if (res3 > 4095U)
|
||||||
|
@ -287,7 +288,7 @@ void CIO::setMode()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void CIO::setParameters(bool rxInvert, bool txInvert, bool pttInvert, uint8_t rxLevel, uint8_t cwIdTXLevel, uint8_t dstarTXLevel, uint8_t dmrTXLevel, uint8_t ysfTXLevel, uint8_t p25TXLevel)
|
void CIO::setParameters(bool rxInvert, bool txInvert, bool pttInvert, uint8_t rxLevel, uint8_t cwIdTXLevel, uint8_t dstarTXLevel, uint8_t dmrTXLevel, uint8_t ysfTXLevel, uint8_t p25TXLevel, int16_t txDCOffset)
|
||||||
{
|
{
|
||||||
m_pttInvert = pttInvert;
|
m_pttInvert = pttInvert;
|
||||||
|
|
||||||
|
@ -297,6 +298,8 @@ void CIO::setParameters(bool rxInvert, bool txInvert, bool pttInvert, uint8_t rx
|
||||||
m_dmrTXLevel = q15_t(dmrTXLevel * 128);
|
m_dmrTXLevel = q15_t(dmrTXLevel * 128);
|
||||||
m_ysfTXLevel = q15_t(ysfTXLevel * 128);
|
m_ysfTXLevel = q15_t(ysfTXLevel * 128);
|
||||||
m_p25TXLevel = q15_t(p25TXLevel * 128);
|
m_p25TXLevel = q15_t(p25TXLevel * 128);
|
||||||
|
|
||||||
|
m_txDCOffset = DC_OFFSET + txDCOffset;
|
||||||
|
|
||||||
if (rxInvert)
|
if (rxInvert)
|
||||||
m_rxLevel = -m_rxLevel;
|
m_rxLevel = -m_rxLevel;
|
||||||
|
|
4
IO.h
4
IO.h
|
@ -42,7 +42,7 @@ public:
|
||||||
|
|
||||||
void interrupt();
|
void interrupt();
|
||||||
|
|
||||||
void setParameters(bool rxInvert, bool txInvert, bool pttInvert, uint8_t rxLevel, uint8_t cwIdTXLevel, uint8_t dstarTXLevel, uint8_t dmrTXLevel, uint8_t ysfTXLevel, uint8_t p25TXLevel);
|
void setParameters(bool rxInvert, bool txInvert, bool pttInvert, uint8_t rxLevel, uint8_t cwIdTXLevel, uint8_t dstarTXLevel, uint8_t dmrTXLevel, uint8_t ysfTXLevel, uint8_t p25TXLevel, int16_t txDCOffset);
|
||||||
|
|
||||||
void getOverflow(bool& adcOverflow, bool& dacOverflow);
|
void getOverflow(bool& adcOverflow, bool& dacOverflow);
|
||||||
|
|
||||||
|
@ -74,6 +74,8 @@ private:
|
||||||
q15_t m_ysfTXLevel;
|
q15_t m_ysfTXLevel;
|
||||||
q15_t m_p25TXLevel;
|
q15_t m_p25TXLevel;
|
||||||
|
|
||||||
|
uint16_t m_txDCOffset;
|
||||||
|
|
||||||
uint32_t m_ledCount;
|
uint32_t m_ledCount;
|
||||||
bool m_ledValue;
|
bool m_ledValue;
|
||||||
|
|
||||||
|
|
|
@ -221,7 +221,7 @@ void CSerialPort::getVersion()
|
||||||
|
|
||||||
uint8_t CSerialPort::setConfig(const uint8_t* data, uint8_t length)
|
uint8_t CSerialPort::setConfig(const uint8_t* data, uint8_t length)
|
||||||
{
|
{
|
||||||
if (length < 13U)
|
if (length < 14U)
|
||||||
return 4U;
|
return 4U;
|
||||||
|
|
||||||
bool rxInvert = (data[0U] & 0x01U) == 0x01U;
|
bool rxInvert = (data[0U] & 0x01U) == 0x01U;
|
||||||
|
@ -268,6 +268,8 @@ uint8_t CSerialPort::setConfig(const uint8_t* data, uint8_t length)
|
||||||
uint8_t ysfTXLevel = data[11U];
|
uint8_t ysfTXLevel = data[11U];
|
||||||
uint8_t p25TXLevel = data[12U];
|
uint8_t p25TXLevel = data[12U];
|
||||||
|
|
||||||
|
int16_t txDCOffset = int16_t(data[13U]) - 128;
|
||||||
|
|
||||||
m_modemState = modemState;
|
m_modemState = modemState;
|
||||||
|
|
||||||
m_dstarEnable = dstarEnable;
|
m_dstarEnable = dstarEnable;
|
||||||
|
@ -289,7 +291,7 @@ uint8_t CSerialPort::setConfig(const uint8_t* data, uint8_t length)
|
||||||
|
|
||||||
ysfTX.setLoDev(ysfLoDev);
|
ysfTX.setLoDev(ysfLoDev);
|
||||||
|
|
||||||
io.setParameters(rxInvert, txInvert, pttInvert, rxLevel, cwIdTXLevel, dstarTXLevel, dmrTXLevel, ysfTXLevel, p25TXLevel);
|
io.setParameters(rxInvert, txInvert, pttInvert, rxLevel, cwIdTXLevel, dstarTXLevel, dmrTXLevel, ysfTXLevel, p25TXLevel, txDCOffset);
|
||||||
|
|
||||||
io.start();
|
io.start();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue