Remove the level tweaking functionality.

This commit is contained in:
Jonathan Naylor 2016-07-07 17:37:06 +01:00
parent dcc52ca479
commit 87b6688f8f
15 changed files with 27 additions and 241 deletions

View File

@ -47,8 +47,7 @@ m_endPtr(NOENDPTR),
m_maxCorr(0),
m_centre(0),
m_threshold(0),
m_colorCode(0U),
m_scale(SCALING_FACTOR)
m_colorCode(0U)
{
}
@ -104,7 +103,7 @@ void CDMRIdleRX::processSample(q15_t sample)
if (corr > m_maxCorr) {
q15_t centre = (max + min) >> 1;
q31_t v1 = (max - centre) * m_scale;
q31_t v1 = (max - centre) * SCALING_FACTOR;
q15_t threshold = q15_t(v1 >> 15);
uint8_t sync[DMR_SYNC_BYTES_LENGTH];
@ -201,20 +200,3 @@ void CDMRIdleRX::setColorCode(uint8_t colorCode)
m_colorCode = colorCode;
}
void CDMRIdleRX::setThreshold(int8_t percent)
{
q31_t res = SCALING_FACTOR * 1000;
if (percent > 0) {
for (int8_t i = 0; i < percent; i++)
res += SCALING_FACTOR;
} else if (percent < 0) {
for (int8_t i = 0; i < -percent; i++)
res -= SCALING_FACTOR;
}
m_scale = res / 1000;
DEBUG2("DMRIdleRX: Scale", m_scale);
}

View File

@ -28,7 +28,6 @@ public:
void samples(const q15_t* samples, uint8_t length);
void setThreshold(int8_t threshold);
void setColorCode(uint8_t colorCode);
void reset();
@ -43,7 +42,6 @@ private:
q15_t m_centre;
q15_t m_threshold;
uint8_t m_colorCode;
q15_t m_scale;
void processSample(q15_t sample);
void samplesToBits(uint16_t start, uint8_t count, uint8_t* buffer, uint16_t offset, q15_t centre, q15_t threshold);

View File

