Make the YSF demodulator stiffer when locked.

This commit is contained in:
Jonathan Naylor 2016-03-21 22:07:33 +00:00
parent 96091c8424
commit 3665d02fe7
2 changed files with 21 additions and 9 deletions

View File

@ -29,7 +29,8 @@ const q15_t SCALING_FACTOR = 19505; // Q15(0.60)
const uint32_t PLLMAX = 0x10000U;
const uint32_t PLLINC = PLLMAX / YSF_RADIO_SYMBOL_LENGTH;
const uint32_t INC = PLLINC / 32U;
const uint32_t INC_UNLOCK = PLLINC / 32U;
const uint32_t INC_LOCK = PLLINC / 64U;
const uint8_t SYNC_SYMBOL_ERRS = 2U;
const uint8_t SYNC_BIT_ERRS = 4U;
@ -311,6 +312,7 @@ static const unsigned short CCITT_TABLE[] = {
CYSFRX::CYSFRX() :
m_pll(0U),
m_prev(false),
m_inc(INC_UNLOCK),
m_state(YSFRXS_NONE),
m_bitBuffer(0x00U),
m_symbols(),
@ -335,6 +337,7 @@ void CYSFRX::reset()
{
m_pll = 0U;
m_prev = false;
m_inc = INC_UNLOCK;
m_state = YSFRXS_NONE;
m_bitBuffer = 0x00U;
m_bufferPtr = 0U;
@ -351,9 +354,9 @@ void CYSFRX::samples(const q15_t* samples, uint8_t length)
if (bit != m_prev) {
if (m_pll < (PLLMAX / 2U))
m_pll += INC;
m_pll += m_inc;
else
m_pll -= INC;
m_pll -= m_inc;
}
m_prev = bit;
@ -440,7 +443,7 @@ void CYSFRX::processNone(q15_t sample)
m_lostCount = MAX_SYNC_FRAMES;
m_bufferPtr = YSF_SYNC_LENGTH_BITS;
m_state = YSFRXS_DATA;
io.setDecode(true);
locked(true);
}
}
@ -506,7 +509,7 @@ void CYSFRX::processData(q15_t sample)
m_lostCount--;
if (m_lostCount == 0U) {
DEBUG1("YSFRX: sync timed out, lost lock");
io.setDecode(false);
locked(false);
serial.writeYSFLost();
@ -531,7 +534,7 @@ void CYSFRX::processData(q15_t sample)
if (ok && (FICH[0U] & 0xC0U) == 0x80U) {
DEBUG1("YSFRX: end of transmission");
io.setDecode(false);
locked(false);
m_state = YSFRXS_NONE;
} else {
// Start the next frame
@ -696,3 +699,10 @@ bool CYSFRX::checksum(const uint8_t* fich) const
return crc8[0U] == fich[5U] && crc8[1U] == fich[4U];
}
void CYSFRX::locked(bool lock)
{
io.setDecode(lock);
m_inc = lock ? INC_LOCK : INC_UNLOCK;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2015 by Jonathan Naylor G4KLX
* Copyright (C) 2015,2016 by Jonathan Naylor G4KLX
*
* 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
@ -38,6 +38,7 @@ public:
private:
uint32_t m_pll;
bool m_prev;
uint32_t m_inc;
YSFRX_STATE m_state;
uint32_t m_symbolBuffer;
uint64_t m_bitBuffer;
@ -64,6 +65,7 @@ private:
uint32_t getSyndrome23127(uint32_t pattern) const;
uint32_t golay24128(const uint8_t* bytes) const;
bool checksum(const uint8_t* fich) const;
void locked(bool lock);
};
#endif