Change the P25 TX and RX filters and add a DMR TX data holdoff counter.

c4fmdemod
Jonathan Naylor 2017-03-06 20:42:37 +00:00
parent 8c970b26db
commit a9b761d1dc
5 changed files with 44 additions and 18 deletions

View File

@ -61,6 +61,8 @@ const uint8_t BIT_MASK_TABLE[] = {0x80U, 0x40U, 0x20U, 0x10U, 0x08U, 0x04U, 0x02
#define WRITE_BIT1(p,i,b) p[(i)>>3] = (b) ? (p[(i)>>3] | BIT_MASK_TABLE[(i)&7]) : (p[(i)>>3] & ~BIT_MASK_TABLE[(i)&7])
#define READ_BIT1(p,i) (p[(i)>>3] & BIT_MASK_TABLE[(i)&7])
const uint32_t STARTUP_COUNT = 20U;
CDMRTX::CDMRTX() :
m_fifo(),
m_modFilter(),
@ -75,6 +77,7 @@ m_poBuffer(),
m_poLen(0U),
m_poPtr(0U),
m_count(0U),
m_frameCount(0U),
m_abort()
{
::memset(m_modState, 0x00U, 70U * sizeof(q15_t));
@ -233,6 +236,8 @@ void CDMRTX::setStart(bool start)
m_count = 0U;
m_frameCount = 0U;
m_abort[0U] = false;
m_abort[1U] = false;
}
@ -313,7 +318,7 @@ uint8_t CDMRTX::getSpace2() const
void CDMRTX::createData(uint8_t slotIndex)
{
if (m_fifo[slotIndex].getData()> 0U) {
if (m_fifo[slotIndex].getData() > 0U && m_frameCount >= STARTUP_COUNT) {
for (unsigned int i = 0U; i < DMR_FRAME_LENGTH_BYTES; i++) {
m_poBuffer[i] = m_fifo[slotIndex].get();
m_markBuffer[i] = MARK_NONE;
@ -344,6 +349,8 @@ void CDMRTX::createCal()
void CDMRTX::createCACH(uint8_t txSlotIndex, uint8_t rxSlotIndex)
{
m_frameCount++;
if (m_cachPtr >= 12U)
m_cachPtr = 0U;
@ -359,7 +366,9 @@ void CDMRTX::createCACH(uint8_t txSlotIndex, uint8_t rxSlotIndex)
m_markBuffer[1U] = MARK_NONE;
m_markBuffer[2U] = rxSlotIndex == 1U ? MARK_SLOT1 : MARK_SLOT2;
bool at = m_fifo[rxSlotIndex].getData() > 0U;
bool at = false;
if (m_frameCount >= STARTUP_COUNT)
m_fifo[rxSlotIndex].getData() > 0U;
bool tc = txSlotIndex == 1U;
bool ls0 = true; // For 1 and 2
bool ls1 = true;

View File

@ -68,6 +68,7 @@ private:
uint16_t m_poLen;
uint16_t m_poPtr;
uint32_t m_count;
uint32_t m_frameCount;
bool m_abort[2U];
void createData(uint8_t slotIndex);

30
IO.cpp
View File

@ -41,6 +41,10 @@ const uint16_t C4FSK_FILTER_LEN = 42U;
static q15_t GMSK_FILTER[] = {8, 104, 760, 3158, 7421, 9866, 7421, 3158, 760, 104, 8, 0};
const uint16_t GMSK_FILTER_LEN = 12U;
// One symbol boxcar filter
static q15_t P25_FILTER[] = {3000, 3000, 3000, 3000, 3000, 0};
const uint16_t P25_FILTER_LEN = 6U;
const uint16_t DC_OFFSET = 2048U;
CIO::CIO() :
@ -50,8 +54,10 @@ m_txBuffer(TX_RINGBUFFER_SIZE),
m_rssiBuffer(RX_RINGBUFFER_SIZE),
m_C4FSKFilter(),
m_GMSKFilter(),
m_P25Filter(),
m_C4FSKState(),
m_GMSKState(),
m_P25State(),
m_pttInvert(false),
m_rxLevel(128 * 128),
m_cwIdTXLevel(128 * 128),
@ -70,6 +76,7 @@ m_lockout(false)
{
::memset(m_C4FSKState, 0x00U, 70U * sizeof(q15_t));
::memset(m_GMSKState, 0x00U, 40U * sizeof(q15_t));
::memset(m_P25State, 0x00U, 30U * sizeof(q15_t));
m_C4FSKFilter.numTaps = C4FSK_FILTER_LEN;
m_C4FSKFilter.pState = m_C4FSKState;
@ -79,6 +86,10 @@ m_lockout(false)
m_GMSKFilter.pState = m_GMSKState;
m_GMSKFilter.pCoeffs = GMSK_FILTER;
m_P25Filter.numTaps = P25_FILTER_LEN;
m_P25Filter.pState = m_P25State;
m_P25Filter.pCoeffs = P25_FILTER;
initInt();
}
@ -187,7 +198,15 @@ void CIO::process()
dstarRX.samples(GMSKVals, rssi, blockSize);
}
if (m_dmrEnable || m_ysfEnable || m_p25Enable) {
if (m_p25Enable) {
q15_t P25Vals[RX_BLOCK_SIZE + 1U];
::arm_fir_fast_q15(&m_P25Filter, samples, P25Vals, blockSize);
p25RX.samples(P25Vals, rssi, blockSize);
}
if (m_dmrEnable || m_ysfEnable) {
q15_t C4FSKVals[RX_BLOCK_SIZE + 1U];
::arm_fir_fast_q15(&m_C4FSKFilter, samples, C4FSKVals, blockSize);
@ -200,9 +219,6 @@ void CIO::process()
if (m_ysfEnable)
ysfRX.samples(C4FSKVals, rssi, blockSize);
if (m_p25Enable)
p25RX.samples(C4FSKVals, rssi, blockSize);
}
} else if (m_modemState == STATE_DSTAR) {
if (m_dstarEnable) {
@ -235,10 +251,10 @@ void CIO::process()
}
} else if (m_modemState == STATE_P25) {
if (m_p25Enable) {
q15_t C4FSKVals[RX_BLOCK_SIZE + 1U];
::arm_fir_fast_q15(&m_C4FSKFilter, samples, C4FSKVals, blockSize);
q15_t P25Vals[RX_BLOCK_SIZE + 1U];
::arm_fir_fast_q15(&m_P25Filter, samples, P25Vals, blockSize);
p25RX.samples(C4FSKVals, rssi, blockSize);
p25RX.samples(P25Vals, rssi, blockSize);
}
} else if (m_modemState == STATE_DSTARCAL) {
q15_t GMSKVals[RX_BLOCK_SIZE + 1U];

2
IO.h
View File

@ -62,8 +62,10 @@ private:
arm_fir_instance_q15 m_C4FSKFilter;
arm_fir_instance_q15 m_GMSKFilter;
arm_fir_instance_q15 m_P25Filter;
q15_t m_C4FSKState[70U]; // NoTaps + BlockSize - 1, 42 + 20 - 1 plus some spare
q15_t m_GMSKState[40U]; // NoTaps + BlockSize - 1, 12 + 20 - 1 plus some spare
q15_t m_P25State[30U]; // NoTaps + BlockSize - 1, 6 + 20 - 1 plus some spare
bool m_pttInvert;
q15_t m_rxLevel;

View File

@ -25,16 +25,14 @@
#include "P25Defines.h"
#if defined(WIDE_C4FSK_FILTERS_TX)
// Generated using rcosdesign(0.2, 4, 5, 'sqrt') in MATLAB
static q15_t P25_C4FSK_FILTER[] = {688, -680, -2158, -3060, -2724, -775, 2684, 7041, 11310, 14425, 15565, 14425,
11310, 7041, 2684, -775, -2724, -3060, -2158, -680, 688, 0};
const uint16_t P25_C4FSK_FILTER_LEN = 22U;
// Generated using rcosdesign(0.2, 4, 5, 'normal') in MATLAB
static q15_t P25_C4FSK_FILTER[] = {-1393, -2602, -3044, -2238, 0, 3460, 7543, 11400, 14152, 15152, 14152, 11400, 7543, 3460, 0, -2238, -3044, -2602, -1393, 0};
const uint16_t P25_C4FSK_FILTER_LEN = 20U;
#else
// Generated using rcosdesign(0.2, 8, 5, 'sqrt') in MATLAB
static q15_t P25_C4FSK_FILTER[] = {401, 104, -340, -731, -847, -553, 112, 909, 1472, 1450, 683, -675, -2144, -3040, -2706, -770, 2667, 6995,
11237, 14331, 15464, 14331, 11237, 6995, 2667, -770, -2706, -3040, -2144, -675, 683, 1450, 1472, 909, 112,
-553, -847, -731, -340, 104, 401, 0};
const uint16_t P25_C4FSK_FILTER_LEN = 42U;
// Generated using rcosdesign(0.2, 8, 5, 'normal') in MATLAB
static q15_t P25_C4FSK_FILTER[] = {0, -413, -750, -845, -587, 0, 741, 1347, 1520, 1062, 0, -1383, -2582, -3021, -2222, 0, 3434, 7487, 11318, 14054, 15044, 14054,
11318, 7487, 3434, 0, -2222, -3021, -2582, -1383, 0, 1062, 1520, 1347, 741, 0, -587, -845, -750, -413};
const uint16_t P25_C4FSK_FILTER_LEN = 40U;
#endif
// Generated in MATLAB using the following commands, and then normalised for unity gain