@ -56,12 +56,6 @@ void CDMRRX::setColorCode(uint8_t colorCode)
m_slot2RX.setColorCode(colorCode);
}
void CDMRRX::setThreshold(int8_t threshold)
{
m_slot1RX.setThreshold(threshold);
m_slot2RX.setThreshold(threshold);
}
void CDMRRX::setDelay(uint8_t delay)
{
m_slot1RX.setDelay(delay);

View File

@ -29,7 +29,6 @@ public:
void samples(const q15_t* samples, const uint8_t* control, uint8_t length);
void setColorCode(uint8_t colorCode);
void setThreshold(int8_t threshold);
void setDelay(uint8_t delay);
void reset();

View File

@ -64,8 +64,7 @@ m_colorCode(0U),
m_delay(0U),
m_state(DMRRXS_NONE),
m_n(0U),
m_type(0U),
m_scale(SCALING_FACTOR)
m_type(0U)
{
}
@ -274,7 +273,7 @@ void CDMRSlotRX::correlateSync(bool first)
if (corr > m_maxCorr) {
q15_t centre = (max + min) >> 1;
q31_t v1 = (max - centre) * m_scale;
q31_t v1 = (max - centre) * SCALING_FACTOR;
q15_t threshold = q15_t(v1 >> 15);
uint8_t sync[DMR_SYNC_BYTES_LENGTH];
@ -375,20 +374,3 @@ void CDMRSlotRX::setDelay(uint8_t delay)
m_delay = delay;
}
void CDMRSlotRX::setThreshold(int8_t percent)
{
q31_t res = SCALING_FACTOR * 1000;
if (percent > 0) {
for (int8_t i = 0; i < percent; i++)
res += SCALING_FACTOR;
} else if (percent < 0) {
for (int8_t i = 0; i < -percent; i++)
res -= SCALING_FACTOR;
}
m_scale = res / 1000;
DEBUG2("DMRSlotRX: Scale", m_scale);
}

View File

@ -37,7 +37,6 @@ public:
bool processSample(q15_t sample);
void setColorCode(uint8_t colorCode);
void setThreshold(int8_t threshold);
void setDelay(uint8_t delay);
void reset();
@ -63,7 +62,6 @@ private:
DMRRX_STATE m_state;
uint8_t m_n;
uint8_t m_type;
q15_t m_scale;
void correlateSync(bool first);
void samplesToBits(uint16_t start, uint8_t count, uint8_t* buffer, uint16_t offset, q15_t centre, q15_t threshold);

View File

@ -29,8 +29,10 @@ static q15_t DMR_C4FSK_FILTER[] = {401, 104, -340, -731, -847, -553, 112, 909, 1
-553, -847, -731, -340, 104, 401, 0};
const uint16_t DMR_C4FSK_FILTER_LEN = 42U;
const q15_t DMR_LEVEL3 = 640;
const q15_t DMR_LEVEL1 = 213;
const q15_t DMR_LEVELA[] = { 640, 640 , 640, 640, 640};
const q15_t DMR_LEVELB[] = { 213, 213, 213, 213, 213};
const q15_t DMR_LEVELC[] = {-213, -213, -213, -213, -213};
const q15_t DMR_LEVELD[] = {-640, -640, -640, -640, -640};
// The PR FILL and Data Sync pattern.
const uint8_t IDLE_DATA[] =
@ -54,10 +56,6 @@ const uint8_t BIT_MASK_TABLE[] = {0x80U, 0x40U, 0x20U, 0x10U, 0x08U, 0x04U, 0x02
CDMRTX::CDMRTX() :
m_fifo(),
m_levelA(),
m_levelB(),
m_levelC(),
m_levelD(),
m_modFilter(),
m_modState(),
m_state(DMRTXSTATE_IDLE),
@ -79,13 +77,6 @@ m_count(0U)
::memcpy(m_newShortLC, EMPTY_SHORT_LC, 12U);
::memcpy(m_shortLC, EMPTY_SHORT_LC, 12U);
for (uint8_t i = 0U; i < DMR_RADIO_SYMBOL_LENGTH; i++) {
m_levelA[i] = DMR_LEVEL3;
m_levelB[i] = DMR_LEVEL1;
m_levelC[i] = -DMR_LEVEL1;
m_levelD[i] = -DMR_LEVEL3;
}
}
void CDMRTX::process()
@ -240,16 +231,16 @@ void CDMRTX::writeByte(uint8_t c, uint8_t control)
for (uint8_t i = 0U; i < 4U; i++, c <<= 2, p += DMR_RADIO_SYMBOL_LENGTH) {
switch (c & MASK) {
case 0xC0U:
::memcpy(p, m_levelA, DMR_RADIO_SYMBOL_LENGTH * sizeof(q15_t));
::memcpy(p, DMR_LEVELA, DMR_RADIO_SYMBOL_LENGTH * sizeof(q15_t));
break;
case 0x80U:
::memcpy(p, m_levelB, DMR_RADIO_SYMBOL_LENGTH * sizeof(q15_t));
::memcpy(p, DMR_LEVELB, DMR_RADIO_SYMBOL_LENGTH * sizeof(q15_t));
break;
case 0x00U:
::memcpy(p, m_levelC, DMR_RADIO_SYMBOL_LENGTH * sizeof(q15_t));
::memcpy(p, DMR_LEVELC, DMR_RADIO_SYMBOL_LENGTH * sizeof(q15_t));
break;
default:
::memcpy(p, m_levelD, DMR_RADIO_SYMBOL_LENGTH * sizeof(q15_t));
::memcpy(p, DMR_LEVELD, DMR_RADIO_SYMBOL_LENGTH * sizeof(q15_t));
break;
}
}
@ -379,37 +370,3 @@ void CDMRTX::setColorCode(uint8_t colorCode)
slotType.encode(colorCode, DT_IDLE, m_idle);
}
void CDMRTX::setLevels(int8_t percent1, int8_t percent3)
{
q31_t res1 = DMR_LEVEL1 * 1000;
q31_t res3 = DMR_LEVEL3 * 1000;
if (percent1 > 0) {
for (int8_t i = 0; i < percent1; i++)
res1 += DMR_LEVEL1;
} else if (percent1 < 0) {
for (int8_t i = 0; i < -percent1; i++)
res1 -= DMR_LEVEL1;
}
if (percent3 > 0) {
for (int8_t i = 0; i < percent3; i++)
res3 += DMR_LEVEL3;
} else if (percent3 < 0) {
for (int8_t i = 0; i < -percent3; i++)
res3 -= DMR_LEVEL3;
}
q15_t level1 = res1 / 1000;
q15_t level3 = res3 / 1000;
for (uint8_t i = 0U; i < DMR_RADIO_SYMBOL_LENGTH; i++) {
m_levelA[i] = level3;
m_levelB[i] = level1;
m_levelC[i] = -level1;
m_levelD[i] = -level3;
}
DEBUG3("DMRTX: Levels 1/3", level1, level3);
}

