mirror of https://github.com/g4klx/MMDVM.git
Add YSF tx hang
This commit is contained in:
parent
7fb3175617
commit
d6e1fadb16
4
Config.h
4
Config.h
|
@ -69,4 +69,8 @@
|
||||||
// To reduce CPU load, you can remove the DC blocker by commenting out the next line
|
// To reduce CPU load, you can remove the DC blocker by commenting out the next line
|
||||||
// #define USE_DCBLOCKER
|
// #define USE_DCBLOCKER
|
||||||
|
|
||||||
|
// Constant Service LED once repeater is running
|
||||||
|
// Do not use if employing an external hardware watchdog
|
||||||
|
// #define CONSTANT_SRV_LED
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
15
DMRDMOTX.cpp
15
DMRDMOTX.cpp
|
@ -44,6 +44,13 @@ 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 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])
|
#define READ_BIT1(p,i) (p[(i)>>3] & BIT_MASK_TABLE[(i)&7])
|
||||||
|
|
||||||
|
// PR FILL pattern
|
||||||
|
const uint8_t PR_FILL[] =
|
||||||
|
{0x63U, 0xEAU, 0x00U, 0x76U, 0x6CU, 0x76U, 0xC4U, 0x52U, 0xC8U, 0x78U,
|
||||||
|
0x09U, 0x2DU, 0xB8U, 0x79U, 0x27U, 0x57U, 0x9BU, 0x31U, 0xBCU, 0x3EU,
|
||||||
|
0xEAU, 0x45U, 0xC3U, 0x30U, 0x49U, 0x17U, 0x93U, 0xAEU, 0x8BU, 0x6DU,
|
||||||
|
0xA4U, 0xA5U, 0xADU, 0xA2U, 0xF1U, 0x35U, 0xB5U, 0x3CU, 0x1EU};
|
||||||
|
|
||||||
const uint8_t DMR_SYNC = 0x5FU;
|
const uint8_t DMR_SYNC = 0x5FU;
|
||||||
|
|
||||||
CDMRDMOTX::CDMRDMOTX() :
|
CDMRDMOTX::CDMRDMOTX() :
|
||||||
|
@ -72,11 +79,11 @@ void CDMRDMOTX::process()
|
||||||
|
|
||||||
m_poLen = m_txDelay;
|
m_poLen = m_txDelay;
|
||||||
} else {
|
} else {
|
||||||
for (unsigned int i = 0U; i < 72U; i++)
|
|
||||||
m_poBuffer[i] = DMR_SYNC;
|
|
||||||
|
|
||||||
for (unsigned int i = 0U; i < DMR_FRAME_LENGTH_BYTES; i++)
|
for (unsigned int i = 0U; i < DMR_FRAME_LENGTH_BYTES; i++)
|
||||||
m_poBuffer[i + 39U] = m_fifo.get();
|
m_poBuffer[i] = m_fifo.get();
|
||||||
|
|
||||||
|
for (unsigned int i = 0U; i < 39U; i++)
|
||||||
|
m_poBuffer[i + DMR_FRAME_LENGTH_BYTES] = PR_FILL[i];
|
||||||
|
|
||||||
m_poLen = 72U;
|
m_poLen = 72U;
|
||||||
}
|
}
|
||||||
|
|
6
IO.cpp
6
IO.cpp
|
@ -260,11 +260,15 @@ void CIO::process()
|
||||||
m_watchdog = 0U;
|
m_watchdog = 0U;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_ledCount >= 48000U) {
|
#if defined(CONSTANT_SRV_LED)
|
||||||
|
setLEDInt(true);
|
||||||
|
#else
|
||||||
|
if (m_ledCount >= 24000U) {
|
||||||
m_ledCount = 0U;
|
m_ledCount = 0U;
|
||||||
m_ledValue = !m_ledValue;
|
m_ledValue = !m_ledValue;
|
||||||
setLEDInt(m_ledValue);
|
setLEDInt(m_ledValue);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
if (m_ledCount >= 480000U) {
|
if (m_ledCount >= 480000U) {
|
||||||
m_ledCount = 0U;
|
m_ledCount = 0U;
|
||||||
|
|
|
@ -275,8 +275,8 @@
|
||||||
<File name="DMRDMORX.h" path="DMRDMORX.h" type="1"/>
|
<File name="DMRDMORX.h" path="DMRDMORX.h" type="1"/>
|
||||||
<File name="SerialPort.h" path="SerialPort.h" type="1"/>
|
<File name="SerialPort.h" path="SerialPort.h" type="1"/>
|
||||||
<File name="STM32F4XX_Lib/STM32F4xx_StdPeriph_Driver/include/stm32f4xx_dac.h" path="STM32F4XX_Lib/STM32F4xx_StdPeriph_Driver/include/stm32f4xx_dac.h" type="1"/>
|
<File name="STM32F4XX_Lib/STM32F4xx_StdPeriph_Driver/include/stm32f4xx_dac.h" path="STM32F4XX_Lib/STM32F4xx_StdPeriph_Driver/include/stm32f4xx_dac.h" type="1"/>
|
||||||
<File name="STM32F4XX_Lib/CMSIS/Include/core_cmFunc.h" path="STM32F4XX_Lib/CMSIS/Include/core_cmFunc.h" type="1"/>
|
|
||||||
<File name="STM32F4XX_Lib/Device/system_stm32f4xx.h" path="STM32F4XX_Lib/Device/system_stm32f4xx.h" type="1"/>
|
<File name="STM32F4XX_Lib/Device/system_stm32f4xx.h" path="STM32F4XX_Lib/Device/system_stm32f4xx.h" type="1"/>
|
||||||
|
<File name="STM32F4XX_Lib/CMSIS/Include/core_cmFunc.h" path="STM32F4XX_Lib/CMSIS/Include/core_cmFunc.h" type="1"/>
|
||||||
<File name="CWIdTX.h" path="CWIdTX.h" type="1"/>
|
<File name="CWIdTX.h" path="CWIdTX.h" type="1"/>
|
||||||
<File name="CalDStarTX.cpp" path="CalDStarTX.cpp" type="1"/>
|
<File name="CalDStarTX.cpp" path="CalDStarTX.cpp" type="1"/>
|
||||||
<File name="STM32F4XX_Lib/STM32F4xx_StdPeriph_Driver/source" path="" type="2"/>
|
<File name="STM32F4XX_Lib/STM32F4xx_StdPeriph_Driver/source" path="" type="2"/>
|
||||||
|
@ -284,15 +284,15 @@
|
||||||
<File name="DMRDMOTX.h" path="DMRDMOTX.h" type="1"/>
|
<File name="DMRDMOTX.h" path="DMRDMOTX.h" type="1"/>
|
||||||
<File name="IODue.cpp" path="IODue.cpp" type="1"/>
|
<File name="IODue.cpp" path="IODue.cpp" type="1"/>
|
||||||
<File name="DMRTX.cpp" path="DMRTX.cpp" type="1"/>
|
<File name="DMRTX.cpp" path="DMRTX.cpp" type="1"/>
|
||||||
<File name="P25RX.cpp" path="P25RX.cpp" type="1"/>
|
|
||||||
<File name="CalRSSI.h" path="CalRSSI.h" type="1"/>
|
<File name="CalRSSI.h" path="CalRSSI.h" type="1"/>
|
||||||
|
<File name="P25RX.cpp" path="P25RX.cpp" type="1"/>
|
||||||
<File name="STM32F4XX_Lib/CMSIS/Lib/GCC" path="" type="2"/>
|
<File name="STM32F4XX_Lib/CMSIS/Lib/GCC" path="" type="2"/>
|
||||||
<File name="STM32F4XX_Lib" path="" type="2"/>
|
<File name="STM32F4XX_Lib" path="" type="2"/>
|
||||||
<File name="STM32F4XX_Lib/CMSIS/Include/core_cmInstr.h" path="STM32F4XX_Lib/CMSIS/Include/core_cmInstr.h" type="1"/>
|
<File name="STM32F4XX_Lib/CMSIS/Include/core_cmInstr.h" path="STM32F4XX_Lib/CMSIS/Include/core_cmInstr.h" type="1"/>
|
||||||
<File name="DMRTX.h" path="DMRTX.h" type="1"/>
|
<File name="DMRTX.h" path="DMRTX.h" type="1"/>
|
||||||
<File name="STM32F4XX_Lib/Device/system_stm32f4xx.c" path="STM32F4XX_Lib/Device/system_stm32f4xx.c" type="1"/>
|
<File name="STM32F4XX_Lib/Device/system_stm32f4xx.c" path="STM32F4XX_Lib/Device/system_stm32f4xx.c" type="1"/>
|
||||||
<File name="STM32F4XX_Lib/Device/startup/startup_stm32f4xx.c" path="STM32F4XX_Lib/Device/startup/startup_stm32f4xx.c" type="1"/>
|
|
||||||
<File name="RSSIRB.h" path="RSSIRB.h" type="1"/>
|
<File name="RSSIRB.h" path="RSSIRB.h" type="1"/>
|
||||||
|
<File name="STM32F4XX_Lib/Device/startup/startup_stm32f4xx.c" path="STM32F4XX_Lib/Device/startup/startup_stm32f4xx.c" type="1"/>
|
||||||
<File name="STM32F4XX_Lib/Device/startup" path="" type="2"/>
|
<File name="STM32F4XX_Lib/Device/startup" path="" type="2"/>
|
||||||
<File name="SerialRB.h" path="SerialRB.h" type="1"/>
|
<File name="SerialRB.h" path="SerialRB.h" type="1"/>
|
||||||
<File name="NXDNDefines.h" path="NXDNDefines.h" type="1"/>
|
<File name="NXDNDefines.h" path="NXDNDefines.h" type="1"/>
|
||||||
|
@ -340,8 +340,8 @@
|
||||||
<File name="P25TX.h" path="P25TX.h" type="1"/>
|
<File name="P25TX.h" path="P25TX.h" type="1"/>
|
||||||
<File name="RSSIRB.cpp" path="RSSIRB.cpp" type="1"/>
|
<File name="RSSIRB.cpp" path="RSSIRB.cpp" type="1"/>
|
||||||
<File name="DStarRX.cpp" path="DStarRX.cpp" type="1"/>
|
<File name="DStarRX.cpp" path="DStarRX.cpp" type="1"/>
|
||||||
<File name="DMRSlotRX.cpp" path="DMRSlotRX.cpp" type="1"/>
|
|
||||||
<File name="IOSTM.cpp" path="IOSTM.cpp" type="1"/>
|
<File name="IOSTM.cpp" path="IOSTM.cpp" type="1"/>
|
||||||
|
<File name="DMRSlotRX.cpp" path="DMRSlotRX.cpp" type="1"/>
|
||||||
<File name="P25TX.cpp" path="P25TX.cpp" type="1"/>
|
<File name="P25TX.cpp" path="P25TX.cpp" type="1"/>
|
||||||
<File name="SerialRB.cpp" path="SerialRB.cpp" type="1"/>
|
<File name="SerialRB.cpp" path="SerialRB.cpp" type="1"/>
|
||||||
<File name="CWIdTX.cpp" path="CWIdTX.cpp" type="1"/>
|
<File name="CWIdTX.cpp" path="CWIdTX.cpp" type="1"/>
|
||||||
|
|
|
@ -233,7 +233,7 @@ void CSerialPort::getVersion()
|
||||||
|
|
||||||
uint8_t CSerialPort::setConfig(const uint8_t* data, uint8_t length)
|
uint8_t CSerialPort::setConfig(const uint8_t* data, uint8_t length)
|
||||||
{
|
{
|
||||||
if (length < 16U)
|
if (length < 17U)
|
||||||
return 4U;
|
return 4U;
|
||||||
|
|
||||||
bool rxInvert = (data[0U] & 0x01U) == 0x01U;
|
bool rxInvert = (data[0U] & 0x01U) == 0x01U;
|
||||||
|
@ -288,6 +288,8 @@ uint8_t CSerialPort::setConfig(const uint8_t* data, uint8_t length)
|
||||||
|
|
||||||
uint8_t nxdnTXLevel = data[15U];
|
uint8_t nxdnTXLevel = data[15U];
|
||||||
|
|
||||||
|
uint8_t ysfTXHang = data[16U];
|
||||||
|
|
||||||
m_modemState = modemState;
|
m_modemState = modemState;
|
||||||
|
|
||||||
m_dstarEnable = dstarEnable;
|
m_dstarEnable = dstarEnable;
|
||||||
|
@ -309,7 +311,7 @@ uint8_t CSerialPort::setConfig(const uint8_t* data, uint8_t length)
|
||||||
dmrDMORX.setColorCode(colorCode);
|
dmrDMORX.setColorCode(colorCode);
|
||||||
dmrIdleRX.setColorCode(colorCode);
|
dmrIdleRX.setColorCode(colorCode);
|
||||||
|
|
||||||
ysfTX.setLoDev(ysfLoDev);
|
ysfTX.setParams(ysfLoDev, ysfTXHang);
|
||||||
|
|
||||||
io.setParameters(rxInvert, txInvert, pttInvert, rxLevel, cwIdTXLevel, dstarTXLevel, dmrTXLevel, ysfTXLevel, p25TXLevel, nxdnTXLevel, txDCOffset, rxDCOffset);
|
io.setParameters(rxInvert, txInvert, pttInvert, rxLevel, cwIdTXLevel, dstarTXLevel, dmrTXLevel, ysfTXLevel, p25TXLevel, nxdnTXLevel, txDCOffset, rxDCOffset);
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ Boston, MA 02110-1301, USA.
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const uint16_t SERIAL_RINGBUFFER_SIZE = 2000U;
|
const uint16_t SERIAL_RINGBUFFER_SIZE = 370U;
|
||||||
|
|
||||||
class CSerialRB {
|
class CSerialRB {
|
||||||
public:
|
public:
|
||||||
|
|
49
YSFTX.cpp
49
YSFTX.cpp
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2009-2017 by Jonathan Naylor G4KLX
|
* Copyright (C) 2009-2018 by Jonathan Naylor G4KLX
|
||||||
* Copyright (C) 2017 by Andy Uribe CA6JAU
|
* Copyright (C) 2017 by Andy Uribe CA6JAU
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
@ -47,6 +47,7 @@ const q15_t YSF_LEVELD_LO = -948;
|
||||||
|
|
||||||
const uint8_t YSF_START_SYNC = 0x77U;
|
const uint8_t YSF_START_SYNC = 0x77U;
|
||||||
const uint8_t YSF_END_SYNC = 0xFFU;
|
const uint8_t YSF_END_SYNC = 0xFFU;
|
||||||
|
const uint8_t YSF_HANG = 0x00U;
|
||||||
|
|
||||||
CYSFTX::CYSFTX() :
|
CYSFTX::CYSFTX() :
|
||||||
m_buffer(4000U),
|
m_buffer(4000U),
|
||||||
|
@ -56,7 +57,9 @@ m_poBuffer(),
|
||||||
m_poLen(0U),
|
m_poLen(0U),
|
||||||
m_poPtr(0U),
|
m_poPtr(0U),
|
||||||
m_txDelay(240U), // 200ms
|
m_txDelay(240U), // 200ms
|
||||||
m_loDev(false)
|
m_loDev(false),
|
||||||
|
m_txHang(4800U), // 4s
|
||||||
|
m_txCount(0U)
|
||||||
{
|
{
|
||||||
::memset(m_modState, 0x00U, 16U * sizeof(q15_t));
|
::memset(m_modState, 0x00U, 16U * sizeof(q15_t));
|
||||||
|
|
||||||
|
@ -66,12 +69,14 @@ m_loDev(false)
|
||||||
m_modFilter.pState = m_modState;
|
m_modFilter.pState = m_modState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CYSFTX::process()
|
void CYSFTX::process()
|
||||||
{
|
{
|
||||||
if (m_buffer.getData() == 0U && m_poLen == 0U)
|
if (m_buffer.getData() == 0U && m_poLen == 0U && m_txCount == 0U)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (m_poLen == 0U) {
|
// If we have YSF data to transmit, do so.
|
||||||
|
if (m_poLen == 0U && m_buffer.getData() > 0U) {
|
||||||
if (!m_tx) {
|
if (!m_tx) {
|
||||||
for (uint16_t i = 0U; i < m_txDelay; i++)
|
for (uint16_t i = 0U; i < m_txDelay; i++)
|
||||||
m_poBuffer[m_poLen++] = YSF_START_SYNC;
|
m_poBuffer[m_poLen++] = YSF_START_SYNC;
|
||||||
|
@ -86,20 +91,37 @@ void CYSFTX::process()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_poLen > 0U) {
|
if (m_poLen > 0U) {
|
||||||
|
// Transmit YSF data.
|
||||||
uint16_t space = io.getSpace();
|
uint16_t space = io.getSpace();
|
||||||
|
|
||||||
while (space > (4U * YSF_RADIO_SYMBOL_LENGTH)) {
|
while (space > (4U * YSF_RADIO_SYMBOL_LENGTH)) {
|
||||||
uint8_t c = m_poBuffer[m_poPtr++];
|
uint8_t c = m_poBuffer[m_poPtr++];
|
||||||
writeByte(c);
|
writeByte(c);
|
||||||
|
|
||||||
|
// Reduce space and reset the hang timer.
|
||||||
space -= 4U * YSF_RADIO_SYMBOL_LENGTH;
|
space -= 4U * YSF_RADIO_SYMBOL_LENGTH;
|
||||||
|
if (m_duplex)
|
||||||
|
m_txCount = m_txHang;
|
||||||
|
|
||||||
if (m_poPtr >= m_poLen) {
|
if (m_poPtr >= m_poLen) {
|
||||||
m_poPtr = 0U;
|
m_poPtr = 0U;
|
||||||
m_poLen = 0U;
|
m_poLen = 0U;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (m_txCount > 0U) {
|
||||||
|
// Transmit silence until the hang timer has expired.
|
||||||
|
uint16_t space = io.getSpace();
|
||||||
|
|
||||||
|
while (space > (4U * YSF_RADIO_SYMBOL_LENGTH)) {
|
||||||
|
writeSilence();
|
||||||
|
|
||||||
|
space -= 4U * YSF_RADIO_SYMBOL_LENGTH;
|
||||||
|
m_txCount--;
|
||||||
|
|
||||||
|
if (m_txCount == 0U)
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,6 +169,16 @@ void CYSFTX::writeByte(uint8_t c)
|
||||||
io.write(STATE_YSF, outBuffer, YSF_RADIO_SYMBOL_LENGTH * 4U);
|
io.write(STATE_YSF, outBuffer, YSF_RADIO_SYMBOL_LENGTH * 4U);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CYSFTX::writeSilence()
|
||||||
|
{
|
||||||
|
q15_t inBuffer[4U] = {0x00U, 0x00U, 0x00U, 0x00U};
|
||||||
|
q15_t outBuffer[YSF_RADIO_SYMBOL_LENGTH * 4U];
|
||||||
|
|
||||||
|
::arm_fir_interpolate_q15(&m_modFilter, inBuffer, outBuffer, 4U);
|
||||||
|
|
||||||
|
io.write(STATE_YSF, outBuffer, YSF_RADIO_SYMBOL_LENGTH * 4U);
|
||||||
|
}
|
||||||
|
|
||||||
void CYSFTX::setTXDelay(uint8_t delay)
|
void CYSFTX::setTXDelay(uint8_t delay)
|
||||||
{
|
{
|
||||||
m_txDelay = 600U + uint16_t(delay) * 12U; // 500ms + tx delay
|
m_txDelay = 600U + uint16_t(delay) * 12U; // 500ms + tx delay
|
||||||
|
@ -160,8 +192,9 @@ uint8_t CYSFTX::getSpace() const
|
||||||
return m_buffer.getSpace() / YSF_FRAME_LENGTH_BYTES;
|
return m_buffer.getSpace() / YSF_FRAME_LENGTH_BYTES;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CYSFTX::setLoDev(bool on)
|
void CYSFTX::setParams(bool on, uint8_t txHang)
|
||||||
{
|
{
|
||||||
m_loDev = on;
|
m_loDev = on;
|
||||||
|
m_txHang = txHang * 1200U;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
5
YSFTX.h
5
YSFTX.h
|
@ -35,7 +35,7 @@ public:
|
||||||
|
|
||||||
uint8_t getSpace() const;
|
uint8_t getSpace() const;
|
||||||
|
|
||||||
void setLoDev(bool on);
|
void setParams(bool on, uint8_t txHang);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CSerialRB m_buffer;
|
CSerialRB m_buffer;
|
||||||
|
@ -46,8 +46,11 @@ private:
|
||||||
uint16_t m_poPtr;
|
uint16_t m_poPtr;
|
||||||
uint16_t m_txDelay;
|
uint16_t m_txDelay;
|
||||||
bool m_loDev;
|
bool m_loDev;
|
||||||
|
uint32_t m_txHang;
|
||||||
|
uint32_t m_txCount;
|
||||||
|
|
||||||
void writeByte(uint8_t c);
|
void writeByte(uint8_t c);
|
||||||
|
void writeSilence();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue