Improve the code efficiency slightly.

This commit is contained in:
Jonathan Naylor
2020-07-14 14:54:47 +01:00
parent dc41fd83d2
commit 1ac0628c1c
+10 -5
View File
@@ -75,14 +75,14 @@ void CFM::samples(bool cos, const q15_t* samples, uint8_t length)
// ARMv7-M has hardware integer division
q15_t currentSample = q15_t((q31_t(samples[i]) << 8) / m_rxLevel);
uint8_t ctcssState = m_ctcssRX.process(currentSample);
switch (m_accessMode) {
case 0U:
stateMachine(cos);
break;
case 1U:
case 1U: {
uint8_t ctcssState = m_ctcssRX.process(currentSample);
// Delay the audio by 100ms to better match the CTCSS detector output
m_inputRB.put(currentSample);
m_inputRB.get(currentSample);
@@ -93,18 +93,22 @@ void CFM::samples(bool cos, const q15_t* samples, uint8_t length)
bool validCTCSS = CTCSS_VALID(ctcssState);
stateMachine(validCTCSS);
}
}
break;
case 2U:
case 2U: {
uint8_t ctcssState = m_ctcssRX.process(currentSample);
if (CTCSS_NOT_READY(ctcssState) && m_modemState != STATE_FM) {
// Not enough samples to determine if you have CTCSS, just carry on
} else {
bool validCTCSS = CTCSS_VALID(ctcssState);
stateMachine(validCTCSS && cos);
}
}
break;
default:
default: {
uint8_t ctcssState = m_ctcssRX.process(currentSample);
if (CTCSS_NOT_READY(ctcssState) && m_modemState != STATE_FM) {
// Not enough samples to determine if you have CTCSS, just carry on
} else if (CTCSS_READY(ctcssState) && m_modemState != STATE_FM) {
@@ -114,6 +118,7 @@ void CFM::samples(bool cos, const q15_t* samples, uint8_t length)
} else {
stateMachine(cos);
}
}
break;
}