View File

@ -53,14 +53,9 @@ public:
uint16_t getSpace2() const;
void setColorCode(uint8_t colorCode);
void setLevels(int8_t level1, int8_t level3);
private:
CSerialRB m_fifo[2U];
q15_t m_levelA[DMR_RADIO_SYMBOL_LENGTH];
q15_t m_levelB[DMR_RADIO_SYMBOL_LENGTH];
q15_t m_levelC[DMR_RADIO_SYMBOL_LENGTH];
q15_t m_levelD[DMR_RADIO_SYMBOL_LENGTH];
arm_fir_instance_q15 m_modFilter;
q15_t m_modState[70U]; // NoTaps + BlockSize - 1, 42 + 20 - 1 plus some spare
DMRTXSTATE m_state;

View File

@ -32,7 +32,8 @@ const uint8_t FRAME_SYNC[] = {0xEAU, 0xA6U, 0x00U};
static q15_t DSTAR_GMSK_FILTER[] = {8, 104, 760, 3158, 7421, 9866, 7421, 3158, 760, 104, 8, 0};
const uint16_t DSTAR_GMSK_FILTER_LEN = 12U;
const q15_t DSTAR_LEVEL = 800;
const q15_t DSTAR_LEVEL0[] = {-800, -800, -800, -800, -800};
const q15_t DSTAR_LEVEL1[] = { 800, 800, 800, 800, 800};
const uint8_t BIT_MASK_TABLE[] = {0x80U, 0x40U, 0x20U, 0x10U, 0x08U, 0x04U, 0x02U, 0x01U};
@ -189,8 +190,6 @@ const uint8_t DSTAR_EOT = 0x02U;
CDStarTX::CDStarTX() :
m_buffer(),
m_level0(),
m_level1(),
m_modFilter(),
m_modState(),
m_poBuffer(),
@ -204,11 +203,6 @@ m_count(0U)
m_modFilter.numTaps = DSTAR_GMSK_FILTER_LEN;
m_modFilter.pState = m_modState;
m_modFilter.pCoeffs = DSTAR_GMSK_FILTER;
for (uint8_t i = 0U; i < DSTAR_RADIO_BIT_LENGTH; i++) {
m_level0[i] = -DSTAR_LEVEL;
m_level1[i] = DSTAR_LEVEL;
}
}
void CDStarTX::process()
@ -425,9 +419,9 @@ void CDStarTX::writeByte(uint8_t c)
q15_t* p = inBuffer;
for (uint8_t i = 0U; i < 8U; i++, p += DSTAR_RADIO_BIT_LENGTH) {
if ((c & mask) == mask)
::memcpy(p, m_level0, DSTAR_RADIO_BIT_LENGTH * sizeof(q15_t));
::memcpy(p, DSTAR_LEVEL0, DSTAR_RADIO_BIT_LENGTH * sizeof(q15_t));
else
::memcpy(p, m_level1, DSTAR_RADIO_BIT_LENGTH * sizeof(q15_t));
::memcpy(p, DSTAR_LEVEL1, DSTAR_RADIO_BIT_LENGTH * sizeof(q15_t));
mask <<= 1;
}
@ -465,25 +459,3 @@ uint16_t CDStarTX::getSpace() const
return m_buffer.getSpace() / (DSTAR_DATA_LENGTH_BYTES + 1U);
}
void CDStarTX::setLevels(int8_t percent)
{
q31_t res = DSTAR_LEVEL * 1000;
if (percent > 0) {
for (int8_t i = 0; i < percent; i++)
res += DSTAR_LEVEL;
} else if (percent < 0) {
for (int8_t i = 0; i < -percent; i++)
res -= DSTAR_LEVEL;
}
q15_t level = res / 1000;
for (uint8_t i = 0U; i < DSTAR_RADIO_BIT_LENGTH; i++) {
m_level0[i] = -level;
m_level1[i] = level;
}
DEBUG2("DStarTX: Level", level);
}

View File

