Add independent transmit levels.

This commit is contained in:
Jonathan Naylor 2016-08-09 07:11:10 +01:00
parent 8c96a48b2b
commit 62743345a4
7 changed files with 44 additions and 19 deletions

View File

@ -104,9 +104,9 @@ void CCWIdTX::process()
while (space > CYCLE_LENGTH) {
bool b = READ_BIT1(m_poBuffer, m_poPtr);
if (b)
io.write(TONE, CYCLE_LENGTH);
io.write(STATE_DSTAR, TONE, CYCLE_LENGTH);
else
io.write(SILENCE, CYCLE_LENGTH);
io.write(STATE_DSTAR, SILENCE, CYCLE_LENGTH);
space -= CYCLE_LENGTH;

View File

@ -298,7 +298,7 @@ void CDMRTX::writeByte(uint8_t c, uint8_t control)
::arm_fir_fast_q15(&m_modFilter, inBuffer, outBuffer, blockSize);
io.write(outBuffer, blockSize, controlBuffer);
io.write(STATE_DMR, outBuffer, blockSize, controlBuffer);
}
uint16_t CDMRTX::getSpace1() const

View File

@ -452,7 +452,7 @@ void CDStarTX::writeByte(uint8_t c)
::arm_fir_fast_q15(&m_modFilter, inBuffer, outBuffer, blockSize);
io.write(outBuffer, blockSize);
io.write(STATE_DSTAR, outBuffer, blockSize);
}
void CDStarTX::setTXDelay(uint8_t delay)

36
IO.cpp
View File

@ -124,7 +124,9 @@ m_C4FSKState(),
m_GMSKState(),
m_pttInvert(false),
m_rxLevel(128 * 128),
m_txLevel(128 * 128),
m_dstarTXLevel(128 * 128),
m_dmrTXLevel(128 * 128),
m_ysfTXLevel(128 * 128),
m_ledCount(0U),
m_ledValue(true),
m_dcd(false),
@ -396,7 +398,7 @@ void CIO::process()
}
}
void CIO::write(q15_t* samples, uint16_t length, const uint8_t* control)
void CIO::write(MMDVM_STATE mode, q15_t* samples, uint16_t length, const uint8_t* control)
{
if (!m_started)
return;
@ -414,8 +416,21 @@ void CIO::write(q15_t* samples, uint16_t length, const uint8_t* control)
#endif
}
q15_t txLevel = 0;
switch (mode) {
case STATE_DMR:
txLevel = m_dmrTXLevel;
break;
case STATE_YSF:
txLevel = m_ysfTXLevel;
break;
default:
txLevel = m_dstarTXLevel;
break;
}
for (uint16_t i = 0U; i < length; i++) {
q31_t res1 = samples[i] * m_txLevel;
q31_t res1 = samples[i] * txLevel;
q15_t res2 = q15_t(__SSAT((res1 >> 15), 16));
uint16_t res3 = uint16_t(res2 + DC_OFFSET);
@ -502,18 +517,23 @@ switch (m_modemState) {
#endif
}
void CIO::setParameters(bool rxInvert, bool txInvert, bool pttInvert, uint8_t rxLevel, uint8_t txLevel)
void CIO::setParameters(bool rxInvert, bool txInvert, bool pttInvert, uint8_t rxLevel, uint8_t dstarTXLevel, uint8_t dmrTXLevel, uint8_t ysfTXLevel)
{
m_pttInvert = pttInvert;
m_rxLevel = q15_t(rxLevel * 128);
m_txLevel = q15_t(txLevel * 128);
m_rxLevel = q15_t(rxLevel * 128);
m_dstarTXLevel = q15_t(dstarTXLevel * 128);
m_dmrTXLevel = q15_t(dmrTXLevel * 128);
m_ysfTXLevel = q15_t(ysfTXLevel * 128);
if (rxInvert)
m_rxLevel = -m_rxLevel;
if (txInvert)
m_txLevel = -m_txLevel;
if (txInvert) {
m_dstarTXLevel = -m_dstarTXLevel;
m_dmrTXLevel = -m_dmrTXLevel;
m_ysfTXLevel = -m_ysfTXLevel;
}
}
void CIO::getOverflow(bool& adcOverflow, bool& dacOverflow)

8
IO.h
View File

@ -31,7 +31,7 @@ public:
void process();
void write(q15_t* samples, uint16_t length, const uint8_t* control = NULL);
void write(MMDVM_STATE mode, q15_t* samples, uint16_t length, const uint8_t* control = NULL);
uint16_t getSpace() const;
@ -41,7 +41,7 @@ public:
void interrupt();
void setParameters(bool rxInvert, bool txInvert, bool pttInvert, uint8_t rxLevel, uint8_t txLevel);
void setParameters(bool rxInvert, bool txInvert, bool pttInvert, uint8_t rxLevel, uint8_t dstarTXLevel, uint8_t dmrTXLevel, uint8_t ysfTXLevel);
void getOverflow(bool& adcOverflow, bool& dacOverflow);
@ -81,7 +81,9 @@ private:
bool m_pttInvert;
q15_t m_rxLevel;
q15_t m_txLevel;
q15_t m_dstarTXLevel;
q15_t m_dmrTXLevel;
q15_t m_ysfTXLevel;
uint32_t m_ledCount;
bool m_ledValue;

View File

@ -185,7 +185,7 @@ void CSerialPort::getVersion()
uint8_t CSerialPort::setConfig(const uint8_t* data, uint8_t length)
{
if (length < 9U)
if (length < 12U)
return 4U;
bool rxInvert = (data[0U] & 0x01U) == 0x01U;
@ -212,7 +212,6 @@ uint8_t CSerialPort::setConfig(const uint8_t* data, uint8_t length)
return 4U;
uint8_t rxLevel = data[4U];
uint8_t txLevel = data[5U];
uint8_t colorCode = data[6U];
if (colorCode > 15U)
@ -232,6 +231,10 @@ uint8_t CSerialPort::setConfig(const uint8_t* data, uint8_t length)
m_sampleInsert = false;
}
uint8_t dstarTXLevel = data[9U];
uint8_t dmrTXLevel = data[10U];
uint8_t ysfTXLevel = data[11U];
m_modemState = modemState;
m_dstarEnable = dstarEnable;
@ -246,7 +249,7 @@ uint8_t CSerialPort::setConfig(const uint8_t* data, uint8_t length)
dmrRX.setDelay(dmrDelay);
dmrIdleRX.setColorCode(colorCode);
io.setParameters(rxInvert, txInvert, pttInvert, rxLevel, txLevel);
io.setParameters(rxInvert, txInvert, pttInvert, rxLevel, dstarTXLevel, dmrTXLevel, ysfTXLevel);
io.start();

View File

@ -161,7 +161,7 @@ void CYSFTX::writeByte(uint8_t c)
::arm_fir_fast_q15(&m_modFilter, inBuffer, outBuffer, blockSize);
io.write(outBuffer, blockSize);
io.write(STATE_YSF, outBuffer, blockSize);
}
void CYSFTX::setTXDelay(uint8_t delay)