Add or remove samples to handle oscillator offsets.

This commit is contained in:
Jonathan Naylor 2016-03-21 21:49:50 +00:00
parent 4d9f8d19e2
commit 89d9dd9a7b
12 changed files with 154 additions and 48 deletions

View file

@ -174,7 +174,7 @@ void CSerialPort::getVersion()
uint8_t CSerialPort::setConfig(const uint8_t* data, uint8_t length)
{
if (length < 8U)
if (length < 9U)
return 4U;
bool rxInvert = (data[0U] & 0x01U) == 0x01U;
@ -209,6 +209,18 @@ uint8_t CSerialPort::setConfig(const uint8_t* data, uint8_t length)
uint8_t dmrDelay = data[7U];
int8_t oscOffset = int8_t(data[8U]) - 128;
if (oscOffset < 0) {
m_sampleCount = 1000000U / uint32_t(-oscOffset);
m_sampleInsert = true;
} else if (oscOffset > 0) {
m_sampleCount = 1000000U / uint32_t(oscOffset);
m_sampleInsert = false;
} else {
m_sampleCount = 0U;
m_sampleInsert = false;
}
m_modemState = modemState;
m_dstarEnable = dstarEnable;