@ -34,14 +34,11 @@ public:
void process();
void setTXDelay(uint8_t delay);
void setLevels(int8_t level);
uint16_t getSpace() const;
private:
CSerialRB m_buffer;
q15_t m_level0[DSTAR_RADIO_BIT_LENGTH];
q15_t m_level1[DSTAR_RADIO_BIT_LENGTH];
arm_fir_instance_q15 m_modFilter;
q15_t m_modState[60U]; // NoTaps + BlockSize - 1, 12 + 40 - 1 plus some spare
uint8_t m_poBuffer[500U];

View File

@ -185,7 +185,7 @@ void CSerialPort::getVersion()
uint8_t CSerialPort::setConfig(const uint8_t* data, uint8_t length)
{
if (length < 16U)
if (length < 9U)
return 4U;
bool rxInvert = (data[0U] & 0x01U) == 0x01U;
@ -232,17 +232,6 @@ uint8_t CSerialPort::setConfig(const uint8_t* data, uint8_t length)
m_sampleInsert = false;
}
int8_t dstarLevel = int8_t(data[9U]) - 128;
int8_t dmrLevel1 = int8_t(data[10U]) - 128;
int8_t dmrLevel3 = int8_t(data[11U]) - 128;
int8_t ysfLevel1 = int8_t(data[12U]) - 128;
int8_t ysfLevel3 = int8_t(data[13U]) - 128;
int8_t dmrThreshold = int8_t(data[14U]) - 128;
int8_t ysfThreshold = int8_t(data[15U]) - 128;
m_modemState = modemState;
m_dstarEnable = dstarEnable;
@ -257,14 +246,6 @@ uint8_t CSerialPort::setConfig(const uint8_t* data, uint8_t length)
dmrRX.setDelay(dmrDelay);
dmrIdleRX.setColorCode(colorCode);
dstarTX.setLevels(dstarLevel);
dmrTX.setLevels(dmrLevel1, dmrLevel3);
ysfTX.setLevels(ysfLevel1, ysfLevel3);
dmrIdleRX.setThreshold(dmrThreshold);
dmrRX.setThreshold(dmrThreshold);
ysfRX.setThreshold(ysfThreshold);
io.setParameters(rxInvert, txInvert, pttInvert, rxLevel, txLevel);
io.start();

View File

@ -55,8 +55,7 @@ m_bufferPtr(0U),
m_symbolPtr(0U),
m_lostCount(0U),
m_centre(0),
m_threshold(0),
m_scale(SCALING_FACTOR)
m_threshold(0)
{
m_buffer = m_outBuffer + 1U;
}
@ -124,7 +123,7 @@ void CYSFRX::processNone(q15_t sample)
q15_t centre = (max + min) >> 1;
q31_t v1 = (max - centre) * m_scale;
q31_t v1 = (max - centre) * SCALING_FACTOR;
q15_t threshold = q15_t(v1 >> 15);
uint16_t ptr = m_symbolPtr + 1U;
@ -243,20 +242,3 @@ void CYSFRX::processData(q15_t sample)
}
}
void CYSFRX::setThreshold(int8_t percent)
{
q31_t res = SCALING_FACTOR * 1000;
if (percent > 0) {
for (int8_t i = 0; i < percent; i++)
res += SCALING_FACTOR;
} else if (percent < 0) {
for (int8_t i = 0; i < -percent; i++)
res -= SCALING_FACTOR;
}
m_scale = res / 1000;
DEBUG2("YSFRX: Scale", m_scale);
}

View File

@ -35,8 +35,6 @@ public:
void reset();
void setThreshold(int8_t threshold);
private:
uint32_t m_pll;
bool m_prev;
@ -51,7 +49,6 @@ private:
uint16_t m_lostCount;
q15_t m_centre;
q15_t m_threshold;
q15_t m_scale;
void processNone(q15_t sample);
void processData(q15_t sample);

View File

