mirror of
https://github.com/g4klx/MMDVM.git
synced 2026-10-15 16:24:11 +02:00
Compare commits
174
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5ef05cb6c0 | ||
|
|
4ed53348b0 | ||
|
|
893d48256b | ||
|
|
9f2ece50d9 | ||
|
|
a4166efa84 | ||
|
|
3a807535fa | ||
|
|
088d6b857c | ||
|
|
1fb7b53b9b | ||
|
|
8b0c87a1aa | ||
|
|
4c7eab5720 | ||
|
|
e9c1ced5d9 | ||
|
|
1ffee17475 | ||
|
|
1214fb0590 | ||
|
|
69f2d82082 | ||
|
|
5f7efa8bcb | ||
|
|
c06a32af07 | ||
|
|
1d8f82a47c | ||
|
|
b40701a8e6 | ||
|
|
4add1453a4 | ||
|
|
2f05727b25 | ||
|
|
608a10d159 | ||
|
|
eb51c9dd17 | ||
|
|
7519429c43 | ||
|
|
7ef6708d9d | ||
|
|
7bfe400c8a | ||
|
|
a0706c9fd4 | ||
|
|
b0e2867663 | ||
|
|
63165a0f9f | ||
|
|
cb25a64a4b | ||
|
|
21cd848064 | ||
|
|
e0f2206825 | ||
|
|
2099096acb | ||
|
|
a69d1adaf0 | ||
|
|
59cbc6846d | ||
|
|
51b0be7e2e | ||
|
|
2eff3090a9 | ||
|
|
748d5823ef | ||
|
|
d30d768bdc | ||
|
|
ce51b8daa8 | ||
|
|
fcd4357bd9 | ||
|
|
7107625b12 | ||
|
|
aa70be0973 | ||
|
|
fe5e9bf4ea | ||
|
|
554094540d | ||
|
|
cadbfaa546 | ||
|
|
1d7b351511 | ||
|
|
ddaac983a4 | ||
|
|
bd413d2e05 | ||
|
|
06b5a08b6d | ||
|
|
4b3736a189 | ||
|
|
7ab774d941 | ||
|
|
700190db9a | ||
|
|
fd5822df19 | ||
|
|
1a1f721b3f | ||
|
|
d31b71fab1 | ||
|
|
508c3000fa | ||
|
|
bed9665b3a | ||
|
|
ae5328142e | ||
|
|
fcd1012ff4 | ||
|
|
056016c022 | ||
|
|
8ad8a18c0e | ||
|
|
f2e9f2d753 | ||
|
|
a582cbe1e3 | ||
|
|
355f7d0152 | ||
|
|
7454a08e4a | ||
|
|
96dc2282a8 | ||
|
|
8a646f36d4 | ||
|
|
00891dfa2f | ||
|
|
0fc3e8182d | ||
|
|
95c1cf1f6c | ||
|
|
335fba3930 | ||
|
|
0bfc59b2d7 | ||
|
|
8409d7e425 | ||
|
|
374fae594c | ||
|
|
387221665f | ||
|
|
3bef5acb6e | ||
|
|
24ac2b902d | ||
|
|
605f079075 | ||
|
|
dbd84d7803 | ||
|
|
8da0ea7740 | ||
|
|
6098ac3e6d | ||
|
|
c1f12705a9 | ||
|
|
46035fa212 | ||
|
|
373e1893bc | ||
|
|
aa52b03bc2 | ||
|
|
6192a88b98 | ||
|
|
017df518a6 | ||
|
|
cf849ccf65 | ||
|
|
8651e3a77b | ||
|
|
83dd360062 | ||
|
|
d298a5bde5 | ||
|
|
925263a216 | ||
|
|
551aa3bb20 | ||
|
|
c62a686d30 | ||
|
|
cb78220156 | ||
|
|
cb00f4aba7 | ||
|
|
750ac02b7e | ||
|
|
22297c613c | ||
|
|
91a87f4581 | ||
|
|
4ccc004de3 | ||
|
|
bf1de4f307 | ||
|
|
24741a11c6 | ||
|
|
293a5b6912 | ||
|
|
442627dc35 | ||
|
|
5f8a323dde | ||
|
|
11809a6baf | ||
|
|
7e8d018242 | ||
|
|
436ca1d851 | ||
|
|
1162354c43 | ||
|
|
3b84cf85c3 | ||
|
|
ec34eb4a64 | ||
|
|
9a5f932e6a | ||
|
|
ef8f5bb80b | ||
|
|
b76e95b540 | ||
|
|
0231ce38d5 | ||
|
|
037810b23b | ||
|
|
b017e75787 | ||
|
|
8ff924e376 | ||
|
|
f7de632cd5 | ||
|
|
6221386873 | ||
|
|
cc3c676082 | ||
|
|
a554a86202 | ||
|
|
3c1b41c03f | ||
|
|
4eda2b61f5 | ||
|
|
f06bd5125b | ||
|
|
84df334f52 | ||
|
|
b88a3d02bf | ||
|
|
a0afe0e54f | ||
|
|
7e85a64a41 | ||
|
|
c820b22524 | ||
|
|
7fae32042f | ||
|
|
edbf2b3ec0 | ||
|
|
ac31999d9d | ||
|
|
2833ed2d2e | ||
|
|
ebd86df3ef | ||
|
|
918403c399 | ||
|
|
7c243af5da | ||
|
|
2b502848c1 | ||
|
|
d91a155084 | ||
|
|
7bb042a6ca | ||
|
|
14ce682210 | ||
|
|
dc9d83f9f0 | ||
|
|
fbd9c4d18b | ||
|
|
76312c7bb9 | ||
|
|
2a5690fd4d | ||
|
|
58966406da | ||
|
|
161736925e | ||
|
|
9398d03e0b | ||
|
|
e707391a5e | ||
|
|
cff5a58bc7 | ||
|
|
51577efd79 | ||
|
|
064de9fef7 | ||
|
|
c43616f3c5 | ||
|
|
e6adc0a296 | ||
|
|
13f340917e | ||
|
|
f195fd6f66 | ||
|
|
469be87dc3 | ||
|
|
7f8a0a71f5 | ||
|
|
16a43db79a | ||
|
|
a033b2db7b | ||
|
|
88ab312da0 | ||
|
|
8ce38eec9a | ||
|
|
49383ca921 | ||
|
|
ed07175437 | ||
|
|
c8208ab1df | ||
|
|
68f0fa8132 | ||
|
|
954131f73c | ||
|
|
06ec4b79a5 | ||
|
|
90797696dd | ||
|
|
de0aed2d2b | ||
|
|
4b253f888d | ||
|
|
c22f360ed1 | ||
|
|
5d74c2f7bf | ||
|
|
316085f2a6 |
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2020 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
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#if !defined(AX25DEFINES_H)
|
||||
#define AX25DEFINES_H
|
||||
|
||||
const uint8_t AX25_RADIO_SYMBOL_LENGTH = 20U; // At 24 kHz sample rate
|
||||
|
||||
const uint8_t AX25_FRAME_START = 0x7EU;
|
||||
const uint8_t AX25_FRAME_END = 0x7EU;
|
||||
const uint8_t AX25_FRAME_ABORT = 0xFEU;
|
||||
|
||||
const uint8_t AX25_MAX_ONES = 5U;
|
||||
|
||||
const uint16_t AX25_MIN_FRAME_LENGTH = 17U; // Callsign (7) + Callsign (7) + Control (1) + Checksum (2)
|
||||
|
||||
const uint16_t AX25_MAX_FRAME_LENGTH = 330U; // Callsign (7) + Callsign (7) + 8 Digipeaters (56) +
|
||||
// Control (1) + PID (1) + Data (256) + Checksum (2)
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,319 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2020 by Jonathan Naylor G4KLX
|
||||
* Copyright 2015-2019 Mobilinkd LLC <[email protected]>
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#if defined(MODE_AX25)
|
||||
|
||||
#include "Globals.h"
|
||||
#include "AX25Demodulator.h"
|
||||
#include "AX25Defines.h"
|
||||
|
||||
const float32_t SAMPLE_RATE = 24000.0F;
|
||||
const float32_t SYMBOL_RATE = 1200.0F;
|
||||
|
||||
const uint16_t DELAY_LEN = 11U;
|
||||
|
||||
const float32_t SAMPLES_PER_SYMBOL = SAMPLE_RATE / SYMBOL_RATE;
|
||||
const float32_t PLL_LIMIT = SAMPLES_PER_SYMBOL / 2.0F;
|
||||
|
||||
const uint32_t LPF_FILTER_LEN = 48U;
|
||||
|
||||
q15_t LPF_FILTER_COEFFS[] = {
|
||||
-2, -8, -17, -28, -40, -47, -47, -34,
|
||||
-5, 46, 122, 224, 354, 510, 689, 885,
|
||||
1092, 1302, 1506, 1693, 1856, 1987, 2077, 2124,
|
||||
2124, 2077, 1987, 1856, 1693, 1506, 1302, 1092,
|
||||
885, 689, 510, 354, 224, 122, 46, -5,
|
||||
-34, -47, -47, -40, -28, -17, -8, -2
|
||||
};
|
||||
|
||||
// Lock low-pass filter taps (80Hz Bessel)
|
||||
// scipy.signal:
|
||||
// b, a = bessel(4, [80.0/(1200/2)], 'lowpass')
|
||||
//
|
||||
const uint8_t PLL_IIR_SIZE = 5U;
|
||||
|
||||
const float32_t PLL_LOCK_B[] = {
|
||||
1.077063e-03,4.308253e-03,6.462379e-03,4.308253e-03,1.077063e-03};
|
||||
|
||||
const float32_t PLL_LOCK_A[] = {
|
||||
1.000000e+00,-2.774567e+00,2.962960e+00,-1.437990e+00,2.668296e-01};
|
||||
|
||||
// 64 Hz loop filter.
|
||||
// scipy.signal:
|
||||
// loop_coeffs = firwin(9, [64.0/(1200/2)], width = None,
|
||||
// pass_zero = True, scale = True, window='hann')
|
||||
//
|
||||
const uint32_t PLL_FILTER_LEN = 7U;
|
||||
|
||||
float32_t PLL_FILTER_COEFFS[] = {3.196252e-02F, 1.204223e-01F, 2.176819e-01F, 2.598666e-01F, 2.176819e-01F, 1.204223e-01F, 3.196252e-02F};
|
||||
|
||||
CAX25Demodulator::CAX25Demodulator(int8_t n) :
|
||||
m_frame(),
|
||||
m_twist(n),
|
||||
m_lpfFilter(),
|
||||
m_lpfState(),
|
||||
m_delayLine(NULL),
|
||||
m_delayPos(0U),
|
||||
m_nrziState(false),
|
||||
m_pllFilter(),
|
||||
m_pllState(),
|
||||
m_pllLast(false),
|
||||
m_pllBits(1U),
|
||||
m_pllCount(0.0F),
|
||||
m_pllJitter(0.0F),
|
||||
m_pllDCD(false),
|
||||
m_iirHistory(),
|
||||
m_hdlcOnes(0U),
|
||||
m_hdlcFlag(false),
|
||||
m_hdlcBuffer(0U),
|
||||
m_hdlcBits(0U),
|
||||
m_hdlcState(AX25_IDLE)
|
||||
{
|
||||
m_delayLine = new bool[DELAY_LEN];
|
||||
|
||||
m_lpfFilter.numTaps = LPF_FILTER_LEN;
|
||||
m_lpfFilter.pState = m_lpfState;
|
||||
m_lpfFilter.pCoeffs = LPF_FILTER_COEFFS;
|
||||
|
||||
m_pllFilter.numTaps = PLL_FILTER_LEN;
|
||||
m_pllFilter.pState = m_pllState;
|
||||
m_pllFilter.pCoeffs = PLL_FILTER_COEFFS;
|
||||
|
||||
for (uint8_t i = 0U; i < PLL_IIR_SIZE; i++)
|
||||
m_iirHistory[i] = 0.0F;
|
||||
}
|
||||
|
||||
bool CAX25Demodulator::process(q15_t* samples, uint8_t length, CAX25Frame& frame)
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
q15_t fa[RX_BLOCK_SIZE];
|
||||
m_twist.process(samples, fa, RX_BLOCK_SIZE);
|
||||
|
||||
int16_t buffer[RX_BLOCK_SIZE];
|
||||
for (uint8_t i = 0; i < length; i++) {
|
||||
bool level = (fa[i] >= 0);
|
||||
bool delayed = delay(level);
|
||||
buffer[i] = (int16_t(level ^ delayed) << 1) - 1;
|
||||
}
|
||||
|
||||
q15_t fc[RX_BLOCK_SIZE];
|
||||
::arm_fir_fast_q15(&m_lpfFilter, buffer, fc, RX_BLOCK_SIZE);
|
||||
|
||||
for (uint8_t i = 0; i < length; i++) {
|
||||
bool bit = fc[i] >= 0;
|
||||
bool sample = PLL(bit);
|
||||
|
||||
if (sample) {
|
||||
// We will only ever get one frame because there are
|
||||
// not enough bits in a block for more than one.
|
||||
if (result) {
|
||||
HDLC(NRZI(bit));
|
||||
} else {
|
||||
result = HDLC(NRZI(bit));
|
||||
if (result) {
|
||||
// Copy the frame data.
|
||||
::memcpy(frame.m_data, m_frame.m_data, AX25_MAX_PACKET_LEN);
|
||||
frame.m_length = m_frame.m_length;
|
||||
frame.m_fcs = m_frame.m_fcs;
|
||||
m_frame.m_length = 0U;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
bool CAX25Demodulator::delay(bool b)
|
||||
{
|
||||
bool r = m_delayLine[m_delayPos];
|
||||
|
||||
m_delayLine[m_delayPos++] = b;
|
||||
|
||||
if (m_delayPos >= DELAY_LEN)
|
||||
m_delayPos = 0U;
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
bool CAX25Demodulator::NRZI(bool b)
|
||||
{
|
||||
bool result = (b == m_nrziState);
|
||||
|
||||
m_nrziState = b;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
bool CAX25Demodulator::PLL(bool input)
|
||||
{
|
||||
bool sample = false;
|
||||
|
||||
if (input != m_pllLast || m_pllBits > 16U) {
|
||||
// Record transition.
|
||||
m_pllLast = input;
|
||||
|
||||
if (m_pllCount > PLL_LIMIT)
|
||||
m_pllCount -= SAMPLES_PER_SYMBOL;
|
||||
|
||||
float32_t adjust = m_pllBits > 16U ? 5.0F : 0.0F;
|
||||
float32_t offset = m_pllCount / float32_t(m_pllBits);
|
||||
float32_t jitter;
|
||||
::arm_fir_f32(&m_pllFilter, &offset, &jitter, 1U);
|
||||
|
||||
float32_t absOffset = adjust;
|
||||
if (offset < 0.0F)
|
||||
absOffset -= offset;
|
||||
else
|
||||
absOffset += offset;
|
||||
m_pllJitter = iir(absOffset);
|
||||
|
||||
m_pllCount -= jitter / 2.0F;
|
||||
m_pllBits = 1U;
|
||||
} else {
|
||||
if (m_pllCount > PLL_LIMIT) {
|
||||
sample = true;
|
||||
m_pllCount -= SAMPLES_PER_SYMBOL;
|
||||
m_pllBits++;
|
||||
}
|
||||
}
|
||||
|
||||
m_pllCount += 1.0F;
|
||||
|
||||
return sample;
|
||||
}
|
||||
|
||||
bool CAX25Demodulator::HDLC(bool b)
|
||||
{
|
||||
if (m_hdlcOnes == AX25_MAX_ONES) {
|
||||
if (b) {
|
||||
// flag byte
|
||||
m_hdlcFlag = true;
|
||||
} else {
|
||||
// bit stuffing...
|
||||
m_hdlcFlag = false;
|
||||
m_hdlcOnes = 0U;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
m_hdlcBuffer >>= 1;
|
||||
m_hdlcBuffer |= b ? 128U : 0U;
|
||||
m_hdlcBits++; // Free-running until Sync byte.
|
||||
|
||||
if (b)
|
||||
m_hdlcOnes++;
|
||||
else
|
||||
m_hdlcOnes = 0U;
|
||||
|
||||
if (m_hdlcFlag) {
|
||||
bool result = false;
|
||||
|
||||
switch (m_hdlcBuffer) {
|
||||
case AX25_FRAME_END:
|
||||
if (m_frame.m_length >= AX25_MIN_FRAME_LENGTH) {
|
||||
result = m_frame.checkCRC();
|
||||
if (!result)
|
||||
m_frame.m_length = 0U;
|
||||
} else {
|
||||
m_frame.m_length = 0U;
|
||||
}
|
||||
m_hdlcState = AX25_SYNC;
|
||||
m_hdlcFlag = false;
|
||||
m_hdlcBits = 0U;
|
||||
break;
|
||||
|
||||
case AX25_FRAME_ABORT:
|
||||
// Frame aborted
|
||||
m_frame.m_length = 0U;
|
||||
m_hdlcState = AX25_IDLE;
|
||||
m_hdlcFlag = false;
|
||||
m_hdlcBits = 0U;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
switch (m_hdlcState) {
|
||||
case AX25_IDLE:
|
||||
break;
|
||||
|
||||
case AX25_SYNC:
|
||||
if (m_hdlcBits == 8U) { // 8th bit.
|
||||
// Start of frame data.
|
||||
m_hdlcState = AX25_RECEIVE;
|
||||
m_frame.append(m_hdlcBuffer);
|
||||
m_hdlcBits = 0U;
|
||||
}
|
||||
break;
|
||||
|
||||
case AX25_RECEIVE:
|
||||
if (m_hdlcBits == 8U) { // 8th bit.
|
||||
m_frame.append(m_hdlcBuffer);
|
||||
m_hdlcBits = 0U;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void CAX25Demodulator::setTwist(int8_t n)
|
||||
{
|
||||
m_twist.setTwist(n);
|
||||
}
|
||||
|
||||
bool CAX25Demodulator::isDCD()
|
||||
{
|
||||
if (m_pllJitter <= (SAMPLES_PER_SYMBOL * 0.03F))
|
||||
m_pllDCD = true;
|
||||
else if (m_pllJitter >= (SAMPLES_PER_SYMBOL * 0.15F))
|
||||
m_pllDCD = false;
|
||||
|
||||
return m_pllDCD;
|
||||
}
|
||||
|
||||
float32_t CAX25Demodulator::iir(float32_t input)
|
||||
{
|
||||
for (int8_t i = int8_t(PLL_IIR_SIZE) - 1; i != 0; i--)
|
||||
m_iirHistory[i] = m_iirHistory[i - 1];
|
||||
|
||||
m_iirHistory[0] = input;
|
||||
for (uint8_t i = 1U; i < PLL_IIR_SIZE; i++)
|
||||
m_iirHistory[0] -= PLL_LOCK_A[i] * m_iirHistory[i];
|
||||
|
||||
float32_t result = 0.0F;
|
||||
for (uint8_t i = 0U; i < PLL_IIR_SIZE; i++)
|
||||
result += PLL_LOCK_B[i] * m_iirHistory[i];
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,77 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2020 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
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#if defined(MODE_AX25)
|
||||
|
||||
#if !defined(AX25Demodulator_H)
|
||||
#define AX25Demodulator_H
|
||||
|
||||
#include "AX25Frame.h"
|
||||
#include "AX25Twist.h"
|
||||
|
||||
enum AX25_STATE {
|
||||
AX25_IDLE,
|
||||
AX25_SYNC,
|
||||
AX25_RECEIVE
|
||||
};
|
||||
|
||||
class CAX25Demodulator {
|
||||
public:
|
||||
CAX25Demodulator(int8_t n);
|
||||
|
||||
bool process(q15_t* samples, uint8_t length, CAX25Frame& frame);
|
||||
|
||||
void setTwist(int8_t n);
|
||||
|
||||
bool isDCD();
|
||||
|
||||
private:
|
||||
CAX25Frame m_frame;
|
||||
CAX25Twist m_twist;
|
||||
arm_fir_instance_q15 m_lpfFilter;
|
||||
q15_t m_lpfState[70U]; // NoTaps + BlockSize - 1, 48 + 20 - 1 plus some spare
|
||||
bool* m_delayLine;
|
||||
uint16_t m_delayPos;
|
||||
bool m_nrziState;
|
||||
arm_fir_instance_f32 m_pllFilter;
|
||||
float32_t m_pllState[20U]; // NoTaps + BlockSize - 1, 7 + 1 - 1 plus some spare
|
||||
bool m_pllLast;
|
||||
uint8_t m_pllBits;
|
||||
float32_t m_pllCount;
|
||||
float32_t m_pllJitter;
|
||||
bool m_pllDCD;
|
||||
float32_t m_iirHistory[5U];
|
||||
uint16_t m_hdlcOnes;
|
||||
bool m_hdlcFlag;
|
||||
uint16_t m_hdlcBuffer;
|
||||
uint16_t m_hdlcBits;
|
||||
AX25_STATE m_hdlcState;
|
||||
|
||||
bool delay(bool b);
|
||||
bool NRZI(bool b);
|
||||
bool PLL(bool b);
|
||||
bool HDLC(bool b);
|
||||
float32_t iir(float32_t input);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
-127
@@ -1,127 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2020 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
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#if defined(MODE_AX25)
|
||||
|
||||
#include "Globals.h"
|
||||
#include "AX25Frame.h"
|
||||
|
||||
const uint16_t CCITT_TABLE[] = {
|
||||
0x0000,0x1189,0x2312,0x329b,0x4624,0x57ad,0x6536,0x74bf,
|
||||
0x8c48,0x9dc1,0xaf5a,0xbed3,0xca6c,0xdbe5,0xe97e,0xf8f7,
|
||||
0x1081,0x0108,0x3393,0x221a,0x56a5,0x472c,0x75b7,0x643e,
|
||||
0x9cc9,0x8d40,0xbfdb,0xae52,0xdaed,0xcb64,0xf9ff,0xe876,
|
||||
0x2102,0x308b,0x0210,0x1399,0x6726,0x76af,0x4434,0x55bd,
|
||||
0xad4a,0xbcc3,0x8e58,0x9fd1,0xeb6e,0xfae7,0xc87c,0xd9f5,
|
||||
0x3183,0x200a,0x1291,0x0318,0x77a7,0x662e,0x54b5,0x453c,
|
||||
0xbdcb,0xac42,0x9ed9,0x8f50,0xfbef,0xea66,0xd8fd,0xc974,
|
||||
0x4204,0x538d,0x6116,0x709f,0x0420,0x15a9,0x2732,0x36bb,
|
||||
0xce4c,0xdfc5,0xed5e,0xfcd7,0x8868,0x99e1,0xab7a,0xbaf3,
|
||||
0x5285,0x430c,0x7197,0x601e,0x14a1,0x0528,0x37b3,0x263a,
|
||||
0xdecd,0xcf44,0xfddf,0xec56,0x98e9,0x8960,0xbbfb,0xaa72,
|
||||
0x6306,0x728f,0x4014,0x519d,0x2522,0x34ab,0x0630,0x17b9,
|
||||
0xef4e,0xfec7,0xcc5c,0xddd5,0xa96a,0xb8e3,0x8a78,0x9bf1,
|
||||
0x7387,0x620e,0x5095,0x411c,0x35a3,0x242a,0x16b1,0x0738,
|
||||
0xffcf,0xee46,0xdcdd,0xcd54,0xb9eb,0xa862,0x9af9,0x8b70,
|
||||
0x8408,0x9581,0xa71a,0xb693,0xc22c,0xd3a5,0xe13e,0xf0b7,
|
||||
0x0840,0x19c9,0x2b52,0x3adb,0x4e64,0x5fed,0x6d76,0x7cff,
|
||||
0x9489,0x8500,0xb79b,0xa612,0xd2ad,0xc324,0xf1bf,0xe036,
|
||||
0x18c1,0x0948,0x3bd3,0x2a5a,0x5ee5,0x4f6c,0x7df7,0x6c7e,
|
||||
0xa50a,0xb483,0x8618,0x9791,0xe32e,0xf2a7,0xc03c,0xd1b5,
|
||||
0x2942,0x38cb,0x0a50,0x1bd9,0x6f66,0x7eef,0x4c74,0x5dfd,
|
||||
0xb58b,0xa402,0x9699,0x8710,0xf3af,0xe226,0xd0bd,0xc134,
|
||||
0x39c3,0x284a,0x1ad1,0x0b58,0x7fe7,0x6e6e,0x5cf5,0x4d7c,
|
||||
0xc60c,0xd785,0xe51e,0xf497,0x8028,0x91a1,0xa33a,0xb2b3,
|
||||
0x4a44,0x5bcd,0x6956,0x78df,0x0c60,0x1de9,0x2f72,0x3efb,
|
||||
0xd68d,0xc704,0xf59f,0xe416,0x90a9,0x8120,0xb3bb,0xa232,
|
||||
0x5ac5,0x4b4c,0x79d7,0x685e,0x1ce1,0x0d68,0x3ff3,0x2e7a,
|
||||
0xe70e,0xf687,0xc41c,0xd595,0xa12a,0xb0a3,0x8238,0x93b1,
|
||||
0x6b46,0x7acf,0x4854,0x59dd,0x2d62,0x3ceb,0x0e70,0x1ff9,
|
||||
0xf78f,0xe606,0xd49d,0xc514,0xb1ab,0xa022,0x92b9,0x8330,
|
||||
0x7bc7,0x6a4e,0x58d5,0x495c,0x3de3,0x2c6a,0x1ef1,0x0f78 };
|
||||
|
||||
CAX25Frame::CAX25Frame(const uint8_t* data, uint16_t length) :
|
||||
m_data(),
|
||||
m_length(0U),
|
||||
m_fcs(0U)
|
||||
{
|
||||
for (uint16_t i = 0U; i < length && i < (AX25_MAX_PACKET_LEN - 2U); i++)
|
||||
m_data[m_length++] = data[i];
|
||||
}
|
||||
|
||||
CAX25Frame::CAX25Frame() :
|
||||
m_data(),
|
||||
m_length(0U),
|
||||
m_fcs(0U)
|
||||
{
|
||||
}
|
||||
|
||||
bool CAX25Frame::append(uint16_t c)
|
||||
{
|
||||
if (m_length == AX25_MAX_PACKET_LEN)
|
||||
return false;
|
||||
|
||||
m_data[m_length++] = uint8_t(c);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CAX25Frame::checkCRC()
|
||||
{
|
||||
union {
|
||||
uint16_t crc16;
|
||||
uint8_t crc8[2U];
|
||||
};
|
||||
|
||||
crc16 = 0xFFFFU;
|
||||
for (uint16_t i = 0U; i < (m_length - 2U); i++)
|
||||
crc16 = uint16_t(crc8[1U]) ^ CCITT_TABLE[crc8[0U] ^ m_data[i]];
|
||||
|
||||
crc16 = ~crc16;
|
||||
|
||||
if (crc8[0U] == m_data[m_length - 2U] && crc8[1U] == m_data[m_length - 1U]) {
|
||||
m_fcs = crc16;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void CAX25Frame::addCRC()
|
||||
{
|
||||
union {
|
||||
uint16_t crc16;
|
||||
uint8_t crc8[2U];
|
||||
};
|
||||
|
||||
crc16 = 0xFFFFU;
|
||||
for (uint16_t i = 0U; i < m_length; i++)
|
||||
crc16 = uint16_t(crc8[1U]) ^ CCITT_TABLE[crc8[0U] ^ m_data[i]];
|
||||
|
||||
crc16 = ~crc16;
|
||||
|
||||
m_fcs = crc16;
|
||||
|
||||
m_data[m_length++] = crc8[0U];
|
||||
m_data[m_length++] = crc8[1U];
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
-47
@@ -1,47 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2020 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
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#if defined(MODE_AX25)
|
||||
|
||||
#if !defined(AX25Frame_H)
|
||||
#define AX25Frame_H
|
||||
|
||||
const uint16_t AX25_MAX_PACKET_LEN = 300U;
|
||||
|
||||
class CAX25Frame {
|
||||
public:
|
||||
CAX25Frame(const uint8_t* data, uint16_t length);
|
||||
CAX25Frame();
|
||||
|
||||
bool append(uint16_t c);
|
||||
|
||||
bool checkCRC();
|
||||
|
||||
void addCRC();
|
||||
|
||||
uint8_t m_data[AX25_MAX_PACKET_LEN];
|
||||
uint16_t m_length;
|
||||
uint16_t m_fcs;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
-211
@@ -1,211 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2020 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
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#if defined(MODE_AX25)
|
||||
|
||||
#include "Globals.h"
|
||||
#include "AX25RX.h"
|
||||
|
||||
/*
|
||||
* Generated with Scipy Filter, 152 coefficients, 1100-2300Hz bandpass,
|
||||
* Hann window, starting and ending 0 value coefficients removed.
|
||||
*
|
||||
* np.array(
|
||||
* firwin2(152,
|
||||
* [
|
||||
* 0.0,
|
||||
* 1000.0/(sample_rate/2),
|
||||
* 1100.0/(sample_rate/2),
|
||||
* 2350.0/(sample_rate/2),
|
||||
* 2500.0/(sample_rate/2),
|
||||
* 1.0
|
||||
* ],
|
||||
* [0,0,1,1,0,0],
|
||||
* antisymmetric = False,
|
||||
* window='hann') * 32768,
|
||||
* dtype=int)[10:-10]
|
||||
*/
|
||||
|
||||
const uint32_t FILTER_LEN = 130U;
|
||||
|
||||
q15_t FILTER_COEFFS[] = {
|
||||
5, 12, 18, 21, 19, 11, -2, -15, -25, -27,
|
||||
-21, -11, -3, -5, -19, -43, -69, -83, -73, -35,
|
||||
27, 98, 155, 180, 163, 109, 39, -20, -45, -26,
|
||||
23, 74, 89, 39, -81, -247, -407, -501, -480, -334,
|
||||
-92, 175, 388, 479, 429, 275, 99, 5, 68, 298,
|
||||
626, 913, 994, 740, 115, -791, -1770, -2544, -2847, -2509,
|
||||
-1527, -76, 1518, 2875, 3653, 3653, 2875, 1518, -76, -1527,
|
||||
-2509, -2847, -2544, -1770, -791, 115, 740, 994, 913, 626,
|
||||
298, 68, 5, 99, 275, 429, 479, 388, 175, -92,
|
||||
-334, -480, -501, -407, -247, -81, 39, 89, 74, 23,
|
||||
-26, -45, -20, 39, 109, 163, 180, 155, 98, 27,
|
||||
-35, -73, -83, -69, -43, -19, -5, -3, -11, -21,
|
||||
-27, -25, -15, -2, 11, 19, 21, 18, 12, 5
|
||||
};
|
||||
|
||||
CAX25RX::CAX25RX() :
|
||||
m_filter(),
|
||||
m_state(),
|
||||
m_demod1(3),
|
||||
m_demod2(6),
|
||||
m_demod3(9),
|
||||
m_lastFCS(0U),
|
||||
m_count(0U),
|
||||
m_slotTime(30U),
|
||||
m_slotCount(0U),
|
||||
m_pPersist(128U),
|
||||
m_dcd(false),
|
||||
m_canTX(false),
|
||||
m_x(1U),
|
||||
m_a(0xB7U),
|
||||
m_b(0x73U),
|
||||
m_c(0xF6U)
|
||||
{
|
||||
m_filter.numTaps = FILTER_LEN;
|
||||
m_filter.pState = m_state;
|
||||
m_filter.pCoeffs = FILTER_COEFFS;
|
||||
|
||||
initRand();
|
||||
}
|
||||
|
||||
void CAX25RX::samples(q15_t* samples, uint8_t length)
|
||||
{
|
||||
q15_t output[RX_BLOCK_SIZE];
|
||||
::arm_fir_fast_q15(&m_filter, samples, output, RX_BLOCK_SIZE);
|
||||
|
||||
m_count++;
|
||||
|
||||
CAX25Frame frame;
|
||||
|
||||
bool ret = m_demod1.process(output, length, frame);
|
||||
if (ret) {
|
||||
if (frame.m_fcs != m_lastFCS || m_count > 2U) {
|
||||
m_lastFCS = frame.m_fcs;
|
||||
m_count = 0U;
|
||||
serial.writeAX25Data(frame.m_data, frame.m_length - 2U);
|
||||
}
|
||||
DEBUG1("Decoder 1 reported");
|
||||
}
|
||||
|
||||
ret = m_demod2.process(output, length, frame);
|
||||
if (ret) {
|
||||
if (frame.m_fcs != m_lastFCS || m_count > 2U) {
|
||||
m_lastFCS = frame.m_fcs;
|
||||
m_count = 0U;
|
||||
serial.writeAX25Data(frame.m_data, frame.m_length - 2U);
|
||||
}
|
||||
DEBUG1("Decoder 2 reported");
|
||||
}
|
||||
|
||||
ret = m_demod3.process(output, length, frame);
|
||||
if (ret) {
|
||||
if (frame.m_fcs != m_lastFCS || m_count > 2U) {
|
||||
m_lastFCS = frame.m_fcs;
|
||||
m_count = 0U;
|
||||
serial.writeAX25Data(frame.m_data, frame.m_length - 2U);
|
||||
}
|
||||
DEBUG1("Decoder 3 reported");
|
||||
}
|
||||
|
||||
m_slotCount += RX_BLOCK_SIZE;
|
||||
if (m_slotCount >= m_slotTime) {
|
||||
m_slotCount = 0U;
|
||||
|
||||
bool dcd1 = m_demod1.isDCD();
|
||||
bool dcd2 = m_demod2.isDCD();
|
||||
bool dcd3 = m_demod3.isDCD();
|
||||
|
||||
if (dcd1 || dcd2 || dcd3) {
|
||||
if (!m_dcd) {
|
||||
io.setDecode(true);
|
||||
io.setADCDetection(true);
|
||||
m_dcd = true;
|
||||
}
|
||||
|
||||
m_canTX = false;
|
||||
} else {
|
||||
if (m_dcd) {
|
||||
io.setDecode(false);
|
||||
io.setADCDetection(false);
|
||||
m_dcd = false;
|
||||
}
|
||||
|
||||
m_canTX = m_pPersist >= rand();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool CAX25RX::canTX() const
|
||||
{
|
||||
return m_canTX;
|
||||
}
|
||||
|
||||
void CAX25RX::setParams(int8_t twist, uint8_t slotTime, uint8_t pPersist)
|
||||
{
|
||||
m_demod1.setTwist(twist - 3);
|
||||
m_demod2.setTwist(twist);
|
||||
m_demod3.setTwist(twist + 3);
|
||||
|
||||
m_slotTime = slotTime * 240U; // Slot time in samples
|
||||
m_pPersist = pPersist;
|
||||
}
|
||||
|
||||
// Taken from https://www.electro-tech-online.com/threads/ultra-fast-pseudorandom-number-generator-for-8-bit.124249/
|
||||
//X ABC Algorithm Random Number Generator for 8-Bit Devices:
|
||||
//This is a small PRNG, experimentally verified to have at least a 50 million byte period
|
||||
//by generating 50 million bytes and observing that there were no overapping sequences and repeats.
|
||||
//This generator passes serial correlation, entropy , Monte Carlo Pi value, arithmetic mean,
|
||||
//And many other statistical tests. This generator may have a period of up to 2^32, but this has
|
||||
//not been verified.
|
||||
//
|
||||
// By XORing 3 bytes into the a,b, and c registers, you can add in entropy from
|
||||
//an external source easily.
|
||||
//
|
||||
//This generator is free to use, but is not suitable for cryptography due to its short period(by //cryptographic standards) and simple construction. No attempt was made to make this generator
|
||||
// suitable for cryptographic use.
|
||||
//
|
||||
//Due to the use of a constant counter, the generator should be resistant to latching up.
|
||||
//A significant performance gain is had in that the x variable is only ever incremented.
|
||||
//
|
||||
//Only 4 bytes of ram are needed for the internal state, and generating a byte requires 3 XORs , //2 ADDs, one bit shift right , and one increment. Difficult or slow operations like multiply, etc
|
||||
//were avoided for maximum speed on ultra low power devices.
|
||||
|
||||
|
||||
void CAX25RX::initRand() //Can also be used to seed the rng with more entropy during use.
|
||||
{
|
||||
m_a = (m_a ^ m_c ^ m_x);
|
||||
m_b = (m_b + m_a);
|
||||
m_c = (m_c + (m_b >> 1) ^ m_a);
|
||||
}
|
||||
|
||||
uint8_t CAX25RX::rand()
|
||||
{
|
||||
m_x++; //x is incremented every round and is not affected by any other variable
|
||||
|
||||
m_a = (m_a ^ m_c ^ m_x); //note the mix of addition and XOR
|
||||
m_b = (m_b + m_a); //And the use of very few instructions
|
||||
m_c = (m_c + (m_b >> 1) ^ m_a); //the right shift is to ensure that high-order bits from b can affect
|
||||
|
||||
return uint8_t(m_c); //low order bits of other variables
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,63 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2020 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
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#if defined(MODE_AX25)
|
||||
|
||||
#if !defined(AX25RX_H)
|
||||
#define AX25RX_H
|
||||
|
||||
#include "AX25Demodulator.h"
|
||||
|
||||
class CAX25RX {
|
||||
public:
|
||||
CAX25RX();
|
||||
|
||||
void samples(q15_t* samples, uint8_t length);
|
||||
|
||||
void setParams(int8_t twist, uint8_t slotTime, uint8_t pPersist);
|
||||
|
||||
bool canTX() const;
|
||||
|
||||
private:
|
||||
arm_fir_instance_q15 m_filter;
|
||||
q15_t m_state[160U]; // NoTaps + BlockSize - 1, 130 + 20 - 1 plus some spare
|
||||
CAX25Demodulator m_demod1;
|
||||
CAX25Demodulator m_demod2;
|
||||
CAX25Demodulator m_demod3;
|
||||
uint16_t m_lastFCS;
|
||||
uint32_t m_count;
|
||||
uint32_t m_slotTime;
|
||||
uint32_t m_slotCount;
|
||||
uint8_t m_pPersist;
|
||||
bool m_dcd;
|
||||
bool m_canTX;
|
||||
uint8_t m_x;
|
||||
uint8_t m_a;
|
||||
uint8_t m_b;
|
||||
uint8_t m_c;
|
||||
|
||||
void initRand();
|
||||
uint8_t rand();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
-191
@@ -1,191 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2020 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
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#if defined(MODE_AX25)
|
||||
|
||||
#include "Globals.h"
|
||||
#include "AX25TX.h"
|
||||
|
||||
#include "AX25Defines.h"
|
||||
#include "AX25Frame.h"
|
||||
|
||||
|
||||
const uint8_t START_FLAG[] = { AX25_FRAME_START };
|
||||
const uint8_t END_FLAG[] = { AX25_FRAME_END };
|
||||
|
||||
const uint8_t BIT_MASK_TABLE1[] = { 0x80U, 0x40U, 0x20U, 0x10U, 0x08U, 0x04U, 0x02U, 0x01U };
|
||||
|
||||
#define WRITE_BIT1(p,i,b) p[(i)>>3] = (b) ? (p[(i)>>3] | BIT_MASK_TABLE1[(i)&7]) : (p[(i)>>3] & ~BIT_MASK_TABLE1[(i)&7])
|
||||
#define READ_BIT1(p,i) (p[(i)>>3] & BIT_MASK_TABLE1[(i)&7])
|
||||
|
||||
const uint8_t BIT_MASK_TABLE2[] = { 0x01U, 0x02U, 0x04U, 0x08U, 0x10U, 0x20U, 0x40U, 0x80U };
|
||||
|
||||
#define WRITE_BIT2(p,i,b) p[(i)>>3] = (b) ? (p[(i)>>3] | BIT_MASK_TABLE2[(i)&7]) : (p[(i)>>3] & ~BIT_MASK_TABLE2[(i)&7])
|
||||
#define READ_BIT2(p,i) (p[(i)>>3] & BIT_MASK_TABLE2[(i)&7])
|
||||
|
||||
const uint16_t AUDIO_TABLE_LEN = 120U;
|
||||
|
||||
const q15_t AUDIO_TABLE_DATA[] = {
|
||||
0, 214, 428, 641, 851, 1060, 1265, 1468, 1666, 1859, 2048, 2230, 2407, 2577, 2740, 2896, 3043, 3182, 3313, 3434, 3546, 3649,
|
||||
3741, 3823, 3895, 3955, 4006, 4045, 4073, 4089, 4095, 4089, 4073, 4045, 4006, 3955, 3895, 3823, 3741, 3649, 3546, 3434, 3313,
|
||||
3182, 3043, 2896, 2740, 2577, 2407, 2230, 2048, 1859, 1666, 1468, 1265, 1060, 851, 641, 428, 214, 0, -214, -428, -641, -851,
|
||||
-1060, -1265, -1468, -1666, -1859, -2047, -2230, -2407, -2577, -2740, -2896, -3043, -3182, -3313, -3434, -3546, -3649, -3741,
|
||||
-3823, -3895, -3955, -4006, -4045, -4073, -4089, -4095, -4089, -4073, -4045, -4006, -3955, -3895, -3823, -3741, -3649, -3546,
|
||||
-3434, -3313, -3182, -3043, -2896, -2740, -2577, -2407, -2230, -2047, -1859, -1666, -1468, -1265, -1060, -851, -641, -428, -214
|
||||
};
|
||||
|
||||
CAX25TX::CAX25TX() :
|
||||
m_poBuffer(),
|
||||
m_poLen(0U),
|
||||
m_poPtr(0U),
|
||||
m_txDelay(360U),
|
||||
m_tablePtr(0U),
|
||||
m_nrzi(false)
|
||||
{
|
||||
}
|
||||
|
||||
void CAX25TX::process()
|
||||
{
|
||||
if (m_poLen == 0U)
|
||||
return;
|
||||
|
||||
if (!m_duplex) {
|
||||
if (m_poPtr == 0U) {
|
||||
bool tx = ax25RX.canTX();
|
||||
if (!tx)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t space = io.getSpace();
|
||||
|
||||
while (space > AX25_RADIO_SYMBOL_LENGTH) {
|
||||
bool b = READ_BIT1(m_poBuffer, m_poPtr) != 0U;
|
||||
m_poPtr++;
|
||||
|
||||
writeBit(b);
|
||||
|
||||
space -= AX25_RADIO_SYMBOL_LENGTH;
|
||||
|
||||
if (m_poPtr >= m_poLen) {
|
||||
m_poPtr = 0U;
|
||||
m_poLen = 0U;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t CAX25TX::writeData(const uint8_t* data, uint16_t length)
|
||||
{
|
||||
CAX25Frame frame(data, length);
|
||||
frame.addCRC();
|
||||
|
||||
m_poLen = 0U;
|
||||
m_poPtr = 0U;
|
||||
m_nrzi = false;
|
||||
m_tablePtr = 0U;
|
||||
|
||||
// Add TX delay
|
||||
for (uint16_t i = 0U; i < m_txDelay; i++, m_poLen++) {
|
||||
bool preamble = NRZI(false);
|
||||
WRITE_BIT1(m_poBuffer, m_poLen, preamble);
|
||||
}
|
||||
|
||||
// Add the Start Flag
|
||||
for (uint16_t i = 0U; i < 8U; i++, m_poLen++) {
|
||||
bool b1 = READ_BIT1(START_FLAG, i) != 0U;
|
||||
bool b2 = NRZI(b1);
|
||||
WRITE_BIT1(m_poBuffer, m_poLen, b2);
|
||||
}
|
||||
|
||||
uint8_t ones = 0U;
|
||||
for (uint16_t i = 0U; i < (frame.m_length * 8U); i++) {
|
||||
bool b1 = READ_BIT2(frame.m_data, i) != 0U;
|
||||
bool b2 = NRZI(b1);
|
||||
WRITE_BIT1(m_poBuffer, m_poLen, b2);
|
||||
m_poLen++;
|
||||
|
||||
if (b1) {
|
||||
ones++;
|
||||
if (ones == AX25_MAX_ONES) {
|
||||
// Bit stuffing
|
||||
bool b = NRZI(false);
|
||||
WRITE_BIT1(m_poBuffer, m_poLen, b);
|
||||
m_poLen++;
|
||||
ones = 0U;
|
||||
}
|
||||
} else {
|
||||
ones = 0U;
|
||||
}
|
||||
}
|
||||
|
||||
// Add the End Flag
|
||||
for (uint16_t i = 0U; i < 8U; i++, m_poLen++) {
|
||||
bool b1 = READ_BIT1(END_FLAG, i) != 0U;
|
||||
bool b2 = NRZI(b1);
|
||||
WRITE_BIT1(m_poBuffer, m_poLen, b2);
|
||||
}
|
||||
|
||||
return 0U;
|
||||
}
|
||||
|
||||
void CAX25TX::writeBit(bool b)
|
||||
{
|
||||
q15_t buffer[AX25_RADIO_SYMBOL_LENGTH];
|
||||
for (uint8_t i = 0U; i < AX25_RADIO_SYMBOL_LENGTH; i++) {
|
||||
q15_t value = AUDIO_TABLE_DATA[m_tablePtr];
|
||||
|
||||
if (b) {
|
||||
// De-emphasise the lower frequency by 6dB
|
||||
value >>= 2;
|
||||
m_tablePtr += 6U;
|
||||
} else {
|
||||
m_tablePtr += 11U;
|
||||
}
|
||||
|
||||
buffer[i] = value;
|
||||
|
||||
if (m_tablePtr >= AUDIO_TABLE_LEN)
|
||||
m_tablePtr -= AUDIO_TABLE_LEN;
|
||||
}
|
||||
|
||||
io.write(STATE_AX25, buffer, AX25_RADIO_SYMBOL_LENGTH);
|
||||
}
|
||||
|
||||
void CAX25TX::setTXDelay(uint8_t delay)
|
||||
{
|
||||
m_txDelay = delay * 12U;
|
||||
}
|
||||
|
||||
uint8_t CAX25TX::getSpace() const
|
||||
{
|
||||
return m_poLen == 0U ? 255U : 0U;
|
||||
}
|
||||
|
||||
bool CAX25TX::NRZI(bool b)
|
||||
{
|
||||
if (!b)
|
||||
m_nrzi = !m_nrzi;
|
||||
|
||||
return m_nrzi;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2020 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
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#if defined(MODE_AX25)
|
||||
|
||||
#if !defined(AX25TX_H)
|
||||
#define AX25TX_H
|
||||
|
||||
class CAX25TX {
|
||||
public:
|
||||
CAX25TX();
|
||||
|
||||
uint8_t writeData(const uint8_t* data, uint16_t length);
|
||||
|
||||
void process();
|
||||
|
||||
void setTXDelay(uint8_t delay);
|
||||
|
||||
uint8_t getSpace() const;
|
||||
|
||||
private:
|
||||
uint8_t m_poBuffer[600U];
|
||||
uint16_t m_poLen;
|
||||
uint16_t m_poPtr;
|
||||
uint16_t m_txDelay;
|
||||
uint16_t m_tablePtr;
|
||||
bool m_nrzi;
|
||||
|
||||
void writeBit(bool b);
|
||||
bool NRZI(bool b);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
-316
@@ -1,316 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2020 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
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#if defined(MODE_AX25)
|
||||
|
||||
#include "Globals.h"
|
||||
#include "AX25Twist.h"
|
||||
|
||||
// 1200Hz = -12dB, 2200Hz = 0dB; 3381Hz cutoff; cosine.
|
||||
q15_t dB12[] = {
|
||||
176,
|
||||
-812,
|
||||
-3916,
|
||||
-7586,
|
||||
23536,
|
||||
-7586,
|
||||
-3916,
|
||||
-812,
|
||||
176
|
||||
};
|
||||
|
||||
// 1200Hz = -11dB, 2200Hz = 0dB; 3258Hz cutoff; cosine.
|
||||
q15_t dB11[] = {
|
||||
121,
|
||||
-957,
|
||||
-3959,
|
||||
-7383,
|
||||
23871,
|
||||
-7383,
|
||||
-3959,
|
||||
-957,
|
||||
121
|
||||
};
|
||||
|
||||
// 1200Hz = -10dB, 2200Hz = 0dB; 3118Hz cutoff; cosine.
|
||||
q15_t dB10[] = {
|
||||
56,
|
||||
-1110,
|
||||
-3987,
|
||||
-7141,
|
||||
24254,
|
||||
-7141,
|
||||
-3987,
|
||||
-1110,
|
||||
56
|
||||
};
|
||||
|
||||
// 1200Hz = -9dB, 2200Hz = 0dB; 2959Hz cutoff; cosine.
|
||||
q15_t dB9[] = {
|
||||
-19,
|
||||
-1268,
|
||||
-3994,
|
||||
-6856,
|
||||
24688,
|
||||
-6856,
|
||||
-3994,
|
||||
-1268,
|
||||
-19
|
||||
};
|
||||
|
||||
// 1200Hz = -8dB, 2200Hz = 0dB; 2778Hz cutoff; cosine.
|
||||
q15_t dB8[] = {
|
||||
-104,
|
||||
-1424,
|
||||
-3968,
|
||||
-6516,
|
||||
25182,
|
||||
-6516,
|
||||
-3968,
|
||||
-1424,
|
||||
-104
|
||||
};
|
||||
|
||||
// 1200Hz = -7dB, 2200Hz = 0dB; 2573Hz cutoff; cosine.
|
||||
q15_t dB7[] = {
|
||||
-196,
|
||||
-1565,
|
||||
-3896,
|
||||
-6114,
|
||||
25742,
|
||||
-6114,
|
||||
-3896,
|
||||
-1565,
|
||||
-196
|
||||
};
|
||||
|
||||
// 1200Hz = -6dB, 2200Hz = 0dB; 2343Hz cutoff; cosine.
|
||||
q15_t dB6[] = {
|
||||
-288,
|
||||
-1676,
|
||||
-3761,
|
||||
-5642,
|
||||
26370,
|
||||
-5642,
|
||||
-3761,
|
||||
-1676,
|
||||
-288
|
||||
};
|
||||
|
||||
// 1200Hz = -5dB, 2200Hz = 0dB; 2085Hz cutoff; cosine.
|
||||
q15_t dB5[] = {
|
||||
-370,
|
||||
-1735,
|
||||
-3545,
|
||||
-5088,
|
||||
27075,
|
||||
-5088,
|
||||
-3545,
|
||||
-1735,
|
||||
-370
|
||||
};
|
||||
|
||||
// 1200Hz = -4dB, 2200Hz = 0dB; 1790Hz cutoff; cosine.
|
||||
q15_t dB4[] = {
|
||||
-432,
|
||||
-1715,
|
||||
-3220,
|
||||
-4427,
|
||||
27880,
|
||||
-4427,
|
||||
-3220,
|
||||
-1715,
|
||||
-432
|
||||
};
|
||||
|
||||
// 1200Hz = -3dB, 2200Hz = 0dB; 1456Hz cutoff; cosine.
|
||||
q15_t dB3[] = {
|
||||
-452,
|
||||
-1582,
|
||||
-2759,
|
||||
-3646,
|
||||
28792,
|
||||
-3646,
|
||||
-2759,
|
||||
-1582,
|
||||
-452
|
||||
};
|
||||
|
||||
// 1200Hz = -2dB, 2200Hz = 0dB; 1070Hz cutoff; cosine.
|
||||
q15_t dB2[] = {
|
||||
-408,
|
||||
-1295,
|
||||
-2123,
|
||||
-2710,
|
||||
29846,
|
||||
-2710,
|
||||
-2123,
|
||||
-1295,
|
||||
-408
|
||||
};
|
||||
|
||||
// 1200Hz = -1dB, 2200Hz = 0dB; 605Hz cutoff; cosine.
|
||||
q15_t dB1[] = {
|
||||
-268,
|
||||
-795,
|
||||
-1244,
|
||||
-1546,
|
||||
31116,
|
||||
-1546,
|
||||
-1244,
|
||||
-795,
|
||||
-268
|
||||
};
|
||||
|
||||
q15_t dB0[] = {
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
32767,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
};
|
||||
|
||||
// 1200Hz = 0dB, 2200Hz = -1dB; 4130Hz cutoff; cosine.
|
||||
q15_t dB_1[] = {
|
||||
-419,
|
||||
-177,
|
||||
3316,
|
||||
8650,
|
||||
11278,
|
||||
8650,
|
||||
3316,
|
||||
-177,
|
||||
-419
|
||||
};
|
||||
|
||||
// 1200Hz = 0dB, 2200Hz = -2dB; 3190Hz cutoff; cosine.
|
||||
q15_t dB_2[] = {
|
||||
-90,
|
||||
1033,
|
||||
3975,
|
||||
7267,
|
||||
8711,
|
||||
7267,
|
||||
3975,
|
||||
1033,
|
||||
-90
|
||||
};
|
||||
|
||||
// 1200Hz = 0dB, 2200Hz = -3dB; 2330Hz cutoff; cosine.
|
||||
q15_t dB_3[] = {
|
||||
292,
|
||||
1680,
|
||||
3752,
|
||||
5615,
|
||||
6362,
|
||||
5615,
|
||||
3752,
|
||||
1680,
|
||||
292
|
||||
};
|
||||
|
||||
// 1200Hz = 0dB, 2200Hz = -4dB; 2657Hz cutoff; boxcar.
|
||||
q15_t dB_4[] = {
|
||||
917,
|
||||
3024,
|
||||
5131,
|
||||
6684,
|
||||
7255,
|
||||
6684,
|
||||
5131,
|
||||
3024,
|
||||
917
|
||||
};
|
||||
|
||||
// 1200Hz = 0dB, 2200Hz = -5dB; 2360Hz cutoff; boxcar.
|
||||
q15_t dB_5[] = {
|
||||
1620,
|
||||
3339,
|
||||
4925,
|
||||
6042,
|
||||
6444,
|
||||
6042,
|
||||
4925,
|
||||
3339,
|
||||
1620
|
||||
};
|
||||
|
||||
// 1200Hz = 0dB, 2200Hz = -6dB; 2067Hz cutoff; boxcar.
|
||||
q15_t dB_6[] = {
|
||||
2161,
|
||||
3472,
|
||||
4605,
|
||||
5373,
|
||||
5644,
|
||||
5373,
|
||||
4605,
|
||||
3472,
|
||||
2161
|
||||
};
|
||||
|
||||
q15_t* coeffs[] = {
|
||||
dB12,
|
||||
dB11,
|
||||
dB10,
|
||||
dB9,
|
||||
dB8,
|
||||
dB7,
|
||||
dB6,
|
||||
dB5,
|
||||
dB4,
|
||||
dB3,
|
||||
dB2,
|
||||
dB1,
|
||||
dB0,
|
||||
dB_1,
|
||||
dB_2,
|
||||
dB_3,
|
||||
dB_4,
|
||||
dB_5,
|
||||
dB_6
|
||||
};
|
||||
|
||||
CAX25Twist::CAX25Twist(int8_t n) :
|
||||
m_filter(),
|
||||
m_state()
|
||||
{
|
||||
setTwist(n);
|
||||
}
|
||||
|
||||
void CAX25Twist::process(q15_t* in, q15_t* out, uint8_t length)
|
||||
{
|
||||
::arm_fir_fast_q15(&m_filter, in, out, length);
|
||||
}
|
||||
|
||||
void CAX25Twist::setTwist(int8_t n)
|
||||
{
|
||||
uint8_t twist = uint8_t(n + 6);
|
||||
|
||||
m_filter.numTaps = 9;
|
||||
m_filter.pState = m_state;
|
||||
m_filter.pCoeffs = coeffs[twist];
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
-42
@@ -1,42 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2020 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
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#if defined(MODE_AX25)
|
||||
|
||||
#if !defined(AX25Twist_H)
|
||||
#define AX25Twist_H
|
||||
|
||||
class CAX25Twist {
|
||||
public:
|
||||
CAX25Twist(int8_t n);
|
||||
|
||||
void process(q15_t* in, q15_t* out, uint8_t length);
|
||||
|
||||
void setTwist(int8_t n);
|
||||
|
||||
private:
|
||||
arm_fir_instance_q15 m_filter;
|
||||
q15_t m_state[40U]; // NoTaps + BlockSize - 1, 9 + 20 - 1 plus some spare
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2009-2017,2020 by Jonathan Naylor G4KLX
|
||||
* Copyright (C) 2009-2017 by Jonathan Naylor G4KLX
|
||||
* Copyright (C) 2016 by Colin Durbridge G4EML
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -125,7 +125,7 @@ void CCWIdTX::process()
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t CCWIdTX::write(const uint8_t* data, uint16_t length)
|
||||
uint8_t CCWIdTX::write(const uint8_t* data, uint8_t length)
|
||||
{
|
||||
::memset(m_poBuffer, 0x00U, 1000U * sizeof(uint8_t));
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (C) 2009-2015 by Jonathan Naylor G4KLX
|
||||
* Copyright (C) 2016,2020 by Colin Durbridge G4EML
|
||||
* Copyright (C) 2016 by Colin Durbridge G4EML
|
||||
*
|
||||
* 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
|
||||
@@ -28,7 +28,7 @@ public:
|
||||
|
||||
void process();
|
||||
|
||||
uint8_t write(const uint8_t* data, uint16_t length);
|
||||
uint8_t write(const uint8_t* data, uint8_t length);
|
||||
|
||||
void reset();
|
||||
|
||||
|
||||
+2
-7
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2009-2015,2020 by Jonathan Naylor G4KLX
|
||||
* Copyright (C) 2009-2015 by Jonathan Naylor G4KLX
|
||||
* Copyright (C) 2016 by Colin Durbridge G4EML
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -18,9 +18,6 @@
|
||||
*/
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#if defined(MODE_DMR)
|
||||
|
||||
#include "Globals.h"
|
||||
#include "CalDMR.h"
|
||||
|
||||
@@ -211,7 +208,7 @@ void CCalDMR::dmrdmo1k()
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t CCalDMR::write(const uint8_t* data, uint16_t length)
|
||||
uint8_t CCalDMR::write(const uint8_t* data, uint8_t length)
|
||||
{
|
||||
if (length != 1U)
|
||||
return 4U;
|
||||
@@ -224,5 +221,3 @@ uint8_t CCalDMR::write(const uint8_t* data, uint16_t length)
|
||||
return 0U;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2009-2015,2020 by Jonathan Naylor G4KLX
|
||||
* Copyright (C) 2009-2015 by Jonathan Naylor G4KLX
|
||||
* Copyright (C) 2016 by Colin Durbridge G4EML
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -17,13 +17,10 @@
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#if defined(MODE_DMR)
|
||||
|
||||
#if !defined(CALDMR_H)
|
||||
#define CALDMR_H
|
||||
|
||||
#include "Config.h"
|
||||
#include "DMRDefines.h"
|
||||
|
||||
enum DMRCAL1K {
|
||||
@@ -44,7 +41,7 @@ public:
|
||||
void createData1k(uint8_t n);
|
||||
void createDataDMO1k(uint8_t n);
|
||||
|
||||
uint8_t write(const uint8_t* data, uint16_t length);
|
||||
uint8_t write(const uint8_t* data, uint8_t length);
|
||||
|
||||
private:
|
||||
bool m_transmit;
|
||||
@@ -56,5 +53,3 @@ private:
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
+1
-6
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2009-2016,2020 by Jonathan Naylor G4KLX
|
||||
* Copyright (C) 2009-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
|
||||
@@ -17,9 +17,6 @@
|
||||
*/
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#if defined(MODE_DSTAR)
|
||||
|
||||
#include "Globals.h"
|
||||
#include "CalDStarRX.h"
|
||||
#include "Utils.h"
|
||||
@@ -129,5 +126,3 @@ void CCalDStarRX::process(q15_t value)
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
+2
-7
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2015,2016,2020 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
|
||||
@@ -16,13 +16,10 @@
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#if defined(MODE_DSTAR)
|
||||
|
||||
#if !defined(CALDSTARRX_H)
|
||||
#define CALDSTARRX_H
|
||||
|
||||
#include "Config.h"
|
||||
#include "DStarDefines.h"
|
||||
|
||||
class CCalDStarRX {
|
||||
@@ -43,5 +40,3 @@ private:
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
+2
-7
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2009-2016,2020 by Jonathan Naylor G4KLX
|
||||
* Copyright (C) 2009-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
|
||||
@@ -17,9 +17,6 @@
|
||||
*/
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#if defined(MODE_DSTAR)
|
||||
|
||||
#include "Globals.h"
|
||||
#include "CalDStarTX.h"
|
||||
|
||||
@@ -165,7 +162,7 @@ void CCalDStarTX::process()
|
||||
m_count = (m_count + 1U) % (30U * 21U);
|
||||
}
|
||||
|
||||
uint8_t CCalDStarTX::write(const uint8_t* data, uint16_t length)
|
||||
uint8_t CCalDStarTX::write(const uint8_t* data, uint8_t length)
|
||||
{
|
||||
if (length != 1U)
|
||||
return 4U;
|
||||
@@ -184,5 +181,3 @@ uint8_t CCalDStarTX::write(const uint8_t* data, uint16_t length)
|
||||
return 0U;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
+3
-8
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2015,2016,2020 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
|
||||
@@ -16,20 +16,17 @@
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#if defined(MODE_DSTAR)
|
||||
|
||||
#if !defined(CALDSTARTX_H)
|
||||
#define CALDSTARTX_H
|
||||
|
||||
#include "Config.h"
|
||||
#include "DStarDefines.h"
|
||||
|
||||
class CCalDStarTX {
|
||||
public:
|
||||
CCalDStarTX();
|
||||
|
||||
uint8_t write(const uint8_t* data, uint16_t length);
|
||||
uint8_t write(const uint8_t* data, uint8_t length);
|
||||
|
||||
void process();
|
||||
|
||||
@@ -40,5 +37,3 @@ private:
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2009-2015,2020 by Jonathan Naylor G4KLX
|
||||
* Copyright (C) 2009-2015 by Jonathan Naylor G4KLX
|
||||
* Copyright (C) 2016 by Colin Durbridge G4EML
|
||||
* Copyright (C) 2020 by Phil Taylor M0VSE
|
||||
*
|
||||
@@ -19,9 +19,6 @@
|
||||
*/
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#if defined(MODE_FM)
|
||||
|
||||
#include "Globals.h"
|
||||
#include "CalFM.h"
|
||||
|
||||
@@ -55,7 +52,7 @@ void CCalFM::process()
|
||||
{
|
||||
const TONE_TABLE* entry = NULL;
|
||||
|
||||
if (m_modemState != m_lastState)
|
||||
if (m_modemState!=m_lastState)
|
||||
{
|
||||
switch (m_modemState) {
|
||||
case STATE_FMCAL10K:
|
||||
@@ -119,7 +116,7 @@ void CCalFM::process()
|
||||
}
|
||||
|
||||
|
||||
uint8_t CCalFM::write(const uint8_t* data, uint16_t length)
|
||||
uint8_t CCalFM::write(const uint8_t* data, uint8_t length)
|
||||
{
|
||||
if (length != 1U)
|
||||
return 4U;
|
||||
@@ -128,6 +125,3 @@ uint8_t CCalFM::write(const uint8_t* data, uint16_t length)
|
||||
|
||||
return 0U;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2009-2015,2020 by Jonathan Naylor G4KLX
|
||||
* Copyright (C) 2009-2015 by Jonathan Naylor G4KLX
|
||||
* Copyright (C) 2016 by Colin Durbridge G4EML
|
||||
* Copyright (C) 2020 by Phil Taylor M0VSE
|
||||
*
|
||||
@@ -18,13 +18,11 @@
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#if defined(MODE_FM)
|
||||
|
||||
#if !defined(CALFM_H)
|
||||
#define CALFM_H
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
class CCalFM {
|
||||
public:
|
||||
CCalFM();
|
||||
@@ -37,7 +35,7 @@ public:
|
||||
void fm25kcal();
|
||||
void fm30kcal();
|
||||
|
||||
uint8_t write(const uint8_t* data, uint16_t length);
|
||||
uint8_t write(const uint8_t* data, uint8_t length);
|
||||
|
||||
private:
|
||||
uint16_t m_frequency;
|
||||
@@ -51,5 +49,3 @@ private:
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
+1
-7
@@ -1,6 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2018 by Andy Uribe CA6JAU
|
||||
* Copyright (C) 2020 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
|
||||
@@ -18,9 +17,6 @@
|
||||
*/
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#if defined(MODE_NXDN)
|
||||
|
||||
#include "Globals.h"
|
||||
#include "CalNXDN.h"
|
||||
|
||||
@@ -83,7 +79,7 @@ void CCalNXDN::process()
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t CCalNXDN::write(const uint8_t* data, uint16_t length)
|
||||
uint8_t CCalNXDN::write(const uint8_t* data, uint8_t length)
|
||||
{
|
||||
if (length != 1U)
|
||||
return 4U;
|
||||
@@ -96,5 +92,3 @@ uint8_t CCalNXDN::write(const uint8_t* data, uint16_t length)
|
||||
return 0U;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2018 by Andy Uribe CA6JAU
|
||||
* Copyright (C) 2020 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
|
||||
@@ -17,13 +16,11 @@
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#if defined(MODE_NXDN)
|
||||
|
||||
#if !defined(CALNXDN_H)
|
||||
#define CALNXDN_H
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
enum NXDNCAL1K {
|
||||
NXDNCAL1K_IDLE,
|
||||
NXDNCAL1K_TX
|
||||
@@ -35,7 +32,7 @@ public:
|
||||
|
||||
void process();
|
||||
|
||||
uint8_t write(const uint8_t* data, uint16_t length);
|
||||
uint8_t write(const uint8_t* data, uint8_t length);
|
||||
|
||||
private:
|
||||
bool m_transmit;
|
||||
@@ -45,5 +42,3 @@ private:
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
+1
-7
@@ -1,6 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2018 by Andy Uribe CA6JAU
|
||||
* Copyright (C) 2020 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
|
||||
@@ -18,9 +17,6 @@
|
||||
*/
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#if defined(MODE_P25)
|
||||
|
||||
#include "Globals.h"
|
||||
#include "CalP25.h"
|
||||
|
||||
@@ -86,7 +82,7 @@ void CCalP25::process()
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t CCalP25::write(const uint8_t* data, uint16_t length)
|
||||
uint8_t CCalP25::write(const uint8_t* data, uint8_t length)
|
||||
{
|
||||
if (length != 1U)
|
||||
return 4U;
|
||||
@@ -99,5 +95,3 @@ uint8_t CCalP25::write(const uint8_t* data, uint16_t length)
|
||||
return 0U;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2018 by Andy Uribe CA6JAU
|
||||
* Copyright (C) 2020 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
|
||||
@@ -17,13 +16,10 @@
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#if defined(MODE_P25)
|
||||
|
||||
#if !defined(CALP25_H)
|
||||
#define CALP25_H
|
||||
|
||||
#include "Config.h"
|
||||
#include "P25Defines.h"
|
||||
|
||||
enum P25CAL1K {
|
||||
@@ -38,7 +34,7 @@ public:
|
||||
|
||||
void process();
|
||||
|
||||
uint8_t write(const uint8_t* data, uint16_t length);
|
||||
uint8_t write(const uint8_t* data, uint8_t length);
|
||||
|
||||
private:
|
||||
bool m_transmit;
|
||||
@@ -47,5 +43,3 @@ private:
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
+2
-8
@@ -1,6 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2019 by Florian Wolters DF2ET
|
||||
* Copyright (C) 2020 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
|
||||
@@ -18,12 +17,10 @@
|
||||
*/
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#if defined(MODE_POCSAG)
|
||||
|
||||
#include "Globals.h"
|
||||
#include "CalPOCSAG.h"
|
||||
|
||||
|
||||
CCalPOCSAG::CCalPOCSAG() :
|
||||
m_state(POCSAGCAL_IDLE)
|
||||
{
|
||||
@@ -41,7 +38,7 @@ void CCalPOCSAG::process()
|
||||
pocsagTX.writeByte(0xAAU);
|
||||
}
|
||||
|
||||
uint8_t CCalPOCSAG::write(const uint8_t* data, uint16_t length)
|
||||
uint8_t CCalPOCSAG::write(const uint8_t* data, uint8_t length)
|
||||
{
|
||||
if (length != 1U)
|
||||
return 4U;
|
||||
@@ -50,6 +47,3 @@ uint8_t CCalPOCSAG::write(const uint8_t* data, uint16_t length)
|
||||
|
||||
return 0U;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
+3
-9
@@ -1,6 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2019 by Florian Wolters DF2ET
|
||||
* Copyright (C) 2020 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
|
||||
@@ -17,13 +16,11 @@
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#if defined(MODE_POCSAG)
|
||||
|
||||
#if !defined(CALPOCSAG_H)
|
||||
#define CALPOCSAG_H
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
enum POCSAGCAL {
|
||||
POCSAGCAL_IDLE,
|
||||
POCSAGCAL_TX
|
||||
@@ -35,13 +32,10 @@ public:
|
||||
|
||||
void process();
|
||||
|
||||
uint8_t write(const uint8_t* data, uint16_t length);
|
||||
uint8_t write(const uint8_t* data, uint8_t length);
|
||||
|
||||
private:
|
||||
POCSAGCAL m_state;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -19,37 +19,6 @@
|
||||
#if !defined(CONFIG_H)
|
||||
#define CONFIG_H
|
||||
|
||||
// Allow for the selection of which modes to compile into the firmware. This is particularly useful for processors
|
||||
// which have limited code space and processing power like the STM32F103, which is found on older/cheaper boards.
|
||||
|
||||
// Enable D-Star support.
|
||||
#define MODE_DSTAR
|
||||
|
||||
// Enable DMR support.
|
||||
#define MODE_DMR
|
||||
|
||||
// Enable System Fusion support.
|
||||
#define MODE_YSF
|
||||
|
||||
// Enable P25 phase 1 support.
|
||||
#define MODE_P25
|
||||
|
||||
// Enable NXDN support, the boxcar filter sometimes improves the performance of NXDN receive on some systems.
|
||||
#define MODE_NXDN
|
||||
#define USE_NXDN_BOXCAR
|
||||
|
||||
// Enable M17 support.
|
||||
#define MODE_M17
|
||||
|
||||
// Enable POCSAG support.
|
||||
#define MODE_POCSAG
|
||||
|
||||
// Enable FM support.
|
||||
#define MODE_FM
|
||||
|
||||
// Enable AX.25 support, this is only enabled if FM is also enabled.
|
||||
#define MODE_AX25
|
||||
|
||||
// Allow for the use of high quality external clock oscillators
|
||||
// The number is the frequency of the oscillator in Hertz.
|
||||
//
|
||||
@@ -66,16 +35,11 @@
|
||||
// For 19.2 MHz
|
||||
// #define EXTERNAL_OSC 19200000
|
||||
|
||||
// Select a baud rate for host communication. The faster speeds are needed for external FM to work.
|
||||
// #define SERIAL_SPEED 115200 // Suitable for most older boards (Arduino Due, STM32F1_POG, etc). External FM will NOT work with this!
|
||||
// #define SERIAL_SPEED 230400 // Only works on newer boards like fast M4, M7, Teensy 3.x. External FM might work with this
|
||||
#define SERIAL_SPEED 460800 // Only works on newer boards like fast M4, M7, Teensy 3.x. External FM should work with this
|
||||
|
||||
// Allow the use of the COS line to lockout the modem
|
||||
// #define USE_COS_AS_LOCKOUT
|
||||
|
||||
// Use pins to output the current mode via LEDs
|
||||
#define MODE_LEDS
|
||||
// #define MODE_LEDS
|
||||
|
||||
// For the original Arduino Due pin layout
|
||||
// #define ARDUINO_DUE_PAPA
|
||||
@@ -85,7 +49,7 @@
|
||||
#define STM32F1_POG
|
||||
#else
|
||||
// For the ZUM V1.0 and V1.0.1 boards pin layout
|
||||
// #define ARDUINO_DUE_ZUM_V10
|
||||
#define ARDUINO_DUE_ZUM_V10
|
||||
#endif
|
||||
|
||||
// For the SP8NTH board
|
||||
@@ -102,13 +66,10 @@
|
||||
// #define VK6MST_TEENSY_PI3_SHIELD_I2C
|
||||
|
||||
// Pass RSSI information to the host
|
||||
#define SEND_RSSI_DATA
|
||||
// #define SEND_RSSI_DATA
|
||||
|
||||
// Use the modem as a serial repeater for Nextion displays
|
||||
#define SERIAL_REPEATER
|
||||
|
||||
// Use the modem as an I2C repeater for OLED displays
|
||||
// #define I2C_REPEATER
|
||||
// #define SERIAL_REPEATER
|
||||
|
||||
// To reduce CPU load, you can remove the DC blocker by commenting out the next line
|
||||
#define USE_DCBLOCKER
|
||||
@@ -120,20 +81,10 @@
|
||||
// Use the YSF and P25 LEDs for NXDN
|
||||
// #define USE_ALTERNATE_NXDN_LEDS
|
||||
|
||||
// Use the D-Star and P25 LEDs for M17
|
||||
#define USE_ALTERNATE_M17_LEDS
|
||||
|
||||
// Use the D-Star and DMR LEDs for POCSAG
|
||||
#define USE_ALTERNATE_POCSAG_LEDS
|
||||
// #define USE_ALTERNATE_POCSAG_LEDS
|
||||
|
||||
// Use the D-Star and YSF LEDs for FM
|
||||
#define USE_ALTERNATE_FM_LEDS
|
||||
|
||||
#if defined(STM32F1_POG)
|
||||
// Slower boards need to run their serial at 115200 baud
|
||||
#undef SERIAL_SPEED
|
||||
#define SERIAL_SPEED 115200
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
+1
-7
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2009-2017,2020 by Jonathan Naylor G4KLX
|
||||
* Copyright (C) 2009-2017 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
|
||||
@@ -17,9 +17,6 @@
|
||||
*/
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#if defined(MODE_DMR)
|
||||
|
||||
#include "Globals.h"
|
||||
#include "DMRDMORX.h"
|
||||
#include "DMRSlotType.h"
|
||||
@@ -426,6 +423,3 @@ void CDMRDMORX::writeRSSIData(uint8_t* frame)
|
||||
serial.writeDMRData(true, frame, DMR_FRAME_LENGTH_BYTES + 1U);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
+2
-8
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2015,2016,2017,2020 by Jonathan Naylor G4KLX
|
||||
* Copyright (C) 2015,2016,2017 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
|
||||
@@ -16,13 +16,10 @@
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#if defined(MODE_DMR)
|
||||
|
||||
#if !defined(DMRDMORX_H)
|
||||
#define DMRDMORX_H
|
||||
|
||||
#include "Config.h"
|
||||
#include "DMRDefines.h"
|
||||
|
||||
const uint16_t DMO_BUFFER_LENGTH_SAMPLES = 1440U; // 60ms at 24 kHz
|
||||
@@ -70,6 +67,3 @@ private:
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
+3
-8
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2009-2017,2020 by Jonathan Naylor G4KLX
|
||||
* Copyright (C) 2009-2017 by Jonathan Naylor G4KLX
|
||||
* Copyright (C) 2016 by Colin Durbridge G4EML
|
||||
* Copyright (C) 2017 by Andy Uribe CA6JAU
|
||||
*
|
||||
@@ -19,9 +19,6 @@
|
||||
*/
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#if defined(MODE_DMR)
|
||||
|
||||
#include "Globals.h"
|
||||
#include "DMRSlotType.h"
|
||||
|
||||
@@ -77,7 +74,7 @@ void CDMRDMOTX::process()
|
||||
m_poLen = m_txDelay;
|
||||
} else {
|
||||
for (unsigned int i = 0U; i < DMR_FRAME_LENGTH_BYTES; i++)
|
||||
m_fifo.get(m_poBuffer[i]);
|
||||
m_poBuffer[i] = m_fifo.get();
|
||||
|
||||
for (unsigned int i = 0U; i < 39U; i++)
|
||||
m_poBuffer[i + DMR_FRAME_LENGTH_BYTES] = PR_FILL[i];
|
||||
@@ -107,7 +104,7 @@ void CDMRDMOTX::process()
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t CDMRDMOTX::writeData(const uint8_t* data, uint16_t length)
|
||||
uint8_t CDMRDMOTX::writeData(const uint8_t* data, uint8_t length)
|
||||
{
|
||||
if (length != (DMR_FRAME_LENGTH_BYTES + 1U))
|
||||
return 4U;
|
||||
@@ -164,5 +161,3 @@ void CDMRDMOTX::setTXDelay(uint8_t delay)
|
||||
m_txDelay = 1200U;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
+5
-10
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2015,2016,2017,2020 by Jonathan Naylor G4KLX
|
||||
* Copyright (C) 2015,2016,2017 by Jonathan Naylor G4KLX
|
||||
* Copyright (C) 2016 by Colin Durbridge G4EML
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -17,22 +17,19 @@
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#if defined(MODE_DMR)
|
||||
|
||||
#if !defined(DMRDMOTX_H)
|
||||
#define DMRDMOTX_H
|
||||
|
||||
#include "Config.h"
|
||||
#include "DMRDefines.h"
|
||||
|
||||
#include "RingBuffer.h"
|
||||
#include "SerialRB.h"
|
||||
|
||||
class CDMRDMOTX {
|
||||
public:
|
||||
CDMRDMOTX();
|
||||
|
||||
uint8_t writeData(const uint8_t* data, uint16_t length);
|
||||
uint8_t writeData(const uint8_t* data, uint8_t length);
|
||||
|
||||
void process();
|
||||
|
||||
@@ -41,7 +38,7 @@ public:
|
||||
uint8_t getSpace() const;
|
||||
|
||||
private:
|
||||
CRingBuffer<uint8_t> m_fifo;
|
||||
CSerialRB m_fifo;
|
||||
arm_fir_interpolate_instance_q15 m_modFilter;
|
||||
q15_t m_modState[16U]; // blockSize + phaseLength - 1, 4 + 9 - 1 plus some spare
|
||||
uint8_t m_poBuffer[1200U];
|
||||
@@ -54,5 +51,3 @@ private:
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
+1
-7
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2009-2017,2020 by Jonathan Naylor G4KLX
|
||||
* Copyright (C) 2009-2017 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
|
||||
@@ -17,9 +17,6 @@
|
||||
*/
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#if defined(MODE_DMR)
|
||||
|
||||
#include "Globals.h"
|
||||
#include "DMRIdleRX.h"
|
||||
#include "DMRSlotType.h"
|
||||
@@ -212,6 +209,3 @@ void CDMRIdleRX::setColorCode(uint8_t colorCode)
|
||||
{
|
||||
m_colorCode = colorCode;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
+2
-7
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2015,2020 by Jonathan Naylor G4KLX
|
||||
* Copyright (C) 2015 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
|
||||
@@ -16,13 +16,10 @@
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#if defined(MODE_DMR)
|
||||
|
||||
#if !defined(DMRIDLERX_H)
|
||||
#define DMRIDLERX_H
|
||||
|
||||
#include "Config.h"
|
||||
#include "DMRDefines.h"
|
||||
|
||||
class CDMRIdleRX {
|
||||
@@ -52,5 +49,3 @@ private:
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2015,2016,2020 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
|
||||
@@ -17,9 +17,6 @@
|
||||
*/
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#if defined(MODE_DMR)
|
||||
|
||||
#include "Globals.h"
|
||||
#include "DMRRX.h"
|
||||
|
||||
@@ -71,5 +68,3 @@ void CDMRRX::reset()
|
||||
m_slot2RX.reset();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2015,2016,2020 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
|
||||
@@ -16,13 +16,10 @@
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#if defined(MODE_DMR)
|
||||
|
||||
#if !defined(DMRRX_H)
|
||||
#define DMRRX_H
|
||||
|
||||
#include "Config.h"
|
||||
#include "DMRSlotRX.h"
|
||||
|
||||
class CDMRRX {
|
||||
@@ -43,5 +40,3 @@ private:
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
+1
-7
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2009-2017,2020 by Jonathan Naylor G4KLX
|
||||
* Copyright (C) 2009-2017 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
|
||||
@@ -17,9 +17,6 @@
|
||||
*/
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#if defined(MODE_DMR)
|
||||
|
||||
#include "Globals.h"
|
||||
#include "DMRSlotRX.h"
|
||||
#include "DMRSlotType.h"
|
||||
@@ -403,6 +400,3 @@ void CDMRSlotRX::writeRSSIData(uint8_t* frame)
|
||||
serial.writeDMRData(m_slot, frame, DMR_FRAME_LENGTH_BYTES + 1U);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
+2
-8
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2015,2016,2017,2020 by Jonathan Naylor G4KLX
|
||||
* Copyright (C) 2015,2016,2017 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
|
||||
@@ -16,13 +16,10 @@
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#if defined(MODE_DMR)
|
||||
|
||||
#if !defined(DMRSLOTRX_H)
|
||||
#define DMRSLOTRX_H
|
||||
|
||||
#include "Config.h"
|
||||
#include "DMRDefines.h"
|
||||
|
||||
enum DMRRX_STATE {
|
||||
@@ -73,6 +70,3 @@ private:
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
+1
-6
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2015,2020 by Jonathan Naylor G4KLX
|
||||
* Copyright (C) 2015 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
|
||||
@@ -17,9 +17,6 @@
|
||||
*/
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#if defined(MODE_DMR)
|
||||
|
||||
#include "Globals.h"
|
||||
#include "DMRSlotType.h"
|
||||
|
||||
@@ -288,5 +285,3 @@ void CDMRSlotType::encode(uint8_t colorCode, uint8_t dataType, uint8_t* frame) c
|
||||
frame[20U] = (frame[20U] & 0x03U) | ((slotType[1U] << 6) & 0xC0U) | ((slotType[2U] >> 2) & 0x3CU);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
+1
-7
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2015,2020 by Jonathan Naylor G4KLX
|
||||
* Copyright (C) 2015 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
|
||||
@@ -16,10 +16,6 @@
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#if defined(MODE_DMR)
|
||||
|
||||
#if !defined(DMRSLOTTYPE_H)
|
||||
#define DMRSLOTTYPE_H
|
||||
|
||||
@@ -39,5 +35,3 @@ private:
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2009-2017,2020 by Jonathan Naylor G4KLX
|
||||
* Copyright (C) 2009-2017 by Jonathan Naylor G4KLX
|
||||
* Copyright (C) 2016 by Colin Durbridge G4EML
|
||||
* Copyright (C) 2017 by Andy Uribe CA6JAU
|
||||
*
|
||||
@@ -19,9 +19,6 @@
|
||||
*/
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#if defined(MODE_DMR)
|
||||
|
||||
#include "Globals.h"
|
||||
#include "DMRSlotType.h"
|
||||
|
||||
@@ -147,7 +144,7 @@ void CDMRTX::process()
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t CDMRTX::writeData1(const uint8_t* data, uint16_t length)
|
||||
uint8_t CDMRTX::writeData1(const uint8_t* data, uint8_t length)
|
||||
{
|
||||
if (length != (DMR_FRAME_LENGTH_BYTES + 1U))
|
||||
return 4U;
|
||||
@@ -171,7 +168,7 @@ uint8_t CDMRTX::writeData1(const uint8_t* data, uint16_t length)
|
||||
return 0U;
|
||||
}
|
||||
|
||||
uint8_t CDMRTX::writeData2(const uint8_t* data, uint16_t length)
|
||||
uint8_t CDMRTX::writeData2(const uint8_t* data, uint8_t length)
|
||||
{
|
||||
if (length != (DMR_FRAME_LENGTH_BYTES + 1U))
|
||||
return 4U;
|
||||
@@ -195,7 +192,7 @@ uint8_t CDMRTX::writeData2(const uint8_t* data, uint16_t length)
|
||||
return 0U;
|
||||
}
|
||||
|
||||
uint8_t CDMRTX::writeShortLC(const uint8_t* data, uint16_t length)
|
||||
uint8_t CDMRTX::writeShortLC(const uint8_t* data, uint8_t length)
|
||||
{
|
||||
if (length != 9U)
|
||||
return 4U;
|
||||
@@ -211,7 +208,7 @@ uint8_t CDMRTX::writeShortLC(const uint8_t* data, uint16_t length)
|
||||
return 0U;
|
||||
}
|
||||
|
||||
uint8_t CDMRTX::writeAbort(const uint8_t* data, uint16_t length)
|
||||
uint8_t CDMRTX::writeAbort(const uint8_t* data, uint8_t length)
|
||||
{
|
||||
if (length != 1U)
|
||||
return 4U;
|
||||
@@ -296,7 +293,7 @@ void CDMRTX::createData(uint8_t slotIndex)
|
||||
{
|
||||
if (m_fifo[slotIndex].getData() >= DMR_FRAME_LENGTH_BYTES && m_frameCount >= STARTUP_COUNT && m_abortCount[slotIndex] >= ABORT_COUNT) {
|
||||
for (unsigned int i = 0U; i < DMR_FRAME_LENGTH_BYTES; i++) {
|
||||
m_fifo[slotIndex].get(m_poBuffer[i]);
|
||||
m_poBuffer[i] = m_fifo[slotIndex].get();
|
||||
m_markBuffer[i] = MARK_NONE;
|
||||
}
|
||||
} else {
|
||||
@@ -417,6 +414,3 @@ uint32_t CDMRTX::getFrameCount()
|
||||
{
|
||||
return m_frameCount;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2015,2016,2017,2020 by Jonathan Naylor G4KLX
|
||||
* Copyright (C) 2015,2016,2017 by Jonathan Naylor G4KLX
|
||||
* Copyright (C) 2016 by Colin Durbridge G4EML
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -17,16 +17,13 @@
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#if defined(MODE_DMR)
|
||||
|
||||
#if !defined(DMRTX_H)
|
||||
#define DMRTX_H
|
||||
|
||||
#include "Config.h"
|
||||
#include "DMRDefines.h"
|
||||
|
||||
#include "RingBuffer.h"
|
||||
#include "SerialRB.h"
|
||||
|
||||
enum DMRTXSTATE {
|
||||
DMRTXSTATE_IDLE,
|
||||
@@ -41,11 +38,11 @@ class CDMRTX {
|
||||
public:
|
||||
CDMRTX();
|
||||
|
||||
uint8_t writeData1(const uint8_t* data, uint16_t length);
|
||||
uint8_t writeData2(const uint8_t* data, uint16_t length);
|
||||
uint8_t writeData1(const uint8_t* data, uint8_t length);
|
||||
uint8_t writeData2(const uint8_t* data, uint8_t length);
|
||||
|
||||
uint8_t writeShortLC(const uint8_t* data, uint16_t length);
|
||||
uint8_t writeAbort(const uint8_t* data, uint16_t length);
|
||||
uint8_t writeShortLC(const uint8_t* data, uint8_t length);
|
||||
uint8_t writeAbort(const uint8_t* data, uint8_t length);
|
||||
|
||||
void setStart(bool start);
|
||||
void setCal(bool start);
|
||||
@@ -62,7 +59,7 @@ public:
|
||||
void setColorCode(uint8_t colorCode);
|
||||
|
||||
private:
|
||||
CRingBuffer<uint8_t> m_fifo[2U];
|
||||
CSerialRB m_fifo[2U];
|
||||
arm_fir_interpolate_instance_q15 m_modFilter;
|
||||
q15_t m_modState[16U]; // blockSize + phaseLength - 1, 4 + 9 - 1 plus some spare
|
||||
DMRTXSTATE m_state;
|
||||
@@ -86,5 +83,3 @@ private:
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2009-2015,2017,2020 by Jonathan Naylor G4KLX
|
||||
* Copyright (C) 2009-2015,2017 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
|
||||
|
||||
+12
-18
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2009-2017,2020 by Jonathan Naylor G4KLX
|
||||
* Copyright (C) 2009-2017 by Jonathan Naylor G4KLX
|
||||
* Copyright (C) 2017 by Andy Uribe CA6JAU
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -18,9 +18,6 @@
|
||||
*/
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#if defined(MODE_DSTAR)
|
||||
|
||||
#include "Globals.h"
|
||||
#include "DStarRX.h"
|
||||
#include "Utils.h"
|
||||
@@ -28,18 +25,18 @@
|
||||
const unsigned int MAX_FRAMES = 150U;
|
||||
|
||||
// D-Star bit order version of 0x55 0x55 0x6E 0x0A
|
||||
const uint64_t FRAME_SYNC_DATA = 0x0000000000557650U;
|
||||
const uint64_t FRAME_SYNC_MASK = 0x0000000000FFFFFFU;
|
||||
const uint8_t FRAME_SYNC_ERRS = 2U;
|
||||
const uint32_t FRAME_SYNC_DATA = 0x00557650U;
|
||||
const uint32_t FRAME_SYNC_MASK = 0x00FFFFFFU;
|
||||
const uint8_t FRAME_SYNC_ERRS = 1U;
|
||||
|
||||
// D-Star bit order version of 0x55 0x2D 0x16
|
||||
const uint64_t DATA_SYNC_DATA = 0x0000000000AAB468U;
|
||||
const uint64_t DATA_SYNC_MASK = 0x0000000000FFFFFFU;
|
||||
const uint32_t DATA_SYNC_DATA = 0x00AAB468U;
|
||||
const uint32_t DATA_SYNC_MASK = 0x00FFFFFFU;
|
||||
const uint8_t DATA_SYNC_ERRS = 2U;
|
||||
|
||||
// D-Star bit order version of 0x55 0x55 0xC8 0x7A
|
||||
const uint64_t END_SYNC_DATA = 0x0000AAAAAAAA135EU;
|
||||
const uint64_t END_SYNC_MASK = 0x0000FFFFFFFFFFFFU;
|
||||
const uint32_t END_SYNC_DATA = 0xAAAA135EU;
|
||||
const uint32_t END_SYNC_MASK = 0xFFFFFFFFU;
|
||||
const uint8_t END_SYNC_ERRS = 1U;
|
||||
|
||||
const uint8_t BIT_MASK_TABLE0[] = {0x7FU, 0xBFU, 0xDFU, 0xEFU, 0xF7U, 0xFBU, 0xFDU, 0xFEU};
|
||||
@@ -324,7 +321,7 @@ void CDStarRX::processNone(q15_t sample)
|
||||
bool ret = correlateFrameSync();
|
||||
if (ret) {
|
||||
m_countdown = 5U;
|
||||
|
||||
|
||||
m_headerBuffer[m_headerPtr] = sample;
|
||||
m_headerPtr++;
|
||||
|
||||
@@ -398,7 +395,7 @@ void CDStarRX::processHeader(q15_t sample)
|
||||
void CDStarRX::processData()
|
||||
{
|
||||
// Fuzzy matching of the end frame sequences
|
||||
if (countBits64((m_bitBuffer[m_bitPtr] & DSTAR_END_SYNC_MASK) ^ DSTAR_END_SYNC_DATA) <= END_SYNC_ERRS) {
|
||||
if (countBits32((m_bitBuffer[m_bitPtr] & DSTAR_END_SYNC_MASK) ^ DSTAR_END_SYNC_DATA) <= END_SYNC_ERRS) {
|
||||
DEBUG1("DStarRX: Found end sync in Data");
|
||||
|
||||
io.setDecode(false);
|
||||
@@ -507,7 +504,7 @@ void CDStarRX::writeRSSIData(unsigned char* data)
|
||||
|
||||
bool CDStarRX::correlateFrameSync()
|
||||
{
|
||||
if (countBits64((m_bitBuffer[m_bitPtr] & DSTAR_FRAME_SYNC_MASK) ^ DSTAR_FRAME_SYNC_DATA) <= FRAME_SYNC_ERRS) {
|
||||
if (countBits32((m_bitBuffer[m_bitPtr] & DSTAR_FRAME_SYNC_MASK) ^ DSTAR_FRAME_SYNC_DATA) <= FRAME_SYNC_ERRS) {
|
||||
uint16_t ptr = m_dataPtr + DSTAR_DATA_LENGTH_SAMPLES - DSTAR_FRAME_SYNC_LENGTH_SAMPLES + DSTAR_RADIO_SYMBOL_LENGTH;
|
||||
if (ptr >= DSTAR_DATA_LENGTH_SAMPLES)
|
||||
ptr -= DSTAR_DATA_LENGTH_SAMPLES;
|
||||
@@ -543,7 +540,7 @@ bool CDStarRX::correlateDataSync()
|
||||
if (m_rxState == DSRXS_DATA)
|
||||
maxErrs = DATA_SYNC_ERRS;
|
||||
|
||||
if (countBits64((m_bitBuffer[m_bitPtr] & DSTAR_DATA_SYNC_MASK) ^ DSTAR_DATA_SYNC_DATA) <= maxErrs) {
|
||||
if (countBits32((m_bitBuffer[m_bitPtr] & DSTAR_DATA_SYNC_MASK) ^ DSTAR_DATA_SYNC_DATA) <= maxErrs) {
|
||||
uint16_t ptr = m_dataPtr + DSTAR_DATA_LENGTH_SAMPLES - DSTAR_DATA_SYNC_LENGTH_SAMPLES + DSTAR_RADIO_SYMBOL_LENGTH;
|
||||
if (ptr >= DSTAR_DATA_LENGTH_SAMPLES)
|
||||
ptr -= DSTAR_DATA_LENGTH_SAMPLES;
|
||||
@@ -819,6 +816,3 @@ bool CDStarRX::checksum(const uint8_t* header) const
|
||||
|
||||
return crc8[0U] == header[DSTAR_HEADER_LENGTH_BYTES - 2U] && crc8[1U] == header[DSTAR_HEADER_LENGTH_BYTES - 1U];
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2015,2016,2017,2020 by Jonathan Naylor G4KLX
|
||||
* Copyright (C) 2015,2016,2017 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
|
||||
@@ -16,13 +16,10 @@
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#if defined(MODE_DSTAR)
|
||||
|
||||
#if !defined(DSTARRX_H)
|
||||
#define DSTARRX_H
|
||||
|
||||
#include "Config.h"
|
||||
#include "DStarDefines.h"
|
||||
|
||||
enum DSRX_STATE {
|
||||
@@ -41,7 +38,7 @@ public:
|
||||
|
||||
private:
|
||||
DSRX_STATE m_rxState;
|
||||
uint64_t m_bitBuffer[DSTAR_RADIO_SYMBOL_LENGTH];
|
||||
uint32_t m_bitBuffer[DSTAR_RADIO_SYMBOL_LENGTH];
|
||||
q15_t m_headerBuffer[DSTAR_FEC_SECTION_LENGTH_SAMPLES + 2U * DSTAR_RADIO_SYMBOL_LENGTH];
|
||||
q15_t m_dataBuffer[DSTAR_DATA_LENGTH_SAMPLES];
|
||||
uint16_t m_bitPtr;
|
||||
@@ -82,5 +79,3 @@ private:
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
+8
-16
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2009-2017,2020 by Jonathan Naylor G4KLX
|
||||
* Copyright (C) 2009-2017 by Jonathan Naylor G4KLX
|
||||
* Copyright (C) 2017 by Andy Uribe CA6JAU
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -18,9 +18,6 @@
|
||||
*/
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#if defined(MODE_DSTAR)
|
||||
|
||||
#include "Globals.h"
|
||||
#include "DStarTX.h"
|
||||
|
||||
@@ -220,12 +217,11 @@ void CDStarTX::process()
|
||||
m_poBuffer[m_poLen++] = BIT_SYNC;
|
||||
} else {
|
||||
// Pop the type byte off
|
||||
uint8_t dummy;
|
||||
m_buffer.get(dummy);
|
||||
m_buffer.get();
|
||||
|
||||
uint8_t header[DSTAR_HEADER_LENGTH_BYTES];
|
||||
for (uint8_t i = 0U; i < DSTAR_HEADER_LENGTH_BYTES; i++)
|
||||
m_buffer.get(header[i]);
|
||||
header[i] = m_buffer.get();
|
||||
|
||||
uint8_t buffer[86U];
|
||||
txHeader(header, buffer + 2U);
|
||||
@@ -243,19 +239,17 @@ void CDStarTX::process()
|
||||
|
||||
if (type == DSTAR_DATA && m_poLen == 0U) {
|
||||
// Pop the type byte off
|
||||
uint8_t dummy;
|
||||
m_buffer.get(dummy);
|
||||
m_buffer.get();
|
||||
|
||||
for (uint8_t i = 0U; i < DSTAR_DATA_LENGTH_BYTES; i++)
|
||||
m_buffer.get(m_poBuffer[m_poLen++]);
|
||||
m_poBuffer[m_poLen++] = m_buffer.get();
|
||||
|
||||
m_poPtr = 0U;
|
||||
}
|
||||
|
||||
if (type == DSTAR_EOT && m_poLen == 0U) {
|
||||
// Pop the type byte off
|
||||
uint8_t dummy;
|
||||
m_buffer.get(dummy);
|
||||
m_buffer.get();
|
||||
|
||||
for (uint8_t j = 0U; j < 3U; j++) {
|
||||
for (uint8_t i = 0U; i < DSTAR_END_SYNC_LENGTH_BYTES; i++)
|
||||
@@ -283,7 +277,7 @@ void CDStarTX::process()
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t CDStarTX::writeHeader(const uint8_t* header, uint16_t length)
|
||||
uint8_t CDStarTX::writeHeader(const uint8_t* header, uint8_t length)
|
||||
{
|
||||
if (length != DSTAR_HEADER_LENGTH_BYTES)
|
||||
return 4U;
|
||||
@@ -302,7 +296,7 @@ uint8_t CDStarTX::writeHeader(const uint8_t* header, uint16_t length)
|
||||
return 0U;
|
||||
}
|
||||
|
||||
uint8_t CDStarTX::writeData(const uint8_t* data, uint16_t length)
|
||||
uint8_t CDStarTX::writeData(const uint8_t* data, uint8_t length)
|
||||
{
|
||||
if (length != DSTAR_DATA_LENGTH_BYTES)
|
||||
return 4U;
|
||||
@@ -449,5 +443,3 @@ uint8_t CDStarTX::getSpace() const
|
||||
return m_buffer.getSpace() / (DSTAR_DATA_LENGTH_BYTES + 1U);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2015,2016,2017,2020 by Jonathan Naylor G4KLX
|
||||
* Copyright (C) 2015,2016,2017 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
|
||||
@@ -16,21 +16,19 @@
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#if defined(MODE_DSTAR)
|
||||
|
||||
#if !defined(DSTARTX_H)
|
||||
#define DSTARTX_H
|
||||
|
||||
#include "RingBuffer.h"
|
||||
#include "Config.h"
|
||||
|
||||
#include "SerialRB.h"
|
||||
|
||||
class CDStarTX {
|
||||
public:
|
||||
CDStarTX();
|
||||
|
||||
uint8_t writeHeader(const uint8_t* header, uint16_t length);
|
||||
uint8_t writeData(const uint8_t* data, uint16_t length);
|
||||
uint8_t writeHeader(const uint8_t* header, uint8_t length);
|
||||
uint8_t writeData(const uint8_t* data, uint8_t length);
|
||||
uint8_t writeEOT();
|
||||
|
||||
void process();
|
||||
@@ -40,7 +38,7 @@ public:
|
||||
uint8_t getSpace() const;
|
||||
|
||||
private:
|
||||
CRingBuffer<uint8_t> m_buffer;
|
||||
CSerialRB m_buffer;
|
||||
arm_fir_interpolate_instance_q15 m_modFilter;
|
||||
q15_t m_modState[20U]; // blockSize + phaseLength - 1, 8 + 9 - 1 plus some spare
|
||||
uint8_t m_poBuffer[600U];
|
||||
@@ -54,5 +52,3 @@ private:
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2015,2016,2017,2021 by Jonathan Naylor G4KLX
|
||||
* Copyright (C) 2015,2016,2017 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
|
||||
@@ -27,7 +27,6 @@
|
||||
#define DEBUG3(a,b,c) serial.writeDebug((a),(b),(c))
|
||||
#define DEBUG4(a,b,c,d) serial.writeDebug((a),(b),(c),(d))
|
||||
#define DEBUG5(a,b,c,d,e) serial.writeDebug((a),(b),(c),(d),(e))
|
||||
#define DEBUG_DUMP(a,b) serial.writeDebugDump((a),(b))
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020,2021 by Jonathan Naylor G4KLX
|
||||
* Copyright (C) 2020 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
|
||||
@@ -16,46 +16,39 @@
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#if defined(MODE_FM)
|
||||
|
||||
#if !defined(FM_H)
|
||||
#define FM_H
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#include "FMBlanking.h"
|
||||
#include "FMCTCSSRX.h"
|
||||
#include "FMCTCSSTX.h"
|
||||
#include "FMTimeout.h"
|
||||
#include "FMKeyer.h"
|
||||
#include "FMTimer.h"
|
||||
#include "RingBuffer.h"
|
||||
#include "FMRB.h"
|
||||
#include "FMDirectForm1.h"
|
||||
#include "FMDownSampler.h"
|
||||
#include "FMUpSampler.h"
|
||||
#include "FMNoiseSquelch.h"
|
||||
#include "FMDownsampler.h"
|
||||
|
||||
enum FM_STATE {
|
||||
FS_LISTENING,
|
||||
FS_KERCHUNK_RF,
|
||||
FS_RELAYING_RF,
|
||||
FS_RELAYING_WAIT_RF,
|
||||
FS_TIMEOUT_RF,
|
||||
FS_TIMEOUT_WAIT_RF,
|
||||
FS_KERCHUNK_EXT,
|
||||
FS_RELAYING_EXT,
|
||||
FS_RELAYING_WAIT_EXT,
|
||||
FS_TIMEOUT_EXT,
|
||||
FS_TIMEOUT_WAIT_EXT,
|
||||
FS_KERCHUNK,
|
||||
FS_RELAYING,
|
||||
FS_RELAYING_WAIT,
|
||||
FS_TIMEOUT,
|
||||
FS_TIMEOUT_WAIT,
|
||||
FS_HANG
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
class CFM {
|
||||
public:
|
||||
CFM();
|
||||
|
||||
void samples(bool cos, q15_t* samples, uint8_t length);
|
||||
void samples(bool cos, const q15_t* samples, uint8_t length);
|
||||
|
||||
void process();
|
||||
|
||||
@@ -63,20 +56,13 @@ public:
|
||||
|
||||
uint8_t setCallsign(const char* callsign, uint8_t speed, uint16_t frequency, uint8_t time, uint8_t holdoff, uint8_t highLevel, uint8_t lowLevel, bool callsignAtStart, bool callsignAtEnd, bool callsignAtLatch);
|
||||
uint8_t setAck(const char* rfAck, uint8_t speed, uint16_t frequency, uint8_t minTime, uint16_t delay, uint8_t level);
|
||||
uint8_t setMisc(uint16_t timeout, uint8_t timeoutLevel, uint8_t ctcssFrequency, uint8_t ctcssHighThreshold, uint8_t ctcssLowThreshold, uint8_t ctcssLevel, uint8_t kerchunkTime, uint8_t hangTime, uint8_t accessMode, bool linkMode, bool cosInvert, bool noiseSquelch, uint8_t squelchHighThreshold, uint8_t squelchLowThreshold, uint8_t rfAudioBoost, uint8_t maxDev, uint8_t rxLevel);
|
||||
uint8_t setExt(const char* ack, uint8_t audioBoost, uint8_t speed, uint16_t frequency, uint8_t level);
|
||||
|
||||
uint8_t getSpace() const;
|
||||
|
||||
uint8_t writeData(const uint8_t* data, uint8_t length);
|
||||
uint8_t setMisc(uint16_t timeout, uint8_t timeoutLevel, uint8_t ctcssFrequency, uint8_t ctcssHighThreshold, uint8_t ctcssLowThreshold, uint8_t ctcssLevel, uint8_t kerchunkTime, uint8_t hangTime, bool useCOS, bool cosInvert, uint8_t rfAudioBoost, uint8_t maxDev, uint8_t rxLevel);
|
||||
|
||||
private:
|
||||
CFMKeyer m_callsign;
|
||||
CFMKeyer m_rfAck;
|
||||
CFMKeyer m_extAck;
|
||||
CFMCTCSSRX m_ctcssRX;
|
||||
CFMCTCSSTX m_ctcssTX;
|
||||
CFMNoiseSquelch m_squelch;
|
||||
CFMTimeout m_timeoutTone;
|
||||
FM_STATE m_state;
|
||||
bool m_callsignAtStart;
|
||||
@@ -89,59 +75,26 @@ private:
|
||||
CFMTimer m_ackMinTimer;
|
||||
CFMTimer m_ackDelayTimer;
|
||||
CFMTimer m_hangTimer;
|
||||
CFMTimer m_statusTimer;
|
||||
CFMTimer m_reverseTimer;
|
||||
bool m_needReverse;
|
||||
CFMDirectFormI m_filterStage1;
|
||||
CFMDirectFormI m_filterStage2;
|
||||
CFMDirectFormI m_filterStage3;
|
||||
CFMBlanking m_blanking;
|
||||
uint8_t m_accessMode;
|
||||
bool m_linkMode;
|
||||
bool m_useCOS;
|
||||
bool m_cosInvert;
|
||||
bool m_noiseSquelch;
|
||||
q15_t m_rfAudioBoost;
|
||||
q15_t m_extAudioBoost;
|
||||
CFMDownSampler m_downSampler;
|
||||
bool m_extEnabled;
|
||||
CFMDownsampler m_downsampler;
|
||||
q15_t m_rxLevel;
|
||||
CRingBuffer<q15_t> m_inputRFRB;
|
||||
CRingBuffer<q15_t> m_outputRFRB;
|
||||
CFMUpSampler m_inputExtRB;
|
||||
bool m_rfSignal;
|
||||
bool m_extSignal;
|
||||
CFMRB m_inputRB;
|
||||
CFMRB m_outputRB;
|
||||
|
||||
void stateMachine(bool validRFSignal, bool validExtSignal);
|
||||
|
||||
void repeaterSamples(bool cos, q15_t* samples, uint8_t length);
|
||||
void linkSamples(bool cos, q15_t* samples, uint8_t length);
|
||||
|
||||
void duplexStateMachine(bool validRFSignal, bool validExtSignal);
|
||||
void listeningStateDuplex(bool validRFSignal, bool validExtSignal);
|
||||
void kerchunkRFStateDuplex(bool validSignal);
|
||||
void relayingRFStateDuplex(bool validSignal);
|
||||
void relayingRFWaitStateDuplex(bool validSignal);
|
||||
void timeoutRFStateDuplex(bool validSignal);
|
||||
void timeoutRFWaitStateDuplex(bool validSignal);
|
||||
void kerchunkExtStateDuplex(bool validSignal);
|
||||
void relayingExtStateDuplex(bool validSignal);
|
||||
void relayingExtWaitStateDuplex(bool validSignal);
|
||||
void timeoutExtStateDuplex(bool validSignal);
|
||||
void timeoutExtWaitStateDuplex(bool validSignal);
|
||||
void hangStateDuplex(bool validRFSignal, bool validExtSignal);
|
||||
|
||||
void simplexStateMachine(bool validRFSignal, bool validExtSignal);
|
||||
void listeningStateSimplex(bool validRFSignal, bool validExtSignal);
|
||||
void relayingRFStateSimplex(bool validSignal);
|
||||
void relayingRFWaitStateSimplex(bool validSignal);
|
||||
void timeoutRFStateSimplex(bool validSignal);
|
||||
void timeoutRFWaitStateSimplex(bool validSignal);
|
||||
void relayingExtStateSimplex(bool validSignal);
|
||||
void relayingExtWaitStateSimplex(bool validSignal);
|
||||
void timeoutExtStateSimplex(bool validSignal);
|
||||
void timeoutExtWaitStateSimplex(bool validSignal);
|
||||
|
||||
void linkStateMachine(bool validRFSignal, bool validExtSignal);
|
||||
void stateMachine(bool validSignal);
|
||||
void listeningState(bool validSignal);
|
||||
void kerchunkState(bool validSignal);
|
||||
void relayingState(bool validSignal);
|
||||
void relayingWaitState(bool validSignal);
|
||||
void timeoutState(bool validSignal);
|
||||
void timeoutWaitState(bool validSignal);
|
||||
void hangState(bool validSignal);
|
||||
|
||||
void clock(uint8_t length);
|
||||
|
||||
@@ -153,6 +106,3 @@ private:
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -17,9 +17,6 @@
|
||||
*/
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#if defined(MODE_FM)
|
||||
|
||||
#include "Globals.h"
|
||||
#include "FMBlanking.h"
|
||||
|
||||
@@ -83,6 +80,3 @@ q15_t CFMBlanking::process(q15_t sample)
|
||||
|
||||
return sample;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
+2
-7
@@ -16,13 +16,11 @@
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#if defined(MODE_FM)
|
||||
|
||||
#if !defined(FMBlanking_H)
|
||||
#define FMBlanking_H
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
class CFMBlanking {
|
||||
public:
|
||||
CFMBlanking();
|
||||
@@ -41,6 +39,3 @@ private:
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
+16
-16
@@ -17,9 +17,6 @@
|
||||
*/
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#if defined(MODE_FM)
|
||||
|
||||
#include "Globals.h"
|
||||
#include "FMCTCSSRX.h"
|
||||
|
||||
@@ -90,7 +87,7 @@ m_lowThreshold(0),
|
||||
m_count(0U),
|
||||
m_q0(0),
|
||||
m_q1(0),
|
||||
m_state(false)
|
||||
m_result(CTS_NONE)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -114,11 +111,13 @@ uint8_t CFMCTCSSRX::setParams(uint8_t frequency, uint8_t highThreshold, uint8_t
|
||||
return 0U;
|
||||
}
|
||||
|
||||
bool CFMCTCSSRX::process(q15_t sample)
|
||||
uint8_t CFMCTCSSRX::process(q15_t sample)
|
||||
{
|
||||
//get more dynamic into the decoder by multiplying the sample by 1.5
|
||||
q31_t sample31 = q31_t(sample) + (q31_t(sample) >> 1);
|
||||
|
||||
m_result &= ~CTS_READY;
|
||||
|
||||
q31_t q2 = m_q1;
|
||||
m_q1 = m_q0;
|
||||
|
||||
@@ -150,32 +149,33 @@ bool CFMCTCSSRX::process(q15_t sample)
|
||||
// value = m_q0 * m_q0 + m_q1 * m_q1 - m_q0 * m_q1 * m_coeffDivTwo * 2
|
||||
q31_t value = t2 + t4 - t9;
|
||||
|
||||
bool previousState = m_state;
|
||||
bool previousCTCSSValid = CTCSS_VALID(m_result);
|
||||
|
||||
q31_t threshold = m_highThreshold;
|
||||
if (previousState)
|
||||
if (previousCTCSSValid)
|
||||
threshold = m_lowThreshold;
|
||||
|
||||
m_state = value >= threshold;
|
||||
m_result |= CTS_READY;
|
||||
if (value >= threshold)
|
||||
m_result |= CTS_VALID;
|
||||
else
|
||||
m_result &= ~CTS_VALID;
|
||||
|
||||
if (previousState != m_state)
|
||||
DEBUG4("CTCSS Value / Threshold / Valid", value, threshold, m_state);
|
||||
if (previousCTCSSValid != CTCSS_VALID(m_result))
|
||||
DEBUG4("CTCSS Value / Threshold / Valid", value, threshold, CTCSS_VALID(m_result));
|
||||
|
||||
m_count = 0U;
|
||||
m_q0 = 0;
|
||||
m_q1 = 0;
|
||||
}
|
||||
|
||||
return m_state;
|
||||
return m_result;
|
||||
}
|
||||
|
||||
void CFMCTCSSRX::reset()
|
||||
{
|
||||
m_q0 = 0;
|
||||
m_q1 = 0;
|
||||
m_state = false;
|
||||
m_count = 0U;
|
||||
m_result = CTS_NONE;
|
||||
m_count = 0U;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
+13
-9
@@ -16,20 +16,27 @@
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#if defined(MODE_FM)
|
||||
|
||||
#if !defined(FMCTCSSRX_H)
|
||||
#define FMCTCSSRX_H
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
const uint8_t CTS_NONE = 0U;
|
||||
const uint8_t CTS_READY = 1U;
|
||||
const uint8_t CTS_VALID = 2U;
|
||||
|
||||
#define CTCSS_READY(a) ((a & CTS_READY) != 0)
|
||||
#define CTCSS_NOT_READY(a) ((a & CTS_READY) == 0)
|
||||
#define CTCSS_VALID(a) ((a & CTS_VALID) != 0)
|
||||
#define CTCSS_NOT_VALID(a) ((a & CTS_VALID) == 0)
|
||||
|
||||
class CFMCTCSSRX {
|
||||
public:
|
||||
CFMCTCSSRX();
|
||||
|
||||
uint8_t setParams(uint8_t frequency, uint8_t highThreshold, uint8_t lowThreshold);
|
||||
|
||||
bool process(q15_t sample);
|
||||
uint8_t process(q15_t sample);
|
||||
|
||||
void reset();
|
||||
|
||||
@@ -40,10 +47,7 @@ private:
|
||||
uint16_t m_count;
|
||||
q31_t m_q0;
|
||||
q31_t m_q1;
|
||||
bool m_state;
|
||||
uint8_t m_result;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
+3
-12
@@ -17,9 +17,6 @@
|
||||
*/
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#if defined(MODE_FM)
|
||||
|
||||
#include "Globals.h"
|
||||
#include "FMCTCSSTX.h"
|
||||
|
||||
@@ -118,17 +115,11 @@ uint8_t CFMCTCSSTX::setParams(uint8_t frequency, uint8_t level)
|
||||
return 0U;
|
||||
}
|
||||
|
||||
q15_t CFMCTCSSTX::getAudio(bool reverse)
|
||||
q15_t CFMCTCSSTX::getAudio()
|
||||
{
|
||||
q15_t sample = m_values[m_n++];
|
||||
if (m_n >= m_length)
|
||||
if(m_n >= m_length)
|
||||
m_n = 0U;
|
||||
|
||||
if (reverse)
|
||||
return -sample;
|
||||
else
|
||||
return sample;
|
||||
return sample;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
+3
-8
@@ -16,20 +16,18 @@
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#if defined(MODE_FM)
|
||||
|
||||
#if !defined(FMCTCSSTX_H)
|
||||
#define FMCTCSSTX_H
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
class CFMCTCSSTX {
|
||||
public:
|
||||
CFMCTCSSTX();
|
||||
|
||||
uint8_t setParams(uint8_t frequency, uint8_t level);
|
||||
|
||||
q15_t getAudio(bool reverse);
|
||||
q15_t getAudio();
|
||||
|
||||
private:
|
||||
q15_t* m_values;
|
||||
@@ -38,6 +36,3 @@ private:
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
+2
-9
@@ -29,11 +29,7 @@ THE SOFTWARE.
|
||||
|
||||
// based on https://raw.githubusercontent.com/berndporr/iir_fixed_point/master/DirectFormI.h
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#if defined(MODE_FM)
|
||||
|
||||
#include <cstdint>
|
||||
#include "Globals.h"
|
||||
|
||||
#ifndef DIRECTFORMI_H_
|
||||
#define DIRECTFORMI_H_
|
||||
@@ -112,7 +108,4 @@ private:
|
||||
q31_t c_a1,c_a2; // IIR
|
||||
};
|
||||
|
||||
#endif /* DIRECTFORMI_H */
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* DIRECTFORMI_H */
|
||||
@@ -1,80 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2020 by Jonathan Naylor G4KLX
|
||||
* Copyright (C) 2020 by Geoffrey Merck F4FXL - KC3FRA
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#if defined(MODE_FM)
|
||||
|
||||
#include "FMDownSampler.h"
|
||||
|
||||
CFMDownSampler::CFMDownSampler(uint16_t length) :
|
||||
m_ringBuffer(length),
|
||||
m_samplePack(0U),
|
||||
m_samplePackPointer(NULL),
|
||||
m_sampleIndex(0U)
|
||||
{
|
||||
m_samplePackPointer = (uint8_t*)&m_samplePack;
|
||||
}
|
||||
|
||||
void CFMDownSampler::addSample(q15_t sample)
|
||||
{
|
||||
uint32_t usample = uint32_t(int32_t(sample) + 2048);
|
||||
//only take one of three samples
|
||||
switch(m_sampleIndex){
|
||||
case 0:
|
||||
m_samplePack = usample << 12;
|
||||
break;
|
||||
case 3:{
|
||||
m_samplePack |= usample;
|
||||
|
||||
//we did not use MSB; skip it
|
||||
TSamplePairPack pair{m_samplePackPointer[0U], m_samplePackPointer[1U], m_samplePackPointer[2U]};
|
||||
|
||||
m_ringBuffer.put(pair);
|
||||
|
||||
m_samplePack = 0U;//reset the sample pack
|
||||
}
|
||||
break;
|
||||
default:
|
||||
//Just skip this sample
|
||||
break;
|
||||
}
|
||||
|
||||
m_sampleIndex++;
|
||||
if (m_sampleIndex >= 6U)//did we pack two samples ?
|
||||
m_sampleIndex = 0U;
|
||||
}
|
||||
|
||||
bool CFMDownSampler::getPackedData(TSamplePairPack& data)
|
||||
{
|
||||
return m_ringBuffer.get(data);
|
||||
}
|
||||
|
||||
uint16_t CFMDownSampler::getData()
|
||||
{
|
||||
return m_ringBuffer.getData();
|
||||
}
|
||||
|
||||
void CFMDownSampler::reset()
|
||||
{
|
||||
m_sampleIndex = 0U;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020 by Jonathan Naylor G4KLX
|
||||
* Copyright (C) 2020 by Geoffrey Merck F4FXL - KC3FRA
|
||||
*
|
||||
* 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
|
||||
@@ -17,19 +16,20 @@
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "RingBuffer.h"
|
||||
|
||||
template <typename TDATATYPE> CRingBuffer<TDATATYPE>::CRingBuffer(uint16_t length) :
|
||||
#include "FMDownsampleRB.h"
|
||||
|
||||
CFMDownsampleRB::CFMDownsampleRB(uint16_t length) :
|
||||
m_length(length),
|
||||
m_head(0U),
|
||||
m_tail(0U),
|
||||
m_full(false),
|
||||
m_overflow(false)
|
||||
{
|
||||
m_buffer = new TDATATYPE[length];
|
||||
m_samples = new uint8_t[length];
|
||||
}
|
||||
|
||||
template <typename TDATATYPE> uint16_t CRingBuffer<TDATATYPE>::getSpace() const
|
||||
uint16_t CFMDownsampleRB::getSpace() const
|
||||
{
|
||||
uint16_t n = 0U;
|
||||
|
||||
@@ -46,7 +46,7 @@ template <typename TDATATYPE> uint16_t CRingBuffer<TDATATYPE>::getSpace() const
|
||||
return n;
|
||||
}
|
||||
|
||||
template <typename TDATATYPE> uint16_t CRingBuffer<TDATATYPE>::getData() const
|
||||
uint16_t CFMDownsampleRB::getData() const
|
||||
{
|
||||
if (m_tail == m_head)
|
||||
return m_full ? m_length : 0U;
|
||||
@@ -56,14 +56,14 @@ template <typename TDATATYPE> uint16_t CRingBuffer<TDATATYPE>::getData() const
|
||||
return m_length - m_tail + m_head;
|
||||
}
|
||||
|
||||
template <typename TDATATYPE> bool CRingBuffer<TDATATYPE>::put(TDATATYPE item) volatile
|
||||
bool CFMDownsampleRB::put(uint8_t sample)
|
||||
{
|
||||
if (m_full) {
|
||||
m_overflow = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
m_buffer[m_head] = item;
|
||||
m_samples[m_head] = sample;
|
||||
|
||||
m_head++;
|
||||
if (m_head >= m_length)
|
||||
@@ -75,17 +75,12 @@ template <typename TDATATYPE> bool CRingBuffer<TDATATYPE>::put(TDATATYPE item) v
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename TDATATYPE> TDATATYPE CRingBuffer<TDATATYPE>::peek() const
|
||||
{
|
||||
return m_buffer[m_tail];
|
||||
}
|
||||
|
||||
template <typename TDATATYPE> bool CRingBuffer<TDATATYPE>::get(TDATATYPE& item) volatile
|
||||
bool CFMDownsampleRB::get(uint8_t& sample)
|
||||
{
|
||||
if (m_head == m_tail && !m_full)
|
||||
return false;
|
||||
|
||||
item = m_buffer[m_tail];
|
||||
sample = m_samples[m_tail];
|
||||
|
||||
m_full = false;
|
||||
|
||||
@@ -96,7 +91,7 @@ template <typename TDATATYPE> bool CRingBuffer<TDATATYPE>::get(TDATATYPE& item)
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename TDATATYPE> bool CRingBuffer<TDATATYPE>::hasOverflowed()
|
||||
bool CFMDownsampleRB::hasOverflowed()
|
||||
{
|
||||
bool overflow = m_overflow;
|
||||
|
||||
@@ -104,11 +99,3 @@ template <typename TDATATYPE> bool CRingBuffer<TDATATYPE>::hasOverflowed()
|
||||
|
||||
return overflow;
|
||||
}
|
||||
|
||||
template <typename TDATATYPE> void CRingBuffer<TDATATYPE>::reset()
|
||||
{
|
||||
m_head = 0U;
|
||||
m_tail = 0U;
|
||||
m_full = false;
|
||||
m_overflow = false;
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020 by Jonathan Naylor G4KLX
|
||||
* Copyright (C) 2020 by Geoffrey Merck F4FXL - KC3FRA
|
||||
*
|
||||
* 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
|
||||
@@ -17,8 +16,8 @@
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#if !defined(RINGBUFFER_H)
|
||||
#define RINGBUFFER_H
|
||||
#if !defined(FMDOWNSAMPLERB_H)
|
||||
#define FMDOWNSAMPLERB_H
|
||||
|
||||
#if defined(STM32F4XX)
|
||||
#include "stm32f4xx.h"
|
||||
@@ -29,7 +28,6 @@
|
||||
#include <cstddef>
|
||||
#else
|
||||
#include <Arduino.h>
|
||||
#undef PI
|
||||
#endif
|
||||
|
||||
#if defined(__SAM3X8E__) || defined(STM32F105xC)
|
||||
@@ -44,34 +42,27 @@
|
||||
|
||||
#include <arm_math.h>
|
||||
|
||||
template <typename TDATATYPE>
|
||||
class CRingBuffer {
|
||||
class CFMDownsampleRB {
|
||||
public:
|
||||
CRingBuffer(uint16_t length = 370U);
|
||||
CFMDownsampleRB(uint16_t length);
|
||||
|
||||
uint16_t getSpace() const;
|
||||
|
||||
uint16_t getData() const;
|
||||
|
||||
bool put(TDATATYPE item) volatile;
|
||||
bool put(uint8_t sample);
|
||||
|
||||
bool get(TDATATYPE& item) volatile;
|
||||
|
||||
TDATATYPE peek() const;
|
||||
bool get(uint8_t& sample);
|
||||
|
||||
bool hasOverflowed();
|
||||
|
||||
void reset();
|
||||
|
||||
private:
|
||||
uint16_t m_length;
|
||||
TDATATYPE* m_buffer;
|
||||
volatile uint16_t m_head;
|
||||
volatile uint16_t m_tail;
|
||||
volatile bool m_full;
|
||||
bool m_overflow;
|
||||
uint16_t m_length;
|
||||
volatile uint8_t* m_samples;
|
||||
volatile uint16_t m_head;
|
||||
volatile uint16_t m_tail;
|
||||
volatile bool m_full;
|
||||
bool m_overflow;
|
||||
};
|
||||
|
||||
#include "RingBuffer.impl.h"
|
||||
|
||||
#endif
|
||||
#endif
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (C) 2020 by Jonathan Naylor G4KLX
|
||||
* Copyright (C) 2020 by Geoffrey Merck F4FXL - KC3FRA
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "Config.h"
|
||||
#include "FMDownsampler.h"
|
||||
|
||||
|
||||
CFMDownsampler::CFMDownsampler(uint16_t length) :
|
||||
m_ringBuffer(length),//length might need tweaking
|
||||
m_packIndex(0),
|
||||
m_downSampleIndex(0)
|
||||
{
|
||||
m_samplePack = 0;
|
||||
}
|
||||
|
||||
void CFMDownsampler::addSample(q15_t sample)
|
||||
{
|
||||
//only take one of three samples
|
||||
if(m_downSampleIndex == 0) {
|
||||
switch(m_packIndex){
|
||||
case 0:
|
||||
m_samplePack = int32_t(sample) << 12;
|
||||
break;
|
||||
case 1:{
|
||||
m_samplePack |= int32_t(sample);
|
||||
|
||||
//we did not use MSB; skip it
|
||||
m_ringBuffer.put(m_samplePackBytes[1]);
|
||||
m_ringBuffer.put(m_samplePackBytes[2]);
|
||||
m_ringBuffer.put(m_samplePackBytes[3]);
|
||||
|
||||
m_samplePack = 0;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
//should never happen
|
||||
break;
|
||||
}
|
||||
m_packIndex++;
|
||||
if(m_packIndex >= 2)
|
||||
m_packIndex = 0;
|
||||
}
|
||||
|
||||
m_downSampleIndex++;
|
||||
if(m_downSampleIndex >= 3)
|
||||
m_downSampleIndex = 0;
|
||||
}
|
||||
@@ -17,36 +17,27 @@
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#if defined(MODE_FM)
|
||||
|
||||
#if !defined(FMDOWNSAMPLER_H)
|
||||
#define FMDOWNSAMPLER_H
|
||||
|
||||
#include "RingBuffer.h"
|
||||
#include "FMSamplePairPack.h"
|
||||
#include "Config.h"
|
||||
#include "FMDownsampleRB.h"
|
||||
|
||||
class CFMDownSampler {
|
||||
class CFMDownsampler {
|
||||
public:
|
||||
CFMDownSampler(uint16_t length);
|
||||
|
||||
CFMDownsampler(uint16_t length);
|
||||
void addSample(q15_t sample);
|
||||
|
||||
bool getPackedData(TSamplePairPack& data);
|
||||
|
||||
uint16_t getData();
|
||||
|
||||
void reset();
|
||||
inline bool getPackedData(uint8_t& data){ return m_ringBuffer.get(data); };
|
||||
inline bool hasOverflowed() { return m_ringBuffer.hasOverflowed(); };
|
||||
|
||||
private:
|
||||
CRingBuffer<TSamplePairPack> m_ringBuffer;
|
||||
uint32_t m_samplePack;
|
||||
uint8_t* m_samplePackPointer;
|
||||
uint8_t m_sampleIndex;
|
||||
CFMDownsampleRB m_ringBuffer;
|
||||
union {
|
||||
int32_t m_samplePack;
|
||||
int8_t m_samplePackBytes[4];
|
||||
};
|
||||
uint8_t m_packIndex;
|
||||
uint8_t m_downSampleIndex;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -17,9 +17,6 @@
|
||||
*/
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#if defined(MODE_FM)
|
||||
|
||||
#include "Globals.h"
|
||||
#include "FMKeyer.h"
|
||||
|
||||
@@ -217,6 +214,3 @@ bool CFMKeyer::isRunning() const
|
||||
{
|
||||
return m_poPos > 0U || m_dotPos > 0U || m_audioPos > 0U;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -16,13 +16,11 @@
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#if defined(MODE_FM)
|
||||
|
||||
#if !defined(FMKeyer_H)
|
||||
#define FMKeyer_H
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
class CFMKeyer {
|
||||
public:
|
||||
CFMKeyer();
|
||||
@@ -54,6 +52,3 @@ private:
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,133 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2020 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
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#if defined(MODE_FM)
|
||||
|
||||
#include "Globals.h"
|
||||
#include "FMNoiseSquelch.h"
|
||||
|
||||
// 4500Hz centre frequency
|
||||
const q31_t COEFF_DIV_TWO = 821806413;
|
||||
|
||||
// 400Hz bandwidth
|
||||
const uint16_t N = 24000U / 400U;
|
||||
|
||||
CFMNoiseSquelch::CFMNoiseSquelch() :
|
||||
m_highThreshold(0),
|
||||
m_lowThreshold(0),
|
||||
m_count(0U),
|
||||
m_q0(0),
|
||||
m_q1(0),
|
||||
m_state(false),
|
||||
m_validCount(0U)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CFMNoiseSquelch::setParams(uint8_t highThreshold, uint8_t lowThreshold)
|
||||
{
|
||||
m_highThreshold = q31_t(highThreshold);
|
||||
m_lowThreshold = q31_t(lowThreshold);
|
||||
}
|
||||
|
||||
bool CFMNoiseSquelch::process(q15_t sample)
|
||||
{
|
||||
//get more dynamic into the decoder by multiplying the sample by 64
|
||||
q31_t sample31 = q31_t(sample) << 6; //+ (q31_t(sample) >> 1);
|
||||
|
||||
q31_t q2 = m_q1;
|
||||
m_q1 = m_q0;
|
||||
|
||||
// Q31 multiplication, t3 = m_coeffDivTwo * 2 * m_q1
|
||||
q63_t t1 = COEFF_DIV_TWO * m_q1;
|
||||
q31_t t2 = __SSAT((t1 >> 31), 31);
|
||||
q31_t t3 = t2 * 2;
|
||||
|
||||
// m_q0 = m_coeffDivTwo * m_q1 * 2 - q2 + sample
|
||||
m_q0 = t3 - q2 + sample31;
|
||||
|
||||
m_count++;
|
||||
if (m_count == N) {
|
||||
// Q31 multiplication, t2 = m_q0 * m_q0
|
||||
q63_t t1 = q63_t(m_q0) * q63_t(m_q0);
|
||||
q31_t t2 = __SSAT((t1 >> 31), 31);
|
||||
|
||||
// Q31 multiplication, t4 = m_q0 * m_q0
|
||||
q63_t t3 = q63_t(m_q1) * q63_t(m_q1);
|
||||
q31_t t4 = __SSAT((t3 >> 31), 31);
|
||||
|
||||
// Q31 multiplication, t9 = m_q0 * m_q1 * m_coeffDivTwo * 2
|
||||
q63_t t5 = q63_t(m_q0) * q63_t(m_q1);
|
||||
q31_t t6 = __SSAT((t5 >> 31), 31);
|
||||
q63_t t7 = t6 * COEFF_DIV_TWO;
|
||||
q31_t t8 = __SSAT((t7 >> 31), 31);
|
||||
q31_t t9 = t8 * 2;
|
||||
|
||||
// value = m_q0 * m_q0 + m_q1 * m_q1 - m_q0 * m_q1 * m_coeffDivTwo * 2
|
||||
q31_t value = t2 + t4 - t9;
|
||||
|
||||
bool previousState = m_state;
|
||||
|
||||
q31_t threshold = m_highThreshold;
|
||||
if (previousState)
|
||||
threshold = m_lowThreshold;
|
||||
|
||||
if (!m_state) {
|
||||
if (value < threshold)
|
||||
m_validCount++;
|
||||
else
|
||||
m_validCount = 0U;
|
||||
}
|
||||
|
||||
if (m_state) {
|
||||
if (value >= threshold)
|
||||
m_invalidCount++;
|
||||
else
|
||||
m_invalidCount = 0U;
|
||||
}
|
||||
|
||||
m_state = m_validCount >= 10U && m_invalidCount < 10U;
|
||||
|
||||
if(previousState && !m_state)
|
||||
m_invalidCount = 0U;
|
||||
|
||||
if (previousState != m_state) {
|
||||
DEBUG4("Noise Squelch Value / Threshold / Valid", value, threshold, m_state);
|
||||
DEBUG3("Valid Count / Invalid Count", m_validCount, m_invalidCount);
|
||||
}
|
||||
|
||||
m_count = 0U;
|
||||
m_q0 = 0;
|
||||
m_q1 = 0;
|
||||
}
|
||||
|
||||
return m_state;
|
||||
}
|
||||
|
||||
void CFMNoiseSquelch::reset()
|
||||
{
|
||||
m_q0 = 0;
|
||||
m_q1 = 0;
|
||||
m_state = false;
|
||||
m_count = 0U;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2020 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
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#if defined(MODE_FM)
|
||||
|
||||
#if !defined(FMNOISESQUELCH_H)
|
||||
#define FMNOISESQUELCH_H
|
||||
|
||||
class CFMNoiseSquelch {
|
||||
public:
|
||||
CFMNoiseSquelch();
|
||||
|
||||
void setParams(uint8_t highThreshold, uint8_t lowThreshold);
|
||||
|
||||
bool process(q15_t sample);
|
||||
|
||||
void reset();
|
||||
|
||||
private:
|
||||
q31_t m_highThreshold;
|
||||
q31_t m_lowThreshold;
|
||||
uint16_t m_count;
|
||||
q31_t m_q0;
|
||||
q31_t m_q1;
|
||||
bool m_state;
|
||||
uint8_t m_validCount;
|
||||
uint8_t m_invalidCount;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
TX fifo control - Copyright (C) KI6ZUM 2015
|
||||
Copyright (C) 2015,2016,2020 by Jonathan Naylor G4KLX
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "FMRB.h"
|
||||
|
||||
CFMRB::CFMRB(uint16_t length) :
|
||||
m_length(length),
|
||||
m_head(0U),
|
||||
m_tail(0U),
|
||||
m_full(false),
|
||||
m_overflow(false)
|
||||
{
|
||||
m_samples = new q15_t[length];
|
||||
}
|
||||
|
||||
uint16_t CFMRB::getSpace() const
|
||||
{
|
||||
uint16_t n = 0U;
|
||||
|
||||
if (m_tail == m_head)
|
||||
n = m_full ? 0U : m_length;
|
||||
else if (m_tail < m_head)
|
||||
n = m_length - m_head + m_tail;
|
||||
else
|
||||
n = m_tail - m_head;
|
||||
|
||||
if (n > m_length)
|
||||
n = 0U;
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
uint16_t CFMRB::getData() const
|
||||
{
|
||||
if (m_tail == m_head)
|
||||
return m_full ? m_length : 0U;
|
||||
else if (m_tail < m_head)
|
||||
return m_head - m_tail;
|
||||
else
|
||||
return m_length - m_tail + m_head;
|
||||
}
|
||||
|
||||
bool CFMRB::put(q15_t sample)
|
||||
{
|
||||
if (m_full) {
|
||||
m_overflow = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
m_samples[m_head] = sample;
|
||||
|
||||
m_head++;
|
||||
if (m_head >= m_length)
|
||||
m_head = 0U;
|
||||
|
||||
if (m_head == m_tail)
|
||||
m_full = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CFMRB::get(q15_t& sample)
|
||||
{
|
||||
if (m_head == m_tail && !m_full)
|
||||
return false;
|
||||
|
||||
sample = m_samples[m_tail];
|
||||
|
||||
m_full = false;
|
||||
|
||||
m_tail++;
|
||||
if (m_tail >= m_length)
|
||||
m_tail = 0U;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CFMRB::hasOverflowed()
|
||||
{
|
||||
bool overflow = m_overflow;
|
||||
|
||||
m_overflow = false;
|
||||
|
||||
return overflow;
|
||||
}
|
||||
|
||||
void CFMRB::reset()
|
||||
{
|
||||
m_head = 0U;
|
||||
m_tail = 0U;
|
||||
m_full = false;
|
||||
m_overflow = false;
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
Serial fifo control - Copyright (C) KI6ZUM 2015
|
||||
Copyright (C) 2015,2016,2020 by Jonathan Naylor G4KLX
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#if !defined(FMRB_H)
|
||||
#define FMRB_H
|
||||
|
||||
#if defined(STM32F4XX)
|
||||
#include "stm32f4xx.h"
|
||||
#elif defined(STM32F7XX)
|
||||
#include "stm32f7xx.h"
|
||||
#elif defined(STM32F105xC)
|
||||
#include "stm32f1xx.h"
|
||||
#include <cstddef>
|
||||
#else
|
||||
#include <Arduino.h>
|
||||
#endif
|
||||
|
||||
#if defined(__SAM3X8E__) || defined(STM32F105xC)
|
||||
#define ARM_MATH_CM3
|
||||
#elif defined(STM32F7XX)
|
||||
#define ARM_MATH_CM7
|
||||
#elif defined(STM32F4XX) || defined(__MK20DX256__) || defined(__MK64FX512__) || defined(__MK66FX1M0__)
|
||||
#define ARM_MATH_CM4
|
||||
#else
|
||||
#error "Unknown processor type"
|
||||
#endif
|
||||
|
||||
#include <arm_math.h>
|
||||
|
||||
class CFMRB {
|
||||
public:
|
||||
CFMRB(uint16_t length);
|
||||
|
||||
uint16_t getSpace() const;
|
||||
|
||||
uint16_t getData() const;
|
||||
|
||||
bool put(q15_t sample);
|
||||
|
||||
bool get(q15_t& sample);
|
||||
|
||||
bool hasOverflowed();
|
||||
|
||||
void reset();
|
||||
|
||||
private:
|
||||
uint16_t m_length;
|
||||
volatile q15_t* m_samples;
|
||||
volatile uint16_t m_head;
|
||||
volatile uint16_t m_tail;
|
||||
volatile bool m_full;
|
||||
bool m_overflow;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2020 by Jonathan Naylor G4KLX
|
||||
* Copyright (C) 2020 by Geoffrey Merck F4FXL - KC3FRA
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#if defined(MODE_FM)
|
||||
|
||||
#if !defined(TSAMPLEPACK_H)
|
||||
#define TSAMPLEPACK_H
|
||||
|
||||
struct TSamplePairPack {
|
||||
uint8_t byte0;
|
||||
uint8_t byte1;
|
||||
uint8_t byte2;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
+7
-11
@@ -17,9 +17,6 @@
|
||||
*/
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#if defined(MODE_FM)
|
||||
|
||||
#include "Globals.h"
|
||||
#include "FMTimeout.h"
|
||||
|
||||
@@ -39,22 +36,24 @@ m_n(0U)
|
||||
|
||||
void CFMTimeout::setParams(uint8_t level)
|
||||
{
|
||||
m_level = q15_t(level * 5);
|
||||
m_level = q15_t(level * 128);
|
||||
}
|
||||
|
||||
q15_t CFMTimeout::getAudio()
|
||||
{
|
||||
q15_t sample = 0;
|
||||
q15_t sample = 0U;
|
||||
if (!m_running)
|
||||
return sample;
|
||||
|
||||
if (m_pos >= 12000U) {
|
||||
q31_t sample31 = BUSY_AUDIO[m_n] * m_level;
|
||||
sample = q15_t(__SSAT((sample31 >> 15), 16));
|
||||
if (m_pos > 12000U) {
|
||||
q31_t sample = BUSY_AUDIO[m_n] * m_level;
|
||||
sample = q15_t(__SSAT((sample >> 15), 16));
|
||||
|
||||
m_n++;
|
||||
if (m_n >= BUSY_AUDIO_LEN)
|
||||
m_n = 0U;
|
||||
} else {
|
||||
sample = 0U;
|
||||
}
|
||||
|
||||
m_pos++;
|
||||
@@ -75,6 +74,3 @@ void CFMTimeout::stop()
|
||||
{
|
||||
m_running = false;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
+2
-7
@@ -16,13 +16,11 @@
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#if defined(MODE_FM)
|
||||
|
||||
#if !defined(FMTimeout_H)
|
||||
#define FMTimeout_H
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
class CFMTimeout {
|
||||
public:
|
||||
CFMTimeout();
|
||||
@@ -42,6 +40,3 @@ private:
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -17,9 +17,6 @@
|
||||
*/
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#if defined(MODE_FM)
|
||||
|
||||
#include "Globals.h"
|
||||
#include "FMTimer.h"
|
||||
|
||||
@@ -71,6 +68,3 @@ bool CFMTimer::hasExpired() const
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -16,13 +16,11 @@
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#if defined(MODE_FM)
|
||||
|
||||
#if !defined(FMTimer_H)
|
||||
#define FMTimer_H
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
class CFMTimer {
|
||||
public:
|
||||
CFMTimer();
|
||||
@@ -47,6 +45,3 @@ private:
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
-104
@@ -1,104 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2020 by Jonathan Naylor G4KLX
|
||||
* Copyright (C) 2020 by Geoffrey Merck F4FXL - KC3FRA
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#if defined(MODE_FM)
|
||||
|
||||
#include "FMUpSampler.h"
|
||||
|
||||
const uint32_t FM_UPSAMPLE_MASK = 0x00000FFFU;
|
||||
|
||||
CFMUpSampler::CFMUpSampler() :
|
||||
m_upSampleIndex(0),
|
||||
m_pack(0U),
|
||||
m_packPointer(NULL),
|
||||
m_samples(3600U), //300ms of 12 bit 8kHz audio
|
||||
m_running(false)
|
||||
{
|
||||
m_packPointer = (uint8_t*)&m_pack;
|
||||
}
|
||||
|
||||
void CFMUpSampler::reset()
|
||||
{
|
||||
m_upSampleIndex = 0U;
|
||||
m_pack = 0U;
|
||||
m_samples.reset();
|
||||
m_running = false;
|
||||
}
|
||||
|
||||
void CFMUpSampler::addData(const uint8_t* data, uint16_t length)
|
||||
{
|
||||
TSamplePairPack* packPointer = (TSamplePairPack*)data;
|
||||
TSamplePairPack* packPointerEnd = packPointer + (length / 3U);
|
||||
while(packPointer != packPointerEnd) {
|
||||
m_samples.put(*packPointer);
|
||||
packPointer++;
|
||||
}
|
||||
if(!m_running)
|
||||
m_running = m_samples.getData() > 300U;//75ms of audio
|
||||
}
|
||||
|
||||
bool CFMUpSampler::getSample(q15_t& sample)
|
||||
{
|
||||
if(!m_running)
|
||||
return false;
|
||||
|
||||
switch (m_upSampleIndex)
|
||||
{
|
||||
case 0: {
|
||||
TSamplePairPack pairPack;
|
||||
if(!m_samples.get(pairPack)) {
|
||||
m_running = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
m_pack = 0U;
|
||||
m_packPointer = (uint8_t*)&m_pack;
|
||||
|
||||
m_packPointer[0U] = pairPack.byte0;
|
||||
m_packPointer[1U] = pairPack.byte1;
|
||||
m_packPointer[2U] = pairPack.byte2;
|
||||
|
||||
sample = q15_t(m_pack >> 12) - 2048;
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
sample = q15_t(m_pack & FM_UPSAMPLE_MASK) - 2048;
|
||||
break;
|
||||
default:
|
||||
sample = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
m_upSampleIndex++;
|
||||
if(m_upSampleIndex >= 6U)
|
||||
m_upSampleIndex = 0U;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
uint16_t CFMUpSampler::getSpace() const
|
||||
{
|
||||
//return available space in bytes
|
||||
return m_samples.getSpace() * sizeof(TSamplePairPack);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2020 by Jonathan Naylor G4KLX
|
||||
* Copyright (C) 2020 by Geoffrey Merck F4FXL - KC3FRA
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#if defined(MODE_FM)
|
||||
|
||||
#if !defined(FMUPSAMPLER_H)
|
||||
#define FMUPSAMPLER_H
|
||||
|
||||
#include "RingBuffer.h"
|
||||
#include "FMSamplePairPack.h"
|
||||
|
||||
class CFMUpSampler {
|
||||
public:
|
||||
CFMUpSampler();
|
||||
|
||||
void reset();
|
||||
|
||||
void addData(const uint8_t* data, uint16_t length);
|
||||
|
||||
bool getSample(q15_t& sample);
|
||||
|
||||
uint16_t getSpace() const;
|
||||
|
||||
private:
|
||||
uint8_t m_upSampleIndex;
|
||||
uint32_t m_pack;
|
||||
uint8_t * m_packPointer;
|
||||
CRingBuffer<TSamplePairPack> m_samples;
|
||||
bool m_running;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
#include "STM32Utils.h"
|
||||
#else
|
||||
#include <Arduino.h>
|
||||
#undef PI //Undefine PI to get rid of annoying warning as it is also defined in arm_math.h.
|
||||
#endif
|
||||
|
||||
#if defined(__SAM3X8E__) || defined(STM32F105xC)
|
||||
@@ -51,9 +50,7 @@ enum MMDVM_STATE {
|
||||
STATE_P25 = 4,
|
||||
STATE_NXDN = 5,
|
||||
STATE_POCSAG = 6,
|
||||
STATE_M17 = 7,
|
||||
STATE_FM = 10,
|
||||
STATE_AX25 = 11,
|
||||
|
||||
// Dummy states start at 90
|
||||
STATE_NXDNCAL1K = 91,
|
||||
@@ -87,8 +84,6 @@ enum MMDVM_STATE {
|
||||
#include "YSFTX.h"
|
||||
#include "P25RX.h"
|
||||
#include "P25TX.h"
|
||||
#include "M17RX.h"
|
||||
#include "M17TX.h"
|
||||
#include "NXDNRX.h"
|
||||
#include "NXDNTX.h"
|
||||
#include "POCSAGTX.h"
|
||||
@@ -101,8 +96,6 @@ enum MMDVM_STATE {
|
||||
#include "CalPOCSAG.h"
|
||||
#include "CalRSSI.h"
|
||||
#include "CWIdTX.h"
|
||||
#include "AX25RX.h"
|
||||
#include "AX25TX.h"
|
||||
#include "Debug.h"
|
||||
#include "IO.h"
|
||||
#include "FM.h"
|
||||
@@ -130,9 +123,7 @@ extern bool m_ysfEnable;
|
||||
extern bool m_p25Enable;
|
||||
extern bool m_nxdnEnable;
|
||||
extern bool m_pocsagEnable;
|
||||
extern bool m_m17Enable;
|
||||
extern bool m_fmEnable;
|
||||
extern bool m_ax25Enable;
|
||||
|
||||
extern bool m_duplex;
|
||||
|
||||
@@ -142,15 +133,9 @@ extern bool m_dcd;
|
||||
extern CSerialPort serial;
|
||||
extern CIO io;
|
||||
|
||||
#if defined(MODE_DSTAR)
|
||||
extern CDStarRX dstarRX;
|
||||
extern CDStarTX dstarTX;
|
||||
|
||||
extern CCalDStarRX calDStarRX;
|
||||
extern CCalDStarTX calDStarTX;
|
||||
#endif
|
||||
|
||||
#if defined(MODE_DMR)
|
||||
extern CDMRIdleRX dmrIdleRX;
|
||||
extern CDMRRX dmrRX;
|
||||
extern CDMRTX dmrTX;
|
||||
@@ -158,51 +143,28 @@ extern CDMRTX dmrTX;
|
||||
extern CDMRDMORX dmrDMORX;
|
||||
extern CDMRDMOTX dmrDMOTX;
|
||||
|
||||
extern CCalDMR calDMR;
|
||||
#endif
|
||||
|
||||
#if defined(MODE_YSF)
|
||||
extern CYSFRX ysfRX;
|
||||
extern CYSFTX ysfTX;
|
||||
#endif
|
||||
|
||||
#if defined(MODE_P25)
|
||||
extern CP25RX p25RX;
|
||||
extern CP25TX p25TX;
|
||||
|
||||
extern CCalP25 calP25;
|
||||
#endif
|
||||
|
||||
#if defined(MODE_NXDN)
|
||||
extern CNXDNRX nxdnRX;
|
||||
extern CNXDNTX nxdnTX;
|
||||
|
||||
extern CCalNXDN calNXDN;
|
||||
#endif
|
||||
extern CPOCSAGTX pocsagTX;
|
||||
|
||||
#if defined(MODE_POCSAG)
|
||||
extern CPOCSAGTX pocsagTX;
|
||||
extern CCalPOCSAG calPOCSAG;
|
||||
#endif
|
||||
extern CFM fm;
|
||||
|
||||
#if defined(MODE_M17)
|
||||
extern CM17RX m17RX;
|
||||
extern CM17TX m17TX;
|
||||
#endif
|
||||
|
||||
#if defined(MODE_FM)
|
||||
extern CFM fm;
|
||||
extern CCalFM calFM;
|
||||
#endif
|
||||
|
||||
#if defined(MODE_AX25)
|
||||
extern CAX25RX ax25RX;
|
||||
extern CAX25TX ax25TX;
|
||||
#endif
|
||||
|
||||
extern CCalRSSI calRSSI;
|
||||
extern CCalDStarRX calDStarRX;
|
||||
extern CCalDStarTX calDStarTX;
|
||||
extern CCalDMR calDMR;
|
||||
extern CCalFM calFM;
|
||||
extern CCalP25 calP25;
|
||||
extern CCalNXDN calNXDN;
|
||||
extern CCalPOCSAG calPOCSAG;
|
||||
extern CCalRSSI calRSSI;
|
||||
|
||||
extern CCWIdTX cwIdTX;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -182,7 +182,7 @@ void CSerialPort::beginInt(uint8_t n, int speed)
|
||||
}
|
||||
}
|
||||
|
||||
int CSerialPort::availableForReadInt(uint8_t n)
|
||||
int CSerialPort::availableInt(uint8_t n)
|
||||
{
|
||||
switch (n) {
|
||||
case 1U:
|
||||
@@ -22,59 +22,16 @@
|
||||
#include "Globals.h"
|
||||
#include "IO.h"
|
||||
|
||||
#if defined(USE_DCBLOCKER)
|
||||
// Generated using [b, a] = butter(1, 0.001) in MATLAB
|
||||
static q31_t DC_FILTER[] = {3367972, 0, 3367972, 0, 2140747704, 0}; // {b0, 0, b1, b2, -a1, -a2}
|
||||
const uint32_t DC_FILTER_STAGES = 1U; // One Biquad stage
|
||||
#endif
|
||||
|
||||
#if defined(MODE_DMR) || defined(MODE_YSF)
|
||||
// Generated using rcosdesign(0.2, 8, 5, 'sqrt') in MATLAB
|
||||
static q15_t RRC_0_2_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 RRC_0_2_FILTER_LEN = 42U;
|
||||
#endif
|
||||
|
||||
#if defined(MODE_M17)
|
||||
// Generated using rcosdesign(0.5, 8, 5, 'sqrt') in MATLAB
|
||||
static q15_t RRC_0_5_FILTER[] = {-147, -88, 72, 220, 223, 46, -197, -285, -79, 334, 623, 390, -498, -1691, -2363, -1556, 1284, 5872, 11033,
|
||||
15109, 16656, 15109, 11033, 5872, 1284, -1556, -2363, -1691, -498, 390, 623, 334, -79, -285, -197, 46, 223,
|
||||
220, 72, -88, -147, 0};
|
||||
const uint16_t RRC_0_5_FILTER_LEN = 42U;
|
||||
#endif
|
||||
|
||||
#if defined(MODE_NXDN)
|
||||
#if defined(USE_NXDN_BOXCAR)
|
||||
// One symbol boxcar filter
|
||||
static q15_t BOXCAR10_FILTER[] = {6000, 6000, 6000, 6000, 6000, 6000, 6000, 6000, 6000, 6000};
|
||||
const uint16_t BOXCAR10_FILTER_LEN = 10U;
|
||||
#else
|
||||
// Generated using rcosdesign(0.2, 8, 10, 'sqrt') in MATLAB
|
||||
static q15_t NXDN_0_2_FILTER[] = {284, 198, 73, -78, -240, -393, -517, -590, -599, -533, -391, -181, 79, 364, 643, 880, 1041, 1097, 1026, 819,
|
||||
483, 39, -477, -1016, -1516, -1915, -2150, -2164, -1914, -1375, -545, 557, 1886, 3376, 4946, 6502, 7946, 9184,
|
||||
10134, 10731, 10935, 10731, 10134, 9184, 7946, 6502, 4946, 3376, 1886, 557, -545, -1375, -1914, -2164, -2150,
|
||||
-1915, -1516, -1016, -477, 39, 483, 819, 1026, 1097, 1041, 880, 643, 364, 79, -181, -391, -533, -599, -590,
|
||||
-517, -393, -240, -78, 73, 198, 284, 0};
|
||||
const uint16_t NXDN_0_2_FILTER_LEN = 82U;
|
||||
|
||||
static q15_t NXDN_ISINC_FILTER[] = {790, -1085, -1073, -553, 747, 2341, 3156, 2152, -893, -4915, -7834, -7536, -3102, 4441, 12354, 17394, 17394,
|
||||
12354, 4441, -3102, -7536, -7834, -4915, -893, 2152, 3156, 2341, 747, -553, -1073, -1085, 790};
|
||||
const uint16_t NXDN_ISINC_FILTER_LEN = 32U;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(MODE_DSTAR)
|
||||
// Generated using gaussfir(0.5, 4, 5) in MATLAB
|
||||
static q15_t GAUSSIAN_0_5_FILTER[] = {8, 104, 760, 3158, 7421, 9866, 7421, 3158, 760, 104, 8, 0};
|
||||
const uint16_t GAUSSIAN_0_5_FILTER_LEN = 12U;
|
||||
#endif
|
||||
|
||||
#if defined(MODE_P25)
|
||||
// One symbol boxcar filter
|
||||
// One symbol boxcar filters
|
||||
static q15_t BOXCAR5_FILTER[] = {12000, 12000, 12000, 12000, 12000, 0};
|
||||
const uint16_t BOXCAR5_FILTER_LEN = 6U;
|
||||
#endif
|
||||
|
||||
static q15_t BOXCAR10_FILTER[] = {6000, 6000, 6000, 6000, 6000, 6000, 6000, 6000, 6000, 6000};
|
||||
const uint16_t BOXCAR10_FILTER_LEN = 10U;
|
||||
|
||||
const uint16_t DC_OFFSET = 2048U;
|
||||
|
||||
@@ -83,37 +40,12 @@ m_started(false),
|
||||
m_rxBuffer(RX_RINGBUFFER_SIZE),
|
||||
m_txBuffer(TX_RINGBUFFER_SIZE),
|
||||
m_rssiBuffer(RX_RINGBUFFER_SIZE),
|
||||
#if defined(USE_DCBLOCKER)
|
||||
m_dcFilter(),
|
||||
m_dcState(),
|
||||
#endif
|
||||
#if defined(MODE_DSTAR)
|
||||
m_gaussianFilter(),
|
||||
m_gaussianState(),
|
||||
#endif
|
||||
#if defined(MODE_DMR) || defined(MODE_YSF)
|
||||
m_rrc02Filter(),
|
||||
m_rrc02State(),
|
||||
#endif
|
||||
#if defined(MODE_P25)
|
||||
m_boxcar5Filter(),
|
||||
m_boxcar5State(),
|
||||
#endif
|
||||
#if defined(MODE_NXDN)
|
||||
#if defined(USE_NXDN_BOXCAR)
|
||||
m_boxcar10Filter(),
|
||||
m_boxcar5State(),
|
||||
m_boxcar10State(),
|
||||
#else
|
||||
m_nxdnFilter(),
|
||||
m_nxdnISincFilter(),
|
||||
m_nxdnState(),
|
||||
m_nxdnISincState(),
|
||||
#endif
|
||||
#endif
|
||||
#if defined(MODE_M17)
|
||||
m_rrc05Filter(),
|
||||
m_rrc05State(),
|
||||
#endif
|
||||
m_pttInvert(false),
|
||||
m_rxLevel(128 * 128),
|
||||
m_cwIdTXLevel(128 * 128),
|
||||
@@ -122,13 +54,10 @@ m_dmrTXLevel(128 * 128),
|
||||
m_ysfTXLevel(128 * 128),
|
||||
m_p25TXLevel(128 * 128),
|
||||
m_nxdnTXLevel(128 * 128),
|
||||
m_m17TXLevel(128 * 128),
|
||||
m_pocsagTXLevel(128 * 128),
|
||||
m_fmTXLevel(128 * 128),
|
||||
m_ax25TXLevel(128 * 128),
|
||||
m_rxDCOffset(DC_OFFSET),
|
||||
m_txDCOffset(DC_OFFSET),
|
||||
m_useCOSAsLockout(false),
|
||||
m_ledCount(0U),
|
||||
m_ledValue(true),
|
||||
m_detect(false),
|
||||
@@ -137,61 +66,22 @@ m_dacOverflow(0U),
|
||||
m_watchdog(0U),
|
||||
m_lockout(false)
|
||||
{
|
||||
#if defined(USE_DCBLOCKER)
|
||||
::memset(m_dcState, 0x00U, 4U * sizeof(q31_t));
|
||||
::memset(m_boxcar5State, 0x00U, 30U * sizeof(q15_t));
|
||||
::memset(m_boxcar10State, 0x00U, 40U * sizeof(q15_t));
|
||||
::memset(m_dcState, 0x00U, 4U * sizeof(q31_t));
|
||||
|
||||
m_dcFilter.numStages = DC_FILTER_STAGES;
|
||||
m_dcFilter.pState = m_dcState;
|
||||
m_dcFilter.pCoeffs = DC_FILTER;
|
||||
m_dcFilter.postShift = 0;
|
||||
#endif
|
||||
|
||||
#if defined(MODE_DSTAR)
|
||||
::memset(m_gaussianState, 0x00U, 40U * sizeof(q15_t));
|
||||
m_gaussianFilter.numTaps = GAUSSIAN_0_5_FILTER_LEN;
|
||||
m_gaussianFilter.pState = m_gaussianState;
|
||||
m_gaussianFilter.pCoeffs = GAUSSIAN_0_5_FILTER;
|
||||
#endif
|
||||
|
||||
#if defined(MODE_DMR) || defined(MODE_YSF)
|
||||
::memset(m_rrc02State, 0x00U, 70U * sizeof(q15_t));
|
||||
m_rrc02Filter.numTaps = RRC_0_2_FILTER_LEN;
|
||||
m_rrc02Filter.pState = m_rrc02State;
|
||||
m_rrc02Filter.pCoeffs = RRC_0_2_FILTER;
|
||||
#endif
|
||||
|
||||
#if defined(MODE_P25)
|
||||
::memset(m_boxcar5State, 0x00U, 30U * sizeof(q15_t));
|
||||
m_boxcar5Filter.numTaps = BOXCAR5_FILTER_LEN;
|
||||
m_boxcar5Filter.pState = m_boxcar5State;
|
||||
m_boxcar5Filter.pCoeffs = BOXCAR5_FILTER;
|
||||
#endif
|
||||
|
||||
#if defined(MODE_NXDN)
|
||||
#if defined(USE_NXDN_BOXCAR)
|
||||
::memset(m_boxcar10State, 0x00U, 40U * sizeof(q15_t));
|
||||
m_boxcar10Filter.numTaps = BOXCAR10_FILTER_LEN;
|
||||
m_boxcar10Filter.pState = m_boxcar10State;
|
||||
m_boxcar10Filter.pCoeffs = BOXCAR10_FILTER;
|
||||
#else
|
||||
::memset(m_nxdnState, 0x00U, 110U * sizeof(q15_t));
|
||||
::memset(m_nxdnISincState, 0x00U, 60U * sizeof(q15_t));
|
||||
|
||||
m_nxdnFilter.numTaps = NXDN_0_2_FILTER_LEN;
|
||||
m_nxdnFilter.pState = m_nxdnState;
|
||||
m_nxdnFilter.pCoeffs = NXDN_0_2_FILTER;
|
||||
|
||||
m_nxdnISincFilter.numTaps = NXDN_ISINC_FILTER_LEN;
|
||||
m_nxdnISincFilter.pState = m_nxdnISincState;
|
||||
m_nxdnISincFilter.pCoeffs = NXDN_ISINC_FILTER;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(MODE_M17)
|
||||
::memset(m_rrc05State, 0x00U, 70U * sizeof(q15_t));
|
||||
m_rrc05Filter.numTaps = RRC_0_5_FILTER_LEN;
|
||||
m_rrc05Filter.pState = m_rrc05State;
|
||||
m_rrc05Filter.pCoeffs = RRC_0_5_FILTER;
|
||||
#endif
|
||||
|
||||
initInt();
|
||||
|
||||
@@ -202,7 +92,7 @@ void CIO::selfTest()
|
||||
{
|
||||
bool ledValue = false;
|
||||
|
||||
for (uint8_t i = 0U; i < 6U; i++) {
|
||||
for (uint8_t i = 0; i < 6; i++) {
|
||||
ledValue = !ledValue;
|
||||
|
||||
// We exclude PTT to avoid trigger the transmitter
|
||||
@@ -213,40 +103,21 @@ void CIO::selfTest()
|
||||
setDMRInt(ledValue);
|
||||
setYSFInt(ledValue);
|
||||
setP25Int(ledValue);
|
||||
#if !defined(USE_ALTERNATE_NXDN_LEDS)
|
||||
setNXDNInt(ledValue);
|
||||
#endif
|
||||
#if !defined(USE_ALTERNATE_M17_LEDS)
|
||||
setM17Int(ledValue);
|
||||
#endif
|
||||
#if !defined(USE_ALTERNATE_POCSAG_LEDS)
|
||||
setPOCSAGInt(ledValue);
|
||||
#endif
|
||||
#if !defined(USE_ALTERNATE_FM_LEDS)
|
||||
setFMInt(ledValue);
|
||||
#endif
|
||||
#endif
|
||||
delayInt(250);
|
||||
}
|
||||
|
||||
#if defined(MODE_LEDS)
|
||||
setDStarInt(false);
|
||||
setDStarInt(true);
|
||||
setDMRInt(false);
|
||||
setYSFInt(false);
|
||||
setP25Int(false);
|
||||
#if !defined(USE_ALTERNATE_NXDN_LEDS)
|
||||
setNXDNInt(false);
|
||||
#endif
|
||||
#if !defined(USE_ALTERNATE_M17_LEDS)
|
||||
setM17Int(false);
|
||||
#endif
|
||||
#if !defined(USE_ALTERNATE_POCSAG_LEDS)
|
||||
setPOCSAGInt(false);
|
||||
#endif
|
||||
#if !defined(USE_ALTERNATE_FM_LEDS)
|
||||
setFMInt(false);
|
||||
#endif
|
||||
setDStarInt(true);
|
||||
|
||||
delayInt(250);
|
||||
setDMRInt(true);
|
||||
@@ -262,11 +133,6 @@ void CIO::selfTest()
|
||||
setNXDNInt(true);
|
||||
#endif
|
||||
|
||||
#if !defined(USE_ALTERNATE_M17_LEDS)
|
||||
delayInt(250);
|
||||
setM17Int(true);
|
||||
#endif
|
||||
|
||||
#if !defined(USE_ALTERNATE_POCSAG_LEDS)
|
||||
delayInt(250);
|
||||
setPOCSAGInt(true);
|
||||
@@ -285,11 +151,6 @@ void CIO::selfTest()
|
||||
setPOCSAGInt(false);
|
||||
#endif
|
||||
|
||||
#if !defined(USE_ALTERNATE_M17_LEDS)
|
||||
delayInt(250);
|
||||
setM17Int(false);
|
||||
#endif
|
||||
|
||||
#if !defined(USE_ALTERNATE_NXDN_LEDS)
|
||||
delayInt(250);
|
||||
setNXDNInt(false);
|
||||
@@ -318,7 +179,7 @@ void CIO::start()
|
||||
|
||||
m_started = true;
|
||||
|
||||
setMode(STATE_IDLE);
|
||||
setMode();
|
||||
}
|
||||
|
||||
void CIO::process()
|
||||
@@ -327,12 +188,11 @@ void CIO::process()
|
||||
if (m_started) {
|
||||
// Two seconds timeout
|
||||
if (m_watchdog >= 48000U) {
|
||||
if (m_modemState == STATE_DSTAR || m_modemState == STATE_DMR || m_modemState == STATE_YSF || m_modemState == STATE_P25 || m_modemState == STATE_NXDN || m_modemState == STATE_M17 || m_modemState == STATE_POCSAG) {
|
||||
#if defined(MODE_DMR)
|
||||
if (m_modemState == STATE_DSTAR || m_modemState == STATE_DMR || m_modemState == STATE_YSF || m_modemState == STATE_P25 || m_modemState == STATE_NXDN || m_modemState == STATE_POCSAG) {
|
||||
if (m_modemState == STATE_DMR && m_tx)
|
||||
dmrTX.setStart(false);
|
||||
#endif
|
||||
setMode(STATE_IDLE);
|
||||
m_modemState = STATE_IDLE;
|
||||
setMode();
|
||||
}
|
||||
|
||||
m_watchdog = 0U;
|
||||
@@ -356,14 +216,14 @@ void CIO::process()
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_useCOSAsLockout)
|
||||
m_lockout = getCOSInt();
|
||||
#if defined(USE_COS_AS_LOCKOUT)
|
||||
m_lockout = getCOSInt();
|
||||
#endif
|
||||
|
||||
// Switch off the transmitter if needed
|
||||
if (m_txBuffer.getData() == 0U && m_tx) {
|
||||
m_tx = false;
|
||||
setPTTInt(m_pttInvert ? true : false);
|
||||
DEBUG1("TX OFF");
|
||||
}
|
||||
|
||||
if (m_rxBuffer.getData() >= RX_BLOCK_SIZE) {
|
||||
@@ -372,16 +232,15 @@ void CIO::process()
|
||||
uint16_t rssi[RX_BLOCK_SIZE];
|
||||
|
||||
for (uint16_t i = 0U; i < RX_BLOCK_SIZE; i++) {
|
||||
TSample sample;
|
||||
m_rxBuffer.get(sample);
|
||||
control[i] = sample.control;
|
||||
uint16_t sample;
|
||||
m_rxBuffer.get(sample, control[i]);
|
||||
m_rssiBuffer.get(rssi[i]);
|
||||
|
||||
// Detect ADC overflow
|
||||
if (m_detect && (sample.sample == 0U || sample.sample == 4095U))
|
||||
if (m_detect && (sample == 0U || sample == 4095U))
|
||||
m_adcOverflow++;
|
||||
|
||||
q15_t res1 = q15_t(sample.sample) - m_rxDCOffset;
|
||||
q15_t res1 = q15_t(sample) - m_rxDCOffset;
|
||||
q31_t res2 = res1 * m_rxLevel;
|
||||
samples[i] = q15_t(__SSAT((res2 >> 15), 16));
|
||||
}
|
||||
@@ -409,89 +268,37 @@ void CIO::process()
|
||||
#endif
|
||||
|
||||
if (m_modemState == STATE_IDLE) {
|
||||
#if defined(MODE_DSTAR)
|
||||
if (m_dstarEnable) {
|
||||
q15_t GMSKVals[RX_BLOCK_SIZE];
|
||||
#if defined(USE_DCBLOCKER)
|
||||
::arm_fir_fast_q15(&m_gaussianFilter, dcSamples, GMSKVals, RX_BLOCK_SIZE);
|
||||
#else
|
||||
::arm_fir_fast_q15(&m_gaussianFilter, samples, GMSKVals, RX_BLOCK_SIZE);
|
||||
#endif
|
||||
dstarRX.samples(GMSKVals, rssi, RX_BLOCK_SIZE);
|
||||
}
|
||||
#endif
|
||||
if (m_dstarEnable || m_dmrEnable || m_ysfEnable || m_p25Enable) {
|
||||
q15_t vals[RX_BLOCK_SIZE];
|
||||
::arm_fir_fast_q15(&m_boxcar5Filter, samples, vals, RX_BLOCK_SIZE);
|
||||
|
||||
#if defined(MODE_P25)
|
||||
if (m_p25Enable) {
|
||||
q15_t P25Vals[RX_BLOCK_SIZE];
|
||||
#if defined(USE_DCBLOCKER)
|
||||
::arm_fir_fast_q15(&m_boxcar5Filter, dcSamples, P25Vals, RX_BLOCK_SIZE);
|
||||
#else
|
||||
::arm_fir_fast_q15(&m_boxcar5Filter, samples, P25Vals, RX_BLOCK_SIZE);
|
||||
#endif
|
||||
p25RX.samples(P25Vals, rssi, RX_BLOCK_SIZE);
|
||||
if (m_dstarEnable)
|
||||
dstarRX.samples(vals, rssi, RX_BLOCK_SIZE);
|
||||
|
||||
if (m_p25Enable)
|
||||
p25RX.samples(vals, rssi, RX_BLOCK_SIZE);
|
||||
|
||||
if (m_ysfEnable)
|
||||
ysfRX.samples(vals, rssi, RX_BLOCK_SIZE);
|
||||
|
||||
if (m_dmrEnable) {
|
||||
if (m_duplex)
|
||||
dmrIdleRX.samples(vals, RX_BLOCK_SIZE);
|
||||
else
|
||||
dmrDMORX.samples(vals, rssi, RX_BLOCK_SIZE);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(MODE_NXDN)
|
||||
if (m_nxdnEnable) {
|
||||
q15_t NXDNVals[RX_BLOCK_SIZE];
|
||||
#if defined(USE_NXDN_BOXCAR)
|
||||
q15_t vals[RX_BLOCK_SIZE];
|
||||
#if defined(USE_DCBLOCKER)
|
||||
::arm_fir_fast_q15(&m_boxcar10Filter, dcSamples, NXDNVals, RX_BLOCK_SIZE);
|
||||
::arm_fir_fast_q15(&m_boxcar10Filter, dcSamples, vals, RX_BLOCK_SIZE);
|
||||
#else
|
||||
::arm_fir_fast_q15(&m_boxcar10Filter, samples, NXDNVals, RX_BLOCK_SIZE);
|
||||
::arm_fir_fast_q15(&m_boxcar10Filter, samples, vals, RX_BLOCK_SIZE);
|
||||
#endif
|
||||
#else
|
||||
q15_t NXDNValsTmp[RX_BLOCK_SIZE];
|
||||
#if defined(USE_DCBLOCKER)
|
||||
::arm_fir_fast_q15(&m_nxdnFilter, dcSamples, NXDNValsTmp, RX_BLOCK_SIZE);
|
||||
#else
|
||||
::arm_fir_fast_q15(&m_nxdnFilter, samples, NXDNValsTmp, RX_BLOCK_SIZE);
|
||||
#endif
|
||||
::arm_fir_fast_q15(&m_nxdnISincFilter, NXDNValsTmp, NXDNVals, RX_BLOCK_SIZE);
|
||||
#endif
|
||||
nxdnRX.samples(NXDNVals, rssi, RX_BLOCK_SIZE);
|
||||
nxdnRX.samples(vals, rssi, RX_BLOCK_SIZE);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(MODE_DMR)
|
||||
if (m_dmrEnable) {
|
||||
q15_t DMRVals[RX_BLOCK_SIZE];
|
||||
::arm_fir_fast_q15(&m_rrc02Filter, samples, DMRVals, RX_BLOCK_SIZE);
|
||||
|
||||
if (m_duplex)
|
||||
dmrIdleRX.samples(DMRVals, RX_BLOCK_SIZE);
|
||||
else
|
||||
dmrDMORX.samples(DMRVals, rssi, RX_BLOCK_SIZE);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(MODE_YSF)
|
||||
if (m_ysfEnable) {
|
||||
q15_t YSFVals[RX_BLOCK_SIZE];
|
||||
#if defined(USE_DCBLOCKER)
|
||||
::arm_fir_fast_q15(&m_rrc02Filter, dcSamples, YSFVals, RX_BLOCK_SIZE);
|
||||
#else
|
||||
::arm_fir_fast_q15(&m_rrc02Filter, samples, YSFVals, RX_BLOCK_SIZE);
|
||||
#endif
|
||||
ysfRX.samples(YSFVals, rssi, RX_BLOCK_SIZE);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(MODE_M17)
|
||||
if (m_m17Enable) {
|
||||
q15_t RRCVals[RX_BLOCK_SIZE];
|
||||
#if defined(USE_DCBLOCKER)
|
||||
::arm_fir_fast_q15(&m_rrc05Filter, dcSamples, RRCVals, RX_BLOCK_SIZE);
|
||||
#else
|
||||
::arm_fir_fast_q15(&m_rrc05Filter, samples, RRCVals, RX_BLOCK_SIZE);
|
||||
#endif
|
||||
m17RX.samples(RRCVals, rssi, RX_BLOCK_SIZE);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(MODE_FM)
|
||||
if (m_fmEnable) {
|
||||
bool cos = getCOSInt();
|
||||
#if defined(USE_DCBLOCKER)
|
||||
@@ -500,149 +307,78 @@ void CIO::process()
|
||||
fm.samples(cos, samples, RX_BLOCK_SIZE);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(MODE_FM) && defined(MODE_AX25)
|
||||
if (m_ax25Enable) {
|
||||
#if defined(USE_DCBLOCKER)
|
||||
ax25RX.samples(dcSamples, RX_BLOCK_SIZE);
|
||||
#else
|
||||
ax25RX.samples(samples, RX_BLOCK_SIZE);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(MODE_DSTAR)
|
||||
else if (m_modemState == STATE_DSTAR) {
|
||||
} else if (m_modemState == STATE_DSTAR) {
|
||||
if (m_dstarEnable) {
|
||||
q15_t GMSKVals[RX_BLOCK_SIZE];
|
||||
q15_t vals[RX_BLOCK_SIZE];
|
||||
#if defined(USE_DCBLOCKER)
|
||||
::arm_fir_fast_q15(&m_gaussianFilter, dcSamples, GMSKVals, RX_BLOCK_SIZE);
|
||||
::arm_fir_fast_q15(&m_boxcar5Filter, dcSamples, vals, RX_BLOCK_SIZE);
|
||||
#else
|
||||
::arm_fir_fast_q15(&m_gaussianFilter, samples, GMSKVals, RX_BLOCK_SIZE);
|
||||
#endif
|
||||
dstarRX.samples(GMSKVals, rssi, RX_BLOCK_SIZE);
|
||||
}
|
||||
}
|
||||
::arm_fir_fast_q15(&m_boxcar5Filter, samples, vals, RX_BLOCK_SIZE);
|
||||
#endif
|
||||
|
||||
#if defined(MODE_DMR)
|
||||
else if (m_modemState == STATE_DMR) {
|
||||
dstarRX.samples(vals, rssi, RX_BLOCK_SIZE);
|
||||
}
|
||||
} else if (m_modemState == STATE_DMR) {
|
||||
if (m_dmrEnable) {
|
||||
q15_t DMRVals[RX_BLOCK_SIZE];
|
||||
::arm_fir_fast_q15(&m_rrc02Filter, samples, DMRVals, RX_BLOCK_SIZE);
|
||||
q15_t vals[RX_BLOCK_SIZE];
|
||||
::arm_fir_fast_q15(&m_boxcar5Filter, samples, vals, RX_BLOCK_SIZE);
|
||||
|
||||
if (m_duplex) {
|
||||
// If the transmitter isn't on, use the DMR idle RX to detect the wakeup CSBKs
|
||||
if (m_tx)
|
||||
dmrRX.samples(DMRVals, rssi, control, RX_BLOCK_SIZE);
|
||||
dmrRX.samples(vals, rssi, control, RX_BLOCK_SIZE);
|
||||
else
|
||||
dmrIdleRX.samples(DMRVals, RX_BLOCK_SIZE);
|
||||
dmrIdleRX.samples(vals, RX_BLOCK_SIZE);
|
||||
} else {
|
||||
dmrDMORX.samples(DMRVals, rssi, RX_BLOCK_SIZE);
|
||||
dmrDMORX.samples(vals, rssi, RX_BLOCK_SIZE);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(MODE_YSF)
|
||||
else if (m_modemState == STATE_YSF) {
|
||||
} else if (m_modemState == STATE_YSF) {
|
||||
if (m_ysfEnable) {
|
||||
q15_t YSFVals[RX_BLOCK_SIZE];
|
||||
q15_t vals[RX_BLOCK_SIZE];
|
||||
#if defined(USE_DCBLOCKER)
|
||||
::arm_fir_fast_q15(&m_rrc02Filter, dcSamples, YSFVals, RX_BLOCK_SIZE);
|
||||
::arm_fir_fast_q15(&m_boxcar5Filter, dcSamples, vals, RX_BLOCK_SIZE);
|
||||
#else
|
||||
::arm_fir_fast_q15(&m_rrc02Filter, samples, YSFVals, RX_BLOCK_SIZE);
|
||||
::arm_fir_fast_q15(&m_boxcar5Filter, samples, vals, RX_BLOCK_SIZE);
|
||||
#endif
|
||||
ysfRX.samples(YSFVals, rssi, RX_BLOCK_SIZE);
|
||||
ysfRX.samples(vals, rssi, RX_BLOCK_SIZE);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(MODE_P25)
|
||||
else if (m_modemState == STATE_P25) {
|
||||
} else if (m_modemState == STATE_P25) {
|
||||
if (m_p25Enable) {
|
||||
q15_t P25Vals[RX_BLOCK_SIZE];
|
||||
q15_t vals[RX_BLOCK_SIZE];
|
||||
#if defined(USE_DCBLOCKER)
|
||||
::arm_fir_fast_q15(&m_boxcar5Filter, dcSamples, P25Vals, RX_BLOCK_SIZE);
|
||||
::arm_fir_fast_q15(&m_boxcar5Filter, dcSamples, vals, RX_BLOCK_SIZE);
|
||||
#else
|
||||
::arm_fir_fast_q15(&m_boxcar5Filter, samples, P25Vals, RX_BLOCK_SIZE);
|
||||
::arm_fir_fast_q15(&m_boxcar5Filter, samples, vals, RX_BLOCK_SIZE);
|
||||
#endif
|
||||
p25RX.samples(P25Vals, rssi, RX_BLOCK_SIZE);
|
||||
p25RX.samples(vals, rssi, RX_BLOCK_SIZE);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(MODE_NXDN)
|
||||
else if (m_modemState == STATE_NXDN) {
|
||||
} else if (m_modemState == STATE_NXDN) {
|
||||
if (m_nxdnEnable) {
|
||||
q15_t NXDNVals[RX_BLOCK_SIZE];
|
||||
#if defined(USE_NXDN_BOXCAR)
|
||||
q15_t vals[RX_BLOCK_SIZE];
|
||||
#if defined(USE_DCBLOCKER)
|
||||
::arm_fir_fast_q15(&m_boxcar10Filter, dcSamples, NXDNVals, RX_BLOCK_SIZE);
|
||||
::arm_fir_fast_q15(&m_boxcar10Filter, dcSamples, vals, RX_BLOCK_SIZE);
|
||||
#else
|
||||
::arm_fir_fast_q15(&m_boxcar10Filter, samples, NXDNVals, RX_BLOCK_SIZE);
|
||||
::arm_fir_fast_q15(&m_boxcar10Filter, samples, vals, RX_BLOCK_SIZE);
|
||||
#endif
|
||||
#else
|
||||
q15_t NXDNValsTmp[RX_BLOCK_SIZE];
|
||||
#if defined(USE_DCBLOCKER)
|
||||
::arm_fir_fast_q15(&m_nxdnFilter, dcSamples, NXDNValsTmp, RX_BLOCK_SIZE);
|
||||
#else
|
||||
::arm_fir_fast_q15(&m_nxdnFilter, samples, NXDNValsTmp, RX_BLOCK_SIZE);
|
||||
#endif
|
||||
::arm_fir_fast_q15(&m_nxdnISincFilter, NXDNValsTmp, NXDNVals, RX_BLOCK_SIZE);
|
||||
#endif
|
||||
nxdnRX.samples(NXDNVals, rssi, RX_BLOCK_SIZE);
|
||||
nxdnRX.samples(vals, rssi, RX_BLOCK_SIZE);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(MODE_M17)
|
||||
else if (m_modemState == STATE_M17) {
|
||||
if (m_m17Enable) {
|
||||
q15_t M17Vals[RX_BLOCK_SIZE];
|
||||
#if defined(USE_DCBLOCKER)
|
||||
::arm_fir_fast_q15(&m_rrc05Filter, dcSamples, M17Vals, RX_BLOCK_SIZE);
|
||||
#else
|
||||
::arm_fir_fast_q15(&m_rrc05Filter, samples, M17Vals, RX_BLOCK_SIZE);
|
||||
#endif
|
||||
m17RX.samples(M17Vals, rssi, RX_BLOCK_SIZE);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(MODE_FM)
|
||||
else if (m_modemState == STATE_FM) {
|
||||
} else if (m_modemState == STATE_FM) {
|
||||
bool cos = getCOSInt();
|
||||
#if defined(USE_DCBLOCKER)
|
||||
fm.samples(cos, dcSamples, RX_BLOCK_SIZE);
|
||||
|
||||
#if defined(MODE_AX25)
|
||||
if (m_ax25Enable)
|
||||
ax25RX.samples(dcSamples, RX_BLOCK_SIZE);
|
||||
#endif
|
||||
#else
|
||||
fm.samples(cos, samples, RX_BLOCK_SIZE);
|
||||
|
||||
#if defined(MODE_AX25)
|
||||
if (m_ax25Enable)
|
||||
ax25RX.samples(samples, RX_BLOCK_SIZE);
|
||||
#endif
|
||||
} else if (m_modemState == STATE_DSTARCAL) {
|
||||
q15_t vals[RX_BLOCK_SIZE];
|
||||
#if defined(USE_DCBLOCKER)
|
||||
::arm_fir_fast_q15(&m_boxcar5Filter, dcSamples, vals, RX_BLOCK_SIZE);
|
||||
#else
|
||||
::arm_fir_fast_q15(&m_boxcar5Filter, samples, vals, RX_BLOCK_SIZE);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(MODE_DSTAR)
|
||||
else if (m_modemState == STATE_DSTARCAL) {
|
||||
q15_t GMSKVals[RX_BLOCK_SIZE];
|
||||
::arm_fir_fast_q15(&m_gaussianFilter, samples, GMSKVals, RX_BLOCK_SIZE);
|
||||
|
||||
calDStarRX.samples(GMSKVals, RX_BLOCK_SIZE);
|
||||
}
|
||||
#endif
|
||||
|
||||
else if (m_modemState == STATE_RSSICAL) {
|
||||
calDStarRX.samples(vals, RX_BLOCK_SIZE);
|
||||
} else if (m_modemState == STATE_RSSICAL) {
|
||||
calRSSI.samples(rssi, RX_BLOCK_SIZE);
|
||||
}
|
||||
}
|
||||
@@ -660,7 +396,6 @@ void CIO::write(MMDVM_STATE mode, q15_t* samples, uint16_t length, const uint8_t
|
||||
if (!m_tx) {
|
||||
m_tx = true;
|
||||
setPTTInt(m_pttInvert ? false : true);
|
||||
DEBUG1("TX ON");
|
||||
}
|
||||
|
||||
q15_t txLevel = 0;
|
||||
@@ -680,18 +415,12 @@ void CIO::write(MMDVM_STATE mode, q15_t* samples, uint16_t length, const uint8_t
|
||||
case STATE_NXDN:
|
||||
txLevel = m_nxdnTXLevel;
|
||||
break;
|
||||
case STATE_M17:
|
||||
txLevel = m_m17TXLevel;
|
||||
break;
|
||||
case STATE_POCSAG:
|
||||
txLevel = m_pocsagTXLevel;
|
||||
break;
|
||||
case STATE_FM:
|
||||
txLevel = m_fmTXLevel;
|
||||
break;
|
||||
case STATE_AX25:
|
||||
txLevel = m_ax25TXLevel;
|
||||
break;
|
||||
default:
|
||||
txLevel = m_cwIdTXLevel;
|
||||
break;
|
||||
@@ -707,9 +436,9 @@ void CIO::write(MMDVM_STATE mode, q15_t* samples, uint16_t length, const uint8_t
|
||||
m_dacOverflow++;
|
||||
|
||||
if (control == NULL)
|
||||
m_txBuffer.put({res3, MARK_NONE});
|
||||
m_txBuffer.put(res3, MARK_NONE);
|
||||
else
|
||||
m_txBuffer.put({res3, control[i]});
|
||||
m_txBuffer.put(res3, control[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -731,41 +460,20 @@ void CIO::setADCDetection(bool detect)
|
||||
m_detect = detect;
|
||||
}
|
||||
|
||||
void CIO::setMode(MMDVM_STATE state)
|
||||
void CIO::setMode()
|
||||
{
|
||||
if (state == m_modemState)
|
||||
return;
|
||||
|
||||
#if defined(MODE_LEDS)
|
||||
switch (m_modemState) {
|
||||
case STATE_DSTAR: setDStarInt(false); break;
|
||||
case STATE_DMR: setDMRInt(false); break;
|
||||
case STATE_YSF: setYSFInt(false); break;
|
||||
case STATE_P25: setP25Int(false); break;
|
||||
case STATE_NXDN: setNXDNInt(false); break;
|
||||
case STATE_M17: setM17Int(false); break;
|
||||
case STATE_POCSAG: setPOCSAGInt(false); break;
|
||||
case STATE_FM: setFMInt(false); break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
switch (state) {
|
||||
case STATE_DSTAR: setDStarInt(true); break;
|
||||
case STATE_DMR: setDMRInt(true); break;
|
||||
case STATE_YSF: setYSFInt(true); break;
|
||||
case STATE_P25: setP25Int(true); break;
|
||||
case STATE_NXDN: setNXDNInt(true); break;
|
||||
case STATE_M17: setM17Int(true); break;
|
||||
case STATE_POCSAG: setPOCSAGInt(true); break;
|
||||
case STATE_FM: setFMInt(true); break;
|
||||
default: break;
|
||||
}
|
||||
setDStarInt(m_modemState == STATE_DSTAR);
|
||||
setDMRInt(m_modemState == STATE_DMR);
|
||||
setYSFInt(m_modemState == STATE_YSF);
|
||||
setP25Int(m_modemState == STATE_P25);
|
||||
setNXDNInt(m_modemState == STATE_NXDN);
|
||||
setPOCSAGInt(m_modemState == STATE_POCSAG);
|
||||
setFMInt(m_modemState == STATE_FM);
|
||||
#endif
|
||||
|
||||
m_modemState = state;
|
||||
}
|
||||
|
||||
void CIO::setParameters(bool rxInvert, bool txInvert, bool pttInvert, uint8_t rxLevel, uint8_t cwIdTXLevel, uint8_t dstarTXLevel, uint8_t dmrTXLevel, uint8_t ysfTXLevel, uint8_t p25TXLevel, uint8_t nxdnTXLevel, uint8_t m17TXLevel, uint8_t pocsagTXLevel, uint8_t fmTXLevel, uint8_t ax25TXLevel, int16_t txDCOffset, int16_t rxDCOffset, bool useCOSAsLockout)
|
||||
void CIO::setParameters(bool rxInvert, bool txInvert, bool pttInvert, uint8_t rxLevel, uint8_t cwIdTXLevel, uint8_t dstarTXLevel, uint8_t dmrTXLevel, uint8_t ysfTXLevel, uint8_t p25TXLevel, uint8_t nxdnTXLevel, uint8_t pocsagTXLevel, uint8_t fmTXLevel, int16_t txDCOffset, int16_t rxDCOffset)
|
||||
{
|
||||
m_pttInvert = pttInvert;
|
||||
|
||||
@@ -776,15 +484,11 @@ void CIO::setParameters(bool rxInvert, bool txInvert, bool pttInvert, uint8_t rx
|
||||
m_ysfTXLevel = q15_t(ysfTXLevel * 128);
|
||||
m_p25TXLevel = q15_t(p25TXLevel * 128);
|
||||
m_nxdnTXLevel = q15_t(nxdnTXLevel * 128);
|
||||
m_m17TXLevel = q15_t(m17TXLevel * 128);
|
||||
m_pocsagTXLevel = q15_t(pocsagTXLevel * 128);
|
||||
m_fmTXLevel = q15_t(fmTXLevel * 128);
|
||||
m_ax25TXLevel = q15_t(ax25TXLevel * 128);
|
||||
|
||||
m_rxDCOffset = DC_OFFSET + rxDCOffset;
|
||||
m_txDCOffset = DC_OFFSET + txDCOffset;
|
||||
|
||||
m_useCOSAsLockout = useCOSAsLockout;
|
||||
|
||||
if (rxInvert)
|
||||
m_rxLevel = -m_rxLevel;
|
||||
@@ -795,7 +499,6 @@ void CIO::setParameters(bool rxInvert, bool txInvert, bool pttInvert, uint8_t rx
|
||||
m_ysfTXLevel = -m_ysfTXLevel;
|
||||
m_p25TXLevel = -m_p25TXLevel;
|
||||
m_nxdnTXLevel = -m_nxdnTXLevel;
|
||||
m_m17TXLevel = -m_m17TXLevel;
|
||||
m_pocsagTXLevel = -m_pocsagTXLevel;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,12 +21,8 @@
|
||||
|
||||
#include "Globals.h"
|
||||
|
||||
#include "RingBuffer.h"
|
||||
|
||||
struct TSample {
|
||||
volatile uint16_t sample;
|
||||
volatile uint8_t control;
|
||||
};
|
||||
#include "SampleRB.h"
|
||||
#include "RSSIRB.h"
|
||||
|
||||
class CIO {
|
||||
public:
|
||||
@@ -42,11 +38,11 @@ public:
|
||||
|
||||
void setDecode(bool dcd);
|
||||
void setADCDetection(bool detect);
|
||||
void setMode(MMDVM_STATE state);
|
||||
void setMode();
|
||||
|
||||
void interrupt();
|
||||
|
||||
void setParameters(bool rxInvert, bool txInvert, bool pttInvert, uint8_t rxLevel, uint8_t cwIdTXLevel, uint8_t dstarTXLevel, uint8_t dmrTXLevel, uint8_t ysfTXLevel, uint8_t p25TXLevel, uint8_t nxdnTXLevel, uint8_t m17TXLevel, uint8_t pocsagTXLevel, uint8_t fmTXLevel, uint8_t ax25TXLevel, int16_t txDCOffset, int16_t rxDCOffset, bool useCOSAsLockout);
|
||||
void setParameters(bool rxInvert, bool txInvert, bool pttInvert, uint8_t rxLevel, uint8_t cwIdTXLevel, uint8_t dstarTXLevel, uint8_t dmrTXLevel, uint8_t ysfTXLevel, uint8_t p25TXLevel, uint8_t nxdnTXLevel, uint8_t pocsagTXLevel, uint8_t fmTXLevel, int16_t txDCOffset, int16_t rxDCOffset);
|
||||
|
||||
void getOverflow(bool& adcOverflow, bool& dacOverflow);
|
||||
|
||||
@@ -58,55 +54,22 @@ public:
|
||||
void resetWatchdog();
|
||||
uint32_t getWatchdog();
|
||||
|
||||
uint8_t getCPU() const;
|
||||
|
||||
void getUDID(uint8_t* buffer);
|
||||
|
||||
void selfTest();
|
||||
|
||||
private:
|
||||
bool m_started;
|
||||
bool m_started;
|
||||
|
||||
CRingBuffer<TSample> m_rxBuffer;
|
||||
CRingBuffer<TSample> m_txBuffer;
|
||||
CRingBuffer<uint16_t> m_rssiBuffer;
|
||||
CSampleRB m_rxBuffer;
|
||||
CSampleRB m_txBuffer;
|
||||
CRSSIRB m_rssiBuffer;
|
||||
|
||||
#if defined(USE_DCBLOCKER)
|
||||
arm_biquad_casd_df1_inst_q31 m_dcFilter;
|
||||
q31_t m_dcState[4];
|
||||
#endif
|
||||
|
||||
#if defined(MODE_DSTAR)
|
||||
arm_fir_instance_q15 m_gaussianFilter;
|
||||
q15_t m_gaussianState[40U]; // NoTaps + BlockSize - 1, 12 + 20 - 1 plus some spare
|
||||
#endif
|
||||
|
||||
#if defined(MODE_DMR) || defined(MODE_YSF)
|
||||
arm_fir_instance_q15 m_rrc02Filter;
|
||||
q15_t m_rrc02State[70U]; // NoTaps + BlockSize - 1, 42 + 20 - 1 plus some spare
|
||||
#endif
|
||||
|
||||
#if defined(MODE_P25)
|
||||
arm_fir_instance_q15 m_boxcar5Filter;
|
||||
q15_t m_boxcar5State[30U]; // NoTaps + BlockSize - 1, 6 + 20 - 1 plus some spare
|
||||
#endif
|
||||
|
||||
#if defined(MODE_NXDN)
|
||||
#if defined(USE_NXDN_BOXCAR)
|
||||
arm_fir_instance_q15 m_boxcar10Filter;
|
||||
q15_t m_boxcar10State[40U]; // NoTaps + BlockSize - 1, 10 + 20 - 1 plus some spare
|
||||
#else
|
||||
arm_fir_instance_q15 m_nxdnFilter;
|
||||
arm_fir_instance_q15 m_nxdnISincFilter;
|
||||
q15_t m_nxdnState[110U]; // NoTaps + BlockSize - 1, 82 + 20 - 1 plus some spare
|
||||
q15_t m_nxdnISincState[60U]; // NoTaps + BlockSize - 1, 32 + 20 - 1 plus some spare
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(MODE_M17)
|
||||
arm_fir_instance_q15 m_rrc05Filter;
|
||||
q15_t m_rrc05State[70U]; // NoTaps + BlockSize - 1, 42 + 20 - 1 plus some spare
|
||||
#endif
|
||||
q15_t m_boxcar5State[30U]; // NoTaps + BlockSize - 1, 6 + 20 - 1 plus some spare
|
||||
q15_t m_boxcar10State[40U]; // NoTaps + BlockSize - 1, 10 + 20 - 1 plus some spare
|
||||
|
||||
bool m_pttInvert;
|
||||
q15_t m_rxLevel;
|
||||
@@ -116,16 +79,12 @@ private:
|
||||
q15_t m_ysfTXLevel;
|
||||
q15_t m_p25TXLevel;
|
||||
q15_t m_nxdnTXLevel;
|
||||
q15_t m_m17TXLevel;
|
||||
q15_t m_pocsagTXLevel;
|
||||
q15_t m_fmTXLevel;
|
||||
q15_t m_ax25TXLevel;
|
||||
|
||||
uint16_t m_rxDCOffset;
|
||||
uint16_t m_txDCOffset;
|
||||
|
||||
bool m_useCOSAsLockout;
|
||||
|
||||
uint32_t m_ledCount;
|
||||
bool m_ledValue;
|
||||
|
||||
@@ -154,7 +113,6 @@ private:
|
||||
void setP25Int(bool on);
|
||||
void setNXDNInt(bool on);
|
||||
void setPOCSAGInt(bool on);
|
||||
void setM17Int(bool on);
|
||||
void setFMInt(bool on);
|
||||
|
||||
void delayInt(unsigned int dly);
|
||||
|
||||
@@ -107,9 +107,6 @@ void CIO::initInt()
|
||||
#if !defined(USE_ALTERNATE_NXDN_LEDS)
|
||||
pinMode(PIN_NXDN, OUTPUT);
|
||||
#endif
|
||||
#if !defined(USE_ALTERNATE_M17_LEDS)
|
||||
pinMode(PIN_M17, OUTPUT);
|
||||
#endif
|
||||
#if !defined(USE_ALTERNATE_POCSAG_LEDS)
|
||||
pinMode(PIN_POCSAG, OUTPUT);
|
||||
#endif
|
||||
@@ -188,13 +185,14 @@ void CIO::startInt()
|
||||
void CIO::interrupt()
|
||||
{
|
||||
if ((ADC->ADC_ISR & ADC_ISR_EOC_Chan) == ADC_ISR_EOC_Chan) { // Ensure there was an End-of-Conversion and we read the ISR reg
|
||||
TSample sample = {DC_OFFSET, MARK_NONE};
|
||||
uint8_t control = MARK_NONE;
|
||||
uint16_t sample = DC_OFFSET;
|
||||
|
||||
m_txBuffer.get(sample);
|
||||
DACC->DACC_CDR = sample.sample;
|
||||
m_txBuffer.get(sample, control);
|
||||
DACC->DACC_CDR = sample;
|
||||
|
||||
sample.sample = ADC->ADC_CDR[ADC_CDR_Chan];
|
||||
m_rxBuffer.put(sample);
|
||||
sample = ADC->ADC_CDR[ADC_CDR_Chan];
|
||||
m_rxBuffer.put(sample, control);
|
||||
|
||||
#if defined(SEND_RSSI_DATA)
|
||||
m_rssiBuffer.put(ADC->ADC_CDR[RSSI_CDR_Chan]);
|
||||
@@ -256,16 +254,6 @@ void CIO::setNXDNInt(bool on)
|
||||
#endif
|
||||
}
|
||||
|
||||
void CIO::setM17Int(bool on)
|
||||
{
|
||||
#if defined(USE_ALTERNATE_M17_LEDS)
|
||||
digitalWrite(PIN_DSTAR, on ? HIGH : LOW);
|
||||
digitalWrite(PIN_P25, on ? HIGH : LOW);
|
||||
#else
|
||||
digitalWrite(PIN_M17, on ? HIGH : LOW);
|
||||
#endif
|
||||
}
|
||||
|
||||
void CIO::setPOCSAGInt(bool on)
|
||||
{
|
||||
#if defined(USE_ALTERNATE_POCSAG_LEDS)
|
||||
@@ -291,33 +279,4 @@ void CIO::delayInt(unsigned int dly)
|
||||
delay(dly);
|
||||
}
|
||||
|
||||
uint8_t CIO::getCPU() const
|
||||
{
|
||||
return 0U;
|
||||
}
|
||||
|
||||
// Code taken from https://github.com/emagii/at91sam3s/blob/master/examples/eefc_uniqueid/main.c
|
||||
void CIO::getUDID(uint8_t* buffer)
|
||||
{
|
||||
uint32_t status;
|
||||
|
||||
EFC1->EEFC_FCR = (0x5A << 24) | EFC_FCMD_STUI;
|
||||
do {
|
||||
status = EFC1->EEFC_FSR;
|
||||
} while ( (status & EEFC_FSR_FRDY) == EEFC_FSR_FRDY );
|
||||
|
||||
for (uint8_t i = 0; i < 16; i+=4) {
|
||||
buffer[i + 0] = *(uint32_t *)(IFLASH1_ADDR + i) >> 24;
|
||||
buffer[i + 1] = *(uint32_t *)(IFLASH1_ADDR + i) >> 16;
|
||||
buffer[i + 2] = *(uint32_t *)(IFLASH1_ADDR + i) >> 8;
|
||||
buffer[i + 3] = *(uint32_t *)(IFLASH1_ADDR + i) >> 0;
|
||||
}
|
||||
|
||||
EFC1->EEFC_FCR = (0x5A << 24) | EFC_FCMD_SPUI;
|
||||
do {
|
||||
status = EFC1->EEFC_FSR;
|
||||
} while ( (status & EEFC_FSR_FRDY) != EEFC_FSR_FRDY );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -59,21 +59,12 @@
|
||||
#elif defined(STM32F4_DVM)
|
||||
#include "pins/pins_f4_stm32dvm_v3.h"
|
||||
|
||||
#elif defined(STM32F7_DVM)
|
||||
#include "pins/pins_f7_stm32dvm_v5.h"
|
||||
|
||||
#elif defined(DRCC_DVM_NQF)
|
||||
#include "pins/pins_f4_drcc_nqf.h"
|
||||
|
||||
#elif defined(DRCC_DVM_HHP446)
|
||||
#include "pins/pins_f4_drcc_hhp446.h"
|
||||
|
||||
#elif defined(STM32F4_EDA_405) || defined(STM32F4_EDA_446)
|
||||
#include "pins/pins_f4_stm32eda.h"
|
||||
|
||||
#else
|
||||
#error "A valid board type macro need to be defined."
|
||||
|
||||
#endif
|
||||
|
||||
#endif //#ifndef _IO_PINS_H
|
||||
#endif //#ifndef _IO_PINS_H
|
||||
@@ -106,14 +106,6 @@ void CIO::initInt()
|
||||
GPIO_Init(PORT_NXDN, &GPIO_InitStruct);
|
||||
#endif
|
||||
|
||||
#if !defined(USE_ALTERNATE_M17_LEDS)
|
||||
// M17 pin
|
||||
RCC_AHB1PeriphClockCmd(RCC_Per_M17, ENABLE);
|
||||
GPIO_InitStruct.GPIO_Pin = PIN_M17;
|
||||
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_OUT;
|
||||
GPIO_Init(PORT_M17, &GPIO_InitStruct);
|
||||
#endif
|
||||
|
||||
#if !defined(USE_ALTERNATE_POCSAG_LEDS)
|
||||
// POCSAG pin
|
||||
RCC_AHB1PeriphClockCmd(RCC_Per_POCSAG, ENABLE);
|
||||
@@ -165,14 +157,6 @@ void CIO::initInt()
|
||||
GPIO_Init(PORT_MNXDN, &GPIO_InitStruct);
|
||||
#endif
|
||||
|
||||
#if !defined(USE_ALTERNATE_M17_LEDS)
|
||||
// M17 mode pin
|
||||
RCC_AHB1PeriphClockCmd(RCC_Per_MM17, ENABLE);
|
||||
GPIO_InitStruct.GPIO_Pin = PIN_MM17;
|
||||
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_OUT;
|
||||
GPIO_Init(PORT_MM17, &GPIO_InitStruct);
|
||||
#endif
|
||||
|
||||
#if !defined(USE_ALTERNATE_POCSAG_LEDS)
|
||||
// POCSAG mode pin
|
||||
RCC_AHB1PeriphClockCmd(RCC_Per_MPOCSAG, ENABLE);
|
||||
@@ -342,24 +326,25 @@ void CIO::startInt()
|
||||
|
||||
void CIO::interrupt()
|
||||
{
|
||||
TSample sample = {DC_OFFSET, MARK_NONE};
|
||||
uint8_t control = MARK_NONE;
|
||||
uint16_t sample = DC_OFFSET;
|
||||
uint16_t rawRSSI = 0U;
|
||||
|
||||
m_txBuffer.get(sample);
|
||||
m_txBuffer.get(sample, control);
|
||||
|
||||
// Send the value to the DAC
|
||||
#if defined(STM32F4_NUCLEO) && defined(STM32F4_NUCLEO_ARDUINO_HEADER)
|
||||
DAC_SetChannel2Data(DAC_Align_12b_R, sample.sample);
|
||||
DAC_SetChannel2Data(DAC_Align_12b_R, sample);
|
||||
#else
|
||||
DAC_SetChannel1Data(DAC_Align_12b_R, sample.sample);
|
||||
DAC_SetChannel1Data(DAC_Align_12b_R, sample);
|
||||
#endif
|
||||
|
||||
// Read value from ADC1 and ADC2
|
||||
if ((ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC) == RESET)) {
|
||||
// shouldn't be still in reset at this point so null the sample value?
|
||||
sample.sample = 0U;
|
||||
sample = 0U;
|
||||
} else {
|
||||
sample.sample = ADC_GetConversionValue(ADC1);
|
||||
sample = ADC_GetConversionValue(ADC1);
|
||||
#if defined(SEND_RSSI_DATA)
|
||||
rawRSSI = ADC_GetConversionValue(ADC2);
|
||||
#endif
|
||||
@@ -369,7 +354,7 @@ void CIO::interrupt()
|
||||
ADC_ClearFlag(ADC1, ADC_FLAG_EOC);
|
||||
ADC_SoftwareStartConv(ADC1);
|
||||
|
||||
m_rxBuffer.put(sample);
|
||||
m_rxBuffer.put(sample, control);
|
||||
m_rssiBuffer.put(rawRSSI);
|
||||
|
||||
m_watchdog++;
|
||||
@@ -456,27 +441,6 @@ void CIO::setNXDNInt(bool on)
|
||||
#endif
|
||||
}
|
||||
|
||||
void CIO::setM17Int(bool on)
|
||||
{
|
||||
#if defined(MODE_LEDS)
|
||||
#if defined(USE_ALTERNATE_M17_LEDS)
|
||||
GPIO_WriteBit(PORT_DSTAR, PIN_DSTAR, on ? Bit_SET : Bit_RESET);
|
||||
GPIO_WriteBit(PORT_P25, PIN_P25, on ? Bit_SET : Bit_RESET);
|
||||
#else
|
||||
GPIO_WriteBit(PORT_M17, PIN_M17, on ? Bit_SET : Bit_RESET);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(MODE_PINS) && defined(STM32F4_NUCLEO_MORPHO_HEADER) && (defined(STM32F4_NUCLEO) || defined(STM32F722_RPT_HAT))
|
||||
#if defined(USE_ALTERNATE_M17_LEDS)
|
||||
GPIO_WriteBit(PORT_MDSTAR, PIN_MDSTAR, on ? Bit_SET : Bit_RESET);
|
||||
GPIO_WriteBit(PORT_MP25, PIN_MP25, on ? Bit_SET : Bit_RESET);
|
||||
#else
|
||||
GPIO_WriteBit(PORT_MM17, PIN_MM17, on ? Bit_SET : Bit_RESET);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void CIO::setPOCSAGInt(bool on)
|
||||
{
|
||||
#if defined(MODE_LEDS)
|
||||
@@ -545,21 +509,4 @@ void CIO::delayInt(unsigned int dly)
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t CIO::getCPU() const
|
||||
{
|
||||
return 2U;
|
||||
}
|
||||
|
||||
void CIO::getUDID(uint8_t* buffer)
|
||||
{
|
||||
#if defined(STM32F4XX)
|
||||
::memcpy(buffer, (void *)0x1FFF7A10, 12U);
|
||||
#elif defined(STM32F722xx)
|
||||
::memcpy(buffer, (void *)0x1FF07A10, 12U);
|
||||
#elif defined(STM32F767xx)
|
||||
::memcpy(buffer, (void *)0x1FF0F420, 12U);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
+52
-44
@@ -23,6 +23,7 @@
|
||||
#include "Globals.h"
|
||||
#include "IO.h"
|
||||
|
||||
|
||||
#if defined(STM32F1)
|
||||
|
||||
#if defined(STM32F1_POG)
|
||||
@@ -40,6 +41,7 @@ YSF PB8 output
|
||||
P25 PB9 output
|
||||
NXDN PB10 output
|
||||
POCSAG PB11 output
|
||||
FM PB12 output
|
||||
|
||||
RX PB0 analog input (ADC1_8)
|
||||
RSSI PB1 analog input (ADC2_9)
|
||||
@@ -83,6 +85,9 @@ USART1_RXD PA10 input (AF)
|
||||
#define PIN_POCSAG 11
|
||||
#define PORT_POCSAG GPIOB
|
||||
#define BB_POCSAG *((bitband_t)BITBAND_PERIPH(&PORT_POCSAG->ODR, PIN_POCSAG))
|
||||
#define PIN_FM 14
|
||||
#define PORT_FM GPIOB
|
||||
#define BB_FM *((bitband_t)BITBAND_PERIPH(&PORT_FM->ODR, PIN_FM))
|
||||
|
||||
#define PIN_RX 0
|
||||
#define PIN_RX_ADC_CH 8
|
||||
@@ -153,16 +158,35 @@ void GPIOConfigPin(GPIO_TypeDef *port_ptr, uint32_t pin, uint32_t mode_cnf_value
|
||||
#if defined(STM32F1_POG)
|
||||
void FancyLEDEffect()
|
||||
{
|
||||
bitband_t foo[] = {&BB_LED, &BB_COSLED, &BB_PTT, &BB_DMR, &BB_DSTAR, &BB_YSF, &BB_P25};
|
||||
|
||||
for(int i=0; i<7; i++){
|
||||
*foo[i] = 0x01;
|
||||
int ledCount = 10;
|
||||
|
||||
bitband_t foo[] = {&BB_LED, &BB_COSLED, &BB_PTT, &BB_DMR, &BB_DSTAR, &BB_YSF, &BB_P25,
|
||||
#if defined(USE_ALTERNATE_NXDN_LEDS)
|
||||
NULL,
|
||||
#else
|
||||
&BB_NXDN,
|
||||
#endif
|
||||
#if defined(USE_ALTERNATE_POCSAG_LEDS)
|
||||
NULL,
|
||||
#else
|
||||
&BB_POCSAG,
|
||||
#endif
|
||||
#if defined(USE_ALTERNATE_FM_LEDS)
|
||||
NULL};
|
||||
#else
|
||||
&BB_FM};
|
||||
#endif
|
||||
|
||||
for(int i=0; i<ledCount; i++){
|
||||
if(foo[i] != NULL)
|
||||
*foo[i] = 0x01;
|
||||
}
|
||||
GPIOConfigPin(PORT_USART1_TXD, PIN_USART1_TXD, GPIO_CRL_MODE0_1);
|
||||
*((bitband_t)BITBAND_PERIPH(&PORT_USART1_TXD->ODR, PIN_USART1_TXD)) = 0x00;
|
||||
delay(SystemCoreClock/1000*100);
|
||||
for(int i=0; i<7; i++){
|
||||
*foo[i] = 0x00;
|
||||
for(int i=0; i<ledCount; i++){
|
||||
if(foo[i] != NULL)
|
||||
*foo[i] = 0x00;
|
||||
}
|
||||
*((bitband_t)BITBAND_PERIPH(&PORT_USART1_TXD->ODR, PIN_USART1_TXD)) = 0x01;
|
||||
delay(SystemCoreClock/1000*20);
|
||||
@@ -171,18 +195,22 @@ void FancyLEDEffect()
|
||||
*((bitband_t)BITBAND_PERIPH(&PORT_USART1_TXD->ODR, PIN_USART1_TXD)) = 0x01;
|
||||
|
||||
*foo[0] = 0x01;
|
||||
for(int i=1; i<7; i++){
|
||||
for(int i=1; i<ledCount; i++){
|
||||
delay(SystemCoreClock/1000*10);
|
||||
*foo[i-1] = 0x00;
|
||||
*foo[i] = 0x01;
|
||||
if (foo[i-1] != NULL)
|
||||
*foo[i-1] = 0x00;
|
||||
if (foo[i] != NULL)
|
||||
*foo[i] = 0x01;
|
||||
}
|
||||
for(int i=5; i>=0; i--){
|
||||
for(int i=ledCount - 2; i>=0; i--) {
|
||||
delay(SystemCoreClock/1000*10);
|
||||
*foo[i+1] = 0x00;
|
||||
*foo[i] = 0x01;
|
||||
if (foo[i+1] != NULL)
|
||||
*foo[i+1] = 0x00;
|
||||
if (foo[i] != NULL)
|
||||
*foo[i] = 0x01;
|
||||
}
|
||||
delay(SystemCoreClock/1000*10);
|
||||
*foo[5+1-6] = 0x00;
|
||||
*foo[0] = 0x00;
|
||||
*((bitband_t)BITBAND_PERIPH(&PORT_USART1_TXD->ODR, PIN_USART1_TXD)) = 0x00;
|
||||
delay(SystemCoreClock/1000*10);
|
||||
*((bitband_t)BITBAND_PERIPH(&PORT_USART1_TXD->ODR, PIN_USART1_TXD)) = 0x01;
|
||||
@@ -224,12 +252,12 @@ static inline void GPIOInit()
|
||||
#if !defined(USE_ALTERNATE_NXDN_LEDS)
|
||||
GPIOConfigPin(PORT_NXDN, PIN_NXDN, GPIO_CRL_MODE0_1);
|
||||
#endif
|
||||
#if !defined(USE_ALTERNATE_M17_LEDS)
|
||||
GPIOConfigPin(PORT_M17, PIN_M17, GPIO_CRL_MODE0_1);
|
||||
#endif
|
||||
#if !defined(USE_ALTERNATE_POCSAG_LEDS)
|
||||
GPIOConfigPin(PORT_POCSAG, PIN_POCSAG, GPIO_CRL_MODE0_1);
|
||||
#endif
|
||||
#if !defined(USE_ALTERNATE_FM_LEDS)
|
||||
GPIOConfigPin(PORT_FM, PIN_FM, GPIO_CRL_MODE0_1);
|
||||
#endif
|
||||
|
||||
GPIOConfigPin(PORT_RX, PIN_RX, 0);
|
||||
#if defined(SEND_RSSI_DATA)
|
||||
@@ -369,7 +397,8 @@ void CIO::startInt()
|
||||
|
||||
void CIO::interrupt()
|
||||
{
|
||||
TSample sample = {DC_OFFSET, MARK_NONE};
|
||||
uint8_t control = MARK_NONE;
|
||||
uint16_t sample = DC_OFFSET;
|
||||
#if defined(SEND_RSSI_DATA)
|
||||
uint16_t rawRSSI = 0U;
|
||||
#endif
|
||||
@@ -386,12 +415,12 @@ void CIO::interrupt()
|
||||
*rssi_adon = 1;
|
||||
#endif
|
||||
|
||||
m_txBuffer.get(sample);
|
||||
DAC->DHR12R1 = sample.sample; // Send the value to the DAC
|
||||
m_txBuffer.get(sample, control);
|
||||
DAC->DHR12R1 = sample; // Send the value to the DAC
|
||||
|
||||
// Read value from ADC1 and ADC2
|
||||
sample.sample = ADC1->DR; // read conversion result; EOC is cleared by this read
|
||||
m_rxBuffer.put(sample);
|
||||
sample = ADC1->DR; // read conversion result; EOC is cleared by this read
|
||||
m_rxBuffer.put(sample, control);
|
||||
#if defined(SEND_RSSI_DATA)
|
||||
rawRSSI = ADC2->DR;
|
||||
m_rssiBuffer.put(rawRSSI);
|
||||
@@ -451,16 +480,6 @@ void CIO::setNXDNInt(bool on)
|
||||
#endif
|
||||
}
|
||||
|
||||
void CIO::setM17Int(bool on)
|
||||
{
|
||||
#if defined(USE_ALTERNATE_M17_LEDS)
|
||||
BB_DSTAR = !!on;
|
||||
BB_P25 = !!on;
|
||||
#else
|
||||
BB_M17 = !!on;
|
||||
#endif
|
||||
}
|
||||
|
||||
void CIO::setPOCSAGInt(bool on)
|
||||
{
|
||||
#if defined(USE_ALTERNATE_POCSAG_LEDS)
|
||||
@@ -476,6 +495,8 @@ void CIO::setFMInt(bool on)
|
||||
#if defined(USE_ALTERNATE_FM_LEDS)
|
||||
BB_DSTAR = !!on;
|
||||
BB_YSF = !!on;
|
||||
#else
|
||||
BB_FM = !!on;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -484,17 +505,4 @@ void CIO::delayInt(unsigned int dly)
|
||||
delay(dly);
|
||||
}
|
||||
|
||||
uint8_t CIO::getCPU() const
|
||||
{
|
||||
return 2U;
|
||||
}
|
||||
|
||||
void CIO::getUDID(uint8_t* buffer)
|
||||
{
|
||||
#if defined(STM32F105xC)
|
||||
::memcpy(buffer, (void *)0x1FFFF7E8, 12U);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
+6
-29
@@ -75,9 +75,6 @@ void CIO::initInt()
|
||||
#if !defined(USE_ALTERNATE_NXDN_LEDS)
|
||||
pinMode(PIN_NXDN, OUTPUT);
|
||||
#endif
|
||||
#if !defined(USE_ALTERNATE_M17_LEDS)
|
||||
pinMode(PIN_M17, OUTPUT);
|
||||
#endif
|
||||
#if !defined(USE_ALTERNATE_POCSAG_LEDS)
|
||||
pinMode(PIN_POCSAG, OUTPUT);
|
||||
#endif
|
||||
@@ -164,14 +161,15 @@ void CIO::startInt()
|
||||
|
||||
void CIO::interrupt()
|
||||
{
|
||||
TSample sample = {DC_OFFSET, MARK_NONE};
|
||||
uint8_t control = MARK_NONE;
|
||||
uint16_t sample = DC_OFFSET;
|
||||
|
||||
m_txBuffer.get(sample);
|
||||
*(int16_t *)&(DAC0_DAT0L) = sample.sample;
|
||||
m_txBuffer.get(sample, control);
|
||||
*(int16_t *)&(DAC0_DAT0L) = sample;
|
||||
|
||||
if ((ADC0_SC1A & ADC_SC1_COCO) == ADC_SC1_COCO) {
|
||||
sample.sample = ADC0_RA;
|
||||
m_rxBuffer.put(sample);
|
||||
sample = ADC0_RA;
|
||||
m_rxBuffer.put(sample, control);
|
||||
}
|
||||
|
||||
#if defined(SEND_RSSI_DATA)
|
||||
@@ -240,16 +238,6 @@ void CIO::setNXDNInt(bool on)
|
||||
#endif
|
||||
}
|
||||
|
||||
void CIO::setM17Int(bool on)
|
||||
{
|
||||
#if defined(USE_ALTERNATE_M17_LEDS)
|
||||
digitalWrite(PIN_DSTAR, on ? HIGH : LOW);
|
||||
digitalWrite(PIN_P25, on ? HIGH : LOW);
|
||||
#else
|
||||
digitalWrite(PIN_M17, on ? HIGH : LOW);
|
||||
#endif
|
||||
}
|
||||
|
||||
void CIO::setPOCSAGInt(bool on)
|
||||
{
|
||||
#if defined(USE_ALTERNATE_POCSAG_LEDS)
|
||||
@@ -275,15 +263,4 @@ void CIO::delayInt(unsigned int dly)
|
||||
delay(dly);
|
||||
}
|
||||
|
||||
uint8_t CIO::getCPU() const
|
||||
{
|
||||
return 1U;
|
||||
}
|
||||
|
||||
void CIO::getUDID(uint8_t* buffer)
|
||||
{
|
||||
::memcpy(buffer, (void *)0x4058, 16U);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2016,2017,2018,2020,2021 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
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#if !defined(M17DEFINES_H)
|
||||
#define M17DEFINES_H
|
||||
|
||||
const unsigned int M17_RADIO_SYMBOL_LENGTH = 5U; // At 24 kHz sample rate
|
||||
|
||||
const unsigned int M17_FRAME_LENGTH_BITS = 384U;
|
||||
const unsigned int M17_FRAME_LENGTH_BYTES = M17_FRAME_LENGTH_BITS / 8U;
|
||||
const unsigned int M17_FRAME_LENGTH_SYMBOLS = M17_FRAME_LENGTH_BITS / 2U;
|
||||
const unsigned int M17_FRAME_LENGTH_SAMPLES = M17_FRAME_LENGTH_SYMBOLS * M17_RADIO_SYMBOL_LENGTH;
|
||||
|
||||
const unsigned int M17_SYNC_LENGTH_BITS = 16U;
|
||||
const unsigned int M17_SYNC_LENGTH_BYTES = M17_SYNC_LENGTH_BITS / 8U;
|
||||
const unsigned int M17_SYNC_LENGTH_SYMBOLS = M17_SYNC_LENGTH_BITS / 2U;
|
||||
const unsigned int M17_SYNC_LENGTH_SAMPLES = M17_SYNC_LENGTH_SYMBOLS * M17_RADIO_SYMBOL_LENGTH;
|
||||
|
||||
const uint8_t M17_LINK_SETUP_SYNC_BYTES[] = {0x55U, 0xF7U};
|
||||
const uint8_t M17_STREAM_SYNC_BYTES[] = {0xFFU, 0x5DU};
|
||||
const uint8_t M17_EOF_SYNC_BYTES[] = {0x55U, 0x5DU};
|
||||
|
||||
const uint16_t M17_LINK_SETUP_SYNC_BITS = 0x55F7U;
|
||||
const uint16_t M17_STREAM_SYNC_BITS = 0xFF5DU;
|
||||
const uint16_t M17_EOF_SYNC_BITS = 0x555DU;
|
||||
|
||||
// 5 5 F 7
|
||||
// 01 01 01 01 11 11 01 11
|
||||
// +3 +3 +3 +3 -3 -3 +3 -3
|
||||
|
||||
const int8_t M17_LINK_SETUP_SYNC_SYMBOLS_VALUES[] = {+3, +3, +3, +3, -3, -3, +3, -3};
|
||||
|
||||
const uint8_t M17_LINK_SETUP_SYNC_SYMBOLS = 0xF2U;
|
||||
|
||||
// F F 5 D
|
||||
// 11 11 11 11 01 01 11 01
|
||||
// -3 -3 -3 -3 +3 +3 -3 +3
|
||||
|
||||
const int8_t M17_STREAM_SYNC_SYMBOLS_VALUES[] = {-3, -3, -3, -3, +3, +3, -3, +3};
|
||||
|
||||
const uint8_t M17_STREAM_SYNC_SYMBOLS = 0x0DU;
|
||||
|
||||
// 5 5 5 D
|
||||
// 01 01 01 01 01 01 11 01
|
||||
// +3 +3 +3 +3 +3 +3 -3 +3
|
||||
|
||||
const int8_t M17_EOF_SYNC_SYMBOLS_VALUES[] = {+3, +3, +3, +3, +3, +3, -3, +3};
|
||||
|
||||
const uint8_t M17_EOF_SYNC_SYMBOLS = 0xFDU;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,485 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2009-2017,2020,2021 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
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#if defined(MODE_M17)
|
||||
|
||||
#include "Globals.h"
|
||||
#include "M17RX.h"
|
||||
#include "Utils.h"
|
||||
|
||||
const q15_t SCALING_FACTOR = 18750; // Q15(0.55)
|
||||
|
||||
const uint8_t MAX_SYNC_BIT_START_ERRS = 0U;
|
||||
const uint8_t MAX_SYNC_BIT_RUN_ERRS = 2U;
|
||||
|
||||
const uint8_t MAX_SYNC_SYMBOL_START_ERRS = 0U;
|
||||
const uint8_t MAX_SYNC_SYMBOL_RUN_ERRS = 1U;
|
||||
|
||||
const uint8_t BIT_MASK_TABLE[] = {0x80U, 0x40U, 0x20U, 0x10U, 0x08U, 0x04U, 0x02U, 0x01U};
|
||||
|
||||
#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])
|
||||
|
||||
const uint8_t NOAVEPTR = 99U;
|
||||
|
||||
const uint16_t NOENDPTR = 9999U;
|
||||
|
||||
const unsigned int MAX_SYNC_FRAMES = 3U + 1U;
|
||||
|
||||
CM17RX::CM17RX() :
|
||||
m_state(M17RXS_NONE),
|
||||
m_bitBuffer(),
|
||||
m_buffer(),
|
||||
m_bitPtr(0U),
|
||||
m_dataPtr(0U),
|
||||
m_startPtr(NOENDPTR),
|
||||
m_endPtr(NOENDPTR),
|
||||
m_syncPtr(NOENDPTR),
|
||||
m_minSyncPtr(NOENDPTR),
|
||||
m_maxSyncPtr(NOENDPTR),
|
||||
m_maxCorr(0),
|
||||
m_lostCount(0U),
|
||||
m_countdown(0U),
|
||||
m_nextState(M17RXS_NONE),
|
||||
m_centre(),
|
||||
m_centreVal(0),
|
||||
m_threshold(),
|
||||
m_thresholdVal(0),
|
||||
m_averagePtr(NOAVEPTR),
|
||||
m_rssiAccum(0U),
|
||||
m_rssiCount(0U)
|
||||
{
|
||||
}
|
||||
|
||||
void CM17RX::reset()
|
||||
{
|
||||
m_state = M17RXS_NONE;
|
||||
m_dataPtr = 0U;
|
||||
m_bitPtr = 0U;
|
||||
m_maxCorr = 0;
|
||||
m_averagePtr = NOAVEPTR;
|
||||
m_startPtr = NOENDPTR;
|
||||
m_endPtr = NOENDPTR;
|
||||
m_syncPtr = NOENDPTR;
|
||||
m_minSyncPtr = NOENDPTR;
|
||||
m_maxSyncPtr = NOENDPTR;
|
||||
m_centreVal = 0;
|
||||
m_thresholdVal = 0;
|
||||
m_lostCount = 0U;
|
||||
m_countdown = 0U;
|
||||
m_nextState = M17RXS_NONE;
|
||||
m_rssiAccum = 0U;
|
||||
m_rssiCount = 0U;
|
||||
}
|
||||
|
||||
void CM17RX::samples(const q15_t* samples, uint16_t* rssi, uint8_t length)
|
||||
{
|
||||
for (uint8_t i = 0U; i < length; i++) {
|
||||
q15_t sample = samples[i];
|
||||
|
||||
m_rssiAccum += rssi[i];
|
||||
m_rssiCount++;
|
||||
|
||||
m_bitBuffer[m_bitPtr] <<= 1;
|
||||
if (sample < 0)
|
||||
m_bitBuffer[m_bitPtr] |= 0x01U;
|
||||
|
||||
m_buffer[m_dataPtr] = sample;
|
||||
|
||||
switch (m_state) {
|
||||
case M17RXS_LINK_SETUP:
|
||||
case M17RXS_STREAM:
|
||||
processData(sample);
|
||||
break;
|
||||
default:
|
||||
processNone(sample);
|
||||
break;
|
||||
}
|
||||
|
||||
m_dataPtr++;
|
||||
if (m_dataPtr >= M17_FRAME_LENGTH_SAMPLES)
|
||||
m_dataPtr = 0U;
|
||||
|
||||
m_bitPtr++;
|
||||
if (m_bitPtr >= M17_RADIO_SYMBOL_LENGTH)
|
||||
m_bitPtr = 0U;
|
||||
}
|
||||
}
|
||||
|
||||
void CM17RX::processNone(q15_t sample)
|
||||
{
|
||||
bool ret1 = correlateSync(M17_LINK_SETUP_SYNC_SYMBOLS, M17_LINK_SETUP_SYNC_SYMBOLS_VALUES, M17_LINK_SETUP_SYNC_BYTES, MAX_SYNC_SYMBOL_START_ERRS, MAX_SYNC_BIT_START_ERRS);
|
||||
bool ret2 = correlateSync(M17_STREAM_SYNC_SYMBOLS, M17_STREAM_SYNC_SYMBOLS_VALUES, M17_STREAM_SYNC_BYTES, MAX_SYNC_SYMBOL_START_ERRS, MAX_SYNC_BIT_START_ERRS);
|
||||
|
||||
if (ret1 || ret2) {
|
||||
// On the first sync, start the countdown to the state change
|
||||
if (m_countdown == 0U) {
|
||||
m_rssiAccum = 0U;
|
||||
m_rssiCount = 0U;
|
||||
|
||||
io.setDecode(true);
|
||||
io.setADCDetection(true);
|
||||
|
||||
m_averagePtr = NOAVEPTR;
|
||||
|
||||
m_countdown = 5U;
|
||||
|
||||
if (ret1) m_nextState = M17RXS_LINK_SETUP;
|
||||
if (ret2) m_nextState = M17RXS_STREAM;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_countdown > 0U)
|
||||
m_countdown--;
|
||||
|
||||
if (m_countdown == 1U) {
|
||||
m_minSyncPtr = m_syncPtr + M17_FRAME_LENGTH_SAMPLES - 1U;
|
||||
if (m_minSyncPtr >= M17_FRAME_LENGTH_SAMPLES)
|
||||
m_minSyncPtr -= M17_FRAME_LENGTH_SAMPLES;
|
||||
|
||||
m_maxSyncPtr = m_syncPtr + 1U;
|
||||
if (m_maxSyncPtr >= M17_FRAME_LENGTH_SAMPLES)
|
||||
m_maxSyncPtr -= M17_FRAME_LENGTH_SAMPLES;
|
||||
|
||||
m_state = m_nextState;
|
||||
m_countdown = 0U;
|
||||
m_nextState = M17RXS_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
void CM17RX::processData(q15_t sample)
|
||||
{
|
||||
bool eof = false;
|
||||
|
||||
if (m_minSyncPtr < m_maxSyncPtr) {
|
||||
if (m_dataPtr >= m_minSyncPtr && m_dataPtr <= m_maxSyncPtr) {
|
||||
bool ret = correlateSync(M17_STREAM_SYNC_SYMBOLS, M17_STREAM_SYNC_SYMBOLS_VALUES, M17_STREAM_SYNC_BYTES, MAX_SYNC_SYMBOL_RUN_ERRS, MAX_SYNC_BIT_RUN_ERRS);
|
||||
|
||||
eof = correlateSync(M17_EOF_SYNC_SYMBOLS, M17_EOF_SYNC_SYMBOLS_VALUES, M17_EOF_SYNC_BYTES, MAX_SYNC_SYMBOL_RUN_ERRS, MAX_SYNC_BIT_RUN_ERRS);
|
||||
|
||||
if (ret) m_state = M17RXS_STREAM;
|
||||
}
|
||||
} else {
|
||||
if (m_dataPtr >= m_minSyncPtr || m_dataPtr <= m_maxSyncPtr) {
|
||||
bool ret = correlateSync(M17_STREAM_SYNC_SYMBOLS, M17_STREAM_SYNC_SYMBOLS_VALUES, M17_STREAM_SYNC_BYTES, MAX_SYNC_SYMBOL_RUN_ERRS, MAX_SYNC_BIT_RUN_ERRS);
|
||||
|
||||
eof = correlateSync(M17_EOF_SYNC_SYMBOLS, M17_EOF_SYNC_SYMBOLS_VALUES, M17_EOF_SYNC_BYTES, MAX_SYNC_SYMBOL_RUN_ERRS, MAX_SYNC_BIT_RUN_ERRS);
|
||||
|
||||
if (ret) m_state = M17RXS_STREAM;
|
||||
}
|
||||
}
|
||||
|
||||
if (eof) {
|
||||
DEBUG4("M17RX: eof sync found pos/centre/threshold", m_syncPtr, m_centreVal, m_thresholdVal);
|
||||
|
||||
io.setDecode(false);
|
||||
io.setADCDetection(false);
|
||||
|
||||
serial.writeM17EOT();
|
||||
|
||||
m_state = M17RXS_NONE;
|
||||
m_endPtr = NOENDPTR;
|
||||
m_averagePtr = NOAVEPTR;
|
||||
m_countdown = 0U;
|
||||
m_nextState = M17RXS_NONE;
|
||||
m_maxCorr = 0;
|
||||
}
|
||||
|
||||
if (m_dataPtr == m_endPtr) {
|
||||
// Only update the centre and threshold if they are from a good sync
|
||||
if (m_lostCount == MAX_SYNC_FRAMES) {
|
||||
m_minSyncPtr = m_syncPtr + M17_FRAME_LENGTH_SAMPLES - 1U;
|
||||
if (m_minSyncPtr >= M17_FRAME_LENGTH_SAMPLES)
|
||||
m_minSyncPtr -= M17_FRAME_LENGTH_SAMPLES;
|
||||
|
||||
m_maxSyncPtr = m_syncPtr + 1U;
|
||||
if (m_maxSyncPtr >= M17_FRAME_LENGTH_SAMPLES)
|
||||
m_maxSyncPtr -= M17_FRAME_LENGTH_SAMPLES;
|
||||
}
|
||||
|
||||
calculateLevels(m_startPtr, M17_FRAME_LENGTH_SYMBOLS);
|
||||
|
||||
switch (m_state) {
|
||||
case M17RXS_LINK_SETUP:
|
||||
DEBUG4("M17RX: link setup sync found pos/centre/threshold", m_syncPtr, m_centreVal, m_thresholdVal);
|
||||
break;
|
||||
case M17RXS_STREAM:
|
||||
DEBUG4("M17RX: stream sync found pos/centre/threshold", m_syncPtr, m_centreVal, m_thresholdVal);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
uint8_t frame[M17_FRAME_LENGTH_BYTES + 3U];
|
||||
samplesToBits(m_startPtr, M17_FRAME_LENGTH_SYMBOLS, frame, 8U, m_centreVal, m_thresholdVal);
|
||||
|
||||
// We've not seen a stream sync for too long, signal RXLOST and change to RX_NONE
|
||||
m_lostCount--;
|
||||
if (m_lostCount == 0U) {
|
||||
DEBUG1("M17RX: sync timed out, lost lock");
|
||||
|
||||
io.setDecode(false);
|
||||
io.setADCDetection(false);
|
||||
|
||||
serial.writeM17Lost();
|
||||
|
||||
m_state = M17RXS_NONE;
|
||||
m_endPtr = NOENDPTR;
|
||||
m_averagePtr = NOAVEPTR;
|
||||
m_countdown = 0U;
|
||||
m_nextState = M17RXS_NONE;
|
||||
m_maxCorr = 0;
|
||||
} else {
|
||||
frame[0U] = m_lostCount == (MAX_SYNC_FRAMES - 1U) ? 0x01U : 0x00U;
|
||||
|
||||
switch (m_state) {
|
||||
case M17RXS_LINK_SETUP:
|
||||
writeRSSILinkSetup(frame);
|
||||
break;
|
||||
case M17RXS_STREAM:
|
||||
writeRSSIStream(frame);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
m_maxCorr = 0;
|
||||
m_nextState = M17RXS_NONE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool CM17RX::correlateSync(uint8_t syncSymbols, const int8_t* syncSymbolValues, const uint8_t* syncBytes, uint8_t maxSymbolErrs, uint8_t maxBitErrs)
|
||||
{
|
||||
if (countBits8(m_bitBuffer[m_bitPtr] ^ syncSymbols) <= maxSymbolErrs) {
|
||||
uint16_t ptr = m_dataPtr + M17_FRAME_LENGTH_SAMPLES - M17_SYNC_LENGTH_SAMPLES + M17_RADIO_SYMBOL_LENGTH;
|
||||
if (ptr >= M17_FRAME_LENGTH_SAMPLES)
|
||||
ptr -= M17_FRAME_LENGTH_SAMPLES;
|
||||
|
||||
q31_t corr = 0;
|
||||
q15_t min = 16000;
|
||||
q15_t max = -16000;
|
||||
|
||||
for (uint8_t i = 0U; i < M17_SYNC_LENGTH_SYMBOLS; i++) {
|
||||
q15_t val = m_buffer[ptr];
|
||||
|
||||
if (val > max)
|
||||
max = val;
|
||||
if (val < min)
|
||||
min = val;
|
||||
|
||||
switch (syncSymbolValues[i]) {
|
||||
case +3:
|
||||
corr -= (val + val + val);
|
||||
break;
|
||||
case +1:
|
||||
corr -= val;
|
||||
break;
|
||||
case -1:
|
||||
corr += val;
|
||||
break;
|
||||
default: // -3
|
||||
corr += (val + val + val);
|
||||
break;
|
||||
}
|
||||
|
||||
ptr += M17_RADIO_SYMBOL_LENGTH;
|
||||
if (ptr >= M17_FRAME_LENGTH_SAMPLES)
|
||||
ptr -= M17_FRAME_LENGTH_SAMPLES;
|
||||
}
|
||||
|
||||
if (corr > m_maxCorr) {
|
||||
if (m_averagePtr == NOAVEPTR) {
|
||||
m_centreVal = (max + min) >> 1;
|
||||
|
||||
q31_t v1 = (max - m_centreVal) * SCALING_FACTOR;
|
||||
m_thresholdVal = q15_t(v1 >> 15);
|
||||
}
|
||||
|
||||
uint16_t startPtr = m_dataPtr + M17_FRAME_LENGTH_SAMPLES - M17_SYNC_LENGTH_SAMPLES + M17_RADIO_SYMBOL_LENGTH;
|
||||
if (startPtr >= M17_FRAME_LENGTH_SAMPLES)
|
||||
startPtr -= M17_FRAME_LENGTH_SAMPLES;
|
||||
|
||||
uint8_t sync[M17_SYNC_LENGTH_BYTES];
|
||||
samplesToBits(startPtr, M17_SYNC_LENGTH_SYMBOLS, sync, 0U, m_centreVal, m_thresholdVal);
|
||||
|
||||
uint8_t errs = 0U;
|
||||
for (uint8_t i = 0U; i < M17_SYNC_LENGTH_BYTES; i++)
|
||||
errs += countBits8(sync[i] ^ syncBytes[i]);
|
||||
|
||||
if (errs <= maxBitErrs) {
|
||||
m_maxCorr = corr;
|
||||
m_lostCount = MAX_SYNC_FRAMES;
|
||||
m_syncPtr = m_dataPtr;
|
||||
|
||||
m_startPtr = startPtr;
|
||||
|
||||
m_endPtr = m_dataPtr + M17_FRAME_LENGTH_SAMPLES - M17_SYNC_LENGTH_SAMPLES - 1U;
|
||||
if (m_endPtr >= M17_FRAME_LENGTH_SAMPLES)
|
||||
m_endPtr -= M17_FRAME_LENGTH_SAMPLES;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void CM17RX::calculateLevels(uint16_t start, uint16_t count)
|
||||
{
|
||||
q15_t maxPos = -16000;
|
||||
q15_t minPos = 16000;
|
||||
q15_t maxNeg = 16000;
|
||||
q15_t minNeg = -16000;
|
||||
|
||||
for (uint16_t i = 0U; i < count; i++) {
|
||||
q15_t sample = m_buffer[start];
|
||||
|
||||
if (sample > 0) {
|
||||
if (sample > maxPos)
|
||||
maxPos = sample;
|
||||
if (sample < minPos)
|
||||
minPos = sample;
|
||||
} else {
|
||||
if (sample < maxNeg)
|
||||
maxNeg = sample;
|
||||
if (sample > minNeg)
|
||||
minNeg = sample;
|
||||
}
|
||||
|
||||
start += M17_RADIO_SYMBOL_LENGTH;
|
||||
if (start >= M17_FRAME_LENGTH_SAMPLES)
|
||||
start -= M17_FRAME_LENGTH_SAMPLES;
|
||||
}
|
||||
|
||||
q15_t posThresh = (maxPos + minPos) >> 1;
|
||||
q15_t negThresh = (maxNeg + minNeg) >> 1;
|
||||
|
||||
q15_t centre = (posThresh + negThresh) >> 1;
|
||||
|
||||
q15_t threshold = posThresh - centre;
|
||||
|
||||
DEBUG5("M17RX: pos/neg/centre/threshold", posThresh, negThresh, centre, threshold);
|
||||
|
||||
if (m_averagePtr == NOAVEPTR) {
|
||||
for (uint8_t i = 0U; i < 16U; i++) {
|
||||
m_centre[i] = centre;
|
||||
m_threshold[i] = threshold;
|
||||
}
|
||||
|
||||
m_averagePtr = 0U;
|
||||
} else {
|
||||
m_centre[m_averagePtr] = centre;
|
||||
m_threshold[m_averagePtr] = threshold;
|
||||
|
||||
m_averagePtr++;
|
||||
if (m_averagePtr >= 16U)
|
||||
m_averagePtr = 0U;
|
||||
}
|
||||
|
||||
m_centreVal = 0;
|
||||
m_thresholdVal = 0;
|
||||
|
||||
for (uint8_t i = 0U; i < 16U; i++) {
|
||||
m_centreVal += m_centre[i];
|
||||
m_thresholdVal += m_threshold[i];
|
||||
}
|
||||
|
||||
m_centreVal >>= 4;
|
||||
m_thresholdVal >>= 4;
|
||||
}
|
||||
|
||||
void CM17RX::samplesToBits(uint16_t start, uint16_t count, uint8_t* buffer, uint16_t offset, q15_t centre, q15_t threshold)
|
||||
{
|
||||
for (uint16_t i = 0U; i < count; i++) {
|
||||
q15_t sample = m_buffer[start] - centre;
|
||||
|
||||
if (sample < -threshold) {
|
||||
WRITE_BIT1(buffer, offset, false);
|
||||
offset++;
|
||||
WRITE_BIT1(buffer, offset, true);
|
||||
offset++;
|
||||
} else if (sample < 0) {
|
||||
WRITE_BIT1(buffer, offset, false);
|
||||
offset++;
|
||||
WRITE_BIT1(buffer, offset, false);
|
||||
offset++;
|
||||
} else if (sample < threshold) {
|
||||
WRITE_BIT1(buffer, offset, true);
|
||||
offset++;
|
||||
WRITE_BIT1(buffer, offset, false);
|
||||
offset++;
|
||||
} else {
|
||||
WRITE_BIT1(buffer, offset, true);
|
||||
offset++;
|
||||
WRITE_BIT1(buffer, offset, true);
|
||||
offset++;
|
||||
}
|
||||
|
||||
start += M17_RADIO_SYMBOL_LENGTH;
|
||||
if (start >= M17_FRAME_LENGTH_SAMPLES)
|
||||
start -= M17_FRAME_LENGTH_SAMPLES;
|
||||
}
|
||||
}
|
||||
|
||||
void CM17RX::writeRSSILinkSetup(uint8_t* data)
|
||||
{
|
||||
#if defined(SEND_RSSI_DATA)
|
||||
if (m_rssiCount > 0U) {
|
||||
uint16_t rssi = m_rssiAccum / m_rssiCount;
|
||||
|
||||
data[49U] = (rssi >> 8) & 0xFFU;
|
||||
data[50U] = (rssi >> 0) & 0xFFU;
|
||||
|
||||
serial.writeM17LinkSetup(data, M17_FRAME_LENGTH_BYTES + 3U);
|
||||
} else {
|
||||
serial.writeM17LinkSetup(data, M17_FRAME_LENGTH_BYTES + 1U);
|
||||
}
|
||||
#else
|
||||
serial.writeM17LinkSetup(data, M17_FRAME_LENGTH_BYTES + 1U);
|
||||
#endif
|
||||
|
||||
m_rssiAccum = 0U;
|
||||
m_rssiCount = 0U;
|
||||
}
|
||||
|
||||
void CM17RX::writeRSSIStream(uint8_t* data)
|
||||
{
|
||||
#if defined(SEND_RSSI_DATA)
|
||||
if (m_rssiCount > 0U) {
|
||||
uint16_t rssi = m_rssiAccum / m_rssiCount;
|
||||
|
||||
data[49U] = (rssi >> 8) & 0xFFU;
|
||||
data[50U] = (rssi >> 0) & 0xFFU;
|
||||
|
||||
serial.writeM17Stream(data, M17_FRAME_LENGTH_BYTES + 3U);
|
||||
} else {
|
||||
serial.writeM17Stream(data, M17_FRAME_LENGTH_BYTES + 1U);
|
||||
}
|
||||
#else
|
||||
serial.writeM17Stream(data, M17_FRAME_LENGTH_BYTES + 1U);
|
||||
#endif
|
||||
|
||||
m_rssiAccum = 0U;
|
||||
m_rssiCount = 0U;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,77 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2015,2016,2017,2020,2021 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
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#if defined(MODE_M17)
|
||||
|
||||
#if !defined(M17RX_H)
|
||||
#define M17RX_H
|
||||
|
||||
#include "M17Defines.h"
|
||||
|
||||
enum M17RX_STATE {
|
||||
M17RXS_NONE,
|
||||
M17RXS_LINK_SETUP,
|
||||
M17RXS_STREAM
|
||||
};
|
||||
|
||||
class CM17RX {
|
||||
public:
|
||||
CM17RX();
|
||||
|
||||
void samples(const q15_t* samples, uint16_t* rssi, uint8_t length);
|
||||
|
||||
void reset();
|
||||
|
||||
private:
|
||||
M17RX_STATE m_state;
|
||||
uint8_t m_bitBuffer[M17_RADIO_SYMBOL_LENGTH];
|
||||
q15_t m_buffer[M17_FRAME_LENGTH_SAMPLES];
|
||||
uint16_t m_bitPtr;
|
||||
uint16_t m_dataPtr;
|
||||
uint16_t m_startPtr;
|
||||
uint16_t m_endPtr;
|
||||
uint16_t m_syncPtr;
|
||||
uint16_t m_minSyncPtr;
|
||||
uint16_t m_maxSyncPtr;
|
||||
q31_t m_maxCorr;
|
||||
uint16_t m_lostCount;
|
||||
uint8_t m_countdown;
|
||||
M17RX_STATE m_nextState;
|
||||
q15_t m_centre[16U];
|
||||
q15_t m_centreVal;
|
||||
q15_t m_threshold[16U];
|
||||
q15_t m_thresholdVal;
|
||||
uint8_t m_averagePtr;
|
||||
uint32_t m_rssiAccum;
|
||||
uint16_t m_rssiCount;
|
||||
|
||||
void processNone(q15_t sample);
|
||||
void processData(q15_t sample);
|
||||
bool correlateSync(uint8_t syncSymbols, const int8_t* syncSymbolValues, const uint8_t* syncBytes, uint8_t maxSymbolErrs, uint8_t maxBitErrs);
|
||||
void calculateLevels(uint16_t start, uint16_t count);
|
||||
void samplesToBits(uint16_t start, uint16_t count, uint8_t* buffer, uint16_t offset, q15_t centre, q15_t threshold);
|
||||
void writeRSSILinkSetup(uint8_t* data);
|
||||
void writeRSSIStream(uint8_t* data);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,190 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2009-2018,2020,2021 by Jonathan Naylor G4KLX
|
||||
* Copyright (C) 2017 by Andy Uribe CA6JAU
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#if defined(MODE_M17)
|
||||
|
||||
#include "Globals.h"
|
||||
#include "M17TX.h"
|
||||
|
||||
#include "M17Defines.h"
|
||||
|
||||
// Generated using rcosdesign(0.5, 8, 5, 'sqrt') in MATLAB
|
||||
static q15_t RRC_0_5_FILTER[] = {0, 0, 0, 0, -290, -174, 142, 432, 438, 90, -387, -561, -155, 658, 1225, 767,
|
||||
-980, -3326, -4648, -3062, 2527, 11552, 21705, 29724, 32767, 29724, 21705,
|
||||
11552, 2527, -3062, -4648, -3326, -980, 767, 1225, 658, -155, -561, -387, 90,
|
||||
438, 432, 142, -174, -290}; // numTaps = 45, L = 5
|
||||
const uint16_t RRC_0_5_FILTER_PHASE_LEN = 9U; // phaseLength = numTaps/L
|
||||
|
||||
const q15_t M17_LEVELA = 1481;
|
||||
const q15_t M17_LEVELB = 494;
|
||||
const q15_t M17_LEVELC = -494;
|
||||
const q15_t M17_LEVELD = -1481;
|
||||
|
||||
const uint8_t M17_START_SYNC = 0x77U;
|
||||
const uint8_t M17_END_SYNC = 0xFFU;
|
||||
const uint8_t M17_HANG = 0x00U;
|
||||
|
||||
CM17TX::CM17TX() :
|
||||
m_buffer(TX_BUFFER_LEN),
|
||||
m_modFilter(),
|
||||
m_modState(),
|
||||
m_poBuffer(),
|
||||
m_poLen(0U),
|
||||
m_poPtr(0U),
|
||||
m_txDelay(240U), // 200ms
|
||||
m_txHang(4800U), // 4s
|
||||
m_txCount(0U)
|
||||
{
|
||||
::memset(m_modState, 0x00U, 16U * sizeof(q15_t));
|
||||
|
||||
m_modFilter.L = M17_RADIO_SYMBOL_LENGTH;
|
||||
m_modFilter.phaseLength = RRC_0_5_FILTER_PHASE_LEN;
|
||||
m_modFilter.pCoeffs = RRC_0_5_FILTER;
|
||||
m_modFilter.pState = m_modState;
|
||||
}
|
||||
|
||||
void CM17TX::process()
|
||||
{
|
||||
// If we have M17 data to transmit, do so.
|
||||
if (m_poLen == 0U && m_buffer.getData() > 0U) {
|
||||
if (!m_tx) {
|
||||
for (uint16_t i = 0U; i < m_txDelay; i++)
|
||||
m_poBuffer[m_poLen++] = M17_START_SYNC;
|
||||
} else {
|
||||
for (uint8_t i = 0U; i < M17_FRAME_LENGTH_BYTES; i++) {
|
||||
uint8_t c = 0U;
|
||||
m_buffer.get(c);
|
||||
m_poBuffer[m_poLen++] = c;
|
||||
}
|
||||
}
|
||||
|
||||
m_poPtr = 0U;
|
||||
}
|
||||
|
||||
if (m_poLen > 0U) {
|
||||
// Transmit M17 data.
|
||||
uint16_t space = io.getSpace();
|
||||
|
||||
while (space > (4U * M17_RADIO_SYMBOL_LENGTH)) {
|
||||
uint8_t c = m_poBuffer[m_poPtr++];
|
||||
writeByte(c);
|
||||
|
||||
// Reduce space and reset the hang timer.
|
||||
space -= 4U * M17_RADIO_SYMBOL_LENGTH;
|
||||
if (m_duplex)
|
||||
m_txCount = m_txHang;
|
||||
|
||||
if (m_poPtr >= m_poLen) {
|
||||
m_poPtr = 0U;
|
||||
m_poLen = 0U;
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else if (m_txCount > 0U) {
|
||||
// Transmit silence until the hang timer has expired.
|
||||
uint16_t space = io.getSpace();
|
||||
|
||||
while (space > (4U * M17_RADIO_SYMBOL_LENGTH)) {
|
||||
writeSilence();
|
||||
|
||||
space -= 4U * M17_RADIO_SYMBOL_LENGTH;
|
||||
m_txCount--;
|
||||
|
||||
if (m_txCount == 0U)
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t CM17TX::writeData(const uint8_t* data, uint8_t length)
|
||||
{
|
||||
if (length != (M17_FRAME_LENGTH_BYTES + 1U))
|
||||
return 4U;
|
||||
|
||||
uint16_t space = m_buffer.getSpace();
|
||||
if (space < M17_FRAME_LENGTH_BYTES)
|
||||
return 5U;
|
||||
|
||||
for (uint8_t i = 0U; i < M17_FRAME_LENGTH_BYTES; i++)
|
||||
m_buffer.put(data[i + 1U]);
|
||||
|
||||
return 0U;
|
||||
}
|
||||
|
||||
void CM17TX::writeByte(uint8_t c)
|
||||
{
|
||||
q15_t inBuffer[4U];
|
||||
q15_t outBuffer[M17_RADIO_SYMBOL_LENGTH * 4U];
|
||||
|
||||
const uint8_t MASK = 0xC0U;
|
||||
|
||||
for (uint8_t i = 0U; i < 4U; i++, c <<= 2) {
|
||||
switch (c & MASK) {
|
||||
case 0xC0U:
|
||||
inBuffer[i] = M17_LEVELA;
|
||||
break;
|
||||
case 0x80U:
|
||||
inBuffer[i] = M17_LEVELB;
|
||||
break;
|
||||
case 0x00U:
|
||||
inBuffer[i] = M17_LEVELC;
|
||||
break;
|
||||
default:
|
||||
inBuffer[i] = M17_LEVELD;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
::arm_fir_interpolate_q15(&m_modFilter, inBuffer, outBuffer, 4U);
|
||||
|
||||
io.write(STATE_M17, outBuffer, M17_RADIO_SYMBOL_LENGTH * 4U);
|
||||
}
|
||||
|
||||
void CM17TX::writeSilence()
|
||||
{
|
||||
q15_t inBuffer[4U] = {0x00U, 0x00U, 0x00U, 0x00U};
|
||||
q15_t outBuffer[M17_RADIO_SYMBOL_LENGTH * 4U];
|
||||
|
||||
::arm_fir_interpolate_q15(&m_modFilter, inBuffer, outBuffer, 4U);
|
||||
|
||||
io.write(STATE_M17, outBuffer, M17_RADIO_SYMBOL_LENGTH * 4U);
|
||||
}
|
||||
|
||||
void CM17TX::setTXDelay(uint8_t delay)
|
||||
{
|
||||
m_txDelay = 600U + uint16_t(delay) * 12U; // 500ms + tx delay
|
||||
|
||||
if (m_txDelay > 1200U)
|
||||
m_txDelay = 1200U;
|
||||
}
|
||||
|
||||
uint8_t CM17TX::getSpace() const
|
||||
{
|
||||
return m_buffer.getSpace() / M17_FRAME_LENGTH_BYTES;
|
||||
}
|
||||
|
||||
void CM17TX::setParams(uint8_t txHang)
|
||||
{
|
||||
m_txHang = txHang * 1200U;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2015,2016,2017,2020 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
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#if defined(MODE_M17)
|
||||
|
||||
#if !defined(M17TX_H)
|
||||
#define M17TX_H
|
||||
|
||||
#include "RingBuffer.h"
|
||||
|
||||
class CM17TX {
|
||||
public:
|
||||
CM17TX();
|
||||
|
||||
uint8_t writeData(const uint8_t* data, uint8_t length);
|
||||
|
||||
void process();
|
||||
|
||||
void setTXDelay(uint8_t delay);
|
||||
|
||||
uint8_t getSpace() const;
|
||||
|
||||
void setParams(uint8_t txHang);
|
||||
|
||||
private:
|
||||
CRingBuffer<uint8_t> m_buffer;
|
||||
arm_fir_interpolate_instance_q15 m_modFilter;
|
||||
q15_t m_modState[16U]; // blockSize + phaseLength - 1, 4 + 9 - 1 plus some spare
|
||||
uint8_t m_poBuffer[1200U];
|
||||
uint16_t m_poLen;
|
||||
uint16_t m_poPtr;
|
||||
uint16_t m_txDelay;
|
||||
uint32_t m_txHang;
|
||||
uint32_t m_txCount;
|
||||
|
||||
void writeByte(uint8_t c);
|
||||
void writeSilence();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -31,75 +31,45 @@ bool m_dmrEnable = true;
|
||||
bool m_ysfEnable = true;
|
||||
bool m_p25Enable = true;
|
||||
bool m_nxdnEnable = true;
|
||||
bool m_m17Enable = true;
|
||||
bool m_pocsagEnable = true;
|
||||
bool m_fmEnable = true;
|
||||
bool m_ax25Enable = true;
|
||||
|
||||
bool m_duplex = true;
|
||||
|
||||
bool m_tx = false;
|
||||
bool m_dcd = false;
|
||||
|
||||
#if defined(MODE_DSTAR)
|
||||
CDStarRX dstarRX;
|
||||
CDStarTX dstarTX;
|
||||
CDStarRX dstarRX;
|
||||
CDStarTX dstarTX;
|
||||
|
||||
CDMRIdleRX dmrIdleRX;
|
||||
CDMRRX dmrRX;
|
||||
CDMRTX dmrTX;
|
||||
|
||||
CDMRDMORX dmrDMORX;
|
||||
CDMRDMOTX dmrDMOTX;
|
||||
|
||||
CYSFRX ysfRX;
|
||||
CYSFTX ysfTX;
|
||||
|
||||
CP25RX p25RX;
|
||||
CP25TX p25TX;
|
||||
|
||||
CNXDNRX nxdnRX;
|
||||
CNXDNTX nxdnTX;
|
||||
|
||||
CPOCSAGTX pocsagTX;
|
||||
|
||||
CFM fm;
|
||||
|
||||
CCalDStarRX calDStarRX;
|
||||
CCalDStarTX calDStarTX;
|
||||
#endif
|
||||
|
||||
#if defined(MODE_DMR)
|
||||
CDMRIdleRX dmrIdleRX;
|
||||
CDMRRX dmrRX;
|
||||
CDMRTX dmrTX;
|
||||
|
||||
CDMRDMORX dmrDMORX;
|
||||
CDMRDMOTX dmrDMOTX;
|
||||
|
||||
CCalDMR calDMR;
|
||||
#endif
|
||||
|
||||
#if defined(MODE_YSF)
|
||||
CYSFRX ysfRX;
|
||||
CYSFTX ysfTX;
|
||||
#endif
|
||||
|
||||
#if defined(MODE_P25)
|
||||
CP25RX p25RX;
|
||||
CP25TX p25TX;
|
||||
|
||||
CCalP25 calP25;
|
||||
#endif
|
||||
|
||||
#if defined(MODE_NXDN)
|
||||
CNXDNRX nxdnRX;
|
||||
CNXDNTX nxdnTX;
|
||||
|
||||
CCalNXDN calNXDN;
|
||||
#endif
|
||||
|
||||
#if defined(MODE_M17)
|
||||
CM17RX m17RX;
|
||||
CM17TX m17TX;
|
||||
#endif
|
||||
|
||||
#if defined(MODE_POCSAG)
|
||||
CPOCSAGTX pocsagTX;
|
||||
CCalPOCSAG calPOCSAG;
|
||||
#endif
|
||||
|
||||
#if defined(MODE_FM)
|
||||
CFM fm;
|
||||
CCalFM calFM;
|
||||
#endif
|
||||
|
||||
#if defined(MODE_AX25)
|
||||
CAX25RX ax25RX;
|
||||
CAX25TX ax25TX;
|
||||
#endif
|
||||
|
||||
CCalRSSI calRSSI;
|
||||
CCalDMR calDMR;
|
||||
CCalP25 calP25;
|
||||
CCalNXDN calNXDN;
|
||||
CCalFM calFM;
|
||||
CCalPOCSAG calPOCSAG;
|
||||
CCalRSSI calRSSI;
|
||||
|
||||
CCWIdTX cwIdTX;
|
||||
|
||||
@@ -118,84 +88,48 @@ void loop()
|
||||
io.process();
|
||||
|
||||
// The following is for transmitting
|
||||
#if defined(MODE_DSTAR)
|
||||
if (m_dstarEnable && m_modemState == STATE_DSTAR)
|
||||
dstarTX.process();
|
||||
#endif
|
||||
|
||||
#if defined(MODE_DMR)
|
||||
if (m_dmrEnable && m_modemState == STATE_DMR) {
|
||||
if (m_duplex)
|
||||
dmrTX.process();
|
||||
else
|
||||
dmrDMOTX.process();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(MODE_YSF)
|
||||
if (m_ysfEnable && m_modemState == STATE_YSF)
|
||||
ysfTX.process();
|
||||
#endif
|
||||
|
||||
#if defined(MODE_P25)
|
||||
if (m_p25Enable && m_modemState == STATE_P25)
|
||||
p25TX.process();
|
||||
#endif
|
||||
|
||||
#if defined(MODE_NXDN)
|
||||
if (m_nxdnEnable && m_modemState == STATE_NXDN)
|
||||
nxdnTX.process();
|
||||
#endif
|
||||
|
||||
#if defined(MODE_M17)
|
||||
if (m_m17Enable && m_modemState == STATE_M17)
|
||||
m17TX.process();
|
||||
#endif
|
||||
|
||||
#if defined(MODE_POCSAG)
|
||||
if (m_pocsagEnable && (m_modemState == STATE_POCSAG || pocsagTX.busy()))
|
||||
pocsagTX.process();
|
||||
#endif
|
||||
|
||||
#if defined(MODE_AX25)
|
||||
if (m_ax25Enable && (m_modemState == STATE_IDLE || m_modemState == STATE_FM))
|
||||
ax25TX.process();
|
||||
#endif
|
||||
|
||||
#if defined(MODE_FM)
|
||||
if (m_fmEnable && m_modemState == STATE_FM)
|
||||
fm.process();
|
||||
#endif
|
||||
|
||||
#if defined(MODE_DSTAR)
|
||||
if (m_modemState == STATE_DSTARCAL)
|
||||
calDStarTX.process();
|
||||
#endif
|
||||
|
||||
#if defined(MODE_DMR)
|
||||
if (m_modemState == STATE_DMRCAL || m_modemState == STATE_LFCAL || m_modemState == STATE_DMRCAL1K || m_modemState == STATE_DMRDMO1K)
|
||||
calDMR.process();
|
||||
#endif
|
||||
|
||||
#if defined(MODE_FM)
|
||||
if (m_modemState == STATE_FMCAL10K || m_modemState == STATE_FMCAL12K || m_modemState == STATE_FMCAL15K || m_modemState == STATE_FMCAL20K || m_modemState == STATE_FMCAL25K || m_modemState == STATE_FMCAL30K)
|
||||
calFM.process();
|
||||
#endif
|
||||
|
||||
#if defined(MODE_P25)
|
||||
if (m_modemState == STATE_P25CAL1K)
|
||||
calP25.process();
|
||||
#endif
|
||||
|
||||
#if defined(MODE_NXDN)
|
||||
if (m_modemState == STATE_NXDNCAL1K)
|
||||
calNXDN.process();
|
||||
#endif
|
||||
|
||||
#if defined(MODE_POCSAG)
|
||||
if (m_modemState == STATE_POCSAGCAL)
|
||||
calPOCSAG.process();
|
||||
#endif
|
||||
|
||||
if (m_modemState == STATE_FMCAL10K || m_modemState == STATE_FMCAL12K || m_modemState == STATE_FMCAL15K || m_modemState == STATE_FMCAL20K || m_modemState == STATE_FMCAL25K ||m_modemState == STATE_FMCAL30K)
|
||||
calFM.process();
|
||||
|
||||
if (m_modemState == STATE_IDLE)
|
||||
cwIdTX.process();
|
||||
|
||||
@@ -28,75 +28,45 @@ bool m_dmrEnable = true;
|
||||
bool m_ysfEnable = true;
|
||||
bool m_p25Enable = true;
|
||||
bool m_nxdnEnable = true;
|
||||
bool m_m17Enable = true;
|
||||
bool m_pocsagEnable = true;
|
||||
bool m_fmEnable = true;
|
||||
bool m_ax25Enable = true;
|
||||
|
||||
bool m_duplex = true;
|
||||
|
||||
bool m_tx = false;
|
||||
bool m_dcd = false;
|
||||
|
||||
#if defined(MODE_DSTAR)
|
||||
CDStarRX dstarRX;
|
||||
CDStarTX dstarTX;
|
||||
CDStarRX dstarRX;
|
||||
CDStarTX dstarTX;
|
||||
|
||||
CDMRIdleRX dmrIdleRX;
|
||||
CDMRRX dmrRX;
|
||||
CDMRTX dmrTX;
|
||||
|
||||
CDMRDMORX dmrDMORX;
|
||||
CDMRDMOTX dmrDMOTX;
|
||||
|
||||
CYSFRX ysfRX;
|
||||
CYSFTX ysfTX;
|
||||
|
||||
CP25RX p25RX;
|
||||
CP25TX p25TX;
|
||||
|
||||
CNXDNRX nxdnRX;
|
||||
CNXDNTX nxdnTX;
|
||||
|
||||
CPOCSAGTX pocsagTX;
|
||||
|
||||
CFM fm;
|
||||
|
||||
CCalDStarRX calDStarRX;
|
||||
CCalDStarTX calDStarTX;
|
||||
#endif
|
||||
|
||||
#if defined(MODE_DMR)
|
||||
CDMRIdleRX dmrIdleRX;
|
||||
CDMRRX dmrRX;
|
||||
CDMRTX dmrTX;
|
||||
|
||||
CDMRDMORX dmrDMORX;
|
||||
CDMRDMOTX dmrDMOTX;
|
||||
|
||||
CCalDMR calDMR;
|
||||
#endif
|
||||
|
||||
#if defined(MODE_YSF)
|
||||
CYSFRX ysfRX;
|
||||
CYSFTX ysfTX;
|
||||
#endif
|
||||
|
||||
#if defined(MODE_P25)
|
||||
CP25RX p25RX;
|
||||
CP25TX p25TX;
|
||||
|
||||
CCalP25 calP25;
|
||||
#endif
|
||||
|
||||
#if defined(MODE_NXDN)
|
||||
CNXDNRX nxdnRX;
|
||||
CNXDNTX nxdnTX;
|
||||
|
||||
CCalNXDN calNXDN;
|
||||
#endif
|
||||
|
||||
#if defined(MODE_M17)
|
||||
CM17RX m17RX;
|
||||
CM17TX m17TX;
|
||||
#endif
|
||||
|
||||
#if defined(MODE_POCSAG)
|
||||
CPOCSAGTX pocsagTX;
|
||||
CCalPOCSAG calPOCSAG;
|
||||
#endif
|
||||
|
||||
#if defined(MODE_FM)
|
||||
CFM fm;
|
||||
CCalFM calFM;
|
||||
#endif
|
||||
|
||||
#if defined(MODE_AX25)
|
||||
CAX25RX ax25RX;
|
||||
CAX25TX ax25TX;
|
||||
#endif
|
||||
|
||||
CCalRSSI calRSSI;
|
||||
CCalDMR calDMR;
|
||||
CCalFM calFM;
|
||||
CCalP25 calP25;
|
||||
CCalNXDN calNXDN;
|
||||
CCalPOCSAG calPOCSAG;
|
||||
CCalRSSI calRSSI;
|
||||
|
||||
CCWIdTX cwIdTX;
|
||||
|
||||
@@ -115,86 +85,49 @@ void loop()
|
||||
io.process();
|
||||
|
||||
// The following is for transmitting
|
||||
#if defined(MODE_DSTAR)
|
||||
if (m_dstarEnable && m_modemState == STATE_DSTAR)
|
||||
dstarTX.process();
|
||||
#endif
|
||||
|
||||
#if defined(MODE_DMR)
|
||||
if (m_dmrEnable && m_modemState == STATE_DMR) {
|
||||
if (m_duplex)
|
||||
dmrTX.process();
|
||||
else
|
||||
dmrDMOTX.process();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(MODE_YSF)
|
||||
if (m_ysfEnable && m_modemState == STATE_YSF)
|
||||
ysfTX.process();
|
||||
#endif
|
||||
|
||||
#if defined(MODE_P25)
|
||||
if (m_p25Enable && m_modemState == STATE_P25)
|
||||
p25TX.process();
|
||||
#endif
|
||||
|
||||
#if defined(MODE_NXDN)
|
||||
if (m_nxdnEnable && m_modemState == STATE_NXDN)
|
||||
nxdnTX.process();
|
||||
#endif
|
||||
|
||||
#if defined(MODE_M17)
|
||||
if (m_m17Enable && m_modemState == STATE_M17)
|
||||
m17TX.process();
|
||||
#endif
|
||||
|
||||
#if defined(MODE_POCSAG)
|
||||
if (m_pocsagEnable && (m_modemState == STATE_POCSAG || pocsagTX.busy()))
|
||||
pocsagTX.process();
|
||||
#endif
|
||||
|
||||
#if defined(MODE_AX25)
|
||||
if (m_ax25Enable && (m_modemState == STATE_IDLE || m_modemState == STATE_FM))
|
||||
ax25TX.process();
|
||||
#endif
|
||||
|
||||
#if defined(MODE_FM)
|
||||
if (m_fmEnable && m_modemState == STATE_FM)
|
||||
fm.process();
|
||||
#endif
|
||||
|
||||
#if defined(MODE_DSTAR)
|
||||
if (m_modemState == STATE_DSTARCAL)
|
||||
calDStarTX.process();
|
||||
#endif
|
||||
|
||||
#if defined(MODE_DMR)
|
||||
if (m_modemState == STATE_DMRCAL || m_modemState == STATE_LFCAL || m_modemState == STATE_DMRCAL1K || m_modemState == STATE_DMRDMO1K)
|
||||
calDMR.process();
|
||||
#endif
|
||||
|
||||
#if defined(MODE_FM)
|
||||
if (m_modemState == STATE_FMCAL10K || m_modemState == STATE_FMCAL12K || m_modemState == STATE_FMCAL15K || m_modemState == STATE_FMCAL20K || m_modemState == STATE_FMCAL25K || m_modemState == STATE_FMCAL30K)
|
||||
calFM.process();
|
||||
#endif
|
||||
|
||||
#if defined(MODE_P25)
|
||||
if (m_modemState == STATE_P25CAL1K)
|
||||
calP25.process();
|
||||
#endif
|
||||
|
||||
#if defined(MODE_NXDN)
|
||||
if (m_modemState == STATE_NXDNCAL1K)
|
||||
calNXDN.process();
|
||||
#endif
|
||||
|
||||
#if defined(MODE_POCSAG)
|
||||
if (m_modemState == STATE_POCSAGCAL)
|
||||
calPOCSAG.process();
|
||||
#endif
|
||||
|
||||
if (m_modemState == STATE_IDLE)
|
||||
cwIdTX.process();
|
||||
}
|
||||
|
||||
|
||||
@@ -133,18 +133,12 @@ DEFS_PI_F722=-DUSE_HAL_DRIVER -DSTM32F722xx -DSTM32F7XX -DSTM32F722_PI -DHSE_VAL
|
||||
DEFS_F7M=-DUSE_HAL_DRIVER -DSTM32F722xx -DSTM32F7XX -DSTM32F722_F7M -DHSE_VALUE=$(OSC) -DMADEBYMAKEFILE
|
||||
# MMDVM_RPT_Hat F0DEI, DB9MAT, DF2ET board:
|
||||
DEFS_RPT_HAT=-DUSE_HAL_DRIVER -DSTM32F722xx -DSTM32F7XX -DSTM32F722_RPT_HAT -DHSE_VALUE=$(OSC) -DMADEBYMAKEFILE
|
||||
# RB STM32F4_DVM board:
|
||||
# STM32F4 DVM board:
|
||||
DEFS_DVM=-DUSE_STDPERIPH_DRIVER -DSTM32F4XX -DSTM32F446xx -DSTM32F4_DVM -DHSE_VALUE=$(OSC) -DMADEBYMAKEFILE
|
||||
# RB STM32F7 DVM board:
|
||||
DEFS_DVM722=-DUSE_HAL_DRIVER -DSTM32F722xx -DSTM32F7XX -DSTM32F7_DVM -DHSE_VALUE=$(OSC) -DMADEBYMAKEFILE
|
||||
# MMDVM_RPT_Hat BG4TGO, BG5HHP board:
|
||||
DEFS_RPT_HAT_TGO=-DUSE_STDPERIPH_DRIVER -DSTM32F4XX -DSTM32F40_41xxx -DSTM32F4_RPT_HAT_TGO -DHSE_VALUE=$(OSC) -DMADEBYMAKEFILE
|
||||
# DRCC_DVM BG7NQF board:
|
||||
DEFS_DRCC_DVM=-DUSE_STDPERIPH_DRIVER -DSTM32F4XX -DSTM32F446xx -DDRCC_DVM -DHSE_VALUE=$(OSC) -DMADEBYMAKEFILE
|
||||
# WA0EDA F405 MTR2K, MASTR3 board:
|
||||
DEFS_EDA_405=-DUSE_STDPERIPH_DRIVER -DSTM32F4XX -DSTM32F40_41xxx -DSTM32F4_EDA_405 -DHSE_VALUE=$(OSC) -DMADEBYMAKEFILE
|
||||
# WA0EDA F446 MTR2K, MASTR3 board:
|
||||
DEFS_EDA_446=-DUSE_STDPERIPH_DRIVER -DSTM32F4XX -DSTM32F446xx -DSTM32F4_EDA_446 -DHSE_VALUE=$(OSC) -DMADEBYMAKEFILE
|
||||
|
||||
|
||||
# Build compiler flags
|
||||
@@ -224,41 +218,17 @@ f767: LDFLAGS+=$(LDFLAGS_F767)
|
||||
f767: release_f7
|
||||
|
||||
dvm: GitVersion.h
|
||||
dvm: CFLAGS+=$(CFLAGS_F4) $(DEFS_DVM) -DDRCC_DVM_446
|
||||
dvm: CXXFLAGS+=$(CXXFLAGS_F4) $(DEFS_DVM) -DDRCC_DVM_446
|
||||
dvm: CFLAGS+=$(CFLAGS_F4) $(DEFS_DVM)
|
||||
dvm: CXXFLAGS+=$(CXXFLAGS_F4) $(DEFS_DVM)
|
||||
dvm: LDFLAGS+=$(LDFLAGS_F4)
|
||||
dvm: release_f4
|
||||
|
||||
dvm722: GitVersion.h
|
||||
dvm722: CFLAGS+=$(CFLAGS_F7) $(DEFS_DVM722) -DDRCC_DVM_722
|
||||
dvm722: CXXFLAGS+=$(CXXFLAGS_F7) $(DEFS_DVM722) -DDRCC_DVM_722
|
||||
dvm722: LDFLAGS+=$(LDFLAGS_F722)
|
||||
dvm722: release_f7
|
||||
|
||||
drcc_nqf: GitVersion.h
|
||||
drcc_nqf: CFLAGS+=$(CFLAGS_F4) $(DEFS_DRCC_DVM) -DDRCC_DVM_NQF
|
||||
drcc_nqf: CXXFLAGS+=$(CXXFLAGS_F4) $(DEFS_DRCC_DVM) -DDRCC_DVM_NQF
|
||||
drcc_nqf: LDFLAGS+=$(LDFLAGS_F4)
|
||||
drcc_nqf: release_f4
|
||||
|
||||
hhp446: GitVersion.h
|
||||
hhp446: CFLAGS+=$(CFLAGS_F4) $(DEFS_DRCC_DVM) -DDRCC_DVM_HHP446
|
||||
hhp446: CXXFLAGS+=$(CXXFLAGS_F4) $(DEFS_DRCC_DVM) -DDRCC_DVM_HHP446
|
||||
hhp446: LDFLAGS+=$(LDFLAGS_F4)
|
||||
hhp446: release_f4
|
||||
|
||||
eda405: GitVersion.h
|
||||
eda405: CFLAGS+=$(CFLAGS_F4) $(DEFS_EDA_405)
|
||||
eda405: CXXFLAGS+=$(CXXFLAGS_F4) $(DEFS_EDA_405)
|
||||
eda405: LDFLAGS+=$(LDFLAGS_F4)
|
||||
eda405: release_f4
|
||||
|
||||
eda446: GitVersion.h
|
||||
eda446: CFLAGS+=$(CFLAGS_F4) $(DEFS_EDA_446)
|
||||
eda446: CXXFLAGS+=$(CXXFLAGS_F4) $(DEFS_EDA_446)
|
||||
eda446: LDFLAGS+=$(LDFLAGS_F4)
|
||||
eda446: release_f4
|
||||
|
||||
release_f4: $(BINDIR)
|
||||
release_f4: $(OBJDIR_F4)
|
||||
release_f4: $(BINDIR)/$(BINHEX_F4)
|
||||
@@ -368,27 +338,27 @@ endif
|
||||
deploy-pi:
|
||||
ifneq ($(wildcard /usr/local/bin/stm32flash),)
|
||||
-/usr/local/bin/stm32flash -i 20,-21,21:-20,21 /dev/ttyAMA0
|
||||
/usr/local/bin/stm32flash -v -w bin/$(BINBIN_F4) -g 0x0 -R /dev/ttyAMA0
|
||||
-/usr/local/bin/stm32ld /dev/ttyAMA0 57600 bin/$(BINBIN_F4)
|
||||
/usr/local/bin/stm32flash -v -w bin/$(BINBIN_F4) -g 0x0 -R -c /dev/ttyAMA0
|
||||
endif
|
||||
|
||||
ifneq ($(wildcard /usr/bin/stm32flash),)
|
||||
-/usr/bin/stm32flash -i 20,-21,21:-20,21 /dev/ttyAMA0
|
||||
/usr/bin/stm32flash -v -w bin/$(BINBIN_F4) -g 0x0 -R /dev/ttyAMA0
|
||||
-/usr/bin/stm32ld /dev/ttyAMA0 57600 bin/$(BINBIN_F4)
|
||||
/usr/bin/stm32flash -v -w bin/$(BINBIN_F4) -g 0x0 -R -c /dev/ttyAMA0
|
||||
endif
|
||||
|
||||
deploy-f4m: deploy-pi
|
||||
deploy-dvm: deploy-pi
|
||||
deploy-eda405: deploy-pi
|
||||
deploy-eda446: deploy-pi
|
||||
|
||||
deploy-pi-f7:
|
||||
ifneq ($(wildcard /usr/local/bin/stm32flash),)
|
||||
-/usr/local/bin/stm32flash -i 20,-21,21:-20,21 /dev/ttyAMA0
|
||||
/usr/local/bin/stm32flash -v -w bin/$(BINBIN_F7) -g 0x0 -R /dev/ttyAMA0
|
||||
/usr/local/bin/stm32flash -v -w bin/$(BINBIN_F7) -g 0x0 -R -c /dev/ttyAMA0
|
||||
|
||||
else ifneq ($(wildcard /usr/bin/stm32flash),)
|
||||
-/usr/bin/stm32flash -i 20,-21,21:-20,21 /dev/ttyAMA0
|
||||
/usr/bin/stm32flash -v -w bin/$(BINBIN_F7) -g 0x0 -R /dev/ttyAMA0
|
||||
/usr/bin/stm32flash -v -w bin/$(BINBIN_F7) -g 0x0 -R -c /dev/ttyAMA0
|
||||
endif
|
||||
|
||||
deploy-f7m: deploy-pi-f7
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/make
|
||||
# makefile for the arduino due (works with arduino IDE 1.6.12)
|
||||
# makefile for the arduino due (works with arduino IDE 1.6.11)
|
||||
#
|
||||
# The original file can be found at https://github.com/pauldreik/arduino-due-makefile
|
||||
#
|
||||
@@ -34,7 +34,7 @@ OBJCOPY:=$(ADIR)/packages/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/arm-n
|
||||
|
||||
C:=$(CC)
|
||||
#SAM:=arduino/sam/
|
||||
SAM:=$(ADIR)/packages/arduino/hardware/sam/1.6.12
|
||||
SAM:=$(ADIR)/packages/arduino/hardware/sam/1.6.11
|
||||
#CMSIS:=arduino/sam/system/CMSIS/
|
||||
#LIBSAM:=arduino/sam/system/libsam
|
||||
TMPDIR:=$(PWD)/build
|
||||
|
||||
+1
-6
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2009-2018,2020 by Jonathan Naylor G4KLX
|
||||
* Copyright (C) 2009-2018 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
|
||||
@@ -17,9 +17,6 @@
|
||||
*/
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#if defined(MODE_NXDN)
|
||||
|
||||
#include "Globals.h"
|
||||
#include "NXDNRX.h"
|
||||
#include "Utils.h"
|
||||
@@ -406,5 +403,3 @@ void CNXDNRX::writeRSSIData(uint8_t* data)
|
||||
m_rssiCount = 0U;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2015,2016,2017,2018,2020 by Jonathan Naylor G4KLX
|
||||
* Copyright (C) 2015,2016,2017,2018 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
|
||||
@@ -16,13 +16,10 @@
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#if defined(MODE_NXDN)
|
||||
|
||||
#if !defined(NXDNRX_H)
|
||||
#define NXDNRX_H
|
||||
|
||||
#include "Config.h"
|
||||
#include "NXDNDefines.h"
|
||||
|
||||
enum NXDNRX_STATE {
|
||||
@@ -70,5 +67,3 @@ private:
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
+2
-9
@@ -18,9 +18,6 @@
|
||||
*/
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#if defined(MODE_NXDN)
|
||||
|
||||
#include "Globals.h"
|
||||
#include "NXDNTX.h"
|
||||
|
||||
@@ -84,8 +81,7 @@ void CNXDNTX::process()
|
||||
m_poBuffer[m_poLen++] = NXDN_PREAMBLE[2U];
|
||||
} else {
|
||||
for (uint8_t i = 0U; i < NXDN_FRAME_LENGTH_BYTES; i++) {
|
||||
uint8_t c = 0U;
|
||||
m_buffer.get(c);
|
||||
uint8_t c = m_buffer.get();
|
||||
m_poBuffer[m_poLen++] = c;
|
||||
}
|
||||
}
|
||||
@@ -126,7 +122,7 @@ void CNXDNTX::process()
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t CNXDNTX::writeData(const uint8_t* data, uint16_t length)
|
||||
uint8_t CNXDNTX::writeData(const uint8_t* data, uint8_t length)
|
||||
{
|
||||
if (length != (NXDN_FRAME_LENGTH_BYTES + 1U))
|
||||
return 4U;
|
||||
@@ -203,6 +199,3 @@ void CNXDNTX::setParams(uint8_t txHang)
|
||||
{
|
||||
m_txHang = txHang * 600U;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -16,20 +16,18 @@
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#if defined(MODE_NXDN)
|
||||
|
||||
#if !defined(NXDNTX_H)
|
||||
#define NXDNTX_H
|
||||
|
||||
#include "RingBuffer.h"
|
||||
#include "Config.h"
|
||||
|
||||
#include "SerialRB.h"
|
||||
|
||||
class CNXDNTX {
|
||||
public:
|
||||
CNXDNTX();
|
||||
|
||||
uint8_t writeData(const uint8_t* data, uint16_t length);
|
||||
uint8_t writeData(const uint8_t* data, uint8_t length);
|
||||
|
||||
void process();
|
||||
|
||||
@@ -40,7 +38,7 @@ public:
|
||||
void setParams(uint8_t txHang);
|
||||
|
||||
private:
|
||||
CRingBuffer<uint8_t> m_buffer;
|
||||
CSerialRB m_buffer;
|
||||
arm_fir_interpolate_instance_q15 m_modFilter;
|
||||
arm_fir_instance_q15 m_sincFilter;
|
||||
q15_t m_modState[16U]; // blockSize + phaseLength - 1, 4 + 9 - 1 plus some spare
|
||||
@@ -57,6 +55,3 @@ private:
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2009-2017,2020 by Jonathan Naylor G4KLX
|
||||
* Copyright (C) 2009-2017 by Jonathan Naylor G4KLX
|
||||
* Copyright (C) 2018 by Bryan Biedenkapp <gatekeep@gmail.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -18,9 +18,6 @@
|
||||
*/
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#if defined(MODE_P25)
|
||||
|
||||
#include "Globals.h"
|
||||
#include "P25RX.h"
|
||||
#include "Utils.h"
|
||||
@@ -538,6 +535,3 @@ void CP25RX::writeRSSILdu(uint8_t* ldu)
|
||||
m_rssiAccum = 0U;
|
||||
m_rssiCount = 0U;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2015,2016,2017,2020 by Jonathan Naylor G4KLX
|
||||
* Copyright (C) 2015,2016,2017 by Jonathan Naylor G4KLX
|
||||
* Copyright (C) 2018 by Bryan Biedenkapp <gatekeep@gmail.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -17,13 +17,10 @@
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#if defined(MODE_P25)
|
||||
|
||||
#if !defined(P25RX_H)
|
||||
#define P25RX_H
|
||||
|
||||
#include "Config.h"
|
||||
#include "P25Defines.h"
|
||||
|
||||
enum P25RX_STATE {
|
||||
@@ -75,6 +72,3 @@ private:
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -18,9 +18,6 @@
|
||||
*/
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#if defined(MODE_P25)
|
||||
|
||||
#include "Globals.h"
|
||||
#include "P25TX.h"
|
||||
|
||||
@@ -78,11 +75,9 @@ void CP25TX::process()
|
||||
for (uint16_t i = 0U; i < m_txDelay; i++)
|
||||
m_poBuffer[m_poLen++] = P25_START_SYNC;
|
||||
} else {
|
||||
uint8_t length;
|
||||
m_buffer.get(length);
|
||||
uint8_t length = m_buffer.get();
|
||||
for (uint8_t i = 0U; i < length; i++) {
|
||||
uint8_t c = 0U;
|
||||
m_buffer.get(c);
|
||||
uint8_t c = m_buffer.get();
|
||||
m_poBuffer[m_poLen++] = c;
|
||||
}
|
||||
}
|
||||
@@ -123,7 +118,7 @@ void CP25TX::process()
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t CP25TX::writeData(const uint8_t* data, uint16_t length)
|
||||
uint8_t CP25TX::writeData(const uint8_t* data, uint8_t length)
|
||||
{
|
||||
if (length < (P25_TERM_FRAME_LENGTH_BYTES + 1U))
|
||||
return 4U;
|
||||
@@ -201,6 +196,3 @@ void CP25TX::setParams(uint8_t txHang)
|
||||
{
|
||||
m_txHang = txHang * 1200U;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user