@ -30,18 +30,16 @@ static q15_t YSF_C4FSK_FILTER[] = {401, 104, -340, -731, -847, -553, 112, 909, 1
-553, -847, -731, -340, 104, 401, 0};
const uint16_t YSF_C4FSK_FILTER_LEN = 42U;
const q15_t YSF_LEVEL3 = 809;
const q15_t YSF_LEVEL1 = 269;
const q15_t YSF_LEVELA[] = { 809, 809, 809, 809, 809};
const q15_t YSF_LEVELB[] = { 269, 269, 269, 269, 269};
const q15_t YSF_LEVELC[] = {-269, -269, -269, -269, -269};
const q15_t YSF_LEVELD[] = {-809, -809, -809, -809, -809};
const uint8_t YSF_START_SYNC = 0x77U;
const uint8_t YSF_END_SYNC = 0xFFU;
CYSFTX::CYSFTX() :
m_buffer(1500U),
m_levelA(),
m_levelB(),
m_levelC(),
m_levelD(),
m_modFilter(),
m_modState(),
m_poBuffer(),
@ -55,13 +53,6 @@ m_count(0U)
m_modFilter.numTaps = YSF_C4FSK_FILTER_LEN;
m_modFilter.pState = m_modState;
m_modFilter.pCoeffs = YSF_C4FSK_FILTER;
for (uint8_t i = 0U; i < YSF_RADIO_SYMBOL_LENGTH; i++) {
m_levelA[i] = YSF_LEVEL3;
m_levelB[i] = YSF_LEVEL1;
m_levelC[i] = -YSF_LEVEL1;
m_levelD[i] = -YSF_LEVEL3;
}
}
void CYSFTX::process()
@ -129,16 +120,16 @@ void CYSFTX::writeByte(uint8_t c)
for (uint8_t i = 0U; i < 4U; i++, c <<= 2, p += YSF_RADIO_SYMBOL_LENGTH) {
switch (c & MASK) {
case 0xC0U:
::memcpy(p, m_levelA, YSF_RADIO_SYMBOL_LENGTH * sizeof(q15_t));
::memcpy(p, YSF_LEVELA, YSF_RADIO_SYMBOL_LENGTH * sizeof(q15_t));
break;
case 0x80U:
::memcpy(p, m_levelB, YSF_RADIO_SYMBOL_LENGTH * sizeof(q15_t));
::memcpy(p, YSF_LEVELB, YSF_RADIO_SYMBOL_LENGTH * sizeof(q15_t));
break;
case 0x00U:
::memcpy(p, m_levelC, YSF_RADIO_SYMBOL_LENGTH * sizeof(q15_t));
::memcpy(p, YSF_LEVELC, YSF_RADIO_SYMBOL_LENGTH * sizeof(q15_t));
break;
default:
::memcpy(p, m_levelD, YSF_RADIO_SYMBOL_LENGTH * sizeof(q15_t));
::memcpy(p, YSF_LEVELD, YSF_RADIO_SYMBOL_LENGTH * sizeof(q15_t));
break;
}
}
@ -176,37 +167,3 @@ uint16_t CYSFTX::getSpace() const
return m_buffer.getSpace() / YSF_FRAME_LENGTH_BYTES;
}
void CYSFTX::setLevels(int8_t percent1, int8_t percent3)
{
q31_t res1 = YSF_LEVEL1 * 1000;
q31_t res3 = YSF_LEVEL3 * 1000;
if (percent1 > 0) {
for (int8_t i = 0; i < percent1; i++)
res1 += YSF_LEVEL1;
} else if (percent1 < 0) {
for (int8_t i = 0; i < -percent1; i++)
res1 -= YSF_LEVEL1;
}
if (percent3 > 0) {
for (int8_t i = 0; i < percent3; i++)
res3 += YSF_LEVEL3;
} else if (percent3 < 0) {
for (int8_t i = 0; i < -percent3; i++)
res3 -= YSF_LEVEL3;
}
q15_t level1 = res1 / 1000;
q15_t level3 = res3 / 1000;
for (uint8_t i = 0U; i < YSF_RADIO_SYMBOL_LENGTH; i++) {
m_levelA[i] = level3;
m_levelB[i] = level1;
m_levelC[i] = -level1;
m_levelD[i] = -level3;
}
DEBUG3("YSFTX: Levels 1/3", level1, level3);
}

View File

@ -32,16 +32,11 @@ public:
void process();
void setTXDelay(uint8_t delay);
void setLevels(int8_t level1, int8_t level3);
uint16_t getSpace() const;
private:
CSerialRB m_buffer;
q15_t m_levelA[YSF_RADIO_SYMBOL_LENGTH];
q15_t m_levelB[YSF_RADIO_SYMBOL_LENGTH];
q15_t m_levelC[YSF_RADIO_SYMBOL_LENGTH];
q15_t m_levelD[YSF_RADIO_SYMBOL_LENGTH];
arm_fir_instance_q15 m_modFilter;
q15_t m_modState[70U]; // NoTaps + BlockSize - 1, 42 + 20 - 1 plus some spare
uint8_t m_poBuffer[920U];