mirror of
https://github.com/g4klx/MMDVM.git
synced 2026-10-15 16:24:11 +02:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7f339556f4 | ||
|
|
0189520ab2 | ||
|
|
5d2d37f44b | ||
|
|
5ede02212a | ||
|
|
85d3086d4c | ||
|
|
ccf3b7301e | ||
|
|
6b3a811ae7 | ||
|
|
3e079f58ad | ||
|
|
7ef0d992d9 | ||
|
|
bf23a94038 | ||
|
|
b2755864ef | ||
|
|
7276ca3929 | ||
|
|
d14b9dede3 | ||
|
|
de87d77ad6 | ||
|
|
2626ad5580 | ||
|
|
031b078e76 | ||
|
|
5d987969a9 | ||
|
|
f898390956 | ||
|
|
f8d1cc7aed | ||
|
|
cf9fa93cb9 | ||
|
|
69adaf2ebb | ||
|
|
7f4ae790ba | ||
|
|
416fc8fc8b | ||
|
|
5b79356ddb | ||
|
|
26fc87aca6 | ||
|
|
54745130c2 | ||
|
|
f65d52bf2f | ||
|
|
5800b33f21 | ||
|
|
105dba2c27 | ||
|
|
777cc9f2ea | ||
|
|
e879b4615a | ||
|
|
8d69fc59be | ||
|
|
2f4e9cc269 | ||
|
|
ee07f76bd5 | ||
|
|
d063a1da1e | ||
|
|
6a4dad4c44 | ||
|
|
ed6bd66fab | ||
|
|
1a07a6f0d1 | ||
|
|
70bf47f93e | ||
|
|
a5eaafc7e0 | ||
|
|
2200945857 | ||
|
|
63a8e61a45 | ||
|
|
7275f65e44 | ||
|
|
2aabdb61ab | ||
|
|
96c0e5b141 | ||
|
|
9c883cfafd | ||
|
|
8a1ab88c3a | ||
|
|
f4e1c0b401 | ||
|
|
43b53fe2fc | ||
|
|
6517229f87 | ||
|
|
d0557ab723 | ||
|
|
b5d106dcb6 | ||
|
|
34cbff41c9 | ||
|
|
752e13821f | ||
|
|
86b45c15eb | ||
|
|
4fa0e052f8 | ||
|
|
0736a5cbe8 | ||
|
|
6ffb68450c | ||
|
|
1ad20fd4a0 | ||
|
|
34f6dfc5bb | ||
|
|
1e065ba17f | ||
|
|
1df7d7a7fc | ||
|
|
7e919b12f7 | ||
|
|
bada4d9285 | ||
|
|
9ae4a5376d | ||
|
|
8038ce9c9c | ||
|
|
842dcdb5c5 | ||
|
|
f7ead5cc0e | ||
|
|
b155597693 | ||
|
|
7148cf9f7d | ||
|
|
9440b43114 | ||
|
|
c06a83660f | ||
|
|
657e71238d | ||
|
|
510d433906 | ||
|
|
ff39a9031b | ||
|
|
4f3aa8b7e1 | ||
|
|
a35b8f929a | ||
|
|
6d0335b357 | ||
|
|
54f4dcabf0 | ||
|
|
19e2ccf150 | ||
|
|
0c4f49fa68 | ||
|
|
98ebefe84b | ||
|
|
029e7eef4a | ||
|
|
ca4fff2ba6 | ||
|
|
23ba73cabd | ||
|
|
519af80ac4 | ||
|
|
c5b542f438 | ||
|
|
3503e0cc2a | ||
|
|
955578789d | ||
|
|
061e10e395 | ||
|
|
fa9040fdf0 | ||
|
|
8240225371 | ||
|
|
f2c7c19444 | ||
|
|
2e5f174cdd | ||
|
|
d144ce6f1c | ||
|
|
31744a237a | ||
|
|
46c0958704 | ||
|
|
99d2a0d822 | ||
|
|
81518bf74c | ||
|
|
dd5a465a39 | ||
|
|
a345586ee9 | ||
|
|
55c89a4413 | ||
|
|
60f87072ba | ||
|
|
f2d2033733 | ||
|
|
0334b5a791 | ||
|
|
a62fd814ae | ||
|
|
02000c8049 | ||
|
|
2509ab5ba1 | ||
|
|
2de9e4d533 | ||
|
|
fda1e3dcf4 | ||
|
|
cb3ed795d0 | ||
|
|
632ddda68b | ||
|
|
b6093406ad | ||
|
|
8d9b49bdb0 | ||
|
|
625ec93af8 | ||
|
|
b2111553c6 | ||
|
|
252d54a484 | ||
|
|
1ad9799123 | ||
|
|
2a001f491d | ||
|
|
b5ba384495 | ||
|
|
d8f138066e | ||
|
|
6964251122 | ||
|
|
9ff59570c7 | ||
|
|
5960fb97f3 | ||
|
|
d29a0bc3a6 | ||
|
|
ad77fd60fd | ||
|
|
aab8f5469f | ||
|
|
f1d6a8b36e | ||
|
|
843997ccad | ||
|
|
d5f2d1c382 | ||
|
|
c99f50575d | ||
|
|
29c8cf9414 | ||
|
|
2c6e2c2a11 | ||
|
|
8d10555dc9 | ||
|
|
14d5098018 | ||
|
|
52a351d0f1 | ||
|
|
43f84ae968 | ||
|
|
a73376671c | ||
|
|
759efd1da4 | ||
|
|
ea0c1953cc | ||
|
|
a29cb23a75 | ||
|
|
bb66c72ef3 | ||
|
|
0ea732780d | ||
|
|
1309ad9326 | ||
|
|
411d439d78 | ||
|
|
ec9428d63e | ||
|
|
2a4b28c35e | ||
|
|
4f060c0047 | ||
|
|
1ed3a4c9d5 | ||
|
|
f414288c9b | ||
|
|
72cd2ce03e | ||
|
|
9137af8e3f | ||
|
|
cdfe3d0ec9 | ||
|
|
4dfab06a50 | ||
|
|
47649171fc | ||
|
|
0bd79fa440 | ||
|
|
26d055a67b | ||
|
|
5db1adb5ea | ||
|
|
f86b5435bb | ||
|
|
31f0e24588 | ||
|
|
04d0b15545 | ||
|
|
f14222e77d | ||
|
|
5039dfbe68 | ||
|
|
f9f81b9b8e | ||
|
|
3cc5d67696 | ||
|
|
3f960f9fc5 | ||
|
|
489853f200 | ||
|
|
96e1a765f9 | ||
|
|
04982c25c0 | ||
|
|
a3ffa9ed36 | ||
|
|
e7a22482db | ||
|
|
625749a546 | ||
|
|
d75042dc4c | ||
|
|
296ac88842 | ||
|
|
48e863d1d0 | ||
|
|
7b915f9cac | ||
|
|
e330c9f52a | ||
|
|
9470b1d6d3 | ||
|
|
388620b182 | ||
|
|
72e45177f3 | ||
|
|
90b82621f2 | ||
|
|
cfcb7ed852 | ||
|
|
b245be464f | ||
|
|
139003d4c7 | ||
|
|
c47eacd010 | ||
|
|
6b01f12602 | ||
|
|
4f93c6022c | ||
|
|
81f6b6be53 | ||
|
|
fa9f89700f | ||
|
|
9023b6ae13 | ||
|
|
df23e15c91 | ||
|
|
51e5e7b851 | ||
|
|
056dd908b3 | ||
|
|
62f239ccc9 | ||
|
|
994226e4b1 | ||
|
|
2cc6c1f68f | ||
|
|
8e8cf35b19 | ||
|
|
66de35b6d8 | ||
|
|
7dc420c8ff | ||
|
|
df0a9ebe72 | ||
|
|
e957f0154e | ||
|
|
b10c72fd78 | ||
|
|
496afcb40e | ||
|
|
9467b10e5c | ||
|
|
13c5f7b0b4 | ||
|
|
b64712f657 | ||
|
|
d23c0900c1 | ||
|
|
a0a3080da2 | ||
|
|
0fad84b46d | ||
|
|
1b40044a23 | ||
|
|
a671263398 | ||
|
|
ca1cc7096a | ||
|
|
a5aabd8fac | ||
|
|
6d0e57ea88 | ||
|
|
1d04c1e903 | ||
|
|
042c26b3bb | ||
|
|
b4a125a759 | ||
|
|
8ecf80ff8f | ||
|
|
6786b9b6b1 | ||
|
|
86ffc69b30 | ||
|
|
5d4df6ffd9 | ||
|
|
eac2aa4ac1 | ||
|
|
8cbd52aa72 | ||
|
|
99b853a976 | ||
|
|
15bc1a4027 | ||
|
|
1836ba928e | ||
|
|
4a5a260c28 | ||
|
|
4bcc1e88c4 | ||
|
|
89458a2c93 | ||
|
|
c91a42f53d | ||
|
|
470a070d96 | ||
|
|
36537c981c | ||
|
|
c85978a4e3 | ||
|
|
3ad443dc2a | ||
|
|
da16ee277c | ||
|
|
0f51ddd0bd | ||
|
|
aaa72e769f | ||
|
|
0e8fdb381a | ||
|
|
0b31c40c2b | ||
|
|
2b3df4e901 | ||
|
|
807f01ba72 | ||
|
|
03f18451f7 | ||
|
|
16c3d418eb | ||
|
|
55df5fe04c | ||
|
|
b0ba3b5dd8 | ||
|
|
05d21c0a14 | ||
|
|
26a703c68c | ||
|
|
6c3dd265ab | ||
|
|
c04e207821 | ||
|
|
67e0bf02e2 | ||
|
|
7302dc8bd7 | ||
|
|
bb7383a301 | ||
|
|
61a69d8536 | ||
|
|
5a11fcea5b | ||
|
|
05775f0bfa | ||
|
|
973a1391d7 | ||
|
|
5d45649096 | ||
|
|
e91c4417cb | ||
|
|
ff3e6feeb6 | ||
|
|
0e2a83bc7b | ||
|
|
c84dbd02e5 | ||
|
|
c0aad5effa | ||
|
|
e0234dfc00 | ||
|
|
7c9385beab | ||
|
|
4c6601d778 | ||
|
|
e3a951b33b | ||
|
|
97192602d8 | ||
|
|
604957b3e2 | ||
|
|
bb731e7890 | ||
|
|
c81d13395b | ||
|
|
18bc0a75b8 | ||
|
|
f1a43ee520 | ||
|
|
b73bca237d | ||
|
|
e7ff0d1898 | ||
|
|
880df2536d | ||
|
|
09b6929100 | ||
|
|
9afcf3acc9 | ||
|
|
d7cd7096d0 | ||
|
|
5d1b66dde3 | ||
|
|
96364dc189 | ||
|
|
a816818e3f |
@@ -1,9 +0,0 @@
|
|||||||
[submodule "STM32F4XX_Lib"]
|
|
||||||
path = STM32F4XX_Lib
|
|
||||||
url = https://github.com/juribeparada/STM32F4XX_Lib.git
|
|
||||||
[submodule "STM32F7XX_Lib"]
|
|
||||||
path = STM32F7XX_Lib
|
|
||||||
url = https://github.com/juribeparada/STM32F7XX_Lib.git
|
|
||||||
[submodule "STM32F10X_Lib"]
|
|
||||||
path = STM32F10X_Lib
|
|
||||||
url = https://github.com/shawnchain/STM32F10X_Lib.git
|
|
||||||
|
|||||||
+88
-14
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2020 by Jonathan Naylor G4KLX
|
* Copyright (C) 2020,2023 by Jonathan Naylor G4KLX
|
||||||
* Copyright 2015-2019 Mobilinkd LLC <[email protected]>
|
* Copyright 2015-2019 Mobilinkd LLC <[email protected]>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@@ -18,6 +18,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
|
|
||||||
|
#if defined(MODE_AX25)
|
||||||
|
|
||||||
#include "Globals.h"
|
#include "Globals.h"
|
||||||
#include "AX25Demodulator.h"
|
#include "AX25Demodulator.h"
|
||||||
#include "AX25Defines.h"
|
#include "AX25Defines.h"
|
||||||
@@ -30,21 +33,29 @@ const uint16_t DELAY_LEN = 11U;
|
|||||||
const float32_t SAMPLES_PER_SYMBOL = SAMPLE_RATE / SYMBOL_RATE;
|
const float32_t SAMPLES_PER_SYMBOL = SAMPLE_RATE / SYMBOL_RATE;
|
||||||
const float32_t PLL_LIMIT = SAMPLES_PER_SYMBOL / 2.0F;
|
const float32_t PLL_LIMIT = SAMPLES_PER_SYMBOL / 2.0F;
|
||||||
|
|
||||||
const uint32_t LPF_FILTER_LEN = 96U;
|
const uint32_t LPF_FILTER_LEN = 48U;
|
||||||
|
|
||||||
q15_t LPF_FILTER_COEFFS[] = {
|
q15_t LPF_FILTER_COEFFS[] = {
|
||||||
0, 0, 0, 1, 2, 5, 8, 12, 18, 23,
|
-2, -8, -17, -28, -40, -47, -47, -34,
|
||||||
29, 33, 36, 36, 33, 25, 13, -5, -28, -57,
|
-5, 46, 122, 224, 354, 510, 689, 885,
|
||||||
-89, -123, -159, -194, -225, -249, -264, -267, -254, -224,
|
1092, 1302, 1506, 1693, 1856, 1987, 2077, 2124,
|
||||||
-175, -104, -12, 102, 236, 389, 557, 738, 926, 1117,
|
2124, 2077, 1987, 1856, 1693, 1506, 1302, 1092,
|
||||||
1306, 1486, 1654, 1802, 1927, 2025, 2092, 2126, 2126, 2092,
|
885, 689, 510, 354, 224, 122, 46, -5,
|
||||||
2025, 1927, 1802, 1654, 1486, 1306, 1117, 926, 738, 557,
|
-34, -47, -47, -40, -28, -17, -8, -2
|
||||||
389, 236, 102, -12, -104, -175, -224, -254, -267, -264,
|
|
||||||
-249, -225, -194, -159, -123, -89, -57, -28, -5, 13,
|
|
||||||
25, 33, 36, 36, 33, 29, 23, 18, 12, 8,
|
|
||||||
5, 2, 1, 0, 0, 0
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 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.
|
// 64 Hz loop filter.
|
||||||
// scipy.signal:
|
// scipy.signal:
|
||||||
// loop_coeffs = firwin(9, [64.0/(1200/2)], width = None,
|
// loop_coeffs = firwin(9, [64.0/(1200/2)], width = None,
|
||||||
@@ -67,11 +78,16 @@ m_pllState(),
|
|||||||
m_pllLast(false),
|
m_pllLast(false),
|
||||||
m_pllBits(1U),
|
m_pllBits(1U),
|
||||||
m_pllCount(0.0F),
|
m_pllCount(0.0F),
|
||||||
|
m_pllJitter(0.0F),
|
||||||
|
m_pllDCD(false),
|
||||||
|
m_iirHistory(),
|
||||||
m_hdlcOnes(0U),
|
m_hdlcOnes(0U),
|
||||||
m_hdlcFlag(false),
|
m_hdlcFlag(false),
|
||||||
m_hdlcBuffer(0U),
|
m_hdlcBuffer(0U),
|
||||||
m_hdlcBits(0U),
|
m_hdlcBits(0U),
|
||||||
m_hdlcState(AX25_IDLE)
|
m_hdlcState(AX25_IDLE),
|
||||||
|
m_rssiAccum(0U),
|
||||||
|
m_rssiCount(0U)
|
||||||
{
|
{
|
||||||
m_delayLine = new bool[DELAY_LEN];
|
m_delayLine = new bool[DELAY_LEN];
|
||||||
|
|
||||||
@@ -82,9 +98,12 @@ m_hdlcState(AX25_IDLE)
|
|||||||
m_pllFilter.numTaps = PLL_FILTER_LEN;
|
m_pllFilter.numTaps = PLL_FILTER_LEN;
|
||||||
m_pllFilter.pState = m_pllState;
|
m_pllFilter.pState = m_pllState;
|
||||||
m_pllFilter.pCoeffs = PLL_FILTER_COEFFS;
|
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 CAX25Demodulator::process(q15_t* samples, const uint16_t* rssi, uint8_t length, CAX25Frame& frame)
|
||||||
{
|
{
|
||||||
bool result = false;
|
bool result = false;
|
||||||
|
|
||||||
@@ -102,6 +121,9 @@ bool CAX25Demodulator::process(q15_t* samples, uint8_t length, CAX25Frame& frame
|
|||||||
::arm_fir_fast_q15(&m_lpfFilter, buffer, fc, RX_BLOCK_SIZE);
|
::arm_fir_fast_q15(&m_lpfFilter, buffer, fc, RX_BLOCK_SIZE);
|
||||||
|
|
||||||
for (uint8_t i = 0; i < length; i++) {
|
for (uint8_t i = 0; i < length; i++) {
|
||||||
|
m_rssiAccum += rssi[i];
|
||||||
|
m_rssiCount++;
|
||||||
|
|
||||||
bool bit = fc[i] >= 0;
|
bool bit = fc[i] >= 0;
|
||||||
bool sample = PLL(bit);
|
bool sample = PLL(bit);
|
||||||
|
|
||||||
@@ -158,10 +180,18 @@ bool CAX25Demodulator::PLL(bool input)
|
|||||||
if (m_pllCount > PLL_LIMIT)
|
if (m_pllCount > PLL_LIMIT)
|
||||||
m_pllCount -= SAMPLES_PER_SYMBOL;
|
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 offset = m_pllCount / float32_t(m_pllBits);
|
||||||
float32_t jitter;
|
float32_t jitter;
|
||||||
::arm_fir_f32(&m_pllFilter, &offset, &jitter, 1U);
|
::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_pllCount -= jitter / 2.0F;
|
||||||
m_pllBits = 1U;
|
m_pllBits = 1U;
|
||||||
} else {
|
} else {
|
||||||
@@ -241,6 +271,8 @@ bool CAX25Demodulator::HDLC(bool b)
|
|||||||
// Start of frame data.
|
// Start of frame data.
|
||||||
m_hdlcState = AX25_RECEIVE;
|
m_hdlcState = AX25_RECEIVE;
|
||||||
m_frame.append(m_hdlcBuffer);
|
m_frame.append(m_hdlcBuffer);
|
||||||
|
m_rssiAccum = 0U;
|
||||||
|
m_rssiCount = 0U;
|
||||||
m_hdlcBits = 0U;
|
m_hdlcBits = 0U;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -264,3 +296,45 @@ void CAX25Demodulator::setTwist(int8_t n)
|
|||||||
m_twist.setTwist(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;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t CAX25Demodulator::getRSSI()
|
||||||
|
{
|
||||||
|
if (m_rssiCount > 0U) {
|
||||||
|
uint16_t rssi = m_rssiAccum / m_rssiCount;
|
||||||
|
|
||||||
|
m_rssiAccum = 0U;
|
||||||
|
m_rssiCount = 0U;
|
||||||
|
|
||||||
|
return rssi;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0U;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|||||||
+19
-5
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2020 by Jonathan Naylor G4KLX
|
* Copyright (C) 2020,2023 by Jonathan Naylor G4KLX
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -16,11 +16,13 @@
|
|||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "Config.h"
|
||||||
|
|
||||||
|
#if defined(MODE_AX25)
|
||||||
|
|
||||||
#if !defined(AX25Demodulator_H)
|
#if !defined(AX25Demodulator_H)
|
||||||
#define AX25Demodulator_H
|
#define AX25Demodulator_H
|
||||||
|
|
||||||
#include "Config.h"
|
|
||||||
|
|
||||||
#include "AX25Frame.h"
|
#include "AX25Frame.h"
|
||||||
#include "AX25Twist.h"
|
#include "AX25Twist.h"
|
||||||
|
|
||||||
@@ -34,15 +36,19 @@ class CAX25Demodulator {
|
|||||||
public:
|
public:
|
||||||
CAX25Demodulator(int8_t n);
|
CAX25Demodulator(int8_t n);
|
||||||
|
|
||||||
bool process(q15_t* samples, uint8_t length, CAX25Frame& frame);
|
bool process(q15_t* samples, const uint16_t* rssi, uint8_t length, CAX25Frame& frame);
|
||||||
|
|
||||||
void setTwist(int8_t n);
|
void setTwist(int8_t n);
|
||||||
|
|
||||||
|
bool isDCD();
|
||||||
|
|
||||||
|
uint16_t getRSSI();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CAX25Frame m_frame;
|
CAX25Frame m_frame;
|
||||||
CAX25Twist m_twist;
|
CAX25Twist m_twist;
|
||||||
arm_fir_instance_q15 m_lpfFilter;
|
arm_fir_instance_q15 m_lpfFilter;
|
||||||
q15_t m_lpfState[120U]; // NoTaps + BlockSize - 1, 96 + 20 - 1 plus some spare
|
q15_t m_lpfState[70U]; // NoTaps + BlockSize - 1, 48 + 20 - 1 plus some spare
|
||||||
bool* m_delayLine;
|
bool* m_delayLine;
|
||||||
uint16_t m_delayPos;
|
uint16_t m_delayPos;
|
||||||
bool m_nrziState;
|
bool m_nrziState;
|
||||||
@@ -51,17 +57,25 @@ private:
|
|||||||
bool m_pllLast;
|
bool m_pllLast;
|
||||||
uint8_t m_pllBits;
|
uint8_t m_pllBits;
|
||||||
float32_t m_pllCount;
|
float32_t m_pllCount;
|
||||||
|
float32_t m_pllJitter;
|
||||||
|
bool m_pllDCD;
|
||||||
|
float32_t m_iirHistory[5U];
|
||||||
uint16_t m_hdlcOnes;
|
uint16_t m_hdlcOnes;
|
||||||
bool m_hdlcFlag;
|
bool m_hdlcFlag;
|
||||||
uint16_t m_hdlcBuffer;
|
uint16_t m_hdlcBuffer;
|
||||||
uint16_t m_hdlcBits;
|
uint16_t m_hdlcBits;
|
||||||
AX25_STATE m_hdlcState;
|
AX25_STATE m_hdlcState;
|
||||||
|
uint32_t m_rssiAccum;
|
||||||
|
uint16_t m_rssiCount;
|
||||||
|
|
||||||
bool delay(bool b);
|
bool delay(bool b);
|
||||||
bool NRZI(bool b);
|
bool NRZI(bool b);
|
||||||
bool PLL(bool b);
|
bool PLL(bool b);
|
||||||
bool HDLC(bool b);
|
bool HDLC(bool b);
|
||||||
|
float32_t iir(float32_t input);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
|
|
||||||
|
#if defined(MODE_AX25)
|
||||||
|
|
||||||
#include "Globals.h"
|
#include "Globals.h"
|
||||||
#include "AX25Frame.h"
|
#include "AX25Frame.h"
|
||||||
|
|
||||||
@@ -120,3 +123,5 @@ void CAX25Frame::addCRC()
|
|||||||
m_data[m_length++] = crc8[1U];
|
m_data[m_length++] = crc8[1U];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|||||||
+6
-2
@@ -16,11 +16,13 @@
|
|||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "Config.h"
|
||||||
|
|
||||||
|
#if defined(MODE_AX25)
|
||||||
|
|
||||||
#if !defined(AX25Frame_H)
|
#if !defined(AX25Frame_H)
|
||||||
#define AX25Frame_H
|
#define AX25Frame_H
|
||||||
|
|
||||||
#include "Config.h"
|
|
||||||
|
|
||||||
const uint16_t AX25_MAX_PACKET_LEN = 300U;
|
const uint16_t AX25_MAX_PACKET_LEN = 300U;
|
||||||
|
|
||||||
class CAX25Frame {
|
class CAX25Frame {
|
||||||
@@ -41,3 +43,5 @@ public:
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|||||||
+137
-22
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2020 by Jonathan Naylor G4KLX
|
* Copyright (C) 2020,2023 by Jonathan Naylor G4KLX
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -17,6 +17,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
|
|
||||||
|
#if defined(MODE_AX25)
|
||||||
|
|
||||||
#include "Globals.h"
|
#include "Globals.h"
|
||||||
#include "AX25RX.h"
|
#include "AX25RX.h"
|
||||||
|
|
||||||
@@ -39,22 +42,23 @@
|
|||||||
* window='hann') * 32768,
|
* window='hann') * 32768,
|
||||||
* dtype=int)[10:-10]
|
* dtype=int)[10:-10]
|
||||||
*/
|
*/
|
||||||
const uint32_t FILTER_LEN = 132;
|
|
||||||
|
const uint32_t FILTER_LEN = 130U;
|
||||||
|
|
||||||
q15_t FILTER_COEFFS[] = {
|
q15_t FILTER_COEFFS[] = {
|
||||||
0, 5, 12, 18, 21, 19, 11, -2, -15, -25,
|
5, 12, 18, 21, 19, 11, -2, -15, -25, -27,
|
||||||
-27, -21, -11, -3, -5, -19, -43, -69, -83, -73,
|
-21, -11, -3, -5, -19, -43, -69, -83, -73, -35,
|
||||||
-35, 27, 98, 155, 180, 163, 109, 39, -20, -45,
|
27, 98, 155, 180, 163, 109, 39, -20, -45, -26,
|
||||||
-26, 23, 74, 89, 39, -81, -247, -407, -501, -480,
|
23, 74, 89, 39, -81, -247, -407, -501, -480, -334,
|
||||||
-334, -92, 175, 388, 479, 429, 275, 99, 5, 68,
|
-92, 175, 388, 479, 429, 275, 99, 5, 68, 298,
|
||||||
298, 626, 913, 994, 740, 115, -791, -1770, -2544, -2847,
|
626, 913, 994, 740, 115, -791, -1770, -2544, -2847, -2509,
|
||||||
-2509, -1527, -76, 1518, 2875, 3653, 3653, 2875, 1518, -76,
|
-1527, -76, 1518, 2875, 3653, 3653, 2875, 1518, -76, -1527,
|
||||||
-1527, -2509, -2847, -2544, -1770, -791, 115, 740, 994, 913,
|
-2509, -2847, -2544, -1770, -791, 115, 740, 994, 913, 626,
|
||||||
626, 298, 68, 5, 99, 275, 429, 479, 388, 175,
|
298, 68, 5, 99, 275, 429, 479, 388, 175, -92,
|
||||||
-92, -334, -480, -501, -407, -247, -81, 39, 89, 74,
|
-334, -480, -501, -407, -247, -81, 39, 89, 74, 23,
|
||||||
23, -26, -45, -20, 39, 109, 163, 180, 155, 98,
|
-26, -45, -20, 39, 109, 163, 180, 155, 98, 27,
|
||||||
27, -35, -73, -83, -69, -43, -19, -5, -3, -11,
|
-35, -73, -83, -69, -43, -19, -5, -3, -11, -21,
|
||||||
-21, -27, -25, -15, -2, 11, 19, 21, 18, 12,
|
-27, -25, -15, -2, 11, 19, 21, 18, 12, 5
|
||||||
5, 0
|
|
||||||
};
|
};
|
||||||
|
|
||||||
CAX25RX::CAX25RX() :
|
CAX25RX::CAX25RX() :
|
||||||
@@ -64,14 +68,25 @@ m_demod1(3),
|
|||||||
m_demod2(6),
|
m_demod2(6),
|
||||||
m_demod3(9),
|
m_demod3(9),
|
||||||
m_lastFCS(0U),
|
m_lastFCS(0U),
|
||||||
m_count(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.numTaps = FILTER_LEN;
|
||||||
m_filter.pState = m_state;
|
m_filter.pState = m_state;
|
||||||
m_filter.pCoeffs = FILTER_COEFFS;
|
m_filter.pCoeffs = FILTER_COEFFS;
|
||||||
|
|
||||||
|
initRand();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAX25RX::samples(q15_t* samples, uint8_t length)
|
void CAX25RX::samples(q15_t* samples, const uint16_t* rssi, uint8_t length)
|
||||||
{
|
{
|
||||||
q15_t output[RX_BLOCK_SIZE];
|
q15_t output[RX_BLOCK_SIZE];
|
||||||
::arm_fir_fast_q15(&m_filter, samples, output, RX_BLOCK_SIZE);
|
::arm_fir_fast_q15(&m_filter, samples, output, RX_BLOCK_SIZE);
|
||||||
@@ -80,41 +95,141 @@ void CAX25RX::samples(q15_t* samples, uint8_t length)
|
|||||||
|
|
||||||
CAX25Frame frame;
|
CAX25Frame frame;
|
||||||
|
|
||||||
bool ret = m_demod1.process(output, length, frame);
|
bool ret = m_demod1.process(output, rssi, length, frame);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
if (frame.m_fcs != m_lastFCS || m_count > 2U) {
|
if (frame.m_fcs != m_lastFCS || m_count > 2U) {
|
||||||
m_lastFCS = frame.m_fcs;
|
m_lastFCS = frame.m_fcs;
|
||||||
m_count = 0U;
|
m_count = 0U;
|
||||||
|
#if defined(SEND_RSSI_DATA)
|
||||||
|
uint16_t rssi = m_demod1.getRSSI();
|
||||||
|
if (rssi > 0U)
|
||||||
|
serial.writeAX25DataEx(rssi, frame.m_data, frame.m_length - 2U);
|
||||||
|
else
|
||||||
|
serial.writeAX25Data(frame.m_data, frame.m_length - 2U);
|
||||||
|
#else
|
||||||
serial.writeAX25Data(frame.m_data, frame.m_length - 2U);
|
serial.writeAX25Data(frame.m_data, frame.m_length - 2U);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
DEBUG1("Decoder 1 reported");
|
DEBUG1("Decoder 1 reported");
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = m_demod2.process(output, length, frame);
|
ret = m_demod2.process(output, rssi, length, frame);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
if (frame.m_fcs != m_lastFCS || m_count > 2U) {
|
if (frame.m_fcs != m_lastFCS || m_count > 2U) {
|
||||||
m_lastFCS = frame.m_fcs;
|
m_lastFCS = frame.m_fcs;
|
||||||
m_count = 0U;
|
m_count = 0U;
|
||||||
|
#if defined(SEND_RSSI_DATA)
|
||||||
|
uint16_t rssi = m_demod2.getRSSI();
|
||||||
|
if (rssi > 0U)
|
||||||
|
serial.writeAX25DataEx(rssi, frame.m_data, frame.m_length - 2U);
|
||||||
|
else
|
||||||
|
serial.writeAX25Data(frame.m_data, frame.m_length - 2U);
|
||||||
|
#else
|
||||||
serial.writeAX25Data(frame.m_data, frame.m_length - 2U);
|
serial.writeAX25Data(frame.m_data, frame.m_length - 2U);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
DEBUG1("Decoder 2 reported");
|
DEBUG1("Decoder 2 reported");
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = m_demod3.process(output, length, frame);
|
ret = m_demod3.process(output, rssi, length, frame);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
if (frame.m_fcs != m_lastFCS || m_count > 2U) {
|
if (frame.m_fcs != m_lastFCS || m_count > 2U) {
|
||||||
m_lastFCS = frame.m_fcs;
|
m_lastFCS = frame.m_fcs;
|
||||||
m_count = 0U;
|
m_count = 0U;
|
||||||
|
#if defined(SEND_RSSI_DATA)
|
||||||
|
uint16_t rssi = m_demod3.getRSSI();
|
||||||
|
if (rssi > 0U)
|
||||||
|
serial.writeAX25DataEx(rssi, frame.m_data, frame.m_length - 2U);
|
||||||
|
else
|
||||||
|
serial.writeAX25Data(frame.m_data, frame.m_length - 2U);
|
||||||
|
#else
|
||||||
serial.writeAX25Data(frame.m_data, frame.m_length - 2U);
|
serial.writeAX25Data(frame.m_data, frame.m_length - 2U);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
DEBUG1("Decoder 3 reported");
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAX25RX::setParams(int8_t twist)
|
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_demod1.setTwist(twist - 3);
|
||||||
m_demod2.setTwist(twist);
|
m_demod2.setTwist(twist);
|
||||||
m_demod3.setTwist(twist + 3);
|
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,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2020 by Jonathan Naylor G4KLX
|
* Copyright (C) 2020,2023 by Jonathan Naylor G4KLX
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -16,30 +16,48 @@
|
|||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "Config.h"
|
||||||
|
|
||||||
|
#if defined(MODE_AX25)
|
||||||
|
|
||||||
#if !defined(AX25RX_H)
|
#if !defined(AX25RX_H)
|
||||||
#define AX25RX_H
|
#define AX25RX_H
|
||||||
|
|
||||||
#include "Config.h"
|
|
||||||
|
|
||||||
#include "AX25Demodulator.h"
|
#include "AX25Demodulator.h"
|
||||||
|
|
||||||
class CAX25RX {
|
class CAX25RX {
|
||||||
public:
|
public:
|
||||||
CAX25RX();
|
CAX25RX();
|
||||||
|
|
||||||
void samples(q15_t* samples, uint8_t length);
|
void samples(q15_t* samples, const uint16_t* rssi, uint8_t length);
|
||||||
|
|
||||||
void setParams(int8_t twist);
|
void setParams(int8_t twist, uint8_t slotTime, uint8_t pPersist);
|
||||||
|
|
||||||
|
bool canTX() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
arm_fir_instance_q15 m_filter;
|
arm_fir_instance_q15 m_filter;
|
||||||
q15_t m_state[160U]; // NoTaps + BlockSize - 1, 132 + 20 - 1 plus some spare
|
q15_t m_state[160U]; // NoTaps + BlockSize - 1, 130 + 20 - 1 plus some spare
|
||||||
CAX25Demodulator m_demod1;
|
CAX25Demodulator m_demod1;
|
||||||
CAX25Demodulator m_demod2;
|
CAX25Demodulator m_demod2;
|
||||||
CAX25Demodulator m_demod3;
|
CAX25Demodulator m_demod3;
|
||||||
uint16_t m_lastFCS;
|
uint16_t m_lastFCS;
|
||||||
uint32_t m_count;
|
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
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|||||||
+33
-22
@@ -17,6 +17,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
|
|
||||||
|
#if defined(MODE_AX25)
|
||||||
|
|
||||||
#include "Globals.h"
|
#include "Globals.h"
|
||||||
#include "AX25TX.h"
|
#include "AX25TX.h"
|
||||||
|
|
||||||
@@ -49,11 +52,10 @@ const q15_t AUDIO_TABLE_DATA[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
CAX25TX::CAX25TX() :
|
CAX25TX::CAX25TX() :
|
||||||
m_twist(-6),
|
|
||||||
m_poBuffer(),
|
m_poBuffer(),
|
||||||
m_poLen(0U),
|
m_poLen(0U),
|
||||||
m_poPtr(0U),
|
m_poPtr(0U),
|
||||||
m_txDelay(120U),
|
m_txDelay(360U),
|
||||||
m_tablePtr(0U),
|
m_tablePtr(0U),
|
||||||
m_nrzi(false)
|
m_nrzi(false)
|
||||||
{
|
{
|
||||||
@@ -64,6 +66,14 @@ void CAX25TX::process()
|
|||||||
if (m_poLen == 0U)
|
if (m_poLen == 0U)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (!m_duplex) {
|
||||||
|
if (m_poPtr == 0U) {
|
||||||
|
bool tx = ax25RX.canTX();
|
||||||
|
if (!tx)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
uint16_t space = io.getSpace();
|
uint16_t space = io.getSpace();
|
||||||
|
|
||||||
while (space > AX25_RADIO_SYMBOL_LENGTH) {
|
while (space > AX25_RADIO_SYMBOL_LENGTH) {
|
||||||
@@ -92,9 +102,11 @@ uint8_t CAX25TX::writeData(const uint8_t* data, uint16_t length)
|
|||||||
m_nrzi = false;
|
m_nrzi = false;
|
||||||
m_tablePtr = 0U;
|
m_tablePtr = 0U;
|
||||||
|
|
||||||
// Add TX delay (already NRZI)
|
// Add TX delay
|
||||||
for (uint16_t i = 0U; i < m_txDelay; i++, m_poLen++)
|
for (uint16_t i = 0U; i < m_txDelay; i++, m_poLen++) {
|
||||||
WRITE_BIT1(m_poBuffer, m_poLen, false);
|
bool preamble = NRZI(false);
|
||||||
|
WRITE_BIT1(m_poBuffer, m_poLen, preamble);
|
||||||
|
}
|
||||||
|
|
||||||
// Add the Start Flag
|
// Add the Start Flag
|
||||||
for (uint16_t i = 0U; i < 8U; i++, m_poLen++) {
|
for (uint16_t i = 0U; i < 8U; i++, m_poLen++) {
|
||||||
@@ -136,27 +148,25 @@ uint8_t CAX25TX::writeData(const uint8_t* data, uint16_t length)
|
|||||||
|
|
||||||
void CAX25TX::writeBit(bool b)
|
void CAX25TX::writeBit(bool b)
|
||||||
{
|
{
|
||||||
q15_t in[AX25_RADIO_SYMBOL_LENGTH];
|
q15_t buffer[AX25_RADIO_SYMBOL_LENGTH];
|
||||||
for (uint8_t i = 0U; i < AX25_RADIO_SYMBOL_LENGTH; i++) {
|
for (uint8_t i = 0U; i < AX25_RADIO_SYMBOL_LENGTH; i++) {
|
||||||
in[i] = AUDIO_TABLE_DATA[m_tablePtr];
|
q15_t value = AUDIO_TABLE_DATA[m_tablePtr];
|
||||||
if (b)
|
|
||||||
|
if (b) {
|
||||||
|
// De-emphasise the lower frequency by 6dB
|
||||||
|
value >>= 2;
|
||||||
m_tablePtr += 6U;
|
m_tablePtr += 6U;
|
||||||
else
|
} else {
|
||||||
m_tablePtr += 11U;
|
m_tablePtr += 11U;
|
||||||
|
}
|
||||||
|
|
||||||
|
buffer[i] = value >> 1;
|
||||||
|
|
||||||
if (m_tablePtr >= AUDIO_TABLE_LEN)
|
if (m_tablePtr >= AUDIO_TABLE_LEN)
|
||||||
m_tablePtr -= AUDIO_TABLE_LEN;
|
m_tablePtr -= AUDIO_TABLE_LEN;
|
||||||
}
|
}
|
||||||
|
|
||||||
q15_t out[AX25_RADIO_SYMBOL_LENGTH];
|
io.write(STATE_AX25, buffer, AX25_RADIO_SYMBOL_LENGTH);
|
||||||
m_twist.process(in, out, AX25_RADIO_SYMBOL_LENGTH);
|
|
||||||
|
|
||||||
io.write(STATE_AX25, out, AX25_RADIO_SYMBOL_LENGTH);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CAX25TX::setParams(int8_t twist)
|
|
||||||
{
|
|
||||||
m_twist.setTwist(twist);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAX25TX::setTXDelay(uint8_t delay)
|
void CAX25TX::setTXDelay(uint8_t delay)
|
||||||
@@ -171,10 +181,11 @@ uint8_t CAX25TX::getSpace() const
|
|||||||
|
|
||||||
bool CAX25TX::NRZI(bool b)
|
bool CAX25TX::NRZI(bool b)
|
||||||
{
|
{
|
||||||
bool result = (b == m_nrzi);
|
if (!b)
|
||||||
|
m_nrzi = !m_nrzi;
|
||||||
|
|
||||||
m_nrzi = b;
|
return m_nrzi;
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -16,12 +16,12 @@
|
|||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if !defined(AX25TX_H)
|
|
||||||
#define AX25TX_H
|
|
||||||
|
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
|
|
||||||
#include "AX25Twist.h"
|
#if defined(MODE_AX25)
|
||||||
|
|
||||||
|
#if !defined(AX25TX_H)
|
||||||
|
#define AX25TX_H
|
||||||
|
|
||||||
class CAX25TX {
|
class CAX25TX {
|
||||||
public:
|
public:
|
||||||
@@ -31,14 +31,11 @@ public:
|
|||||||
|
|
||||||
void process();
|
void process();
|
||||||
|
|
||||||
void setParams(int8_t twist);
|
|
||||||
|
|
||||||
void setTXDelay(uint8_t delay);
|
void setTXDelay(uint8_t delay);
|
||||||
|
|
||||||
uint8_t getSpace() const;
|
uint8_t getSpace() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CAX25Twist m_twist;
|
|
||||||
uint8_t m_poBuffer[600U];
|
uint8_t m_poBuffer[600U];
|
||||||
uint16_t m_poLen;
|
uint16_t m_poLen;
|
||||||
uint16_t m_poPtr;
|
uint16_t m_poPtr;
|
||||||
@@ -52,3 +49,5 @@ private:
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
|
|
||||||
|
#if defined(MODE_AX25)
|
||||||
|
|
||||||
#include "Globals.h"
|
#include "Globals.h"
|
||||||
#include "AX25Twist.h"
|
#include "AX25Twist.h"
|
||||||
|
|
||||||
@@ -309,3 +312,5 @@ void CAX25Twist::setTwist(int8_t n)
|
|||||||
m_filter.pCoeffs = coeffs[twist];
|
m_filter.pCoeffs = coeffs[twist];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|||||||
+6
-3
@@ -16,11 +16,12 @@
|
|||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if !defined(AX25Twist_H)
|
|
||||||
#define AX25Twist_H
|
|
||||||
|
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
|
|
||||||
|
#if defined(MODE_AX25)
|
||||||
|
|
||||||
|
#if !defined(AX25Twist_H)
|
||||||
|
#define AX25Twist_H
|
||||||
|
|
||||||
class CAX25Twist {
|
class CAX25Twist {
|
||||||
public:
|
public:
|
||||||
@@ -37,3 +38,5 @@ private:
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -1,125 +0,0 @@
|
|||||||
In order to build MMDVM, you need to tell the Arduino GUI to link with the
|
|
||||||
CMSIS DSP library, which is doesn't do by default.
|
|
||||||
|
|
||||||
My development is on Windows and so I can vouch for the following instructions.
|
|
||||||
|
|
||||||
For Arduino 1.6.3 with SAM 1.6.4
|
|
||||||
--------------------------------
|
|
||||||
|
|
||||||
1. Go to the where the platform.txt file is located. On my Windows machine it's
|
|
||||||
in:
|
|
||||||
|
|
||||||
C:\Users\Jonathan\AppData\Roaming\Arduino15\packages\arduino\hardware\sam\1.6.4
|
|
||||||
|
|
||||||
On Mac OS X it's located in:
|
|
||||||
|
|
||||||
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/sam
|
|
||||||
Or
|
|
||||||
~/Library/Arduino15/packages/arduino/hardware/sam/1.6.6
|
|
||||||
|
|
||||||
2. You'll need to open the file in a text editor and find the line:
|
|
||||||
|
|
||||||
## Combine gc-sections, archives, and objects
|
|
||||||
recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" {compiler.c.elf.flags} -mcpu={build.mcu} "-T{build.variant.path}/{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" {compiler.c.elf.extra_flags} -o "{build.path}/{build.project_name}.elf" "-L{build.path}" -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--entry=Reset_Handler -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align -Wl,--warn-unresolved-symbols -Wl,--start-group "{build.path}/syscalls_sam3.c.o" {object_files} "{build.variant.path}/{build.variant_system_lib}" "{build.path}/{archive_file}" -Wl,--end-group -lm -gcc
|
|
||||||
|
|
||||||
In my version it's line 73.
|
|
||||||
|
|
||||||
3. Modify it to read as follows:
|
|
||||||
|
|
||||||
## Combine gc-sections, archives, and objects
|
|
||||||
recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" {compiler.c.elf.flags} -mcpu={build.mcu} "-T{build.variant.path}/{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" {compiler.c.elf.extra_flags} -o "{build.path}/{build.project_name}.elf" "-L{build.path}" -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--entry=Reset_Handler -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align -Wl,--warn-unresolved-symbols -Wl,--start-group "{build.path}/syscalls_sam3.c.o" {object_files} "{build.variant.path}/{build.variant_system_lib}" "{build.system.path}/CMSIS/CMSIS/Lib/ARM/arm_cortexM3l_math.lib" "{build.path}/{archive_file}" -Wl,--end-group -lm -gcc
|
|
||||||
|
|
||||||
The change is near the end, and is the addition of:
|
|
||||||
|
|
||||||
"{build.system.path}/CMSIS/CMSIS/Lib/ARM/arm_cortexM3l_math.lib"
|
|
||||||
|
|
||||||
Which is the CMSIS AMR3 DSP library for little-endian operation.
|
|
||||||
|
|
||||||
4. Save the file and start up the Arduino GUI and build MMDVM.
|
|
||||||
|
|
||||||
I would like to get instructions for doing the same on a Linux platform. As a
|
|
||||||
starter find the relevent platform.txt and try adding:
|
|
||||||
|
|
||||||
"{build.system.path}/CMSIS/CMSIS/Lib/ARM/libarm_cortexM3l_math.a"
|
|
||||||
|
|
||||||
or maybe:
|
|
||||||
|
|
||||||
"{build.variant.path}/libarm_cortexM3l_math.a"
|
|
||||||
|
|
||||||
Likely on Linux
|
|
||||||
|
|
||||||
"{build.system.path}/CMSIS/CMSIS/Lib/GCC/libarm_cortexM3l_math.a"
|
|
||||||
|
|
||||||
As with Arduino 1.6.7 with SAM 1.6.6, see below.
|
|
||||||
|
|
||||||
|
|
||||||
For Arduino 1.6.7 with SAM 1.6.6
|
|
||||||
--------------------------------
|
|
||||||
(checked OK on Arduino 1.6.11 and SAM 1.6.9)
|
|
||||||
|
|
||||||
1. Go to the where the platform.txt file is located. On my Windows machine it's
|
|
||||||
in:
|
|
||||||
|
|
||||||
C:\Users\Jonathan\AppData\Local\Arduino15\packages\arduino\hardware\sam\1.6.6
|
|
||||||
|
|
||||||
On Mac OS X it's located in:
|
|
||||||
|
|
||||||
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/sam
|
|
||||||
|
|
||||||
On Linux, it's located in my home directory, downloaded and extracted from Arduino website, but must be installed.
|
|
||||||
|
|
||||||
/home/m1geo/arduino-1.6.7/hardware/arduino/sam
|
|
||||||
|
|
||||||
or
|
|
||||||
|
|
||||||
/home/m1geo/.arduino15/packages/arduino/hardware/sam/1.6.9 (if you let the board/library manager install SAM)
|
|
||||||
|
|
||||||
|
|
||||||
I (M1GEO) found it was necessary to download SAM-1.6.6 outside of the Arduino IDE, and manually extract the files.
|
|
||||||
The Board Manager didn't seem to install the SAM files correctly. Here's how I did it:
|
|
||||||
|
|
||||||
a) wget http://downloads.arduino.cc/cores/sam-1.6.6.tar.bz2 -O /tmp/sam-1.6.6.tar.bz2 (download and save in /tmp)
|
|
||||||
b) cd arduino-1.6.7/hardware/arduino/ (Arduino root, here, in my home directory)
|
|
||||||
c) tar xvfj /tmp/sam-1.6.6.tar.bz2
|
|
||||||
|
|
||||||
2. You'll need to open the file (platform.txt) in a text editor and find the line:
|
|
||||||
|
|
||||||
## Combine gc-sections, archives, and objects
|
|
||||||
recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" -mcpu={build.mcu} -mthumb {compiler.c.elf.flags} "-T{build.variant.path}/{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" {compiler.c.elf.extra_flags} -o "{build.path}/{build.project_name}.elf" "-L{build.path}" -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--entry=Reset_Handler -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align -Wl,--start-group "{build.path}/core/syscalls_sam3.c.o" {object_files} "{build.variant.path}/{build.variant_system_lib}" "{build.path}/{archive_file}" -Wl,--end-group -lm -gcc
|
|
||||||
|
|
||||||
In my version it's line 73.
|
|
||||||
|
|
||||||
3. Modify it to read as follows:
|
|
||||||
|
|
||||||
## Combine gc-sections, archives, and objects
|
|
||||||
recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" -mcpu={build.mcu} -mthumb {compiler.c.elf.flags} "-T{build.variant.path}/{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" {compiler.c.elf.extra_flags} -o "{build.path}/{build.project_name}.elf" "-L{build.path}" -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--entry=Reset_Handler -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align -Wl,--start-group "{build.path}/core/syscalls_sam3.c.o" {object_files} "{build.variant.path}/{build.variant_system_lib}" "{build.system.path}/CMSIS/CMSIS/Lib/ARM/arm_cortexM3l_math.lib" "{build.path}/{archive_file}" -Wl,--end-group -lm -gcc
|
|
||||||
|
|
||||||
The change is near the end, and is the addition of:
|
|
||||||
|
|
||||||
"{build.system.path}/CMSIS/CMSIS/Lib/ARM/arm_cortexM3l_math.lib"
|
|
||||||
|
|
||||||
On Linux, the path was found to differ slightly (GCC instead of ARM):
|
|
||||||
|
|
||||||
"{build.system.path}/CMSIS/CMSIS/Lib/GCC/libarm_cortexM3l_math.a"
|
|
||||||
|
|
||||||
Which is the CMSIS AMR3 DSP library for little-endian operation.
|
|
||||||
|
|
||||||
4. Save the file and start up the Arduino GUI and build MMDVM.
|
|
||||||
|
|
||||||
For Arduino 1.6.9 with SAM 1.6.8
|
|
||||||
--------------------------------
|
|
||||||
|
|
||||||
1. Locate platform.txt. On Ubuntu 14.04 LTS x86_64 OS it is in:
|
|
||||||
|
|
||||||
/home/$user/.arduino15/packages/arduino/hardware/sam/1.6.8/
|
|
||||||
|
|
||||||
2. Open the file in a text editor and change the line:
|
|
||||||
|
|
||||||
## Combine gc-sections, archives, and objects
|
|
||||||
recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" -mcpu={build.mcu} -mthumb {compiler.c.elf.flags} "-T{build.variant.path}/{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" {compiler.c.elf.extra_flags} -o "{build.path}/{build.project_name}.elf" "-L{build.path}" -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--entry=Reset_Handler -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align -Wl,--start-group {compiler.combine.flags} {object_files} "{build.variant.path}/{build.variant_system_lib}" "{build.path}/{archive_file}" -Wl,--end-group -lm -gcc
|
|
||||||
|
|
||||||
to
|
|
||||||
|
|
||||||
recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" -mcpu={build.mcu} -mthumb {compiler.c.elf.flags} "-T{build.variant.path}/{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" {compiler.c.elf.extra_flags} -o "{build.path}/{build.project_name}.elf" "-L{build.path}" -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--entry=Reset_Handler -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align -Wl,--start-group {compiler.combine.flags} {object_files} "{build.variant.path}/{build.variant_system_lib}" "{build.system.path}/CMSIS/CMSIS/Lib/GCC/libarm_cortexM3l_math.a" "{build.path}/{archive_file}" -Wl,--end-group -lm -gcc
|
|
||||||
|
|
||||||
3. Save the file, open the Arduino IDE and build MMDVM
|
|
||||||
@@ -18,6 +18,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
|
|
||||||
|
#if defined(MODE_DMR)
|
||||||
|
|
||||||
#include "Globals.h"
|
#include "Globals.h"
|
||||||
#include "CalDMR.h"
|
#include "CalDMR.h"
|
||||||
|
|
||||||
@@ -221,3 +224,5 @@ uint8_t CCalDMR::write(const uint8_t* data, uint16_t length)
|
|||||||
return 0U;
|
return 0U;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -17,10 +17,13 @@
|
|||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "Config.h"
|
||||||
|
|
||||||
|
#if defined(MODE_DMR)
|
||||||
|
|
||||||
#if !defined(CALDMR_H)
|
#if !defined(CALDMR_H)
|
||||||
#define CALDMR_H
|
#define CALDMR_H
|
||||||
|
|
||||||
#include "Config.h"
|
|
||||||
#include "DMRDefines.h"
|
#include "DMRDefines.h"
|
||||||
|
|
||||||
enum DMRCAL1K {
|
enum DMRCAL1K {
|
||||||
@@ -53,3 +56,5 @@ private:
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|||||||
+7
-2
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2009-2016 by Jonathan Naylor G4KLX
|
* Copyright (C) 2009-2016,2020 by Jonathan Naylor G4KLX
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -17,6 +17,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
|
|
||||||
|
#if defined(MODE_DSTAR)
|
||||||
|
|
||||||
#include "Globals.h"
|
#include "Globals.h"
|
||||||
#include "CalDStarRX.h"
|
#include "CalDStarRX.h"
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
@@ -24,7 +27,7 @@
|
|||||||
const unsigned int BUFFER_LENGTH = 200U;
|
const unsigned int BUFFER_LENGTH = 200U;
|
||||||
|
|
||||||
const uint32_t PLLMAX = 0x10000U;
|
const uint32_t PLLMAX = 0x10000U;
|
||||||
const uint32_t PLLINC = PLLMAX / DSTAR_RADIO_BIT_LENGTH;
|
const uint32_t PLLINC = PLLMAX / DSTAR_RADIO_SYMBOL_LENGTH;
|
||||||
const uint32_t INC = PLLINC / 32U;
|
const uint32_t INC = PLLINC / 32U;
|
||||||
|
|
||||||
// D-Star bit order version of 0x55 0x2D 0x16
|
// D-Star bit order version of 0x55 0x2D 0x16
|
||||||
@@ -126,3 +129,5 @@ void CCalDStarRX::process(q15_t value)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|||||||
+7
-2
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2015,2016 by Jonathan Naylor G4KLX
|
* Copyright (C) 2015,2016,2020 by Jonathan Naylor G4KLX
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -16,10 +16,13 @@
|
|||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "Config.h"
|
||||||
|
|
||||||
|
#if defined(MODE_DSTAR)
|
||||||
|
|
||||||
#if !defined(CALDSTARRX_H)
|
#if !defined(CALDSTARRX_H)
|
||||||
#define CALDSTARRX_H
|
#define CALDSTARRX_H
|
||||||
|
|
||||||
#include "Config.h"
|
|
||||||
#include "DStarDefines.h"
|
#include "DStarDefines.h"
|
||||||
|
|
||||||
class CCalDStarRX {
|
class CCalDStarRX {
|
||||||
@@ -40,3 +43,5 @@ private:
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
|
|
||||||
|
#if defined(MODE_DSTAR)
|
||||||
|
|
||||||
#include "Globals.h"
|
#include "Globals.h"
|
||||||
#include "CalDStarTX.h"
|
#include "CalDStarTX.h"
|
||||||
|
|
||||||
@@ -181,3 +184,5 @@ uint8_t CCalDStarTX::write(const uint8_t* data, uint16_t length)
|
|||||||
return 0U;
|
return 0U;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|||||||
+6
-1
@@ -16,10 +16,13 @@
|
|||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "Config.h"
|
||||||
|
|
||||||
|
#if defined(MODE_DSTAR)
|
||||||
|
|
||||||
#if !defined(CALDSTARTX_H)
|
#if !defined(CALDSTARTX_H)
|
||||||
#define CALDSTARTX_H
|
#define CALDSTARTX_H
|
||||||
|
|
||||||
#include "Config.h"
|
|
||||||
#include "DStarDefines.h"
|
#include "DStarDefines.h"
|
||||||
|
|
||||||
class CCalDStarTX {
|
class CCalDStarTX {
|
||||||
@@ -37,3 +40,5 @@ private:
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
|
|
||||||
|
#if defined(MODE_FM)
|
||||||
|
|
||||||
#include "Globals.h"
|
#include "Globals.h"
|
||||||
#include "CalFM.h"
|
#include "CalFM.h"
|
||||||
|
|
||||||
@@ -52,7 +55,7 @@ void CCalFM::process()
|
|||||||
{
|
{
|
||||||
const TONE_TABLE* entry = NULL;
|
const TONE_TABLE* entry = NULL;
|
||||||
|
|
||||||
if (m_modemState!=m_lastState)
|
if (m_modemState != m_lastState)
|
||||||
{
|
{
|
||||||
switch (m_modemState) {
|
switch (m_modemState) {
|
||||||
case STATE_FMCAL10K:
|
case STATE_FMCAL10K:
|
||||||
@@ -125,3 +128,6 @@ uint8_t CCalFM::write(const uint8_t* data, uint16_t length)
|
|||||||
|
|
||||||
return 0U;
|
return 0U;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -18,11 +18,13 @@
|
|||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "Config.h"
|
||||||
|
|
||||||
|
#if defined(MODE_FM)
|
||||||
|
|
||||||
#if !defined(CALFM_H)
|
#if !defined(CALFM_H)
|
||||||
#define CALFM_H
|
#define CALFM_H
|
||||||
|
|
||||||
#include "Config.h"
|
|
||||||
|
|
||||||
class CCalFM {
|
class CCalFM {
|
||||||
public:
|
public:
|
||||||
CCalFM();
|
CCalFM();
|
||||||
@@ -49,3 +51,5 @@ private:
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|||||||
+66
@@ -0,0 +1,66 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2009-2015,2020,2021 by Jonathan Naylor G4KLX
|
||||||
|
* 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
|
||||||
|
* 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 "CalM17.h"
|
||||||
|
#include "M17Defines.h"
|
||||||
|
|
||||||
|
const uint8_t PREAMBLE[] = {0x00U,
|
||||||
|
0x77U, 0x77U, 0x77U, 0x77U, 0x77U, 0x77U, 0x77U, 0x77U,
|
||||||
|
0x77U, 0x77U, 0x77U, 0x77U, 0x77U, 0x77U, 0x77U, 0x77U,
|
||||||
|
0x77U, 0x77U, 0x77U, 0x77U, 0x77U, 0x77U, 0x77U, 0x77U,
|
||||||
|
0x77U, 0x77U, 0x77U, 0x77U, 0x77U, 0x77U, 0x77U, 0x77U,
|
||||||
|
0x77U, 0x77U, 0x77U, 0x77U, 0x77U, 0x77U, 0x77U, 0x77U,
|
||||||
|
0x77U, 0x77U, 0x77U, 0x77U, 0x77U, 0x77U, 0x77U, 0x77U};
|
||||||
|
|
||||||
|
CCalM17::CCalM17() :
|
||||||
|
m_transmit(false)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void CCalM17::process()
|
||||||
|
{
|
||||||
|
m17TX.process();
|
||||||
|
|
||||||
|
if (!m_transmit)
|
||||||
|
return;
|
||||||
|
|
||||||
|
uint16_t space = m17TX.getSpace();
|
||||||
|
if (space < 2U)
|
||||||
|
return;
|
||||||
|
|
||||||
|
m17TX.writeData(PREAMBLE, M17_FRAME_LENGTH_BYTES + 1U);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t CCalM17::write(const uint8_t* data, uint16_t length)
|
||||||
|
{
|
||||||
|
if (length != 1U)
|
||||||
|
return 4U;
|
||||||
|
|
||||||
|
m_transmit = data[0U] == 1U;
|
||||||
|
|
||||||
|
return 0U;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2009-2015,2020,2021 by Jonathan Naylor G4KLX
|
||||||
|
* 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
|
||||||
|
* 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(CALM17_H)
|
||||||
|
#define CALM17_H
|
||||||
|
|
||||||
|
|
||||||
|
class CCalM17 {
|
||||||
|
public:
|
||||||
|
CCalM17();
|
||||||
|
|
||||||
|
void process();
|
||||||
|
|
||||||
|
uint8_t write(const uint8_t* data, uint16_t length);
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool m_transmit;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
@@ -18,6 +18,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
|
|
||||||
|
#if defined(MODE_NXDN)
|
||||||
|
|
||||||
#include "Globals.h"
|
#include "Globals.h"
|
||||||
#include "CalNXDN.h"
|
#include "CalNXDN.h"
|
||||||
|
|
||||||
@@ -93,3 +96,5 @@ uint8_t CCalNXDN::write(const uint8_t* data, uint16_t length)
|
|||||||
return 0U;
|
return 0U;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -17,11 +17,13 @@
|
|||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "Config.h"
|
||||||
|
|
||||||
|
#if defined(MODE_NXDN)
|
||||||
|
|
||||||
#if !defined(CALNXDN_H)
|
#if !defined(CALNXDN_H)
|
||||||
#define CALNXDN_H
|
#define CALNXDN_H
|
||||||
|
|
||||||
#include "Config.h"
|
|
||||||
|
|
||||||
enum NXDNCAL1K {
|
enum NXDNCAL1K {
|
||||||
NXDNCAL1K_IDLE,
|
NXDNCAL1K_IDLE,
|
||||||
NXDNCAL1K_TX
|
NXDNCAL1K_TX
|
||||||
@@ -43,3 +45,5 @@ private:
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
|
|
||||||
|
#if defined(MODE_P25)
|
||||||
|
|
||||||
#include "Globals.h"
|
#include "Globals.h"
|
||||||
#include "CalP25.h"
|
#include "CalP25.h"
|
||||||
|
|
||||||
@@ -96,3 +99,5 @@ uint8_t CCalP25::write(const uint8_t* data, uint16_t length)
|
|||||||
return 0U;
|
return 0U;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -17,10 +17,13 @@
|
|||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "Config.h"
|
||||||
|
|
||||||
|
#if defined(MODE_P25)
|
||||||
|
|
||||||
#if !defined(CALP25_H)
|
#if !defined(CALP25_H)
|
||||||
#define CALP25_H
|
#define CALP25_H
|
||||||
|
|
||||||
#include "Config.h"
|
|
||||||
#include "P25Defines.h"
|
#include "P25Defines.h"
|
||||||
|
|
||||||
enum P25CAL1K {
|
enum P25CAL1K {
|
||||||
@@ -44,3 +47,5 @@ private:
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|||||||
+6
-1
@@ -18,10 +18,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
|
|
||||||
|
#if defined(MODE_POCSAG)
|
||||||
|
|
||||||
#include "Globals.h"
|
#include "Globals.h"
|
||||||
#include "CalPOCSAG.h"
|
#include "CalPOCSAG.h"
|
||||||
|
|
||||||
|
|
||||||
CCalPOCSAG::CCalPOCSAG() :
|
CCalPOCSAG::CCalPOCSAG() :
|
||||||
m_state(POCSAGCAL_IDLE)
|
m_state(POCSAGCAL_IDLE)
|
||||||
{
|
{
|
||||||
@@ -48,3 +50,6 @@ uint8_t CCalPOCSAG::write(const uint8_t* data, uint16_t length)
|
|||||||
|
|
||||||
return 0U;
|
return 0U;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|||||||
+7
-2
@@ -17,11 +17,13 @@
|
|||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "Config.h"
|
||||||
|
|
||||||
|
#if defined(MODE_POCSAG)
|
||||||
|
|
||||||
#if !defined(CALPOCSAG_H)
|
#if !defined(CALPOCSAG_H)
|
||||||
#define CALPOCSAG_H
|
#define CALPOCSAG_H
|
||||||
|
|
||||||
#include "Config.h"
|
|
||||||
|
|
||||||
enum POCSAGCAL {
|
enum POCSAGCAL {
|
||||||
POCSAGCAL_IDLE,
|
POCSAGCAL_IDLE,
|
||||||
POCSAGCAL_TX
|
POCSAGCAL_TX
|
||||||
@@ -40,3 +42,6 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2015,2016,2017,2018,2020 by Jonathan Naylor G4KLX
|
* Copyright (C) 2015,2016,2017,2018,2020,2023 by Jonathan Naylor G4KLX
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -19,6 +19,37 @@
|
|||||||
#if !defined(CONFIG_H)
|
#if !defined(CONFIG_H)
|
||||||
#define 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
|
// Allow for the use of high quality external clock oscillators
|
||||||
// The number is the frequency of the oscillator in Hertz.
|
// The number is the frequency of the oscillator in Hertz.
|
||||||
//
|
//
|
||||||
@@ -35,23 +66,15 @@
|
|||||||
// For 19.2 MHz
|
// For 19.2 MHz
|
||||||
// #define EXTERNAL_OSC 19200000
|
// #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
|
||||||
|
//#define SERIAL_SPEED 500000 // Used with newer boards and Armbian on AllWinner SOCs (H2, H3) that do not support 460800
|
||||||
|
|
||||||
// Use pins to output the current mode via LEDs
|
// 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
|
|
||||||
|
|
||||||
#if defined(STM32F1)
|
|
||||||
// For the SQ6POG board
|
|
||||||
#define STM32F1_POG
|
|
||||||
#else
|
|
||||||
// For the ZUM V1.0 and V1.0.1 boards pin layout
|
|
||||||
#define ARDUINO_DUE_ZUM_V10
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// For the SP8NTH board
|
|
||||||
// #define ARDUINO_DUE_NTH
|
|
||||||
|
|
||||||
// For ST Nucleo-64 STM32F446RE board
|
// For ST Nucleo-64 STM32F446RE board
|
||||||
// #define STM32F4_NUCLEO_MORPHO_HEADER
|
// #define STM32F4_NUCLEO_MORPHO_HEADER
|
||||||
// #define STM32F4_NUCLEO_ARDUINO_HEADER
|
// #define STM32F4_NUCLEO_ARDUINO_HEADER
|
||||||
@@ -63,10 +86,13 @@
|
|||||||
// #define VK6MST_TEENSY_PI3_SHIELD_I2C
|
// #define VK6MST_TEENSY_PI3_SHIELD_I2C
|
||||||
|
|
||||||
// Pass RSSI information to the host
|
// Pass RSSI information to the host
|
||||||
// #define SEND_RSSI_DATA
|
#define SEND_RSSI_DATA
|
||||||
|
|
||||||
// Use the modem as a serial repeater for Nextion displays
|
// Use the modem as a serial repeater for Nextion displays
|
||||||
// #define SERIAL_REPEATER
|
#define SERIAL_REPEATER
|
||||||
|
|
||||||
|
// Use the modem as an I2C repeater for OLED displays
|
||||||
|
// #define I2C_REPEATER
|
||||||
|
|
||||||
// To reduce CPU load, you can remove the DC blocker by commenting out the next line
|
// To reduce CPU load, you can remove the DC blocker by commenting out the next line
|
||||||
#define USE_DCBLOCKER
|
#define USE_DCBLOCKER
|
||||||
@@ -78,10 +104,14 @@
|
|||||||
// Use the YSF and P25 LEDs for NXDN
|
// Use the YSF and P25 LEDs for NXDN
|
||||||
// #define USE_ALTERNATE_NXDN_LEDS
|
// #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
|
// 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
|
// Use the D-Star and YSF LEDs for FM
|
||||||
#define USE_ALTERNATE_FM_LEDS
|
#define USE_ALTERNATE_FM_LEDS
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
+7
-1
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2009-2017 by Jonathan Naylor G4KLX
|
* Copyright (C) 2009-2017,2020 by Jonathan Naylor G4KLX
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -17,6 +17,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
|
|
||||||
|
#if defined(MODE_DMR)
|
||||||
|
|
||||||
#include "Globals.h"
|
#include "Globals.h"
|
||||||
#include "DMRDMORX.h"
|
#include "DMRDMORX.h"
|
||||||
#include "DMRSlotType.h"
|
#include "DMRSlotType.h"
|
||||||
@@ -423,3 +426,6 @@ void CDMRDMORX::writeRSSIData(uint8_t* frame)
|
|||||||
serial.writeDMRData(true, frame, DMR_FRAME_LENGTH_BYTES + 1U);
|
serial.writeDMRData(true, frame, DMR_FRAME_LENGTH_BYTES + 1U);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|||||||
+8
-2
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2015,2016,2017 by Jonathan Naylor G4KLX
|
* Copyright (C) 2015,2016,2017,2020 by Jonathan Naylor G4KLX
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -16,10 +16,13 @@
|
|||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "Config.h"
|
||||||
|
|
||||||
|
#if defined(MODE_DMR)
|
||||||
|
|
||||||
#if !defined(DMRDMORX_H)
|
#if !defined(DMRDMORX_H)
|
||||||
#define DMRDMORX_H
|
#define DMRDMORX_H
|
||||||
|
|
||||||
#include "Config.h"
|
|
||||||
#include "DMRDefines.h"
|
#include "DMRDefines.h"
|
||||||
|
|
||||||
const uint16_t DMO_BUFFER_LENGTH_SAMPLES = 1440U; // 60ms at 24 kHz
|
const uint16_t DMO_BUFFER_LENGTH_SAMPLES = 1440U; // 60ms at 24 kHz
|
||||||
@@ -67,3 +70,6 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|||||||
+6
-1
@@ -19,6 +19,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
|
|
||||||
|
#if defined(MODE_DMR)
|
||||||
|
|
||||||
#include "Globals.h"
|
#include "Globals.h"
|
||||||
#include "DMRSlotType.h"
|
#include "DMRSlotType.h"
|
||||||
|
|
||||||
@@ -74,7 +77,7 @@ void CDMRDMOTX::process()
|
|||||||
m_poLen = m_txDelay;
|
m_poLen = m_txDelay;
|
||||||
} else {
|
} else {
|
||||||
for (unsigned int i = 0U; i < DMR_FRAME_LENGTH_BYTES; i++)
|
for (unsigned int i = 0U; i < DMR_FRAME_LENGTH_BYTES; i++)
|
||||||
m_poBuffer[i] = m_fifo.get();
|
m_fifo.get(m_poBuffer[i]);
|
||||||
|
|
||||||
for (unsigned int i = 0U; i < 39U; i++)
|
for (unsigned int i = 0U; i < 39U; i++)
|
||||||
m_poBuffer[i + DMR_FRAME_LENGTH_BYTES] = PR_FILL[i];
|
m_poBuffer[i + DMR_FRAME_LENGTH_BYTES] = PR_FILL[i];
|
||||||
@@ -161,3 +164,5 @@ void CDMRDMOTX::setTXDelay(uint8_t delay)
|
|||||||
m_txDelay = 1200U;
|
m_txDelay = 1200U;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|||||||
+8
-3
@@ -17,13 +17,16 @@
|
|||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "Config.h"
|
||||||
|
|
||||||
|
#if defined(MODE_DMR)
|
||||||
|
|
||||||
#if !defined(DMRDMOTX_H)
|
#if !defined(DMRDMOTX_H)
|
||||||
#define DMRDMOTX_H
|
#define DMRDMOTX_H
|
||||||
|
|
||||||
#include "Config.h"
|
|
||||||
#include "DMRDefines.h"
|
#include "DMRDefines.h"
|
||||||
|
|
||||||
#include "SerialRB.h"
|
#include "RingBuffer.h"
|
||||||
|
|
||||||
class CDMRDMOTX {
|
class CDMRDMOTX {
|
||||||
public:
|
public:
|
||||||
@@ -38,7 +41,7 @@ public:
|
|||||||
uint8_t getSpace() const;
|
uint8_t getSpace() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CSerialRB m_fifo;
|
CRingBuffer<uint8_t> m_fifo;
|
||||||
arm_fir_interpolate_instance_q15 m_modFilter;
|
arm_fir_interpolate_instance_q15 m_modFilter;
|
||||||
q15_t m_modState[16U]; // blockSize + phaseLength - 1, 4 + 9 - 1 plus some spare
|
q15_t m_modState[16U]; // blockSize + phaseLength - 1, 4 + 9 - 1 plus some spare
|
||||||
uint8_t m_poBuffer[1200U];
|
uint8_t m_poBuffer[1200U];
|
||||||
@@ -51,3 +54,5 @@ private:
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|||||||
+7
-1
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2009-2017 by Jonathan Naylor G4KLX
|
* Copyright (C) 2009-2017,2020 by Jonathan Naylor G4KLX
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -17,6 +17,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
|
|
||||||
|
#if defined(MODE_DMR)
|
||||||
|
|
||||||
#include "Globals.h"
|
#include "Globals.h"
|
||||||
#include "DMRIdleRX.h"
|
#include "DMRIdleRX.h"
|
||||||
#include "DMRSlotType.h"
|
#include "DMRSlotType.h"
|
||||||
@@ -209,3 +212,6 @@ void CDMRIdleRX::setColorCode(uint8_t colorCode)
|
|||||||
{
|
{
|
||||||
m_colorCode = colorCode;
|
m_colorCode = colorCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|||||||
+7
-2
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2015 by Jonathan Naylor G4KLX
|
* Copyright (C) 2015,2020 by Jonathan Naylor G4KLX
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -16,10 +16,13 @@
|
|||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "Config.h"
|
||||||
|
|
||||||
|
#if defined(MODE_DMR)
|
||||||
|
|
||||||
#if !defined(DMRIDLERX_H)
|
#if !defined(DMRIDLERX_H)
|
||||||
#define DMRIDLERX_H
|
#define DMRIDLERX_H
|
||||||
|
|
||||||
#include "Config.h"
|
|
||||||
#include "DMRDefines.h"
|
#include "DMRDefines.h"
|
||||||
|
|
||||||
class CDMRIdleRX {
|
class CDMRIdleRX {
|
||||||
@@ -49,3 +52,5 @@ private:
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2015,2016 by Jonathan Naylor G4KLX
|
* Copyright (C) 2015,2016,2020 by Jonathan Naylor G4KLX
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -17,6 +17,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
|
|
||||||
|
#if defined(MODE_DMR)
|
||||||
|
|
||||||
#include "Globals.h"
|
#include "Globals.h"
|
||||||
#include "DMRRX.h"
|
#include "DMRRX.h"
|
||||||
|
|
||||||
@@ -68,3 +71,5 @@ void CDMRRX::reset()
|
|||||||
m_slot2RX.reset();
|
m_slot2RX.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2015,2016 by Jonathan Naylor G4KLX
|
* Copyright (C) 2015,2016,2020 by Jonathan Naylor G4KLX
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -16,10 +16,13 @@
|
|||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "Config.h"
|
||||||
|
|
||||||
|
#if defined(MODE_DMR)
|
||||||
|
|
||||||
#if !defined(DMRRX_H)
|
#if !defined(DMRRX_H)
|
||||||
#define DMRRX_H
|
#define DMRRX_H
|
||||||
|
|
||||||
#include "Config.h"
|
|
||||||
#include "DMRSlotRX.h"
|
#include "DMRSlotRX.h"
|
||||||
|
|
||||||
class CDMRRX {
|
class CDMRRX {
|
||||||
@@ -40,3 +43,5 @@ private:
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|||||||
+7
-1
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2009-2017 by Jonathan Naylor G4KLX
|
* Copyright (C) 2009-2017,2020 by Jonathan Naylor G4KLX
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -17,6 +17,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
|
|
||||||
|
#if defined(MODE_DMR)
|
||||||
|
|
||||||
#include "Globals.h"
|
#include "Globals.h"
|
||||||
#include "DMRSlotRX.h"
|
#include "DMRSlotRX.h"
|
||||||
#include "DMRSlotType.h"
|
#include "DMRSlotType.h"
|
||||||
@@ -400,3 +403,6 @@ void CDMRSlotRX::writeRSSIData(uint8_t* frame)
|
|||||||
serial.writeDMRData(m_slot, frame, DMR_FRAME_LENGTH_BYTES + 1U);
|
serial.writeDMRData(m_slot, frame, DMR_FRAME_LENGTH_BYTES + 1U);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|||||||
+8
-2
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2015,2016,2017 by Jonathan Naylor G4KLX
|
* Copyright (C) 2015,2016,2017,2020 by Jonathan Naylor G4KLX
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -16,10 +16,13 @@
|
|||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "Config.h"
|
||||||
|
|
||||||
|
#if defined(MODE_DMR)
|
||||||
|
|
||||||
#if !defined(DMRSLOTRX_H)
|
#if !defined(DMRSLOTRX_H)
|
||||||
#define DMRSLOTRX_H
|
#define DMRSLOTRX_H
|
||||||
|
|
||||||
#include "Config.h"
|
|
||||||
#include "DMRDefines.h"
|
#include "DMRDefines.h"
|
||||||
|
|
||||||
enum DMRRX_STATE {
|
enum DMRRX_STATE {
|
||||||
@@ -70,3 +73,6 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|||||||
+6
-1
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2015 by Jonathan Naylor G4KLX
|
* Copyright (C) 2015,2020 by Jonathan Naylor G4KLX
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -17,6 +17,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
|
|
||||||
|
#if defined(MODE_DMR)
|
||||||
|
|
||||||
#include "Globals.h"
|
#include "Globals.h"
|
||||||
#include "DMRSlotType.h"
|
#include "DMRSlotType.h"
|
||||||
|
|
||||||
@@ -285,3 +288,5 @@ 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);
|
frame[20U] = (frame[20U] & 0x03U) | ((slotType[1U] << 6) & 0xC0U) | ((slotType[2U] >> 2) & 0x3CU);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|||||||
+7
-1
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2015 by Jonathan Naylor G4KLX
|
* Copyright (C) 2015,2020 by Jonathan Naylor G4KLX
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -16,6 +16,10 @@
|
|||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "Config.h"
|
||||||
|
|
||||||
|
#if defined(MODE_DMR)
|
||||||
|
|
||||||
#if !defined(DMRSLOTTYPE_H)
|
#if !defined(DMRSLOTTYPE_H)
|
||||||
#define DMRSLOTTYPE_H
|
#define DMRSLOTTYPE_H
|
||||||
|
|
||||||
@@ -35,3 +39,5 @@ private:
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
|
|
||||||
|
#if defined(MODE_DMR)
|
||||||
|
|
||||||
#include "Globals.h"
|
#include "Globals.h"
|
||||||
#include "DMRSlotType.h"
|
#include "DMRSlotType.h"
|
||||||
|
|
||||||
@@ -293,7 +296,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) {
|
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++) {
|
for (unsigned int i = 0U; i < DMR_FRAME_LENGTH_BYTES; i++) {
|
||||||
m_poBuffer[i] = m_fifo[slotIndex].get();
|
m_fifo[slotIndex].get(m_poBuffer[i]);
|
||||||
m_markBuffer[i] = MARK_NONE;
|
m_markBuffer[i] = MARK_NONE;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -414,3 +417,6 @@ uint32_t CDMRTX::getFrameCount()
|
|||||||
{
|
{
|
||||||
return m_frameCount;
|
return m_frameCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -17,13 +17,16 @@
|
|||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "Config.h"
|
||||||
|
|
||||||
|
#if defined(MODE_DMR)
|
||||||
|
|
||||||
#if !defined(DMRTX_H)
|
#if !defined(DMRTX_H)
|
||||||
#define DMRTX_H
|
#define DMRTX_H
|
||||||
|
|
||||||
#include "Config.h"
|
|
||||||
#include "DMRDefines.h"
|
#include "DMRDefines.h"
|
||||||
|
|
||||||
#include "SerialRB.h"
|
#include "RingBuffer.h"
|
||||||
|
|
||||||
enum DMRTXSTATE {
|
enum DMRTXSTATE {
|
||||||
DMRTXSTATE_IDLE,
|
DMRTXSTATE_IDLE,
|
||||||
@@ -59,7 +62,7 @@ public:
|
|||||||
void setColorCode(uint8_t colorCode);
|
void setColorCode(uint8_t colorCode);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CSerialRB m_fifo[2U];
|
CRingBuffer<uint8_t> m_fifo[2U];
|
||||||
arm_fir_interpolate_instance_q15 m_modFilter;
|
arm_fir_interpolate_instance_q15 m_modFilter;
|
||||||
q15_t m_modState[16U]; // blockSize + phaseLength - 1, 4 + 9 - 1 plus some spare
|
q15_t m_modState[16U]; // blockSize + phaseLength - 1, 4 + 9 - 1 plus some spare
|
||||||
DMRTXSTATE m_state;
|
DMRTXSTATE m_state;
|
||||||
@@ -83,3 +86,5 @@ private:
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|||||||
+37
-17
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2009-2015 by Jonathan Naylor G4KLX
|
* Copyright (C) 2009-2015,2017,2020 by Jonathan Naylor G4KLX
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -19,30 +19,50 @@
|
|||||||
#if !defined(DSTARDEFINES_H)
|
#if !defined(DSTARDEFINES_H)
|
||||||
#define DSTARDEFINES_H
|
#define DSTARDEFINES_H
|
||||||
|
|
||||||
const unsigned int DSTAR_RADIO_BIT_LENGTH = 5U; // At 24 kHz sample rate
|
const unsigned int DSTAR_RADIO_SYMBOL_LENGTH = 5U; // At 24 kHz sample rate
|
||||||
|
|
||||||
const unsigned int DSTAR_HEADER_LENGTH_BYTES = 41U;
|
const unsigned int DSTAR_HEADER_LENGTH_BYTES = 41U;
|
||||||
const unsigned int DSTAR_HEADER_LENGTH_BITS = DSTAR_HEADER_LENGTH_BYTES * 8U;
|
|
||||||
|
|
||||||
const unsigned int DSTAR_FEC_SECTION_LENGTH_BYTES = 83U;
|
const unsigned int DSTAR_FEC_SECTION_LENGTH_BYTES = 83U;
|
||||||
const unsigned int DSTAR_FEC_SECTION_LENGTH_BITS = 660U;
|
const unsigned int DSTAR_FEC_SECTION_LENGTH_SYMBOLS = 660U;
|
||||||
|
const unsigned int DSTAR_FEC_SECTION_LENGTH_SAMPLES = DSTAR_FEC_SECTION_LENGTH_SYMBOLS * DSTAR_RADIO_SYMBOL_LENGTH;
|
||||||
|
|
||||||
const unsigned int DSTAR_DATA_LENGTH_BYTES = 12U;
|
const unsigned int DSTAR_DATA_LENGTH_BYTES = 12U;
|
||||||
const unsigned int DSTAR_DATA_LENGTH_BITS = DSTAR_DATA_LENGTH_BYTES * 8U;
|
const unsigned int DSTAR_DATA_LENGTH_SYMBOLS = DSTAR_DATA_LENGTH_BYTES * 8U;
|
||||||
|
const unsigned int DSTAR_DATA_LENGTH_SAMPLES = DSTAR_DATA_LENGTH_SYMBOLS * DSTAR_RADIO_SYMBOL_LENGTH;
|
||||||
|
|
||||||
const uint8_t DSTAR_EOT_BYTES[] = {0x55, 0x55, 0x55, 0x55, 0xC8, 0x7A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
const unsigned int DSTAR_END_SYNC_LENGTH_BYTES = 6U;
|
||||||
const unsigned int DSTAR_EOT_LENGTH_BYTES = 6U;
|
const unsigned int DSTAR_END_SYNC_LENGTH_BITS = DSTAR_END_SYNC_LENGTH_BYTES * 8U;
|
||||||
const unsigned int DSTAR_EOT_LENGTH_BITS = DSTAR_EOT_LENGTH_BYTES * 8U;
|
|
||||||
|
|
||||||
const uint8_t DSTAR_DATA_SYNC_LENGTH_BYTES = 3U;
|
const unsigned int DSTAR_FRAME_SYNC_LENGTH_BYTES = 3U;
|
||||||
const uint8_t DSTAR_DATA_SYNC_LENGTH_BITS = DSTAR_DATA_SYNC_LENGTH_BYTES * 8U;
|
const unsigned int DSTAR_FRAME_SYNC_LENGTH_SYMBOLS = DSTAR_FRAME_SYNC_LENGTH_BYTES * 8U;
|
||||||
|
const unsigned int DSTAR_FRAME_SYNC_LENGTH_SAMPLES = DSTAR_FRAME_SYNC_LENGTH_SYMBOLS * DSTAR_RADIO_SYMBOL_LENGTH;
|
||||||
|
|
||||||
const uint8_t DSTAR_DATA_SYNC_BYTES[] = {0x9E, 0x8D, 0x32, 0x88, 0x26, 0x1A, 0x3F, 0x61, 0xE8, 0x55, 0x2D, 0x16};
|
const unsigned int DSTAR_DATA_SYNC_LENGTH_BYTES = 3U;
|
||||||
|
const unsigned int DSTAR_DATA_SYNC_LENGTH_SYMBOLS = DSTAR_DATA_SYNC_LENGTH_BYTES * 8U;
|
||||||
|
const unsigned int DSTAR_DATA_SYNC_LENGTH_SAMPLES = DSTAR_DATA_SYNC_LENGTH_SYMBOLS * DSTAR_RADIO_SYMBOL_LENGTH;
|
||||||
|
|
||||||
const uint8_t DSTAR_SLOW_DATA_TYPE_TEXT = 0x40U;
|
const uint8_t DSTAR_DATA_SYNC_BYTES[] = {0x9E, 0x8D, 0x32, 0x88, 0x26, 0x1A, 0x3F, 0x61, 0xE8, 0x55, 0x2D, 0x16};
|
||||||
const uint8_t DSTAR_SLOW_DATA_TYPE_HEADER = 0x50U;
|
|
||||||
|
|
||||||
const uint8_t DSTAR_SCRAMBLER_BYTES[] = {0x70U, 0x4FU, 0x93U};
|
// D-Star bit order version of 0x55 0x6E 0x0A
|
||||||
|
const uint32_t DSTAR_FRAME_SYNC_DATA = 0x00557650U;
|
||||||
|
const uint32_t DSTAR_FRAME_SYNC_MASK = 0x00FFFFFFU;
|
||||||
|
const bool DSTAR_FRAME_SYNC_SYMBOLS[] = {false, true, false, true, false, true, false, true, false, true, true, true, false, true, true, false, false, true, false, true, false, false, false, false};
|
||||||
|
|
||||||
|
// D-Star bit order version of 0x55 0x2D 0x16
|
||||||
|
const uint32_t DSTAR_DATA_SYNC_DATA = 0x00AAB468U;
|
||||||
|
const uint32_t DSTAR_DATA_SYNC_MASK = 0x00FFFFFFU;
|
||||||
|
const bool DSTAR_DATA_SYNC_SYMBOLS[] = {true, false, true, false, true, false, true, false, true, false, true, true, false, true, false, false, false, true, true, false, true, false, false, false};
|
||||||
|
|
||||||
|
// D-Star bit order version of 0x55 0x55 0xC8 0x7A
|
||||||
|
const uint32_t DSTAR_END_SYNC_DATA = 0xAAAA135EU;
|
||||||
|
const uint32_t DSTAR_END_SYNC_MASK = 0xFFFFFFFFU;
|
||||||
|
const uint8_t DSTAR_END_SYNC_BYTES[] = {0x55, 0x55, 0x55, 0x55, 0xC8, 0x7A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||||
|
|
||||||
|
const uint8_t DSTAR_SLOW_DATA_TYPE_TEXT = 0x40U;
|
||||||
|
const uint8_t DSTAR_SLOW_DATA_TYPE_HEADER = 0x50U;
|
||||||
|
|
||||||
|
const uint8_t DSTAR_SCRAMBLER_BYTES[] = {0x70U, 0x4FU, 0x93U};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
+249
-142
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2009-2017 by Jonathan Naylor G4KLX
|
* Copyright (C) 2009-2017,2020 by Jonathan Naylor G4KLX
|
||||||
* Copyright (C) 2017 by Andy Uribe CA6JAU
|
* Copyright (C) 2017 by Andy Uribe CA6JAU
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@@ -18,31 +18,28 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
|
|
||||||
|
#if defined(MODE_DSTAR)
|
||||||
|
|
||||||
#include "Globals.h"
|
#include "Globals.h"
|
||||||
#include "DStarRX.h"
|
#include "DStarRX.h"
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
|
|
||||||
const unsigned int BUFFER_LENGTH = 200U;
|
const unsigned int MAX_FRAMES = 150U;
|
||||||
|
|
||||||
const uint32_t PLLMAX = 0x10000U;
|
|
||||||
const uint32_t PLLINC = PLLMAX / DSTAR_RADIO_BIT_LENGTH;
|
|
||||||
const uint32_t INC = PLLINC / 32U;
|
|
||||||
|
|
||||||
const unsigned int MAX_SYNC_BITS = 100U * DSTAR_DATA_LENGTH_BITS;
|
|
||||||
|
|
||||||
// D-Star bit order version of 0x55 0x55 0x6E 0x0A
|
// D-Star bit order version of 0x55 0x55 0x6E 0x0A
|
||||||
const uint32_t FRAME_SYNC_DATA = 0x00557650U;
|
const uint64_t FRAME_SYNC_DATA = 0x0000000000557650U;
|
||||||
const uint32_t FRAME_SYNC_MASK = 0x00FFFFFFU;
|
const uint64_t FRAME_SYNC_MASK = 0x0000000000FFFFFFU;
|
||||||
const uint8_t FRAME_SYNC_ERRS = 2U;
|
const uint8_t FRAME_SYNC_ERRS = 2U;
|
||||||
|
|
||||||
// D-Star bit order version of 0x55 0x2D 0x16
|
// D-Star bit order version of 0x55 0x2D 0x16
|
||||||
const uint32_t DATA_SYNC_DATA = 0x00AAB468U;
|
const uint64_t DATA_SYNC_DATA = 0x0000000000AAB468U;
|
||||||
const uint32_t DATA_SYNC_MASK = 0x00FFFFFFU;
|
const uint64_t DATA_SYNC_MASK = 0x0000000000FFFFFFU;
|
||||||
const uint8_t DATA_SYNC_ERRS = 2U;
|
const uint8_t DATA_SYNC_ERRS = 2U;
|
||||||
|
|
||||||
// D-Star bit order version of 0x55 0x55 0xC8 0x7A
|
// D-Star bit order version of 0x55 0x55 0xC8 0x7A
|
||||||
const uint32_t END_SYNC_DATA = 0xAAAA135EU;
|
const uint64_t END_SYNC_DATA = 0x0000AAAAAAAA135EU;
|
||||||
const uint32_t END_SYNC_MASK = 0xFFFFFFFFU;
|
const uint64_t END_SYNC_MASK = 0x0000FFFFFFFFFFFFU;
|
||||||
const uint8_t END_SYNC_ERRS = 1U;
|
const uint8_t END_SYNC_ERRS = 1U;
|
||||||
|
|
||||||
const uint8_t BIT_MASK_TABLE0[] = {0x7FU, 0xBFU, 0xDFU, 0xEFU, 0xF7U, 0xFBU, 0xFDU, 0xFEU};
|
const uint8_t BIT_MASK_TABLE0[] = {0x7FU, 0xBFU, 0xDFU, 0xEFU, 0xF7U, 0xFBU, 0xFDU, 0xFEU};
|
||||||
@@ -237,14 +234,24 @@ const uint16_t CCITT_TABLE[] = {
|
|||||||
0xf78fU, 0xe606U, 0xd49dU, 0xc514U, 0xb1abU, 0xa022U, 0x92b9U, 0x8330U,
|
0xf78fU, 0xe606U, 0xd49dU, 0xc514U, 0xb1abU, 0xa022U, 0x92b9U, 0x8330U,
|
||||||
0x7bc7U, 0x6a4eU, 0x58d5U, 0x495cU, 0x3de3U, 0x2c6aU, 0x1ef1U, 0x0f78U};
|
0x7bc7U, 0x6a4eU, 0x58d5U, 0x495cU, 0x3de3U, 0x2c6aU, 0x1ef1U, 0x0f78U};
|
||||||
|
|
||||||
|
const uint16_t NOENDPTR = 9999U;
|
||||||
|
|
||||||
CDStarRX::CDStarRX() :
|
CDStarRX::CDStarRX() :
|
||||||
m_pll(0U),
|
|
||||||
m_prev(false),
|
|
||||||
m_rxState(DSRXS_NONE),
|
m_rxState(DSRXS_NONE),
|
||||||
m_patternBuffer(0x00U),
|
m_bitBuffer(),
|
||||||
m_rxBuffer(),
|
m_headerBuffer(),
|
||||||
m_rxBufferBits(0U),
|
m_dataBuffer(),
|
||||||
m_dataBits(0U),
|
m_bitPtr(0U),
|
||||||
|
m_headerPtr(0U),
|
||||||
|
m_dataPtr(0U),
|
||||||
|
m_startPtr(NOENDPTR),
|
||||||
|
m_syncPtr(NOENDPTR),
|
||||||
|
m_minSyncPtr(NOENDPTR),
|
||||||
|
m_maxSyncPtr(NOENDPTR),
|
||||||
|
m_maxFrameCorr(0),
|
||||||
|
m_maxDataCorr(0),
|
||||||
|
m_frameCount(0U),
|
||||||
|
m_countdown(0U),
|
||||||
m_mar(0U),
|
m_mar(0U),
|
||||||
m_pathMetric(),
|
m_pathMetric(),
|
||||||
m_pathMemory0(),
|
m_pathMemory0(),
|
||||||
@@ -259,14 +266,20 @@ m_rssiCount(0U)
|
|||||||
|
|
||||||
void CDStarRX::reset()
|
void CDStarRX::reset()
|
||||||
{
|
{
|
||||||
m_pll = 0U;
|
m_rxState = DSRXS_NONE;
|
||||||
m_prev = false;
|
m_headerPtr = 0U;
|
||||||
m_rxState = DSRXS_NONE;
|
m_dataPtr = 0U;
|
||||||
m_patternBuffer = 0x00U;
|
m_bitPtr = 0U;
|
||||||
m_rxBufferBits = 0U;
|
m_maxFrameCorr = 0;
|
||||||
m_dataBits = 0U;
|
m_maxDataCorr = 0;
|
||||||
m_rssiAccum = 0U;
|
m_startPtr = NOENDPTR;
|
||||||
m_rssiCount = 0U;
|
m_syncPtr = NOENDPTR;
|
||||||
|
m_minSyncPtr = NOENDPTR;
|
||||||
|
m_maxSyncPtr = NOENDPTR;
|
||||||
|
m_frameCount = 0U;
|
||||||
|
m_countdown = 0U;
|
||||||
|
m_rssiAccum = 0U;
|
||||||
|
m_rssiCount = 0U;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDStarRX::samples(const q15_t* samples, const uint16_t* rssi, uint8_t length)
|
void CDStarRX::samples(const q15_t* samples, const uint16_t* rssi, uint8_t length)
|
||||||
@@ -275,125 +288,117 @@ void CDStarRX::samples(const q15_t* samples, const uint16_t* rssi, uint8_t lengt
|
|||||||
m_rssiAccum += rssi[i];
|
m_rssiAccum += rssi[i];
|
||||||
m_rssiCount++;
|
m_rssiCount++;
|
||||||
|
|
||||||
bool bit = samples[i] < 0;
|
q15_t sample = samples[i];
|
||||||
|
|
||||||
if (bit != m_prev) {
|
m_bitBuffer[m_bitPtr] <<= 1;
|
||||||
if (m_pll < (PLLMAX / 2U))
|
if (sample < 0)
|
||||||
m_pll += INC;
|
m_bitBuffer[m_bitPtr] |= 0x01U;
|
||||||
else
|
|
||||||
m_pll -= INC;
|
m_dataBuffer[m_dataPtr] = sample;
|
||||||
|
|
||||||
|
switch (m_rxState) {
|
||||||
|
case DSRXS_HEADER:
|
||||||
|
processHeader(sample);
|
||||||
|
break;
|
||||||
|
case DSRXS_DATA:
|
||||||
|
processData();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
processNone(sample);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_prev = bit;
|
m_dataPtr++;
|
||||||
|
if (m_dataPtr >= DSTAR_DATA_LENGTH_SAMPLES)
|
||||||
|
m_dataPtr = 0U;
|
||||||
|
|
||||||
m_pll += PLLINC;
|
m_bitPtr++;
|
||||||
|
if (m_bitPtr >= DSTAR_RADIO_SYMBOL_LENGTH)
|
||||||
if (m_pll >= PLLMAX) {
|
m_bitPtr = 0U;
|
||||||
m_pll -= PLLMAX;
|
|
||||||
|
|
||||||
switch (m_rxState) {
|
|
||||||
case DSRXS_NONE:
|
|
||||||
processNone(bit);
|
|
||||||
break;
|
|
||||||
case DSRXS_HEADER:
|
|
||||||
processHeader(bit);
|
|
||||||
break;
|
|
||||||
case DSRXS_DATA:
|
|
||||||
processData(bit);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDStarRX::processNone(bool bit)
|
void CDStarRX::processNone(q15_t sample)
|
||||||
{
|
{
|
||||||
m_patternBuffer <<= 1;
|
|
||||||
if (bit)
|
|
||||||
m_patternBuffer |= 0x01U;
|
|
||||||
|
|
||||||
// Fuzzy matching of the frame sync sequence
|
// Fuzzy matching of the frame sync sequence
|
||||||
if (countBits32((m_patternBuffer & FRAME_SYNC_MASK) ^ FRAME_SYNC_DATA) <= FRAME_SYNC_ERRS) {
|
bool ret = correlateFrameSync();
|
||||||
DEBUG1("DStarRX: found frame sync in None");
|
if (ret) {
|
||||||
|
m_countdown = 5U;
|
||||||
|
|
||||||
::memset(m_rxBuffer, 0x00U, DSTAR_FEC_SECTION_LENGTH_BYTES);
|
m_headerBuffer[m_headerPtr] = sample;
|
||||||
m_rxBufferBits = 0U;
|
m_headerPtr++;
|
||||||
|
|
||||||
m_rssiAccum = 0U;
|
m_rssiAccum = 0U;
|
||||||
m_rssiCount = 0U;
|
m_rssiCount = 0U;
|
||||||
|
|
||||||
m_rxState = DSRXS_HEADER;
|
m_rxState = DSRXS_HEADER;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Exact matching of the data sync bit sequence
|
// Fuzzy matching of the data sync bit sequence
|
||||||
if (countBits32((m_patternBuffer & DATA_SYNC_MASK) ^ DATA_SYNC_DATA) == 0U) {
|
ret = correlateDataSync();
|
||||||
|
if (ret) {
|
||||||
DEBUG1("DStarRX: found data sync in None");
|
DEBUG1("DStarRX: found data sync in None");
|
||||||
|
|
||||||
io.setDecode(true);
|
io.setDecode(true);
|
||||||
io.setADCDetection(true);
|
io.setADCDetection(true);
|
||||||
|
|
||||||
// Suppress RSSI on the dummy sync message
|
m_rxState = DSRXS_DATA;
|
||||||
m_rssiAccum = 0U;
|
|
||||||
m_rssiCount = 0U;
|
|
||||||
|
|
||||||
::memcpy(m_rxBuffer, DSTAR_DATA_SYNC_BYTES, DSTAR_DATA_LENGTH_BYTES);
|
|
||||||
writeRSSIData(m_rxBuffer);
|
|
||||||
|
|
||||||
::memset(m_rxBuffer, 0x00U, DSTAR_DATA_LENGTH_BYTES + 2U);
|
|
||||||
m_rxBufferBits = 0U;
|
|
||||||
|
|
||||||
m_dataBits = MAX_SYNC_BITS;
|
|
||||||
m_rxState = DSRXS_DATA;
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDStarRX::processHeader(bool bit)
|
void CDStarRX::processHeader(q15_t sample)
|
||||||
{
|
{
|
||||||
m_patternBuffer <<= 1;
|
if (m_countdown > 0U) {
|
||||||
if (bit)
|
correlateFrameSync();
|
||||||
m_patternBuffer |= 0x01U;
|
m_countdown--;
|
||||||
|
}
|
||||||
|
|
||||||
WRITE_BIT2(m_rxBuffer, m_rxBufferBits, bit);
|
m_headerBuffer[m_headerPtr] = sample;
|
||||||
m_rxBufferBits++;
|
m_headerPtr++;
|
||||||
|
|
||||||
// A full FEC header
|
// A full FEC header
|
||||||
if (m_rxBufferBits == DSTAR_FEC_SECTION_LENGTH_BITS) {
|
if (m_headerPtr == (DSTAR_FEC_SECTION_LENGTH_SAMPLES + DSTAR_RADIO_SYMBOL_LENGTH)) {
|
||||||
// Process the scrambling, interleaving and FEC, then return if the chcksum was correct
|
uint8_t buffer[DSTAR_FEC_SECTION_LENGTH_BYTES];
|
||||||
unsigned char header[DSTAR_HEADER_LENGTH_BYTES];
|
samplesToBits(m_headerBuffer, DSTAR_RADIO_SYMBOL_LENGTH, DSTAR_FEC_SECTION_LENGTH_SYMBOLS, buffer, DSTAR_FEC_SECTION_LENGTH_SAMPLES);
|
||||||
bool ok = rxHeader(m_rxBuffer, header);
|
|
||||||
if (ok) {
|
// Process the scrambling, interleaving and FEC, then return true if the chcksum was correct
|
||||||
|
uint8_t header[DSTAR_HEADER_LENGTH_BYTES];
|
||||||
|
bool ok = rxHeader(buffer, header);
|
||||||
|
if (!ok) {
|
||||||
|
// The checksum failed, return to looking for syncs
|
||||||
|
m_rxState = DSRXS_NONE;
|
||||||
|
m_maxFrameCorr = 0;
|
||||||
|
m_maxDataCorr = 0;
|
||||||
|
} else {
|
||||||
io.setDecode(true);
|
io.setDecode(true);
|
||||||
io.setADCDetection(true);
|
io.setADCDetection(true);
|
||||||
|
|
||||||
writeRSSIHeader(header);
|
writeRSSIHeader(header);
|
||||||
|
|
||||||
::memset(m_rxBuffer, 0x00U, DSTAR_DATA_LENGTH_BYTES + 2U);
|
|
||||||
m_rxBufferBits = 0U;
|
|
||||||
|
|
||||||
m_rxState = DSRXS_DATA;
|
|
||||||
m_dataBits = MAX_SYNC_BITS;
|
|
||||||
} else {
|
|
||||||
// The checksum failed, return to looking for syncs
|
|
||||||
m_rxState = DSRXS_NONE;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ready to start the first data section
|
||||||
|
if (m_headerPtr == (DSTAR_FEC_SECTION_LENGTH_SAMPLES + 2U * DSTAR_RADIO_SYMBOL_LENGTH)) {
|
||||||
|
m_frameCount = 0U;
|
||||||
|
m_dataPtr = 0U;
|
||||||
|
|
||||||
|
m_startPtr = 476U;
|
||||||
|
m_syncPtr = 471U;
|
||||||
|
m_maxSyncPtr = 472U;
|
||||||
|
m_minSyncPtr = 470U;
|
||||||
|
|
||||||
|
DEBUG5("DStarRX: calc start/sync/max/min", m_startPtr, m_syncPtr, m_maxSyncPtr, m_minSyncPtr);
|
||||||
|
|
||||||
|
m_rxState = DSRXS_DATA;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDStarRX::processData(bool bit)
|
void CDStarRX::processData()
|
||||||
{
|
{
|
||||||
m_patternBuffer <<= 1;
|
|
||||||
if (bit)
|
|
||||||
m_patternBuffer |= 0x01U;
|
|
||||||
|
|
||||||
WRITE_BIT2(m_rxBuffer, m_rxBufferBits, bit);
|
|
||||||
m_rxBufferBits++;
|
|
||||||
|
|
||||||
// Fuzzy matching of the end frame sequences
|
// Fuzzy matching of the end frame sequences
|
||||||
if (countBits32((m_patternBuffer & END_SYNC_MASK) ^ END_SYNC_DATA) <= END_SYNC_ERRS) {
|
if (countBits64((m_bitBuffer[m_bitPtr] & DSTAR_END_SYNC_MASK) ^ DSTAR_END_SYNC_DATA) <= END_SYNC_ERRS) {
|
||||||
DEBUG1("DStarRX: Found end sync in Data");
|
DEBUG1("DStarRX: Found end sync in Data");
|
||||||
|
|
||||||
io.setDecode(false);
|
io.setDecode(false);
|
||||||
@@ -401,35 +406,24 @@ void CDStarRX::processData(bool bit)
|
|||||||
|
|
||||||
serial.writeDStarEOT();
|
serial.writeDStarEOT();
|
||||||
|
|
||||||
|
m_maxFrameCorr = 0;
|
||||||
|
m_maxDataCorr = 0;
|
||||||
|
|
||||||
m_rxState = DSRXS_NONE;
|
m_rxState = DSRXS_NONE;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fuzzy matching of the data sync bit sequence
|
// Fuzzy matching of the data sync bit sequence
|
||||||
bool syncSeen = false;
|
if (m_minSyncPtr < m_maxSyncPtr) {
|
||||||
if (m_rxBufferBits >= (DSTAR_DATA_LENGTH_BITS - 3U)) {
|
if (m_dataPtr >= m_minSyncPtr && m_dataPtr <= m_maxSyncPtr)
|
||||||
if (countBits32((m_patternBuffer & DATA_SYNC_MASK) ^ DATA_SYNC_DATA) <= DATA_SYNC_ERRS) {
|
correlateDataSync();
|
||||||
m_rxBufferBits = DSTAR_DATA_LENGTH_BITS;
|
} else {
|
||||||
m_dataBits = MAX_SYNC_BITS;
|
if (m_dataPtr >= m_minSyncPtr || m_dataPtr <= m_maxSyncPtr)
|
||||||
syncSeen = true;
|
correlateDataSync();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check to see if the sync is arriving late
|
// We've not seen a data sync for too long, signal RXLOST and change to RX_NONE
|
||||||
if (m_rxBufferBits == DSTAR_DATA_LENGTH_BITS && !syncSeen) {
|
if (m_frameCount >= MAX_FRAMES) {
|
||||||
for (uint8_t i = 1U; i <= 3U; i++) {
|
|
||||||
uint32_t syncMask = DATA_SYNC_MASK >> i;
|
|
||||||
uint32_t syncData = DATA_SYNC_DATA >> i;
|
|
||||||
if (countBits32((m_patternBuffer & syncMask) ^ syncData) <= DATA_SYNC_ERRS) {
|
|
||||||
m_rxBufferBits -= i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
m_dataBits--;
|
|
||||||
|
|
||||||
if (m_dataBits == 0U) {
|
|
||||||
DEBUG1("DStarRX: data sync timed out, lost lock");
|
DEBUG1("DStarRX: data sync timed out, lost lock");
|
||||||
|
|
||||||
io.setDecode(false);
|
io.setDecode(false);
|
||||||
@@ -437,24 +431,35 @@ void CDStarRX::processData(bool bit)
|
|||||||
|
|
||||||
serial.writeDStarLost();
|
serial.writeDStarLost();
|
||||||
|
|
||||||
|
m_maxFrameCorr = 0;
|
||||||
|
m_maxDataCorr = 0;
|
||||||
|
|
||||||
m_rxState = DSRXS_NONE;
|
m_rxState = DSRXS_NONE;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send a data frame to the host if the required number of bits have been received, or if a data sync has been seen
|
// Send a data frame to the host if the required number of bits have been received
|
||||||
if (m_rxBufferBits == DSTAR_DATA_LENGTH_BITS) {
|
if (m_dataPtr == m_maxSyncPtr) {
|
||||||
if (syncSeen) {
|
uint8_t buffer[DSTAR_DATA_LENGTH_BYTES + 2U];
|
||||||
m_rxBuffer[9U] = DSTAR_DATA_SYNC_BYTES[9U];
|
samplesToBits(m_dataBuffer, m_startPtr, DSTAR_DATA_LENGTH_SYMBOLS, buffer, DSTAR_DATA_LENGTH_SAMPLES);
|
||||||
m_rxBuffer[10U] = DSTAR_DATA_SYNC_BYTES[10U];
|
|
||||||
m_rxBuffer[11U] = DSTAR_DATA_SYNC_BYTES[11U];
|
|
||||||
writeRSSIData(m_rxBuffer);
|
|
||||||
} else {
|
|
||||||
serial.writeDStarData(m_rxBuffer, DSTAR_DATA_LENGTH_BYTES);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Start the next frame
|
if ((m_frameCount % 21U) == 0U) {
|
||||||
::memset(m_rxBuffer, 0x00U, DSTAR_DATA_LENGTH_BYTES + 2U);
|
if (m_frameCount == 0U) {
|
||||||
m_rxBufferBits = 0U;
|
buffer[9U] = DSTAR_DATA_SYNC_BYTES[9U];
|
||||||
|
buffer[10U] = DSTAR_DATA_SYNC_BYTES[10U];
|
||||||
|
buffer[11U] = DSTAR_DATA_SYNC_BYTES[11U];
|
||||||
|
DEBUG5("DStarRX: found start/sync/max/min", m_startPtr, m_syncPtr, m_maxSyncPtr, m_minSyncPtr);
|
||||||
|
}
|
||||||
|
|
||||||
|
writeRSSIData(buffer);
|
||||||
|
} else {
|
||||||
|
serial.writeDStarData(buffer, DSTAR_DATA_LENGTH_BYTES);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_frameCount++;
|
||||||
|
|
||||||
|
m_maxFrameCorr = 0;
|
||||||
|
m_maxDataCorr = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -500,6 +505,105 @@ void CDStarRX::writeRSSIData(unsigned char* data)
|
|||||||
m_rssiCount = 0U;
|
m_rssiCount = 0U;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CDStarRX::correlateFrameSync()
|
||||||
|
{
|
||||||
|
if (countBits64((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;
|
||||||
|
|
||||||
|
q31_t corr = 0;
|
||||||
|
|
||||||
|
for (uint8_t i = 0U; i < DSTAR_FRAME_SYNC_LENGTH_SYMBOLS; i++) {
|
||||||
|
q15_t val = m_dataBuffer[ptr];
|
||||||
|
|
||||||
|
if (DSTAR_FRAME_SYNC_SYMBOLS[i])
|
||||||
|
corr -= val;
|
||||||
|
else
|
||||||
|
corr += val;
|
||||||
|
|
||||||
|
ptr += DSTAR_RADIO_SYMBOL_LENGTH;
|
||||||
|
if (ptr >= DSTAR_DATA_LENGTH_SAMPLES)
|
||||||
|
ptr -= DSTAR_DATA_LENGTH_SAMPLES;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (corr > m_maxFrameCorr) {
|
||||||
|
m_maxFrameCorr = corr;
|
||||||
|
m_headerPtr = 0U;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CDStarRX::correlateDataSync()
|
||||||
|
{
|
||||||
|
uint8_t maxErrs = 0U;
|
||||||
|
if (m_rxState == DSRXS_DATA)
|
||||||
|
maxErrs = DATA_SYNC_ERRS;
|
||||||
|
|
||||||
|
if (countBits64((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;
|
||||||
|
|
||||||
|
q31_t corr = 0;
|
||||||
|
|
||||||
|
for (uint8_t i = 0U; i < DSTAR_DATA_SYNC_LENGTH_SYMBOLS; i++) {
|
||||||
|
q15_t val = m_dataBuffer[ptr];
|
||||||
|
|
||||||
|
if (DSTAR_DATA_SYNC_SYMBOLS[i])
|
||||||
|
corr -= val;
|
||||||
|
else
|
||||||
|
corr += val;
|
||||||
|
|
||||||
|
ptr += DSTAR_RADIO_SYMBOL_LENGTH;
|
||||||
|
if (ptr >= DSTAR_DATA_LENGTH_SAMPLES)
|
||||||
|
ptr -= DSTAR_DATA_LENGTH_SAMPLES;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (corr > m_maxDataCorr) {
|
||||||
|
m_maxDataCorr = corr;
|
||||||
|
m_frameCount = 0U;
|
||||||
|
|
||||||
|
m_syncPtr = m_dataPtr;
|
||||||
|
|
||||||
|
m_startPtr = m_dataPtr + DSTAR_RADIO_SYMBOL_LENGTH;
|
||||||
|
if (m_startPtr >= DSTAR_DATA_LENGTH_SAMPLES)
|
||||||
|
m_startPtr -= DSTAR_DATA_LENGTH_SAMPLES;
|
||||||
|
|
||||||
|
m_maxSyncPtr = m_syncPtr + 1U;
|
||||||
|
if (m_maxSyncPtr >= DSTAR_DATA_LENGTH_SAMPLES)
|
||||||
|
m_maxSyncPtr -= DSTAR_DATA_LENGTH_SAMPLES;
|
||||||
|
|
||||||
|
m_minSyncPtr = m_syncPtr + DSTAR_DATA_LENGTH_SAMPLES - 1U;
|
||||||
|
if (m_minSyncPtr >= DSTAR_DATA_LENGTH_SAMPLES)
|
||||||
|
m_minSyncPtr -= DSTAR_DATA_LENGTH_SAMPLES;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CDStarRX::samplesToBits(const q15_t* inBuffer, uint16_t start, uint16_t count, uint8_t* outBuffer, uint16_t limit)
|
||||||
|
{
|
||||||
|
for (uint16_t i = 0U; i < count; i++) {
|
||||||
|
q15_t sample = inBuffer[start];
|
||||||
|
|
||||||
|
if (sample < 0)
|
||||||
|
WRITE_BIT2(outBuffer, i, true);
|
||||||
|
else
|
||||||
|
WRITE_BIT2(outBuffer, i, false);
|
||||||
|
|
||||||
|
start += DSTAR_RADIO_SYMBOL_LENGTH;
|
||||||
|
if (start >= limit)
|
||||||
|
start -= limit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool CDStarRX::rxHeader(uint8_t* in, uint8_t* out)
|
bool CDStarRX::rxHeader(uint8_t* in, uint8_t* out)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@@ -715,3 +819,6 @@ 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];
|
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 by Jonathan Naylor G4KLX
|
* Copyright (C) 2015,2016,2017,2020 by Jonathan Naylor G4KLX
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -16,10 +16,13 @@
|
|||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "Config.h"
|
||||||
|
|
||||||
|
#if defined(MODE_DSTAR)
|
||||||
|
|
||||||
#if !defined(DSTARRX_H)
|
#if !defined(DSTARRX_H)
|
||||||
#define DSTARRX_H
|
#define DSTARRX_H
|
||||||
|
|
||||||
#include "Config.h"
|
|
||||||
#include "DStarDefines.h"
|
#include "DStarDefines.h"
|
||||||
|
|
||||||
enum DSRX_STATE {
|
enum DSRX_STATE {
|
||||||
@@ -37,13 +40,21 @@ public:
|
|||||||
void reset();
|
void reset();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint32_t m_pll;
|
|
||||||
bool m_prev;
|
|
||||||
DSRX_STATE m_rxState;
|
DSRX_STATE m_rxState;
|
||||||
uint32_t m_patternBuffer;
|
uint64_t m_bitBuffer[DSTAR_RADIO_SYMBOL_LENGTH];
|
||||||
uint8_t m_rxBuffer[100U];
|
q15_t m_headerBuffer[DSTAR_FEC_SECTION_LENGTH_SAMPLES + 2U * DSTAR_RADIO_SYMBOL_LENGTH];
|
||||||
unsigned int m_rxBufferBits;
|
q15_t m_dataBuffer[DSTAR_DATA_LENGTH_SAMPLES];
|
||||||
unsigned int m_dataBits;
|
uint16_t m_bitPtr;
|
||||||
|
uint16_t m_headerPtr;
|
||||||
|
uint16_t m_dataPtr;
|
||||||
|
uint16_t m_startPtr;
|
||||||
|
uint16_t m_syncPtr;
|
||||||
|
uint16_t m_minSyncPtr;
|
||||||
|
uint16_t m_maxSyncPtr;
|
||||||
|
q31_t m_maxFrameCorr;
|
||||||
|
q31_t m_maxDataCorr;
|
||||||
|
uint16_t m_frameCount;
|
||||||
|
uint8_t m_countdown;
|
||||||
unsigned int m_mar;
|
unsigned int m_mar;
|
||||||
int m_pathMetric[4U];
|
int m_pathMetric[4U];
|
||||||
unsigned int m_pathMemory0[42U];
|
unsigned int m_pathMemory0[42U];
|
||||||
@@ -54,9 +65,12 @@ private:
|
|||||||
uint32_t m_rssiAccum;
|
uint32_t m_rssiAccum;
|
||||||
uint16_t m_rssiCount;
|
uint16_t m_rssiCount;
|
||||||
|
|
||||||
void processNone(bool bit);
|
void processNone(q15_t sample);
|
||||||
void processHeader(bool bit);
|
void processHeader(q15_t sample);
|
||||||
void processData(bool bit);
|
void processData();
|
||||||
|
bool correlateFrameSync();
|
||||||
|
bool correlateDataSync();
|
||||||
|
void samplesToBits(const q15_t* inBuffer, uint16_t start, uint16_t count, uint8_t* outBuffer, uint16_t limit);
|
||||||
void writeRSSIHeader(unsigned char* header);
|
void writeRSSIHeader(unsigned char* header);
|
||||||
void writeRSSIData(unsigned char* data);
|
void writeRSSIData(unsigned char* data);
|
||||||
bool rxHeader(uint8_t* in, uint8_t* out);
|
bool rxHeader(uint8_t* in, uint8_t* out);
|
||||||
@@ -68,3 +82,5 @@ private:
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|||||||
+20
-12
@@ -18,6 +18,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
|
|
||||||
|
#if defined(MODE_DSTAR)
|
||||||
|
|
||||||
#include "Globals.h"
|
#include "Globals.h"
|
||||||
#include "DStarTX.h"
|
#include "DStarTX.h"
|
||||||
|
|
||||||
@@ -198,7 +201,7 @@ m_txDelay(60U) // 100ms
|
|||||||
{
|
{
|
||||||
::memset(m_modState, 0x00U, 20U * sizeof(q15_t));
|
::memset(m_modState, 0x00U, 20U * sizeof(q15_t));
|
||||||
|
|
||||||
m_modFilter.L = DSTAR_RADIO_BIT_LENGTH;
|
m_modFilter.L = DSTAR_RADIO_SYMBOL_LENGTH;
|
||||||
m_modFilter.phaseLength = GAUSSIAN_0_35_FILTER_PHASE_LEN;
|
m_modFilter.phaseLength = GAUSSIAN_0_35_FILTER_PHASE_LEN;
|
||||||
m_modFilter.pCoeffs = GAUSSIAN_0_35_FILTER;
|
m_modFilter.pCoeffs = GAUSSIAN_0_35_FILTER;
|
||||||
m_modFilter.pState = m_modState;
|
m_modFilter.pState = m_modState;
|
||||||
@@ -217,11 +220,12 @@ void CDStarTX::process()
|
|||||||
m_poBuffer[m_poLen++] = BIT_SYNC;
|
m_poBuffer[m_poLen++] = BIT_SYNC;
|
||||||
} else {
|
} else {
|
||||||
// Pop the type byte off
|
// Pop the type byte off
|
||||||
m_buffer.get();
|
uint8_t dummy;
|
||||||
|
m_buffer.get(dummy);
|
||||||
|
|
||||||
uint8_t header[DSTAR_HEADER_LENGTH_BYTES];
|
uint8_t header[DSTAR_HEADER_LENGTH_BYTES];
|
||||||
for (uint8_t i = 0U; i < DSTAR_HEADER_LENGTH_BYTES; i++)
|
for (uint8_t i = 0U; i < DSTAR_HEADER_LENGTH_BYTES; i++)
|
||||||
header[i] = m_buffer.get();
|
m_buffer.get(header[i]);
|
||||||
|
|
||||||
uint8_t buffer[86U];
|
uint8_t buffer[86U];
|
||||||
txHeader(header, buffer + 2U);
|
txHeader(header, buffer + 2U);
|
||||||
@@ -239,21 +243,23 @@ void CDStarTX::process()
|
|||||||
|
|
||||||
if (type == DSTAR_DATA && m_poLen == 0U) {
|
if (type == DSTAR_DATA && m_poLen == 0U) {
|
||||||
// Pop the type byte off
|
// Pop the type byte off
|
||||||
m_buffer.get();
|
uint8_t dummy;
|
||||||
|
m_buffer.get(dummy);
|
||||||
|
|
||||||
for (uint8_t i = 0U; i < DSTAR_DATA_LENGTH_BYTES; i++)
|
for (uint8_t i = 0U; i < DSTAR_DATA_LENGTH_BYTES; i++)
|
||||||
m_poBuffer[m_poLen++] = m_buffer.get();
|
m_buffer.get(m_poBuffer[m_poLen++]);
|
||||||
|
|
||||||
m_poPtr = 0U;
|
m_poPtr = 0U;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == DSTAR_EOT && m_poLen == 0U) {
|
if (type == DSTAR_EOT && m_poLen == 0U) {
|
||||||
// Pop the type byte off
|
// Pop the type byte off
|
||||||
m_buffer.get();
|
uint8_t dummy;
|
||||||
|
m_buffer.get(dummy);
|
||||||
|
|
||||||
for (uint8_t j = 0U; j < 3U; j++) {
|
for (uint8_t j = 0U; j < 3U; j++) {
|
||||||
for (uint8_t i = 0U; i < DSTAR_EOT_LENGTH_BYTES; i++)
|
for (uint8_t i = 0U; i < DSTAR_END_SYNC_LENGTH_BYTES; i++)
|
||||||
m_poBuffer[m_poLen++] = DSTAR_EOT_BYTES[i];
|
m_poBuffer[m_poLen++] = DSTAR_END_SYNC_BYTES[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
m_poPtr = 0U;
|
m_poPtr = 0U;
|
||||||
@@ -262,11 +268,11 @@ void CDStarTX::process()
|
|||||||
if (m_poLen > 0U) {
|
if (m_poLen > 0U) {
|
||||||
uint16_t space = io.getSpace();
|
uint16_t space = io.getSpace();
|
||||||
|
|
||||||
while (space > (8U * DSTAR_RADIO_BIT_LENGTH)) {
|
while (space > (8U * DSTAR_RADIO_SYMBOL_LENGTH)) {
|
||||||
uint8_t c = m_poBuffer[m_poPtr++];
|
uint8_t c = m_poBuffer[m_poPtr++];
|
||||||
writeByte(c);
|
writeByte(c);
|
||||||
|
|
||||||
space -= 8U * DSTAR_RADIO_BIT_LENGTH;
|
space -= 8U * DSTAR_RADIO_SYMBOL_LENGTH;
|
||||||
|
|
||||||
if (m_poPtr >= m_poLen) {
|
if (m_poPtr >= m_poLen) {
|
||||||
m_poPtr = 0U;
|
m_poPtr = 0U;
|
||||||
@@ -412,7 +418,7 @@ void CDStarTX::txHeader(const uint8_t* in, uint8_t* out) const
|
|||||||
void CDStarTX::writeByte(uint8_t c)
|
void CDStarTX::writeByte(uint8_t c)
|
||||||
{
|
{
|
||||||
q15_t inBuffer[8U];
|
q15_t inBuffer[8U];
|
||||||
q15_t outBuffer[DSTAR_RADIO_BIT_LENGTH * 8U];
|
q15_t outBuffer[DSTAR_RADIO_SYMBOL_LENGTH * 8U];
|
||||||
|
|
||||||
uint8_t mask = 0x01U;
|
uint8_t mask = 0x01U;
|
||||||
|
|
||||||
@@ -427,7 +433,7 @@ void CDStarTX::writeByte(uint8_t c)
|
|||||||
|
|
||||||
::arm_fir_interpolate_q15(&m_modFilter, inBuffer, outBuffer, 8U);
|
::arm_fir_interpolate_q15(&m_modFilter, inBuffer, outBuffer, 8U);
|
||||||
|
|
||||||
io.write(STATE_DSTAR, outBuffer, DSTAR_RADIO_BIT_LENGTH * 8U);
|
io.write(STATE_DSTAR, outBuffer, DSTAR_RADIO_SYMBOL_LENGTH * 8U);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDStarTX::setTXDelay(uint8_t delay)
|
void CDStarTX::setTXDelay(uint8_t delay)
|
||||||
@@ -443,3 +449,5 @@ uint8_t CDStarTX::getSpace() const
|
|||||||
return m_buffer.getSpace() / (DSTAR_DATA_LENGTH_BYTES + 1U);
|
return m_buffer.getSpace() / (DSTAR_DATA_LENGTH_BYTES + 1U);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -16,12 +16,14 @@
|
|||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "Config.h"
|
||||||
|
|
||||||
|
#if defined(MODE_DSTAR)
|
||||||
|
|
||||||
#if !defined(DSTARTX_H)
|
#if !defined(DSTARTX_H)
|
||||||
#define DSTARTX_H
|
#define DSTARTX_H
|
||||||
|
|
||||||
#include "Config.h"
|
#include "RingBuffer.h"
|
||||||
|
|
||||||
#include "SerialRB.h"
|
|
||||||
|
|
||||||
class CDStarTX {
|
class CDStarTX {
|
||||||
public:
|
public:
|
||||||
@@ -38,7 +40,7 @@ public:
|
|||||||
uint8_t getSpace() const;
|
uint8_t getSpace() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CSerialRB m_buffer;
|
CRingBuffer<uint8_t> m_buffer;
|
||||||
arm_fir_interpolate_instance_q15 m_modFilter;
|
arm_fir_interpolate_instance_q15 m_modFilter;
|
||||||
q15_t m_modState[20U]; // blockSize + phaseLength - 1, 8 + 9 - 1 plus some spare
|
q15_t m_modState[20U]; // blockSize + phaseLength - 1, 8 + 9 - 1 plus some spare
|
||||||
uint8_t m_poBuffer[600U];
|
uint8_t m_poBuffer[600U];
|
||||||
@@ -52,3 +54,5 @@ private:
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2015,2016,2017 by Jonathan Naylor G4KLX
|
* Copyright (C) 2015,2016,2017,2021 by Jonathan Naylor G4KLX
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -27,6 +27,7 @@
|
|||||||
#define DEBUG3(a,b,c) serial.writeDebug((a),(b),(c))
|
#define DEBUG3(a,b,c) serial.writeDebug((a),(b),(c))
|
||||||
#define DEBUG4(a,b,c,d) serial.writeDebug((a),(b),(c),(d))
|
#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 DEBUG5(a,b,c,d,e) serial.writeDebug((a),(b),(c),(d),(e))
|
||||||
|
#define DEBUG_DUMP(a,b) serial.writeDebugDump((a),(b))
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2020 by Jonathan Naylor G4KLX
|
* Copyright (C) 2020,2021,2023 by Jonathan Naylor G4KLX
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -16,39 +16,31 @@
|
|||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "Config.h"
|
||||||
|
|
||||||
|
#if defined(MODE_FM)
|
||||||
|
|
||||||
#if !defined(FM_H)
|
#if !defined(FM_H)
|
||||||
#define FM_H
|
#define FM_H
|
||||||
|
|
||||||
#include "Config.h"
|
|
||||||
|
|
||||||
#include "FMBlanking.h"
|
#include "FMBlanking.h"
|
||||||
#include "FMCTCSSRX.h"
|
#include "FMCTCSSRX.h"
|
||||||
#include "FMCTCSSTX.h"
|
#include "FMCTCSSTX.h"
|
||||||
#include "FMTimeout.h"
|
#include "FMTimeout.h"
|
||||||
#include "FMKeyer.h"
|
#include "FMKeyer.h"
|
||||||
#include "FMTimer.h"
|
#include "FMTimer.h"
|
||||||
#include "FMRB.h"
|
#include "RingBuffer.h"
|
||||||
#include "FMDirectForm1.h"
|
#include "FMDirectForm1.h"
|
||||||
#include "FMDownsampler.h"
|
#include "FMDownSampler.h"
|
||||||
|
#include "FMUpSampler.h"
|
||||||
enum FM_STATE {
|
#include "FMNoiseSquelch.h"
|
||||||
FS_LISTENING,
|
|
||||||
FS_KERCHUNK,
|
|
||||||
FS_RELAYING,
|
|
||||||
FS_RELAYING_WAIT,
|
|
||||||
FS_TIMEOUT,
|
|
||||||
FS_TIMEOUT_WAIT,
|
|
||||||
FS_HANG
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class CFM {
|
class CFM {
|
||||||
public:
|
public:
|
||||||
CFM();
|
CFM();
|
||||||
|
|
||||||
void samples(bool cos, const q15_t* samples, uint8_t length);
|
void samples(bool cos, q15_t* samples, const uint16_t* rssi, uint8_t length);
|
||||||
|
|
||||||
void process();
|
void process();
|
||||||
|
|
||||||
@@ -56,15 +48,22 @@ 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 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 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 cosInvert, uint8_t rfAudioBoost, uint8_t maxDev, uint8_t rxLevel);
|
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);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CFMKeyer m_callsign;
|
CFMKeyer m_callsign;
|
||||||
CFMKeyer m_rfAck;
|
CFMKeyer m_rfAck;
|
||||||
|
CFMKeyer m_extAck;
|
||||||
CFMCTCSSRX m_ctcssRX;
|
CFMCTCSSRX m_ctcssRX;
|
||||||
CFMCTCSSTX m_ctcssTX;
|
CFMCTCSSTX m_ctcssTX;
|
||||||
|
CFMNoiseSquelch m_squelch;
|
||||||
CFMTimeout m_timeoutTone;
|
CFMTimeout m_timeoutTone;
|
||||||
FM_STATE m_state;
|
uint8_t m_state;
|
||||||
bool m_callsignAtStart;
|
bool m_callsignAtStart;
|
||||||
bool m_callsignAtEnd;
|
bool m_callsignAtEnd;
|
||||||
bool m_callsignAtLatch;
|
bool m_callsignAtLatch;
|
||||||
@@ -76,26 +75,59 @@ private:
|
|||||||
CFMTimer m_ackDelayTimer;
|
CFMTimer m_ackDelayTimer;
|
||||||
CFMTimer m_hangTimer;
|
CFMTimer m_hangTimer;
|
||||||
CFMTimer m_reverseTimer;
|
CFMTimer m_reverseTimer;
|
||||||
|
bool m_needReverse;
|
||||||
CFMDirectFormI m_filterStage1;
|
CFMDirectFormI m_filterStage1;
|
||||||
CFMDirectFormI m_filterStage2;
|
CFMDirectFormI m_filterStage2;
|
||||||
CFMDirectFormI m_filterStage3;
|
CFMDirectFormI m_filterStage3;
|
||||||
CFMBlanking m_blanking;
|
CFMBlanking m_blanking;
|
||||||
uint8_t m_accessMode;
|
uint8_t m_accessMode;
|
||||||
|
bool m_linkMode;
|
||||||
bool m_cosInvert;
|
bool m_cosInvert;
|
||||||
|
bool m_noiseSquelch;
|
||||||
q15_t m_rfAudioBoost;
|
q15_t m_rfAudioBoost;
|
||||||
CFMDownsampler m_downsampler;
|
q15_t m_extAudioBoost;
|
||||||
|
CFMDownSampler m_downSampler;
|
||||||
|
bool m_extEnabled;
|
||||||
q15_t m_rxLevel;
|
q15_t m_rxLevel;
|
||||||
CFMRB m_inputRB;
|
CRingBuffer<q15_t> m_inputRFRB;
|
||||||
CFMRB m_outputRB;
|
CRingBuffer<q15_t> m_outputRFRB;
|
||||||
|
CFMUpSampler m_inputExtRB;
|
||||||
|
bool m_rfSignal;
|
||||||
|
bool m_extSignal;
|
||||||
|
uint32_t m_rssiAccum;
|
||||||
|
uint16_t m_rssiCount;
|
||||||
|
|
||||||
void stateMachine(bool validSignal);
|
void stateMachine(bool validRFSignal, bool validExtSignal);
|
||||||
void listeningState(bool validSignal);
|
|
||||||
void kerchunkState(bool validSignal);
|
void repeaterSamples(bool cos, q15_t* samples, const uint16_t* rssi, uint8_t length);
|
||||||
void relayingState(bool validSignal);
|
void linkSamples(bool cos, q15_t* samples, uint8_t length);
|
||||||
void relayingWaitState(bool validSignal);
|
|
||||||
void timeoutState(bool validSignal);
|
void duplexStateMachine(bool validRFSignal, bool validExtSignal);
|
||||||
void timeoutWaitState(bool validSignal);
|
void listeningStateDuplex(bool validRFSignal, bool validExtSignal);
|
||||||
void hangState(bool validSignal);
|
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 clock(uint8_t length);
|
void clock(uint8_t length);
|
||||||
|
|
||||||
@@ -107,3 +139,6 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
|
|
||||||
|
#if defined(MODE_FM)
|
||||||
|
|
||||||
#include "Globals.h"
|
#include "Globals.h"
|
||||||
#include "FMBlanking.h"
|
#include "FMBlanking.h"
|
||||||
|
|
||||||
@@ -80,3 +83,6 @@ q15_t CFMBlanking::process(q15_t sample)
|
|||||||
|
|
||||||
return sample;
|
return sample;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|||||||
+7
-2
@@ -16,11 +16,13 @@
|
|||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "Config.h"
|
||||||
|
|
||||||
|
#if defined(MODE_FM)
|
||||||
|
|
||||||
#if !defined(FMBlanking_H)
|
#if !defined(FMBlanking_H)
|
||||||
#define FMBlanking_H
|
#define FMBlanking_H
|
||||||
|
|
||||||
#include "Config.h"
|
|
||||||
|
|
||||||
class CFMBlanking {
|
class CFMBlanking {
|
||||||
public:
|
public:
|
||||||
CFMBlanking();
|
CFMBlanking();
|
||||||
@@ -39,3 +41,6 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|||||||
+16
-16
@@ -17,6 +17,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
|
|
||||||
|
#if defined(MODE_FM)
|
||||||
|
|
||||||
#include "Globals.h"
|
#include "Globals.h"
|
||||||
#include "FMCTCSSRX.h"
|
#include "FMCTCSSRX.h"
|
||||||
|
|
||||||
@@ -87,7 +90,7 @@ m_lowThreshold(0),
|
|||||||
m_count(0U),
|
m_count(0U),
|
||||||
m_q0(0),
|
m_q0(0),
|
||||||
m_q1(0),
|
m_q1(0),
|
||||||
m_result(CTS_NONE)
|
m_state(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,13 +114,11 @@ uint8_t CFMCTCSSRX::setParams(uint8_t frequency, uint8_t highThreshold, uint8_t
|
|||||||
return 0U;
|
return 0U;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t CFMCTCSSRX::process(q15_t sample)
|
bool CFMCTCSSRX::process(q15_t sample)
|
||||||
{
|
{
|
||||||
//get more dynamic into the decoder by multiplying the sample by 1.5
|
//get more dynamic into the decoder by multiplying the sample by 1.5
|
||||||
q31_t sample31 = q31_t(sample) + (q31_t(sample) >> 1);
|
q31_t sample31 = q31_t(sample) + (q31_t(sample) >> 1);
|
||||||
|
|
||||||
m_result &= ~CTS_READY;
|
|
||||||
|
|
||||||
q31_t q2 = m_q1;
|
q31_t q2 = m_q1;
|
||||||
m_q1 = m_q0;
|
m_q1 = m_q0;
|
||||||
|
|
||||||
@@ -149,33 +150,32 @@ uint8_t CFMCTCSSRX::process(q15_t sample)
|
|||||||
// value = m_q0 * m_q0 + m_q1 * m_q1 - m_q0 * m_q1 * m_coeffDivTwo * 2
|
// value = m_q0 * m_q0 + m_q1 * m_q1 - m_q0 * m_q1 * m_coeffDivTwo * 2
|
||||||
q31_t value = t2 + t4 - t9;
|
q31_t value = t2 + t4 - t9;
|
||||||
|
|
||||||
bool previousCTCSSValid = CTCSS_VALID(m_result);
|
bool previousState = m_state;
|
||||||
|
|
||||||
q31_t threshold = m_highThreshold;
|
q31_t threshold = m_highThreshold;
|
||||||
if (previousCTCSSValid)
|
if (previousState)
|
||||||
threshold = m_lowThreshold;
|
threshold = m_lowThreshold;
|
||||||
|
|
||||||
m_result |= CTS_READY;
|
m_state = value >= threshold;
|
||||||
if (value >= threshold)
|
|
||||||
m_result |= CTS_VALID;
|
|
||||||
else
|
|
||||||
m_result &= ~CTS_VALID;
|
|
||||||
|
|
||||||
if (previousCTCSSValid != CTCSS_VALID(m_result))
|
if (previousState != m_state)
|
||||||
DEBUG4("CTCSS Value / Threshold / Valid", value, threshold, CTCSS_VALID(m_result));
|
DEBUG4("CTCSS Value / Threshold / Valid", value, threshold, m_state);
|
||||||
|
|
||||||
m_count = 0U;
|
m_count = 0U;
|
||||||
m_q0 = 0;
|
m_q0 = 0;
|
||||||
m_q1 = 0;
|
m_q1 = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return m_result;
|
return m_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CFMCTCSSRX::reset()
|
void CFMCTCSSRX::reset()
|
||||||
{
|
{
|
||||||
m_q0 = 0;
|
m_q0 = 0;
|
||||||
m_q1 = 0;
|
m_q1 = 0;
|
||||||
m_result = CTS_NONE;
|
m_state = false;
|
||||||
m_count = 0U;
|
m_count = 0U;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|||||||
+8
-12
@@ -16,19 +16,12 @@
|
|||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if !defined(FMCTCSSRX_H)
|
|
||||||
#define FMCTCSSRX_H
|
|
||||||
|
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
|
|
||||||
const uint8_t CTS_NONE = 0U;
|
#if defined(MODE_FM)
|
||||||
const uint8_t CTS_READY = 1U;
|
|
||||||
const uint8_t CTS_VALID = 2U;
|
|
||||||
|
|
||||||
#define CTCSS_READY(a) ((a & CTS_READY) != 0)
|
#if !defined(FMCTCSSRX_H)
|
||||||
#define CTCSS_NOT_READY(a) ((a & CTS_READY) == 0)
|
#define FMCTCSSRX_H
|
||||||
#define CTCSS_VALID(a) ((a & CTS_VALID) != 0)
|
|
||||||
#define CTCSS_NOT_VALID(a) ((a & CTS_VALID) == 0)
|
|
||||||
|
|
||||||
class CFMCTCSSRX {
|
class CFMCTCSSRX {
|
||||||
public:
|
public:
|
||||||
@@ -36,7 +29,7 @@ public:
|
|||||||
|
|
||||||
uint8_t setParams(uint8_t frequency, uint8_t highThreshold, uint8_t lowThreshold);
|
uint8_t setParams(uint8_t frequency, uint8_t highThreshold, uint8_t lowThreshold);
|
||||||
|
|
||||||
uint8_t process(q15_t sample);
|
bool process(q15_t sample);
|
||||||
|
|
||||||
void reset();
|
void reset();
|
||||||
|
|
||||||
@@ -47,7 +40,10 @@ private:
|
|||||||
uint16_t m_count;
|
uint16_t m_count;
|
||||||
q31_t m_q0;
|
q31_t m_q0;
|
||||||
q31_t m_q1;
|
q31_t m_q1;
|
||||||
uint8_t m_result;
|
bool m_state;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
|
|
||||||
|
#if defined(MODE_FM)
|
||||||
|
|
||||||
#include "Globals.h"
|
#include "Globals.h"
|
||||||
#include "FMCTCSSTX.h"
|
#include "FMCTCSSTX.h"
|
||||||
|
|
||||||
@@ -126,3 +129,6 @@ q15_t CFMCTCSSTX::getAudio(bool reverse)
|
|||||||
else
|
else
|
||||||
return sample;
|
return sample;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|||||||
+7
-2
@@ -16,11 +16,13 @@
|
|||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "Config.h"
|
||||||
|
|
||||||
|
#if defined(MODE_FM)
|
||||||
|
|
||||||
#if !defined(FMCTCSSTX_H)
|
#if !defined(FMCTCSSTX_H)
|
||||||
#define FMCTCSSTX_H
|
#define FMCTCSSTX_H
|
||||||
|
|
||||||
#include "Config.h"
|
|
||||||
|
|
||||||
class CFMCTCSSTX {
|
class CFMCTCSSTX {
|
||||||
public:
|
public:
|
||||||
CFMCTCSSTX();
|
CFMCTCSSTX();
|
||||||
@@ -36,3 +38,6 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|||||||
+9
-2
@@ -29,7 +29,11 @@ THE SOFTWARE.
|
|||||||
|
|
||||||
// based on https://raw.githubusercontent.com/berndporr/iir_fixed_point/master/DirectFormI.h
|
// based on https://raw.githubusercontent.com/berndporr/iir_fixed_point/master/DirectFormI.h
|
||||||
|
|
||||||
#include "Globals.h"
|
#include "Config.h"
|
||||||
|
|
||||||
|
#if defined(MODE_FM)
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
#ifndef DIRECTFORMI_H_
|
#ifndef DIRECTFORMI_H_
|
||||||
#define DIRECTFORMI_H_
|
#define DIRECTFORMI_H_
|
||||||
@@ -108,4 +112,7 @@ private:
|
|||||||
q31_t c_a1,c_a2; // IIR
|
q31_t c_a1,c_a2; // IIR
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* DIRECTFORMI_H */
|
#endif /* DIRECTFORMI_H */
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,80 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
||||||
|
|
||||||
@@ -17,27 +17,36 @@
|
|||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "Config.h"
|
||||||
|
|
||||||
|
#if defined(MODE_FM)
|
||||||
|
|
||||||
#if !defined(FMDOWNSAMPLER_H)
|
#if !defined(FMDOWNSAMPLER_H)
|
||||||
#define FMDOWNSAMPLER_H
|
#define FMDOWNSAMPLER_H
|
||||||
|
|
||||||
#include "Config.h"
|
#include "RingBuffer.h"
|
||||||
#include "FMDownsampleRB.h"
|
#include "FMSamplePairPack.h"
|
||||||
|
|
||||||
class CFMDownsampler {
|
class CFMDownSampler {
|
||||||
public:
|
public:
|
||||||
CFMDownsampler(uint16_t length);
|
CFMDownSampler(uint16_t length);
|
||||||
|
|
||||||
void addSample(q15_t sample);
|
void addSample(q15_t sample);
|
||||||
inline bool getPackedData(uint8_t& data){ return m_ringBuffer.get(data); };
|
|
||||||
inline bool hasOverflowed() { return m_ringBuffer.hasOverflowed(); };
|
bool getPackedData(TSamplePairPack& data);
|
||||||
|
|
||||||
|
uint16_t getData();
|
||||||
|
|
||||||
|
void reset();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CFMDownsampleRB m_ringBuffer;
|
CRingBuffer<TSamplePairPack> m_ringBuffer;
|
||||||
union {
|
uint32_t m_samplePack;
|
||||||
int32_t m_samplePack;
|
uint8_t* m_samplePackPointer;
|
||||||
int8_t m_samplePackBytes[4];
|
uint8_t m_sampleIndex;
|
||||||
};
|
|
||||||
uint8_t m_packIndex;
|
|
||||||
uint8_t m_downSampleIndex;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
@@ -1,63 +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"
|
|
||||||
#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,6 +17,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
|
|
||||||
|
#if defined(MODE_FM)
|
||||||
|
|
||||||
#include "Globals.h"
|
#include "Globals.h"
|
||||||
#include "FMKeyer.h"
|
#include "FMKeyer.h"
|
||||||
|
|
||||||
@@ -214,3 +217,6 @@ bool CFMKeyer::isRunning() const
|
|||||||
{
|
{
|
||||||
return m_poPos > 0U || m_dotPos > 0U || m_audioPos > 0U;
|
return m_poPos > 0U || m_dotPos > 0U || m_audioPos > 0U;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -16,11 +16,13 @@
|
|||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "Config.h"
|
||||||
|
|
||||||
|
#if defined(MODE_FM)
|
||||||
|
|
||||||
#if !defined(FMKeyer_H)
|
#if !defined(FMKeyer_H)
|
||||||
#define FMKeyer_H
|
#define FMKeyer_H
|
||||||
|
|
||||||
#include "Config.h"
|
|
||||||
|
|
||||||
class CFMKeyer {
|
class CFMKeyer {
|
||||||
public:
|
public:
|
||||||
CFMKeyer();
|
CFMKeyer();
|
||||||
@@ -52,3 +54,6 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,133 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
||||||
|
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
||||||
|
|
||||||
@@ -1,110 +0,0 @@
|
|||||||
/*
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
@@ -1,72 +0,0 @@
|
|||||||
/*
|
|
||||||
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
|
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
||||||
|
|
||||||
@@ -17,6 +17,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
|
|
||||||
|
#if defined(MODE_FM)
|
||||||
|
|
||||||
#include "Globals.h"
|
#include "Globals.h"
|
||||||
#include "FMTimeout.h"
|
#include "FMTimeout.h"
|
||||||
|
|
||||||
@@ -72,3 +75,6 @@ void CFMTimeout::stop()
|
|||||||
{
|
{
|
||||||
m_running = false;
|
m_running = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|||||||
+7
-2
@@ -16,11 +16,13 @@
|
|||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "Config.h"
|
||||||
|
|
||||||
|
#if defined(MODE_FM)
|
||||||
|
|
||||||
#if !defined(FMTimeout_H)
|
#if !defined(FMTimeout_H)
|
||||||
#define FMTimeout_H
|
#define FMTimeout_H
|
||||||
|
|
||||||
#include "Config.h"
|
|
||||||
|
|
||||||
class CFMTimeout {
|
class CFMTimeout {
|
||||||
public:
|
public:
|
||||||
CFMTimeout();
|
CFMTimeout();
|
||||||
@@ -40,3 +42,6 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
|
|
||||||
|
#if defined(MODE_FM)
|
||||||
|
|
||||||
#include "Globals.h"
|
#include "Globals.h"
|
||||||
#include "FMTimer.h"
|
#include "FMTimer.h"
|
||||||
|
|
||||||
@@ -68,3 +71,6 @@ bool CFMTimer::hasExpired() const
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -16,11 +16,13 @@
|
|||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "Config.h"
|
||||||
|
|
||||||
|
#if defined(MODE_FM)
|
||||||
|
|
||||||
#if !defined(FMTimer_H)
|
#if !defined(FMTimer_H)
|
||||||
#define FMTimer_H
|
#define FMTimer_H
|
||||||
|
|
||||||
#include "Config.h"
|
|
||||||
|
|
||||||
class CFMTimer {
|
class CFMTimer {
|
||||||
public:
|
public:
|
||||||
CFMTimer();
|
CFMTimer();
|
||||||
@@ -45,3 +47,6 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|||||||
+104
@@ -0,0 +1,104 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
||||||
|
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
||||||
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2015,2016,2017,2018,2020 by Jonathan Naylor G4KLX
|
* Copyright (C) 2015,2016,2017,2018,2020,2021,2023 by Jonathan Naylor G4KLX
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -23,16 +23,12 @@
|
|||||||
#include "stm32f4xx.h"
|
#include "stm32f4xx.h"
|
||||||
#elif defined(STM32F7XX)
|
#elif defined(STM32F7XX)
|
||||||
#include "stm32f7xx.h"
|
#include "stm32f7xx.h"
|
||||||
#elif defined(STM32F105xC)
|
|
||||||
#include "stm32f1xx.h"
|
|
||||||
#include "STM32Utils.h"
|
|
||||||
#else
|
#else
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
#undef PI //Undefine PI to get rid of annoying warning as it is also defined in arm_math.h.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__SAM3X8E__) || defined(STM32F105xC)
|
#if defined(STM32F7XX)
|
||||||
#define ARM_MATH_CM3
|
|
||||||
#elif defined(STM32F7XX)
|
|
||||||
#define ARM_MATH_CM7
|
#define ARM_MATH_CM7
|
||||||
#elif defined(STM32F4XX) || defined(__MK20DX256__) || defined(__MK64FX512__) || defined(__MK66FX1M0__)
|
#elif defined(STM32F4XX) || defined(__MK20DX256__) || defined(__MK64FX512__) || defined(__MK66FX1M0__)
|
||||||
#define ARM_MATH_CM4
|
#define ARM_MATH_CM4
|
||||||
@@ -50,6 +46,7 @@ enum MMDVM_STATE {
|
|||||||
STATE_P25 = 4,
|
STATE_P25 = 4,
|
||||||
STATE_NXDN = 5,
|
STATE_NXDN = 5,
|
||||||
STATE_POCSAG = 6,
|
STATE_POCSAG = 6,
|
||||||
|
STATE_M17 = 7,
|
||||||
STATE_FM = 10,
|
STATE_FM = 10,
|
||||||
STATE_AX25 = 11,
|
STATE_AX25 = 11,
|
||||||
|
|
||||||
@@ -70,7 +67,8 @@ enum MMDVM_STATE {
|
|||||||
STATE_FMCAL15K = 104,
|
STATE_FMCAL15K = 104,
|
||||||
STATE_FMCAL20K = 105,
|
STATE_FMCAL20K = 105,
|
||||||
STATE_FMCAL25K = 106,
|
STATE_FMCAL25K = 106,
|
||||||
STATE_FMCAL30K = 107
|
STATE_FMCAL30K = 107,
|
||||||
|
STATE_M17CAL = 108
|
||||||
};
|
};
|
||||||
|
|
||||||
#include "SerialPort.h"
|
#include "SerialPort.h"
|
||||||
@@ -85,6 +83,8 @@ enum MMDVM_STATE {
|
|||||||
#include "YSFTX.h"
|
#include "YSFTX.h"
|
||||||
#include "P25RX.h"
|
#include "P25RX.h"
|
||||||
#include "P25TX.h"
|
#include "P25TX.h"
|
||||||
|
#include "M17RX.h"
|
||||||
|
#include "M17TX.h"
|
||||||
#include "NXDNRX.h"
|
#include "NXDNRX.h"
|
||||||
#include "NXDNTX.h"
|
#include "NXDNTX.h"
|
||||||
#include "POCSAGTX.h"
|
#include "POCSAGTX.h"
|
||||||
@@ -99,6 +99,7 @@ enum MMDVM_STATE {
|
|||||||
#include "CWIdTX.h"
|
#include "CWIdTX.h"
|
||||||
#include "AX25RX.h"
|
#include "AX25RX.h"
|
||||||
#include "AX25TX.h"
|
#include "AX25TX.h"
|
||||||
|
#include "CalM17.h"
|
||||||
#include "Debug.h"
|
#include "Debug.h"
|
||||||
#include "IO.h"
|
#include "IO.h"
|
||||||
#include "FM.h"
|
#include "FM.h"
|
||||||
@@ -126,6 +127,7 @@ extern bool m_ysfEnable;
|
|||||||
extern bool m_p25Enable;
|
extern bool m_p25Enable;
|
||||||
extern bool m_nxdnEnable;
|
extern bool m_nxdnEnable;
|
||||||
extern bool m_pocsagEnable;
|
extern bool m_pocsagEnable;
|
||||||
|
extern bool m_m17Enable;
|
||||||
extern bool m_fmEnable;
|
extern bool m_fmEnable;
|
||||||
extern bool m_ax25Enable;
|
extern bool m_ax25Enable;
|
||||||
|
|
||||||
@@ -137,9 +139,15 @@ extern bool m_dcd;
|
|||||||
extern CSerialPort serial;
|
extern CSerialPort serial;
|
||||||
extern CIO io;
|
extern CIO io;
|
||||||
|
|
||||||
|
#if defined(MODE_DSTAR)
|
||||||
extern CDStarRX dstarRX;
|
extern CDStarRX dstarRX;
|
||||||
extern CDStarTX dstarTX;
|
extern CDStarTX dstarTX;
|
||||||
|
|
||||||
|
extern CCalDStarRX calDStarRX;
|
||||||
|
extern CCalDStarTX calDStarTX;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(MODE_DMR)
|
||||||
extern CDMRIdleRX dmrIdleRX;
|
extern CDMRIdleRX dmrIdleRX;
|
||||||
extern CDMRRX dmrRX;
|
extern CDMRRX dmrRX;
|
||||||
extern CDMRTX dmrTX;
|
extern CDMRTX dmrTX;
|
||||||
@@ -147,29 +155,51 @@ extern CDMRTX dmrTX;
|
|||||||
extern CDMRDMORX dmrDMORX;
|
extern CDMRDMORX dmrDMORX;
|
||||||
extern CDMRDMOTX dmrDMOTX;
|
extern CDMRDMOTX dmrDMOTX;
|
||||||
|
|
||||||
|
extern CCalDMR calDMR;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(MODE_YSF)
|
||||||
extern CYSFRX ysfRX;
|
extern CYSFRX ysfRX;
|
||||||
extern CYSFTX ysfTX;
|
extern CYSFTX ysfTX;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(MODE_P25)
|
||||||
extern CP25RX p25RX;
|
extern CP25RX p25RX;
|
||||||
extern CP25TX p25TX;
|
extern CP25TX p25TX;
|
||||||
|
|
||||||
|
extern CCalP25 calP25;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(MODE_NXDN)
|
||||||
extern CNXDNRX nxdnRX;
|
extern CNXDNRX nxdnRX;
|
||||||
extern CNXDNTX nxdnTX;
|
extern CNXDNTX nxdnTX;
|
||||||
|
|
||||||
extern CPOCSAGTX pocsagTX;
|
extern CCalNXDN calNXDN;
|
||||||
|
#endif
|
||||||
|
|
||||||
extern CFM fm;
|
#if defined(MODE_POCSAG)
|
||||||
|
extern CPOCSAGTX pocsagTX;
|
||||||
|
extern CCalPOCSAG calPOCSAG;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(MODE_M17)
|
||||||
|
extern CM17RX m17RX;
|
||||||
|
extern CM17TX m17TX;
|
||||||
|
|
||||||
|
extern CCalM17 calM17;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(MODE_FM)
|
||||||
|
extern CFM fm;
|
||||||
|
extern CCalFM calFM;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(MODE_AX25)
|
||||||
extern CAX25RX ax25RX;
|
extern CAX25RX ax25RX;
|
||||||
extern CAX25TX ax25TX;
|
extern CAX25TX ax25TX;
|
||||||
|
#endif
|
||||||
|
|
||||||
extern CCalDStarRX calDStarRX;
|
extern CCalRSSI calRSSI;
|
||||||
extern CCalDStarTX calDStarTX;
|
|
||||||
extern CCalDMR calDMR;
|
|
||||||
extern CCalFM calFM;
|
|
||||||
extern CCalP25 calP25;
|
|
||||||
extern CCalNXDN calNXDN;
|
|
||||||
extern CCalPOCSAG calPOCSAG;
|
|
||||||
extern CCalRSSI calRSSI;
|
|
||||||
|
|
||||||
extern CCWIdTX cwIdTX;
|
extern CCWIdTX cwIdTX;
|
||||||
|
|
||||||
|
|||||||
-235
@@ -1,235 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
* 28-4-2017 Created for MMDVM Pi shield for Teensy by Chris Huitema
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "Config.h"
|
|
||||||
#include "Globals.h"
|
|
||||||
|
|
||||||
#if defined(VK6MST_TEENSY_PI3_SHIELD_I2C)
|
|
||||||
|
|
||||||
#include <i2c_t3.h> //available here https://github.com/nox771/i2c_t3 or maybe the normal wire will work #include <wire.h> justs need to test i guess
|
|
||||||
|
|
||||||
#define I2C_ADDRESS 0x22
|
|
||||||
#define I2C_SPEED 100000
|
|
||||||
|
|
||||||
// Function prototypes
|
|
||||||
void receiveEvent(size_t count);
|
|
||||||
void requestEvent(void);
|
|
||||||
|
|
||||||
#define TX_FIFO_SIZE 512U
|
|
||||||
#define RX_FIFO_SIZE 512U
|
|
||||||
|
|
||||||
volatile uint8_t TXfifo[TX_FIFO_SIZE];
|
|
||||||
volatile uint8_t RXfifo[RX_FIFO_SIZE];
|
|
||||||
volatile uint16_t TXfifohead, TXfifotail;
|
|
||||||
volatile uint16_t RXfifohead, RXfifotail;
|
|
||||||
|
|
||||||
// Init queues
|
|
||||||
void TXfifoinit(void)
|
|
||||||
{
|
|
||||||
TXfifohead = 0U;
|
|
||||||
TXfifotail = 0U;
|
|
||||||
}
|
|
||||||
|
|
||||||
void RXfifoinit()
|
|
||||||
{
|
|
||||||
RXfifohead = 0U;
|
|
||||||
RXfifotail = 0U;
|
|
||||||
}
|
|
||||||
|
|
||||||
// How full is queue
|
|
||||||
|
|
||||||
uint16_t TXfifolevel(void)
|
|
||||||
{
|
|
||||||
uint32_t tail = TXfifotail;
|
|
||||||
uint32_t head = TXfifohead;
|
|
||||||
|
|
||||||
if (tail > head)
|
|
||||||
return TX_FIFO_SIZE + head - tail;
|
|
||||||
else
|
|
||||||
return head - tail;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t RXfifolevel(void)
|
|
||||||
{
|
|
||||||
uint32_t tail = RXfifotail;
|
|
||||||
uint32_t head = RXfifohead;
|
|
||||||
|
|
||||||
if (tail > head)
|
|
||||||
return RX_FIFO_SIZE + head - tail;
|
|
||||||
else
|
|
||||||
return head - tail;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
uint8_t TXfifoput(uint8_t next)
|
|
||||||
{
|
|
||||||
if (TXfifolevel() < TX_FIFO_SIZE) {
|
|
||||||
TXfifo[TXfifohead] = next;
|
|
||||||
|
|
||||||
TXfifohead++;
|
|
||||||
if (TXfifohead >= TX_FIFO_SIZE)
|
|
||||||
TXfifohead = 0U;
|
|
||||||
return 1U;
|
|
||||||
} else {
|
|
||||||
return 0U; // signal an overflow occurred by returning a zero count
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void I2Cbegin(void)
|
|
||||||
{
|
|
||||||
// Setup for Slave mode, address 0x22, pins 18/19, external pullups, speed in hz
|
|
||||||
Wire.begin(I2C_SLAVE, I2C_ADDRESS, I2C_PINS_18_19, I2C_PULLUP_EXT, I2C_SPEED);
|
|
||||||
|
|
||||||
// register events
|
|
||||||
Wire.onReceive(receiveEvent);
|
|
||||||
Wire.onRequest(requestEvent);
|
|
||||||
|
|
||||||
// initialize the fifos
|
|
||||||
TXfifoinit();
|
|
||||||
RXfifoinit();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int I2Cavailable(void)
|
|
||||||
{
|
|
||||||
if (RXfifolevel() > 0U)
|
|
||||||
return 1U;
|
|
||||||
else
|
|
||||||
return 0U;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
uint8_t I2Cread(void)
|
|
||||||
{
|
|
||||||
uint8_t data_c = RXfifo[RXfifotail];
|
|
||||||
|
|
||||||
RXfifotail++;
|
|
||||||
if (RXfifotail >= RX_FIFO_SIZE)
|
|
||||||
RXfifotail = 0U;
|
|
||||||
|
|
||||||
return data_c;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void I2Cwrite(const uint8_t* data, uint16_t length)
|
|
||||||
{
|
|
||||||
for (uint16_t i = 0U; i < length; i++)
|
|
||||||
TXfifoput(data[i]); //puts it in the fifo
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// handle Rx Event (incoming I2C data)
|
|
||||||
//
|
|
||||||
void receiveEvent(size_t count)
|
|
||||||
{
|
|
||||||
for (uint16_t i = 0U; i < count; i++)
|
|
||||||
{
|
|
||||||
if (RXfifolevel() < RX_FIFO_SIZE) {
|
|
||||||
RXfifo[RXfifohead] = Wire.readByte();
|
|
||||||
if (RXfifo[RXfifohead] != -1){
|
|
||||||
RXfifohead++;
|
|
||||||
if (RXfifohead >= RX_FIFO_SIZE) RXfifohead = 0U;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Wire.readByte(); // drop data if mem full.
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// handle Tx Event (outgoing I2C data)
|
|
||||||
//
|
|
||||||
void requestEvent(void)
|
|
||||||
{
|
|
||||||
if (TXfifolevel() > 0) {
|
|
||||||
if (Wire.write(TXfifo[TXfifotail])){ //write to i2c
|
|
||||||
TXfifotail++;
|
|
||||||
if (TXfifotail >= TX_FIFO_SIZE) TXfifotail = 0U;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/************************************/
|
|
||||||
|
|
||||||
void CSerialPort::beginInt(uint8_t n, int speed)
|
|
||||||
{
|
|
||||||
switch (n) {
|
|
||||||
case 1U:
|
|
||||||
return I2Cbegin();
|
|
||||||
case 3U:
|
|
||||||
Serial3.begin(speed);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int CSerialPort::availableInt(uint8_t n)
|
|
||||||
{
|
|
||||||
switch (n) {
|
|
||||||
case 1U:
|
|
||||||
return I2Cavailable();
|
|
||||||
case 3U:
|
|
||||||
return Serial3.available();
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int CSerialPort::availableForWriteInt(uint8_t n)
|
|
||||||
{
|
|
||||||
switch (n) {
|
|
||||||
case 3U:
|
|
||||||
return Serial3.availableForWrite();
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t CSerialPort::readInt(uint8_t n)
|
|
||||||
{
|
|
||||||
switch (n) {
|
|
||||||
case 1U:
|
|
||||||
return I2Cread();
|
|
||||||
case 3U:
|
|
||||||
return Serial3.read();
|
|
||||||
default:
|
|
||||||
return 0U;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSerialPort::writeInt(uint8_t n, const uint8_t* data, uint16_t length, bool flush)
|
|
||||||
{
|
|
||||||
switch (n) {
|
|
||||||
case 1U:
|
|
||||||
I2Cwrite(data, length);
|
|
||||||
break;
|
|
||||||
case 3U:
|
|
||||||
Serial3.write(data, length);
|
|
||||||
if (flush)
|
|
||||||
Serial3.flush();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2015,2016,2017,2018,2020 by Jonathan Naylor G4KLX
|
* Copyright (C) 2015,2016,2017,2018,2020,2021,2023 by Jonathan Naylor G4KLX
|
||||||
* Copyright (C) 2015 by Jim Mclaughlin KI6ZUM
|
* Copyright (C) 2015 by Jim Mclaughlin KI6ZUM
|
||||||
* Copyright (C) 2016 by Colin Durbridge G4EML
|
* Copyright (C) 2016 by Colin Durbridge G4EML
|
||||||
*
|
*
|
||||||
@@ -22,16 +22,34 @@
|
|||||||
#include "Globals.h"
|
#include "Globals.h"
|
||||||
#include "IO.h"
|
#include "IO.h"
|
||||||
|
|
||||||
|
#if defined(USE_DCBLOCKER)
|
||||||
// Generated using [b, a] = butter(1, 0.001) in MATLAB
|
// 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}
|
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
|
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
|
// 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,
|
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,
|
11237, 14331, 15464, 14331, 11237, 6995, 2667, -770, -2706, -3040, -2144, -675, 683, 1450, 1472, 909, 112,
|
||||||
-553, -847, -731, -340, 104, 401, 0};
|
-553, -847, -731, -340, 104, 401, 0};
|
||||||
const uint16_t RRC_0_2_FILTER_LEN = 42U;
|
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
|
// 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,
|
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,
|
483, 39, -477, -1016, -1516, -1915, -2150, -2164, -1914, -1375, -545, 557, 1886, 3376, 4946, 6502, 7946, 9184,
|
||||||
@@ -43,14 +61,20 @@ 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,
|
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};
|
12354, 4441, -3102, -7536, -7834, -4915, -893, 2152, 3156, 2341, 747, -553, -1073, -1085, 790};
|
||||||
const uint16_t NXDN_ISINC_FILTER_LEN = 32U;
|
const uint16_t NXDN_ISINC_FILTER_LEN = 32U;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(MODE_DSTAR)
|
||||||
// Generated using gaussfir(0.5, 4, 5) in MATLAB
|
// 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};
|
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;
|
const uint16_t GAUSSIAN_0_5_FILTER_LEN = 12U;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(MODE_P25)
|
||||||
// One symbol boxcar filter
|
// One symbol boxcar filter
|
||||||
static q15_t BOXCAR_FILTER[] = {12000, 12000, 12000, 12000, 12000, 0};
|
static q15_t BOXCAR5_FILTER[] = {12000, 12000, 12000, 12000, 12000, 0};
|
||||||
const uint16_t BOXCAR_FILTER_LEN = 6U;
|
const uint16_t BOXCAR5_FILTER_LEN = 6U;
|
||||||
|
#endif
|
||||||
|
|
||||||
const uint16_t DC_OFFSET = 2048U;
|
const uint16_t DC_OFFSET = 2048U;
|
||||||
|
|
||||||
@@ -59,18 +83,41 @@ m_started(false),
|
|||||||
m_rxBuffer(RX_RINGBUFFER_SIZE),
|
m_rxBuffer(RX_RINGBUFFER_SIZE),
|
||||||
m_txBuffer(TX_RINGBUFFER_SIZE),
|
m_txBuffer(TX_RINGBUFFER_SIZE),
|
||||||
m_rssiBuffer(RX_RINGBUFFER_SIZE),
|
m_rssiBuffer(RX_RINGBUFFER_SIZE),
|
||||||
|
#if defined(USE_DCBLOCKER)
|
||||||
m_dcFilter(),
|
m_dcFilter(),
|
||||||
m_dcState(),
|
m_dcState(),
|
||||||
m_rrcFilter(),
|
#endif
|
||||||
|
#if defined(MODE_DSTAR)
|
||||||
m_gaussianFilter(),
|
m_gaussianFilter(),
|
||||||
m_boxcarFilter(),
|
m_gaussianState(),
|
||||||
|
#endif
|
||||||
|
#if defined(MODE_DMR)
|
||||||
|
m_rrc02Filter1(),
|
||||||
|
m_rrc02State1(),
|
||||||
|
#endif
|
||||||
|
#if defined(MODE_YSF)
|
||||||
|
m_rrc02Filter2(),
|
||||||
|
m_rrc02State2(),
|
||||||
|
#endif
|
||||||
|
#if defined(MODE_P25)
|
||||||
|
m_boxcar5Filter(),
|
||||||
|
m_boxcar5State(),
|
||||||
|
#endif
|
||||||
|
#if defined(MODE_NXDN)
|
||||||
|
#if defined(USE_NXDN_BOXCAR)
|
||||||
|
m_boxcar10Filter(),
|
||||||
|
m_boxcar10State(),
|
||||||
|
#else
|
||||||
m_nxdnFilter(),
|
m_nxdnFilter(),
|
||||||
m_nxdnISincFilter(),
|
m_nxdnISincFilter(),
|
||||||
m_rrcState(),
|
|
||||||
m_gaussianState(),
|
|
||||||
m_boxcarState(),
|
|
||||||
m_nxdnState(),
|
m_nxdnState(),
|
||||||
m_nxdnISincState(),
|
m_nxdnISincState(),
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#if defined(MODE_M17)
|
||||||
|
m_rrc05Filter(),
|
||||||
|
m_rrc05State(),
|
||||||
|
#endif
|
||||||
m_pttInvert(false),
|
m_pttInvert(false),
|
||||||
m_rxLevel(128 * 128),
|
m_rxLevel(128 * 128),
|
||||||
m_cwIdTXLevel(128 * 128),
|
m_cwIdTXLevel(128 * 128),
|
||||||
@@ -79,6 +126,7 @@ m_dmrTXLevel(128 * 128),
|
|||||||
m_ysfTXLevel(128 * 128),
|
m_ysfTXLevel(128 * 128),
|
||||||
m_p25TXLevel(128 * 128),
|
m_p25TXLevel(128 * 128),
|
||||||
m_nxdnTXLevel(128 * 128),
|
m_nxdnTXLevel(128 * 128),
|
||||||
|
m_m17TXLevel(128 * 128),
|
||||||
m_pocsagTXLevel(128 * 128),
|
m_pocsagTXLevel(128 * 128),
|
||||||
m_fmTXLevel(128 * 128),
|
m_fmTXLevel(128 * 128),
|
||||||
m_ax25TXLevel(128 * 128),
|
m_ax25TXLevel(128 * 128),
|
||||||
@@ -93,30 +141,52 @@ m_dacOverflow(0U),
|
|||||||
m_watchdog(0U),
|
m_watchdog(0U),
|
||||||
m_lockout(false)
|
m_lockout(false)
|
||||||
{
|
{
|
||||||
::memset(m_rrcState, 0x00U, 70U * sizeof(q15_t));
|
#if defined(USE_DCBLOCKER)
|
||||||
::memset(m_gaussianState, 0x00U, 40U * sizeof(q15_t));
|
::memset(m_dcState, 0x00U, 4U * sizeof(q31_t));
|
||||||
::memset(m_boxcarState, 0x00U, 30U * sizeof(q15_t));
|
|
||||||
::memset(m_nxdnState, 0x00U, 110U * sizeof(q15_t));
|
|
||||||
::memset(m_nxdnISincState, 0x00U, 60U * sizeof(q15_t));
|
|
||||||
::memset(m_dcState, 0x00U, 4U * sizeof(q31_t));
|
|
||||||
|
|
||||||
m_dcFilter.numStages = DC_FILTER_STAGES;
|
m_dcFilter.numStages = DC_FILTER_STAGES;
|
||||||
m_dcFilter.pState = m_dcState;
|
m_dcFilter.pState = m_dcState;
|
||||||
m_dcFilter.pCoeffs = DC_FILTER;
|
m_dcFilter.pCoeffs = DC_FILTER;
|
||||||
m_dcFilter.postShift = 0;
|
m_dcFilter.postShift = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
m_rrcFilter.numTaps = RRC_0_2_FILTER_LEN;
|
#if defined(MODE_DSTAR)
|
||||||
m_rrcFilter.pState = m_rrcState;
|
::memset(m_gaussianState, 0x00U, 40U * sizeof(q15_t));
|
||||||
m_rrcFilter.pCoeffs = RRC_0_2_FILTER;
|
|
||||||
|
|
||||||
m_gaussianFilter.numTaps = GAUSSIAN_0_5_FILTER_LEN;
|
m_gaussianFilter.numTaps = GAUSSIAN_0_5_FILTER_LEN;
|
||||||
m_gaussianFilter.pState = m_gaussianState;
|
m_gaussianFilter.pState = m_gaussianState;
|
||||||
m_gaussianFilter.pCoeffs = GAUSSIAN_0_5_FILTER;
|
m_gaussianFilter.pCoeffs = GAUSSIAN_0_5_FILTER;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(MODE_DMR)
|
||||||
|
::memset(m_rrc02State1, 0x00U, 70U * sizeof(q15_t));
|
||||||
|
m_rrc02Filter1.numTaps = RRC_0_2_FILTER_LEN;
|
||||||
|
m_rrc02Filter1.pState = m_rrc02State1;
|
||||||
|
m_rrc02Filter1.pCoeffs = RRC_0_2_FILTER;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(MODE_YSF)
|
||||||
|
::memset(m_rrc02State2, 0x00U, 70U * sizeof(q15_t));
|
||||||
|
m_rrc02Filter2.numTaps = RRC_0_2_FILTER_LEN;
|
||||||
|
m_rrc02Filter2.pState = m_rrc02State2;
|
||||||
|
m_rrc02Filter2.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_boxcarFilter.numTaps = BOXCAR_FILTER_LEN;
|
|
||||||
m_boxcarFilter.pState = m_boxcarState;
|
|
||||||
m_boxcarFilter.pCoeffs = BOXCAR_FILTER;
|
|
||||||
|
|
||||||
m_nxdnFilter.numTaps = NXDN_0_2_FILTER_LEN;
|
m_nxdnFilter.numTaps = NXDN_0_2_FILTER_LEN;
|
||||||
m_nxdnFilter.pState = m_nxdnState;
|
m_nxdnFilter.pState = m_nxdnState;
|
||||||
m_nxdnFilter.pCoeffs = NXDN_0_2_FILTER;
|
m_nxdnFilter.pCoeffs = NXDN_0_2_FILTER;
|
||||||
@@ -124,6 +194,15 @@ m_lockout(false)
|
|||||||
m_nxdnISincFilter.numTaps = NXDN_ISINC_FILTER_LEN;
|
m_nxdnISincFilter.numTaps = NXDN_ISINC_FILTER_LEN;
|
||||||
m_nxdnISincFilter.pState = m_nxdnISincState;
|
m_nxdnISincFilter.pState = m_nxdnISincState;
|
||||||
m_nxdnISincFilter.pCoeffs = NXDN_ISINC_FILTER;
|
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();
|
initInt();
|
||||||
|
|
||||||
@@ -134,7 +213,7 @@ void CIO::selfTest()
|
|||||||
{
|
{
|
||||||
bool ledValue = false;
|
bool ledValue = false;
|
||||||
|
|
||||||
for (uint8_t i = 0; i < 6; i++) {
|
for (uint8_t i = 0U; i < 6U; i++) {
|
||||||
ledValue = !ledValue;
|
ledValue = !ledValue;
|
||||||
|
|
||||||
// We exclude PTT to avoid trigger the transmitter
|
// We exclude PTT to avoid trigger the transmitter
|
||||||
@@ -145,21 +224,40 @@ void CIO::selfTest()
|
|||||||
setDMRInt(ledValue);
|
setDMRInt(ledValue);
|
||||||
setYSFInt(ledValue);
|
setYSFInt(ledValue);
|
||||||
setP25Int(ledValue);
|
setP25Int(ledValue);
|
||||||
|
#if !defined(USE_ALTERNATE_NXDN_LEDS)
|
||||||
setNXDNInt(ledValue);
|
setNXDNInt(ledValue);
|
||||||
|
#endif
|
||||||
|
#if !defined(USE_ALTERNATE_M17_LEDS)
|
||||||
|
setM17Int(ledValue);
|
||||||
|
#endif
|
||||||
|
#if !defined(USE_ALTERNATE_POCSAG_LEDS)
|
||||||
setPOCSAGInt(ledValue);
|
setPOCSAGInt(ledValue);
|
||||||
|
#endif
|
||||||
|
#if !defined(USE_ALTERNATE_FM_LEDS)
|
||||||
setFMInt(ledValue);
|
setFMInt(ledValue);
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
delayInt(250);
|
delayInt(250);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(MODE_LEDS)
|
#if defined(MODE_LEDS)
|
||||||
setDStarInt(true);
|
setDStarInt(false);
|
||||||
setDMRInt(false);
|
setDMRInt(false);
|
||||||
setYSFInt(false);
|
setYSFInt(false);
|
||||||
setP25Int(false);
|
setP25Int(false);
|
||||||
|
#if !defined(USE_ALTERNATE_NXDN_LEDS)
|
||||||
setNXDNInt(false);
|
setNXDNInt(false);
|
||||||
|
#endif
|
||||||
|
#if !defined(USE_ALTERNATE_M17_LEDS)
|
||||||
|
setM17Int(false);
|
||||||
|
#endif
|
||||||
|
#if !defined(USE_ALTERNATE_POCSAG_LEDS)
|
||||||
setPOCSAGInt(false);
|
setPOCSAGInt(false);
|
||||||
|
#endif
|
||||||
|
#if !defined(USE_ALTERNATE_FM_LEDS)
|
||||||
setFMInt(false);
|
setFMInt(false);
|
||||||
|
#endif
|
||||||
|
setDStarInt(true);
|
||||||
|
|
||||||
delayInt(250);
|
delayInt(250);
|
||||||
setDMRInt(true);
|
setDMRInt(true);
|
||||||
@@ -175,6 +273,11 @@ void CIO::selfTest()
|
|||||||
setNXDNInt(true);
|
setNXDNInt(true);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if !defined(USE_ALTERNATE_M17_LEDS)
|
||||||
|
delayInt(250);
|
||||||
|
setM17Int(true);
|
||||||
|
#endif
|
||||||
|
|
||||||
#if !defined(USE_ALTERNATE_POCSAG_LEDS)
|
#if !defined(USE_ALTERNATE_POCSAG_LEDS)
|
||||||
delayInt(250);
|
delayInt(250);
|
||||||
setPOCSAGInt(true);
|
setPOCSAGInt(true);
|
||||||
@@ -193,6 +296,11 @@ void CIO::selfTest()
|
|||||||
setPOCSAGInt(false);
|
setPOCSAGInt(false);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if !defined(USE_ALTERNATE_M17_LEDS)
|
||||||
|
delayInt(250);
|
||||||
|
setM17Int(false);
|
||||||
|
#endif
|
||||||
|
|
||||||
#if !defined(USE_ALTERNATE_NXDN_LEDS)
|
#if !defined(USE_ALTERNATE_NXDN_LEDS)
|
||||||
delayInt(250);
|
delayInt(250);
|
||||||
setNXDNInt(false);
|
setNXDNInt(false);
|
||||||
@@ -221,7 +329,7 @@ void CIO::start()
|
|||||||
|
|
||||||
m_started = true;
|
m_started = true;
|
||||||
|
|
||||||
setMode();
|
setMode(STATE_IDLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CIO::process()
|
void CIO::process()
|
||||||
@@ -230,11 +338,12 @@ void CIO::process()
|
|||||||
if (m_started) {
|
if (m_started) {
|
||||||
// Two seconds timeout
|
// Two seconds timeout
|
||||||
if (m_watchdog >= 48000U) {
|
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_POCSAG) {
|
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_DMR && m_tx)
|
if (m_modemState == STATE_DMR && m_tx)
|
||||||
dmrTX.setStart(false);
|
dmrTX.setStart(false);
|
||||||
m_modemState = STATE_IDLE;
|
#endif
|
||||||
setMode();
|
setMode(STATE_IDLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_watchdog = 0U;
|
m_watchdog = 0U;
|
||||||
@@ -265,6 +374,7 @@ void CIO::process()
|
|||||||
if (m_txBuffer.getData() == 0U && m_tx) {
|
if (m_txBuffer.getData() == 0U && m_tx) {
|
||||||
m_tx = false;
|
m_tx = false;
|
||||||
setPTTInt(m_pttInvert ? true : false);
|
setPTTInt(m_pttInvert ? true : false);
|
||||||
|
DEBUG1("TX OFF");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_rxBuffer.getData() >= RX_BLOCK_SIZE) {
|
if (m_rxBuffer.getData() >= RX_BLOCK_SIZE) {
|
||||||
@@ -273,15 +383,16 @@ void CIO::process()
|
|||||||
uint16_t rssi[RX_BLOCK_SIZE];
|
uint16_t rssi[RX_BLOCK_SIZE];
|
||||||
|
|
||||||
for (uint16_t i = 0U; i < RX_BLOCK_SIZE; i++) {
|
for (uint16_t i = 0U; i < RX_BLOCK_SIZE; i++) {
|
||||||
uint16_t sample;
|
TSample sample;
|
||||||
m_rxBuffer.get(sample, control[i]);
|
m_rxBuffer.get(sample);
|
||||||
|
control[i] = sample.control;
|
||||||
m_rssiBuffer.get(rssi[i]);
|
m_rssiBuffer.get(rssi[i]);
|
||||||
|
|
||||||
// Detect ADC overflow
|
// Detect ADC overflow
|
||||||
if (m_detect && (sample == 0U || sample == 4095U))
|
if (m_detect && (sample.sample == 0U || sample.sample == 4095U))
|
||||||
m_adcOverflow++;
|
m_adcOverflow++;
|
||||||
|
|
||||||
q15_t res1 = q15_t(sample) - m_rxDCOffset;
|
q15_t res1 = q15_t(sample.sample) - m_rxDCOffset;
|
||||||
q31_t res2 = res1 * m_rxLevel;
|
q31_t res2 = res1 * m_rxLevel;
|
||||||
samples[i] = q15_t(__SSAT((res2 >> 15), 16));
|
samples[i] = q15_t(__SSAT((res2 >> 15), 16));
|
||||||
}
|
}
|
||||||
@@ -309,6 +420,7 @@ void CIO::process()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (m_modemState == STATE_IDLE) {
|
if (m_modemState == STATE_IDLE) {
|
||||||
|
#if defined(MODE_DSTAR)
|
||||||
if (m_dstarEnable) {
|
if (m_dstarEnable) {
|
||||||
q15_t GMSKVals[RX_BLOCK_SIZE];
|
q15_t GMSKVals[RX_BLOCK_SIZE];
|
||||||
#if defined(USE_DCBLOCKER)
|
#if defined(USE_DCBLOCKER)
|
||||||
@@ -318,62 +430,102 @@ void CIO::process()
|
|||||||
#endif
|
#endif
|
||||||
dstarRX.samples(GMSKVals, rssi, RX_BLOCK_SIZE);
|
dstarRX.samples(GMSKVals, rssi, RX_BLOCK_SIZE);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(MODE_P25)
|
||||||
if (m_p25Enable) {
|
if (m_p25Enable) {
|
||||||
q15_t P25Vals[RX_BLOCK_SIZE];
|
q15_t P25Vals[RX_BLOCK_SIZE];
|
||||||
#if defined(USE_DCBLOCKER)
|
#if defined(USE_DCBLOCKER)
|
||||||
::arm_fir_fast_q15(&m_boxcarFilter, dcSamples, P25Vals, RX_BLOCK_SIZE);
|
::arm_fir_fast_q15(&m_boxcar5Filter, dcSamples, P25Vals, RX_BLOCK_SIZE);
|
||||||
#else
|
#else
|
||||||
::arm_fir_fast_q15(&m_boxcarFilter, samples, P25Vals, RX_BLOCK_SIZE);
|
::arm_fir_fast_q15(&m_boxcar5Filter, samples, P25Vals, RX_BLOCK_SIZE);
|
||||||
#endif
|
#endif
|
||||||
p25RX.samples(P25Vals, rssi, RX_BLOCK_SIZE);
|
p25RX.samples(P25Vals, rssi, RX_BLOCK_SIZE);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(MODE_NXDN)
|
||||||
if (m_nxdnEnable) {
|
if (m_nxdnEnable) {
|
||||||
|
q15_t NXDNVals[RX_BLOCK_SIZE];
|
||||||
|
#if defined(USE_NXDN_BOXCAR)
|
||||||
|
#if defined(USE_DCBLOCKER)
|
||||||
|
::arm_fir_fast_q15(&m_boxcar10Filter, dcSamples, NXDNVals, RX_BLOCK_SIZE);
|
||||||
|
#else
|
||||||
|
::arm_fir_fast_q15(&m_boxcar10Filter, samples, NXDNVals, RX_BLOCK_SIZE);
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
q15_t NXDNValsTmp[RX_BLOCK_SIZE];
|
q15_t NXDNValsTmp[RX_BLOCK_SIZE];
|
||||||
#if defined(USE_DCBLOCKER)
|
#if defined(USE_DCBLOCKER)
|
||||||
::arm_fir_fast_q15(&m_nxdnFilter, dcSamples, NXDNValsTmp, RX_BLOCK_SIZE);
|
::arm_fir_fast_q15(&m_nxdnFilter, dcSamples, NXDNValsTmp, RX_BLOCK_SIZE);
|
||||||
#else
|
#else
|
||||||
::arm_fir_fast_q15(&m_nxdnFilter, samples, NXDNValsTmp, RX_BLOCK_SIZE);
|
::arm_fir_fast_q15(&m_nxdnFilter, samples, NXDNValsTmp, RX_BLOCK_SIZE);
|
||||||
#endif
|
#endif
|
||||||
q15_t NXDNVals[RX_BLOCK_SIZE];
|
|
||||||
::arm_fir_fast_q15(&m_nxdnISincFilter, NXDNValsTmp, NXDNVals, RX_BLOCK_SIZE);
|
::arm_fir_fast_q15(&m_nxdnISincFilter, NXDNValsTmp, NXDNVals, RX_BLOCK_SIZE);
|
||||||
|
#endif
|
||||||
nxdnRX.samples(NXDNVals, rssi, RX_BLOCK_SIZE);
|
nxdnRX.samples(NXDNVals, rssi, RX_BLOCK_SIZE);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (m_dmrEnable || m_ysfEnable) {
|
#if defined(MODE_DMR)
|
||||||
q15_t RRCVals[RX_BLOCK_SIZE];
|
if (m_dmrEnable) {
|
||||||
::arm_fir_fast_q15(&m_rrcFilter, samples, RRCVals, RX_BLOCK_SIZE);
|
q15_t DMRVals[RX_BLOCK_SIZE];
|
||||||
|
::arm_fir_fast_q15(&m_rrc02Filter1, samples, DMRVals, RX_BLOCK_SIZE);
|
||||||
|
|
||||||
if (m_ysfEnable)
|
if (m_duplex)
|
||||||
ysfRX.samples(RRCVals, rssi, RX_BLOCK_SIZE);
|
dmrIdleRX.samples(DMRVals, RX_BLOCK_SIZE);
|
||||||
|
else
|
||||||
if (m_dmrEnable) {
|
dmrDMORX.samples(DMRVals, rssi, RX_BLOCK_SIZE);
|
||||||
if (m_duplex)
|
|
||||||
dmrIdleRX.samples(RRCVals, RX_BLOCK_SIZE);
|
|
||||||
else
|
|
||||||
dmrDMORX.samples(RRCVals, 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_rrc02Filter2, dcSamples, YSFVals, RX_BLOCK_SIZE);
|
||||||
|
#else
|
||||||
|
::arm_fir_fast_q15(&m_rrc02Filter2, 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) {
|
if (m_fmEnable) {
|
||||||
bool cos = getCOSInt();
|
bool cos = getCOSInt();
|
||||||
#if defined(USE_DCBLOCKER)
|
#if defined(USE_DCBLOCKER)
|
||||||
fm.samples(cos, dcSamples, RX_BLOCK_SIZE);
|
fm.samples(cos, dcSamples, rssi, RX_BLOCK_SIZE);
|
||||||
#else
|
#else
|
||||||
fm.samples(cos, samples, RX_BLOCK_SIZE);
|
fm.samples(cos, samples, rssi, RX_BLOCK_SIZE);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(MODE_FM) && defined(MODE_AX25)
|
||||||
if (m_ax25Enable) {
|
if (m_ax25Enable) {
|
||||||
#if defined(USE_DCBLOCKER)
|
#if defined(USE_DCBLOCKER)
|
||||||
ax25RX.samples(dcSamples, RX_BLOCK_SIZE);
|
ax25RX.samples(dcSamples, rssi, RX_BLOCK_SIZE);
|
||||||
#else
|
#else
|
||||||
ax25RX.samples(samples, RX_BLOCK_SIZE);
|
ax25RX.samples(samples, rssi, RX_BLOCK_SIZE);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
} else if (m_modemState == STATE_DSTAR) {
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(MODE_DSTAR)
|
||||||
|
else if (m_modemState == STATE_DSTAR) {
|
||||||
if (m_dstarEnable) {
|
if (m_dstarEnable) {
|
||||||
q15_t GMSKVals[RX_BLOCK_SIZE];
|
q15_t GMSKVals[RX_BLOCK_SIZE];
|
||||||
#if defined(USE_DCBLOCKER)
|
#if defined(USE_DCBLOCKER)
|
||||||
@@ -383,10 +535,14 @@ void CIO::process()
|
|||||||
#endif
|
#endif
|
||||||
dstarRX.samples(GMSKVals, rssi, RX_BLOCK_SIZE);
|
dstarRX.samples(GMSKVals, rssi, RX_BLOCK_SIZE);
|
||||||
}
|
}
|
||||||
} else if (m_modemState == STATE_DMR) {
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(MODE_DMR)
|
||||||
|
else if (m_modemState == STATE_DMR) {
|
||||||
if (m_dmrEnable) {
|
if (m_dmrEnable) {
|
||||||
q15_t DMRVals[RX_BLOCK_SIZE];
|
q15_t DMRVals[RX_BLOCK_SIZE];
|
||||||
::arm_fir_fast_q15(&m_rrcFilter, samples, DMRVals, RX_BLOCK_SIZE);
|
::arm_fir_fast_q15(&m_rrc02Filter1, samples, DMRVals, RX_BLOCK_SIZE);
|
||||||
|
|
||||||
if (m_duplex) {
|
if (m_duplex) {
|
||||||
// If the transmitter isn't on, use the DMR idle RX to detect the wakeup CSBKs
|
// If the transmitter isn't on, use the DMR idle RX to detect the wakeup CSBKs
|
||||||
@@ -398,56 +554,106 @@ void CIO::process()
|
|||||||
dmrDMORX.samples(DMRVals, rssi, RX_BLOCK_SIZE);
|
dmrDMORX.samples(DMRVals, rssi, RX_BLOCK_SIZE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (m_modemState == STATE_YSF) {
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(MODE_YSF)
|
||||||
|
else if (m_modemState == STATE_YSF) {
|
||||||
if (m_ysfEnable) {
|
if (m_ysfEnable) {
|
||||||
q15_t YSFVals[RX_BLOCK_SIZE];
|
q15_t YSFVals[RX_BLOCK_SIZE];
|
||||||
#if defined(USE_DCBLOCKER)
|
#if defined(USE_DCBLOCKER)
|
||||||
::arm_fir_fast_q15(&m_rrcFilter, dcSamples, YSFVals, RX_BLOCK_SIZE);
|
::arm_fir_fast_q15(&m_rrc02Filter2, dcSamples, YSFVals, RX_BLOCK_SIZE);
|
||||||
#else
|
#else
|
||||||
::arm_fir_fast_q15(&m_rrcFilter, samples, YSFVals, RX_BLOCK_SIZE);
|
::arm_fir_fast_q15(&m_rrc02Filter2, samples, YSFVals, RX_BLOCK_SIZE);
|
||||||
#endif
|
#endif
|
||||||
ysfRX.samples(YSFVals, rssi, RX_BLOCK_SIZE);
|
ysfRX.samples(YSFVals, rssi, RX_BLOCK_SIZE);
|
||||||
}
|
}
|
||||||
} else if (m_modemState == STATE_P25) {
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(MODE_P25)
|
||||||
|
else if (m_modemState == STATE_P25) {
|
||||||
if (m_p25Enable) {
|
if (m_p25Enable) {
|
||||||
q15_t P25Vals[RX_BLOCK_SIZE];
|
q15_t P25Vals[RX_BLOCK_SIZE];
|
||||||
#if defined(USE_DCBLOCKER)
|
#if defined(USE_DCBLOCKER)
|
||||||
::arm_fir_fast_q15(&m_boxcarFilter, dcSamples, P25Vals, RX_BLOCK_SIZE);
|
::arm_fir_fast_q15(&m_boxcar5Filter, dcSamples, P25Vals, RX_BLOCK_SIZE);
|
||||||
#else
|
#else
|
||||||
::arm_fir_fast_q15(&m_boxcarFilter, samples, P25Vals, RX_BLOCK_SIZE);
|
::arm_fir_fast_q15(&m_boxcar5Filter, samples, P25Vals, RX_BLOCK_SIZE);
|
||||||
#endif
|
#endif
|
||||||
p25RX.samples(P25Vals, rssi, RX_BLOCK_SIZE);
|
p25RX.samples(P25Vals, rssi, RX_BLOCK_SIZE);
|
||||||
}
|
}
|
||||||
} else if (m_modemState == STATE_NXDN) {
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(MODE_NXDN)
|
||||||
|
else if (m_modemState == STATE_NXDN) {
|
||||||
if (m_nxdnEnable) {
|
if (m_nxdnEnable) {
|
||||||
|
q15_t NXDNVals[RX_BLOCK_SIZE];
|
||||||
|
#if defined(USE_NXDN_BOXCAR)
|
||||||
|
#if defined(USE_DCBLOCKER)
|
||||||
|
::arm_fir_fast_q15(&m_boxcar10Filter, dcSamples, NXDNVals, RX_BLOCK_SIZE);
|
||||||
|
#else
|
||||||
|
::arm_fir_fast_q15(&m_boxcar10Filter, samples, NXDNVals, RX_BLOCK_SIZE);
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
q15_t NXDNValsTmp[RX_BLOCK_SIZE];
|
q15_t NXDNValsTmp[RX_BLOCK_SIZE];
|
||||||
#if defined(USE_DCBLOCKER)
|
#if defined(USE_DCBLOCKER)
|
||||||
::arm_fir_fast_q15(&m_nxdnFilter, dcSamples, NXDNValsTmp, RX_BLOCK_SIZE);
|
::arm_fir_fast_q15(&m_nxdnFilter, dcSamples, NXDNValsTmp, RX_BLOCK_SIZE);
|
||||||
#else
|
#else
|
||||||
::arm_fir_fast_q15(&m_nxdnFilter, samples, NXDNValsTmp, RX_BLOCK_SIZE);
|
::arm_fir_fast_q15(&m_nxdnFilter, samples, NXDNValsTmp, RX_BLOCK_SIZE);
|
||||||
#endif
|
#endif
|
||||||
q15_t NXDNVals[RX_BLOCK_SIZE];
|
|
||||||
::arm_fir_fast_q15(&m_nxdnISincFilter, NXDNValsTmp, NXDNVals, RX_BLOCK_SIZE);
|
::arm_fir_fast_q15(&m_nxdnISincFilter, NXDNValsTmp, NXDNVals, RX_BLOCK_SIZE);
|
||||||
|
#endif
|
||||||
nxdnRX.samples(NXDNVals, rssi, RX_BLOCK_SIZE);
|
nxdnRX.samples(NXDNVals, rssi, RX_BLOCK_SIZE);
|
||||||
}
|
}
|
||||||
} else if (m_modemState == STATE_FM) {
|
}
|
||||||
|
#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) {
|
||||||
bool cos = getCOSInt();
|
bool cos = getCOSInt();
|
||||||
#if defined(USE_DCBLOCKER)
|
#if defined(USE_DCBLOCKER)
|
||||||
fm.samples(cos, dcSamples, RX_BLOCK_SIZE);
|
fm.samples(cos, dcSamples, rssi, RX_BLOCK_SIZE);
|
||||||
|
|
||||||
|
#if defined(MODE_AX25)
|
||||||
if (m_ax25Enable)
|
if (m_ax25Enable)
|
||||||
ax25RX.samples(dcSamples, RX_BLOCK_SIZE);
|
ax25RX.samples(dcSamples, rssi, RX_BLOCK_SIZE);
|
||||||
#else
|
|
||||||
fm.samples(cos, samples, RX_BLOCK_SIZE);
|
|
||||||
if (m_ax25Enable)
|
|
||||||
ax25RX.samples(samples, RX_BLOCK_SIZE);
|
|
||||||
#endif
|
#endif
|
||||||
} else if (m_modemState == STATE_DSTARCAL) {
|
#else
|
||||||
|
fm.samples(cos, samples, rssi, RX_BLOCK_SIZE);
|
||||||
|
|
||||||
|
#if defined(MODE_AX25)
|
||||||
|
if (m_ax25Enable)
|
||||||
|
ax25RX.samples(samples, rssi, RX_BLOCK_SIZE);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(MODE_DSTAR)
|
||||||
|
else if (m_modemState == STATE_DSTARCAL) {
|
||||||
q15_t GMSKVals[RX_BLOCK_SIZE];
|
q15_t GMSKVals[RX_BLOCK_SIZE];
|
||||||
::arm_fir_fast_q15(&m_gaussianFilter, samples, GMSKVals, RX_BLOCK_SIZE);
|
::arm_fir_fast_q15(&m_gaussianFilter, samples, GMSKVals, RX_BLOCK_SIZE);
|
||||||
|
|
||||||
calDStarRX.samples(GMSKVals, RX_BLOCK_SIZE);
|
calDStarRX.samples(GMSKVals, RX_BLOCK_SIZE);
|
||||||
} else if (m_modemState == STATE_RSSICAL) {
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
else if (m_modemState == STATE_RSSICAL) {
|
||||||
calRSSI.samples(rssi, RX_BLOCK_SIZE);
|
calRSSI.samples(rssi, RX_BLOCK_SIZE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -465,6 +671,7 @@ void CIO::write(MMDVM_STATE mode, q15_t* samples, uint16_t length, const uint8_t
|
|||||||
if (!m_tx) {
|
if (!m_tx) {
|
||||||
m_tx = true;
|
m_tx = true;
|
||||||
setPTTInt(m_pttInvert ? false : true);
|
setPTTInt(m_pttInvert ? false : true);
|
||||||
|
DEBUG1("TX ON");
|
||||||
}
|
}
|
||||||
|
|
||||||
q15_t txLevel = 0;
|
q15_t txLevel = 0;
|
||||||
@@ -484,6 +691,9 @@ void CIO::write(MMDVM_STATE mode, q15_t* samples, uint16_t length, const uint8_t
|
|||||||
case STATE_NXDN:
|
case STATE_NXDN:
|
||||||
txLevel = m_nxdnTXLevel;
|
txLevel = m_nxdnTXLevel;
|
||||||
break;
|
break;
|
||||||
|
case STATE_M17:
|
||||||
|
txLevel = m_m17TXLevel;
|
||||||
|
break;
|
||||||
case STATE_POCSAG:
|
case STATE_POCSAG:
|
||||||
txLevel = m_pocsagTXLevel;
|
txLevel = m_pocsagTXLevel;
|
||||||
break;
|
break;
|
||||||
@@ -508,9 +718,9 @@ void CIO::write(MMDVM_STATE mode, q15_t* samples, uint16_t length, const uint8_t
|
|||||||
m_dacOverflow++;
|
m_dacOverflow++;
|
||||||
|
|
||||||
if (control == NULL)
|
if (control == NULL)
|
||||||
m_txBuffer.put(res3, MARK_NONE);
|
m_txBuffer.put({res3, MARK_NONE});
|
||||||
else
|
else
|
||||||
m_txBuffer.put(res3, control[i]);
|
m_txBuffer.put({res3, control[i]});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -532,20 +742,41 @@ void CIO::setADCDetection(bool detect)
|
|||||||
m_detect = detect;
|
m_detect = detect;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CIO::setMode()
|
void CIO::setMode(MMDVM_STATE state)
|
||||||
{
|
{
|
||||||
|
if (state == m_modemState)
|
||||||
|
return;
|
||||||
|
|
||||||
#if defined(MODE_LEDS)
|
#if defined(MODE_LEDS)
|
||||||
setDStarInt(m_modemState == STATE_DSTAR);
|
switch (m_modemState) {
|
||||||
setDMRInt(m_modemState == STATE_DMR);
|
case STATE_DSTAR: setDStarInt(false); break;
|
||||||
setYSFInt(m_modemState == STATE_YSF);
|
case STATE_DMR: setDMRInt(false); break;
|
||||||
setP25Int(m_modemState == STATE_P25);
|
case STATE_YSF: setYSFInt(false); break;
|
||||||
setNXDNInt(m_modemState == STATE_NXDN);
|
case STATE_P25: setP25Int(false); break;
|
||||||
setPOCSAGInt(m_modemState == STATE_POCSAG);
|
case STATE_NXDN: setNXDNInt(false); break;
|
||||||
setFMInt(m_modemState == STATE_FM);
|
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;
|
||||||
|
}
|
||||||
#endif
|
#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 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 m17TXLevel, uint8_t pocsagTXLevel, uint8_t fmTXLevel, uint8_t ax25TXLevel, int16_t txDCOffset, int16_t rxDCOffset, bool useCOSAsLockout)
|
||||||
{
|
{
|
||||||
m_pttInvert = pttInvert;
|
m_pttInvert = pttInvert;
|
||||||
|
|
||||||
@@ -556,6 +787,7 @@ void CIO::setParameters(bool rxInvert, bool txInvert, bool pttInvert, uint8_t rx
|
|||||||
m_ysfTXLevel = q15_t(ysfTXLevel * 128);
|
m_ysfTXLevel = q15_t(ysfTXLevel * 128);
|
||||||
m_p25TXLevel = q15_t(p25TXLevel * 128);
|
m_p25TXLevel = q15_t(p25TXLevel * 128);
|
||||||
m_nxdnTXLevel = q15_t(nxdnTXLevel * 128);
|
m_nxdnTXLevel = q15_t(nxdnTXLevel * 128);
|
||||||
|
m_m17TXLevel = q15_t(m17TXLevel * 128);
|
||||||
m_pocsagTXLevel = q15_t(pocsagTXLevel * 128);
|
m_pocsagTXLevel = q15_t(pocsagTXLevel * 128);
|
||||||
m_fmTXLevel = q15_t(fmTXLevel * 128);
|
m_fmTXLevel = q15_t(fmTXLevel * 128);
|
||||||
m_ax25TXLevel = q15_t(ax25TXLevel * 128);
|
m_ax25TXLevel = q15_t(ax25TXLevel * 128);
|
||||||
@@ -574,6 +806,7 @@ void CIO::setParameters(bool rxInvert, bool txInvert, bool pttInvert, uint8_t rx
|
|||||||
m_ysfTXLevel = -m_ysfTXLevel;
|
m_ysfTXLevel = -m_ysfTXLevel;
|
||||||
m_p25TXLevel = -m_p25TXLevel;
|
m_p25TXLevel = -m_p25TXLevel;
|
||||||
m_nxdnTXLevel = -m_nxdnTXLevel;
|
m_nxdnTXLevel = -m_nxdnTXLevel;
|
||||||
|
m_m17TXLevel = -m_m17TXLevel;
|
||||||
m_pocsagTXLevel = -m_pocsagTXLevel;
|
m_pocsagTXLevel = -m_pocsagTXLevel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2015,2016,2017,2018,2020 by Jonathan Naylor G4KLX
|
* Copyright (C) 2015,2016,2017,2018,2020,2021 by Jonathan Naylor G4KLX
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -21,8 +21,12 @@
|
|||||||
|
|
||||||
#include "Globals.h"
|
#include "Globals.h"
|
||||||
|
|
||||||
#include "SampleRB.h"
|
#include "RingBuffer.h"
|
||||||
#include "RSSIRB.h"
|
|
||||||
|
struct TSample {
|
||||||
|
volatile uint16_t sample;
|
||||||
|
volatile uint8_t control;
|
||||||
|
};
|
||||||
|
|
||||||
class CIO {
|
class CIO {
|
||||||
public:
|
public:
|
||||||
@@ -38,11 +42,11 @@ public:
|
|||||||
|
|
||||||
void setDecode(bool dcd);
|
void setDecode(bool dcd);
|
||||||
void setADCDetection(bool detect);
|
void setADCDetection(bool detect);
|
||||||
void setMode();
|
void setMode(MMDVM_STATE state);
|
||||||
|
|
||||||
void interrupt();
|
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 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 m17TXLevel, uint8_t pocsagTXLevel, uint8_t fmTXLevel, uint8_t ax25TXLevel, int16_t txDCOffset, int16_t rxDCOffset, bool useCOSAsLockout);
|
||||||
|
|
||||||
void getOverflow(bool& adcOverflow, bool& dacOverflow);
|
void getOverflow(bool& adcOverflow, bool& dacOverflow);
|
||||||
|
|
||||||
@@ -54,28 +58,60 @@ public:
|
|||||||
void resetWatchdog();
|
void resetWatchdog();
|
||||||
uint32_t getWatchdog();
|
uint32_t getWatchdog();
|
||||||
|
|
||||||
|
uint8_t getCPU() const;
|
||||||
|
|
||||||
|
void getUDID(uint8_t* buffer);
|
||||||
|
|
||||||
void selfTest();
|
void selfTest();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_started;
|
bool m_started;
|
||||||
|
|
||||||
CSampleRB m_rxBuffer;
|
CRingBuffer<TSample> m_rxBuffer;
|
||||||
CSampleRB m_txBuffer;
|
CRingBuffer<TSample> m_txBuffer;
|
||||||
CRSSIRB m_rssiBuffer;
|
CRingBuffer<uint16_t> m_rssiBuffer;
|
||||||
|
|
||||||
|
#if defined(USE_DCBLOCKER)
|
||||||
arm_biquad_casd_df1_inst_q31 m_dcFilter;
|
arm_biquad_casd_df1_inst_q31 m_dcFilter;
|
||||||
q31_t m_dcState[4];
|
q31_t m_dcState[4];
|
||||||
|
#endif
|
||||||
|
|
||||||
arm_fir_instance_q15 m_rrcFilter;
|
#if defined(MODE_DSTAR)
|
||||||
arm_fir_instance_q15 m_gaussianFilter;
|
arm_fir_instance_q15 m_gaussianFilter;
|
||||||
arm_fir_instance_q15 m_boxcarFilter;
|
q15_t m_gaussianState[40U]; // NoTaps + BlockSize - 1, 12 + 20 - 1 plus some spare
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(MODE_DMR)
|
||||||
|
arm_fir_instance_q15 m_rrc02Filter1;
|
||||||
|
q15_t m_rrc02State1[70U]; // NoTaps + BlockSize - 1, 42 + 20 - 1 plus some spare
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(MODE_YSF)
|
||||||
|
arm_fir_instance_q15 m_rrc02Filter2;
|
||||||
|
q15_t m_rrc02State2[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_nxdnFilter;
|
||||||
arm_fir_instance_q15 m_nxdnISincFilter;
|
arm_fir_instance_q15 m_nxdnISincFilter;
|
||||||
q15_t m_rrcState[70U]; // NoTaps + BlockSize - 1, 42 + 20 - 1 plus some spare
|
|
||||||
q15_t m_gaussianState[40U]; // NoTaps + BlockSize - 1, 12 + 20 - 1 plus some spare
|
|
||||||
q15_t m_boxcarState[30U]; // NoTaps + BlockSize - 1, 6 + 20 - 1 plus some spare
|
|
||||||
q15_t m_nxdnState[110U]; // NoTaps + BlockSize - 1, 82 + 20 - 1 plus some spare
|
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
|
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
|
||||||
|
|
||||||
bool m_pttInvert;
|
bool m_pttInvert;
|
||||||
q15_t m_rxLevel;
|
q15_t m_rxLevel;
|
||||||
@@ -85,6 +121,7 @@ private:
|
|||||||
q15_t m_ysfTXLevel;
|
q15_t m_ysfTXLevel;
|
||||||
q15_t m_p25TXLevel;
|
q15_t m_p25TXLevel;
|
||||||
q15_t m_nxdnTXLevel;
|
q15_t m_nxdnTXLevel;
|
||||||
|
q15_t m_m17TXLevel;
|
||||||
q15_t m_pocsagTXLevel;
|
q15_t m_pocsagTXLevel;
|
||||||
q15_t m_fmTXLevel;
|
q15_t m_fmTXLevel;
|
||||||
q15_t m_ax25TXLevel;
|
q15_t m_ax25TXLevel;
|
||||||
@@ -122,6 +159,7 @@ private:
|
|||||||
void setP25Int(bool on);
|
void setP25Int(bool on);
|
||||||
void setNXDNInt(bool on);
|
void setNXDNInt(bool on);
|
||||||
void setPOCSAGInt(bool on);
|
void setPOCSAGInt(bool on);
|
||||||
|
void setM17Int(bool on);
|
||||||
void setFMInt(bool on);
|
void setFMInt(bool on);
|
||||||
|
|
||||||
void delayInt(unsigned int dly);
|
void delayInt(unsigned int dly);
|
||||||
|
|||||||
@@ -1,282 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2015,2016,2017,2018,2020 by Jonathan Naylor G4KLX
|
|
||||||
* Copyright (C) 2015 by Jim Mclaughlin KI6ZUM
|
|
||||||
* 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
|
|
||||||
* 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 "Globals.h"
|
|
||||||
#include "IO.h"
|
|
||||||
|
|
||||||
#if defined(__SAM3X8E__)
|
|
||||||
|
|
||||||
// An Arduino Due
|
|
||||||
#if defined(ARDUINO_DUE_PAPA)
|
|
||||||
#define PIN_COS 7
|
|
||||||
#define PIN_PTT 8
|
|
||||||
#define PIN_COSLED 11
|
|
||||||
#define PIN_DSTAR 16
|
|
||||||
#define PIN_DMR 17
|
|
||||||
#define PIN_YSF 18
|
|
||||||
#define PIN_P25 19
|
|
||||||
#define PIN_NXDN 20
|
|
||||||
#define PIN_POCSAG 4
|
|
||||||
#define PIN_FM 5
|
|
||||||
#define ADC_CHER_Chan (1<<7) // ADC on Due pin A0 - Due AD7 - (1 << 7)
|
|
||||||
#define ADC_ISR_EOC_Chan ADC_ISR_EOC7
|
|
||||||
#define ADC_CDR_Chan 7
|
|
||||||
#define DACC_MR_USER_SEL_Chan DACC_MR_USER_SEL_CHANNEL0 // DAC on Due DAC0
|
|
||||||
#define DACC_CHER_Chan DACC_CHER_CH0
|
|
||||||
#elif defined(ARDUINO_DUE_ZUM_V10)
|
|
||||||
#define PIN_COS 52
|
|
||||||
#define PIN_PTT 23
|
|
||||||
#define PIN_COSLED 22
|
|
||||||
#define PIN_DSTAR 9
|
|
||||||
#define PIN_DMR 8
|
|
||||||
#define PIN_YSF 7
|
|
||||||
#define PIN_P25 6
|
|
||||||
#define PIN_NXDN 5
|
|
||||||
#define PIN_POCSAG 4
|
|
||||||
#define PIN_FM 3
|
|
||||||
#define ADC_CHER_Chan (1<<13) // ADC on Due pin A11 - Due AD13 - (1 << 13)
|
|
||||||
#define ADC_ISR_EOC_Chan ADC_ISR_EOC13
|
|
||||||
#define ADC_CDR_Chan 13
|
|
||||||
#define DACC_MR_USER_SEL_Chan DACC_MR_USER_SEL_CHANNEL1 // DAC on Due DAC1
|
|
||||||
#define DACC_CHER_Chan DACC_CHER_CH1
|
|
||||||
#define RSSI_CHER_Chan (1<<1) // ADC on Due pin A6 - Due AD1 - (1 << 1)
|
|
||||||
#define RSSI_CDR_Chan 1
|
|
||||||
#elif defined(ARDUINO_DUE_NTH)
|
|
||||||
#define PIN_COS A7
|
|
||||||
#define PIN_PTT A8
|
|
||||||
#define PIN_COSLED A11
|
|
||||||
#define PIN_DSTAR 9
|
|
||||||
#define PIN_DMR 8
|
|
||||||
#define PIN_YSF 7
|
|
||||||
#define PIN_P25 6
|
|
||||||
#define PIN_NXDN 5
|
|
||||||
#define PIN_POCSAG 4
|
|
||||||
#define PIN_FM 3
|
|
||||||
#define ADC_CHER_Chan (1<<7) // ADC on Due pin A0 - Due AD7 - (1 << 7)
|
|
||||||
#define ADC_ISR_EOC_Chan ADC_ISR_EOC7
|
|
||||||
#define ADC_CDR_Chan 7
|
|
||||||
#define DACC_MR_USER_SEL_Chan DACC_MR_USER_SEL_CHANNEL0 // DAC on Due DAC0
|
|
||||||
#define DACC_CHER_Chan DACC_CHER_CH0
|
|
||||||
#define RSSI_CHER_Chan (1<<1) // ADC on Due pin A6 - Due AD1 - (1 << 1)
|
|
||||||
#define RSSI_CDR_Chan 1
|
|
||||||
#else
|
|
||||||
#error "Either ARDUINO_DUE_PAPA, ARDUINO_DUE_ZUM_V10, or ARDUINO_DUE_NTH need to be defined"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
const uint16_t DC_OFFSET = 2048U;
|
|
||||||
|
|
||||||
extern "C" {
|
|
||||||
void ADC_Handler()
|
|
||||||
{
|
|
||||||
io.interrupt();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CIO::initInt()
|
|
||||||
{
|
|
||||||
// Set up the TX, COS and LED pins
|
|
||||||
pinMode(PIN_PTT, OUTPUT);
|
|
||||||
pinMode(PIN_COSLED, OUTPUT);
|
|
||||||
pinMode(PIN_LED, OUTPUT);
|
|
||||||
pinMode(PIN_COS, INPUT);
|
|
||||||
|
|
||||||
#if defined(MODE_LEDS)
|
|
||||||
// Set up the mode output pins
|
|
||||||
pinMode(PIN_DSTAR, OUTPUT);
|
|
||||||
pinMode(PIN_DMR, OUTPUT);
|
|
||||||
pinMode(PIN_YSF, OUTPUT);
|
|
||||||
pinMode(PIN_P25, OUTPUT);
|
|
||||||
#if !defined(USE_ALTERNATE_NXDN_LEDS)
|
|
||||||
pinMode(PIN_NXDN, OUTPUT);
|
|
||||||
#endif
|
|
||||||
#if !defined(USE_ALTERNATE_POCSAG_LEDS)
|
|
||||||
pinMode(PIN_POCSAG, OUTPUT);
|
|
||||||
#endif
|
|
||||||
#if !defined(USE_ALTERNATE_POCSAG_LEDS)
|
|
||||||
pinMode(PIN_FM, OUTPUT);
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void CIO::startInt()
|
|
||||||
{
|
|
||||||
if (ADC->ADC_ISR & ADC_ISR_EOC_Chan) // Ensure there was an End-of-Conversion and we read the ISR reg
|
|
||||||
io.interrupt();
|
|
||||||
|
|
||||||
// Set up the ADC
|
|
||||||
NVIC_EnableIRQ(ADC_IRQn); // Enable ADC interrupt vector
|
|
||||||
ADC->ADC_IDR = 0xFFFFFFFF; // Disable interrupts
|
|
||||||
ADC->ADC_IER = ADC_CHER_Chan; // Enable End-Of-Conv interrupt
|
|
||||||
ADC->ADC_CHDR = 0xFFFF; // Disable all channels
|
|
||||||
ADC->ADC_CHER = ADC_CHER_Chan; // Enable rx input channel
|
|
||||||
#if defined(SEND_RSSI_DATA)
|
|
||||||
ADC->ADC_CHER |= RSSI_CHER_Chan; // and RSSI input
|
|
||||||
#endif
|
|
||||||
ADC->ADC_CGR = 0x15555555; // All gains set to x1
|
|
||||||
ADC->ADC_COR = 0x00000000; // All offsets off
|
|
||||||
ADC->ADC_MR = (ADC->ADC_MR & 0xFFFFFFF0) | (1 << 1) | ADC_MR_TRGEN; // 1 = trig source TIO from TC0
|
|
||||||
|
|
||||||
#if defined(EXTERNAL_OSC)
|
|
||||||
// Set up the external clock input on PA4 = AI5
|
|
||||||
REG_PIOA_ODR = 0x10; // Set pin as input
|
|
||||||
REG_PIOA_PDR = 0x10; // Disable PIO A bit 4
|
|
||||||
REG_PIOA_ABSR &= ~0x10; // Select A peripheral = TCLK1 Input
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Set up the timer
|
|
||||||
pmc_enable_periph_clk(TC_INTERFACE_ID + 0*3+0) ; // Clock the TC0 channel 0
|
|
||||||
TcChannel* t = &(TC0->TC_CHANNEL)[0]; // Pointer to TC0 registers for its channel 0
|
|
||||||
t->TC_CCR = TC_CCR_CLKDIS; // Disable internal clocking while setup regs
|
|
||||||
t->TC_IDR = 0xFFFFFFFF; // Disable interrupts
|
|
||||||
t->TC_SR; // Read int status reg to clear pending
|
|
||||||
#if defined(EXTERNAL_OSC)
|
|
||||||
t->TC_CMR = TC_CMR_TCCLKS_XC1 | // Use XC1 = TCLK1 external clock
|
|
||||||
#else
|
|
||||||
t->TC_CMR = TC_CMR_TCCLKS_TIMER_CLOCK1 | // Use TCLK1 (prescale by 2, = 42MHz)
|
|
||||||
#endif
|
|
||||||
TC_CMR_WAVE | // Waveform mode
|
|
||||||
TC_CMR_WAVSEL_UP_RC | // Count-up PWM using RC as threshold
|
|
||||||
TC_CMR_EEVT_XC0 | // Set external events from XC0 (this setup TIOB as output)
|
|
||||||
TC_CMR_ACPA_CLEAR | TC_CMR_ACPC_CLEAR |
|
|
||||||
TC_CMR_BCPB_CLEAR | TC_CMR_BCPC_CLEAR;
|
|
||||||
#if defined(EXTERNAL_OSC)
|
|
||||||
t->TC_RC = EXTERNAL_OSC / 24000; // Counter resets on RC, so sets period in terms of the external clock
|
|
||||||
t->TC_RA = EXTERNAL_OSC / 48000; // Roughly square wave
|
|
||||||
#else
|
|
||||||
t->TC_RC = 1750; // Counter resets on RC, so sets period in terms of 42MHz internal clock
|
|
||||||
t->TC_RA = 880; // Roughly square wave
|
|
||||||
#endif
|
|
||||||
t->TC_CMR = (t->TC_CMR & 0xFFF0FFFF) | TC_CMR_ACPA_CLEAR | TC_CMR_ACPC_SET; // Set clear and set from RA and RC compares
|
|
||||||
t->TC_CCR = TC_CCR_CLKEN | TC_CCR_SWTRG; // re-enable local clocking and switch to hardware trigger source.
|
|
||||||
|
|
||||||
// Set up the DAC
|
|
||||||
pmc_enable_periph_clk(DACC_INTERFACE_ID); // Start clocking DAC
|
|
||||||
DACC->DACC_CR = DACC_CR_SWRST; // Reset DAC
|
|
||||||
DACC->DACC_MR =
|
|
||||||
DACC_MR_TRGEN_EN | DACC_MR_TRGSEL(1) | // Trigger 1 = TIO output of TC0
|
|
||||||
DACC_MR_USER_SEL_Chan | // Select channel
|
|
||||||
(24 << DACC_MR_STARTUP_Pos); // 24 = 1536 cycles which I think is in range 23..45us since DAC clock = 42MHz
|
|
||||||
DACC->DACC_IDR = 0xFFFFFFFF; // No interrupts
|
|
||||||
DACC->DACC_CHER = DACC_CHER_Chan; // Enable channel
|
|
||||||
|
|
||||||
digitalWrite(PIN_PTT, m_pttInvert ? HIGH : LOW);
|
|
||||||
digitalWrite(PIN_COSLED, LOW);
|
|
||||||
digitalWrite(PIN_LED, HIGH);
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
|
||||||
uint8_t control = MARK_NONE;
|
|
||||||
uint16_t sample = DC_OFFSET;
|
|
||||||
|
|
||||||
m_txBuffer.get(sample, control);
|
|
||||||
DACC->DACC_CDR = 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]);
|
|
||||||
#else
|
|
||||||
m_rssiBuffer.put(0U);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
m_watchdog++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CIO::getCOSInt()
|
|
||||||
{
|
|
||||||
return digitalRead(PIN_COS) == HIGH;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CIO::setLEDInt(bool on)
|
|
||||||
{
|
|
||||||
digitalWrite(PIN_LED, on ? HIGH : LOW);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CIO::setPTTInt(bool on)
|
|
||||||
{
|
|
||||||
digitalWrite(PIN_PTT, on ? HIGH : LOW);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CIO::setCOSInt(bool on)
|
|
||||||
{
|
|
||||||
digitalWrite(PIN_COSLED, on ? HIGH : LOW);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CIO::setDStarInt(bool on)
|
|
||||||
{
|
|
||||||
digitalWrite(PIN_DSTAR, on ? HIGH : LOW);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CIO::setDMRInt(bool on)
|
|
||||||
{
|
|
||||||
digitalWrite(PIN_DMR, on ? HIGH : LOW);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CIO::setYSFInt(bool on)
|
|
||||||
{
|
|
||||||
digitalWrite(PIN_YSF, on ? HIGH : LOW);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CIO::setP25Int(bool on)
|
|
||||||
{
|
|
||||||
digitalWrite(PIN_P25, on ? HIGH : LOW);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CIO::setNXDNInt(bool on)
|
|
||||||
{
|
|
||||||
#if defined(USE_ALTERNATE_NXDN_LEDS)
|
|
||||||
digitalWrite(PIN_YSF, on ? HIGH : LOW);
|
|
||||||
digitalWrite(PIN_P25, on ? HIGH : LOW);
|
|
||||||
#else
|
|
||||||
digitalWrite(PIN_NXDN, on ? HIGH : LOW);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void CIO::setPOCSAGInt(bool on)
|
|
||||||
{
|
|
||||||
#if defined(USE_ALTERNATE_POCSAG_LEDS)
|
|
||||||
digitalWrite(PIN_DSTAR, on ? HIGH : LOW);
|
|
||||||
digitalWrite(PIN_DMR, on ? HIGH : LOW);
|
|
||||||
#else
|
|
||||||
digitalWrite(PIN_POCSAG, on ? HIGH : LOW);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void CIO::setFMInt(bool on)
|
|
||||||
{
|
|
||||||
#if defined(USE_ALTERNATE_FM_LEDS)
|
|
||||||
digitalWrite(PIN_DSTAR, on ? HIGH : LOW);
|
|
||||||
digitalWrite(PIN_YSF, on ? HIGH : LOW);
|
|
||||||
#else
|
|
||||||
digitalWrite(PIN_FM, on ? HIGH : LOW);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void CIO::delayInt(unsigned int dly)
|
|
||||||
{
|
|
||||||
delay(dly);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -59,9 +59,15 @@
|
|||||||
#elif defined(STM32F4_DVM)
|
#elif defined(STM32F4_DVM)
|
||||||
#include "pins/pins_f4_stm32dvm_v3.h"
|
#include "pins/pins_f4_stm32dvm_v3.h"
|
||||||
|
|
||||||
|
#elif defined(STM32F7_DVM)
|
||||||
|
#include "pins/pins_f7_stm32dvm_v5.h"
|
||||||
|
|
||||||
#elif defined(DRCC_DVM_NQF)
|
#elif defined(DRCC_DVM_NQF)
|
||||||
#include "pins/pins_f4_drcc_nqf.h"
|
#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)
|
#elif defined(STM32F4_EDA_405) || defined(STM32F4_EDA_446)
|
||||||
#include "pins/pins_f4_stm32eda.h"
|
#include "pins/pins_f4_stm32eda.h"
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2016 by Jim McLaughlin KI6ZUM
|
* Copyright (C) 2016 by Jim McLaughlin KI6ZUM
|
||||||
* Copyright (C) 2016,2017,2018 by Andy Uribe CA6JAU
|
* Copyright (C) 2016,2017,2018 by Andy Uribe CA6JAU
|
||||||
* Copyright (C) 2017,2018,2020 by Jonathan Naylor G4KLX
|
* Copyright (C) 2017,2018,2020,2023 by Jonathan Naylor G4KLX
|
||||||
* Copyright (C) 2019,2020 by BG5HHP
|
* Copyright (C) 2019,2020 by BG5HHP
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@@ -106,6 +106,14 @@ void CIO::initInt()
|
|||||||
GPIO_Init(PORT_NXDN, &GPIO_InitStruct);
|
GPIO_Init(PORT_NXDN, &GPIO_InitStruct);
|
||||||
#endif
|
#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)
|
#if !defined(USE_ALTERNATE_POCSAG_LEDS)
|
||||||
// POCSAG pin
|
// POCSAG pin
|
||||||
RCC_AHB1PeriphClockCmd(RCC_Per_POCSAG, ENABLE);
|
RCC_AHB1PeriphClockCmd(RCC_Per_POCSAG, ENABLE);
|
||||||
@@ -157,6 +165,14 @@ void CIO::initInt()
|
|||||||
GPIO_Init(PORT_MNXDN, &GPIO_InitStruct);
|
GPIO_Init(PORT_MNXDN, &GPIO_InitStruct);
|
||||||
#endif
|
#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)
|
#if !defined(USE_ALTERNATE_POCSAG_LEDS)
|
||||||
// POCSAG mode pin
|
// POCSAG mode pin
|
||||||
RCC_AHB1PeriphClockCmd(RCC_Per_MPOCSAG, ENABLE);
|
RCC_AHB1PeriphClockCmd(RCC_Per_MPOCSAG, ENABLE);
|
||||||
@@ -326,35 +342,40 @@ void CIO::startInt()
|
|||||||
|
|
||||||
void CIO::interrupt()
|
void CIO::interrupt()
|
||||||
{
|
{
|
||||||
uint8_t control = MARK_NONE;
|
TSample sample = {DC_OFFSET, MARK_NONE};
|
||||||
uint16_t sample = DC_OFFSET;
|
|
||||||
uint16_t rawRSSI = 0U;
|
uint16_t rawRSSI = 0U;
|
||||||
|
|
||||||
m_txBuffer.get(sample, control);
|
m_txBuffer.get(sample);
|
||||||
|
|
||||||
// Send the value to the DAC
|
// Send the value to the DAC
|
||||||
#if defined(STM32F4_NUCLEO) && defined(STM32F4_NUCLEO_ARDUINO_HEADER)
|
#if defined(STM32F4_NUCLEO) && defined(STM32F4_NUCLEO_ARDUINO_HEADER)
|
||||||
DAC_SetChannel2Data(DAC_Align_12b_R, sample);
|
DAC_SetChannel2Data(DAC_Align_12b_R, sample.sample);
|
||||||
#else
|
#else
|
||||||
DAC_SetChannel1Data(DAC_Align_12b_R, sample);
|
DAC_SetChannel1Data(DAC_Align_12b_R, sample.sample);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Read value from ADC1 and ADC2
|
// Read value from ADC1 and ADC2
|
||||||
if ((ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC) == RESET)) {
|
if ((ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC) == RESET)) {
|
||||||
// shouldn't be still in reset at this point so null the sample value?
|
// shouldn't be still in reset at this point so null the sample value?
|
||||||
sample = 0U;
|
sample.sample = 0U;
|
||||||
} else {
|
} else {
|
||||||
sample = ADC_GetConversionValue(ADC1);
|
sample.sample = ADC_GetConversionValue(ADC1);
|
||||||
#if defined(SEND_RSSI_DATA)
|
#if defined(SEND_RSSI_DATA)
|
||||||
rawRSSI = ADC_GetConversionValue(ADC2);
|
rawRSSI = ADC_GetConversionValue(ADC2);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// trigger next ADC1
|
// Trigger next ADC1
|
||||||
ADC_ClearFlag(ADC1, ADC_FLAG_EOC);
|
ADC_ClearFlag(ADC1, ADC_FLAG_EOC);
|
||||||
ADC_SoftwareStartConv(ADC1);
|
ADC_SoftwareStartConv(ADC1);
|
||||||
|
|
||||||
m_rxBuffer.put(sample, control);
|
#if defined(SEND_RSSI_DATA)
|
||||||
|
// Trigger next ADC2
|
||||||
|
ADC_ClearFlag(ADC2, ADC_FLAG_EOC);
|
||||||
|
ADC_SoftwareStartConv(ADC2);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
m_rxBuffer.put(sample);
|
||||||
m_rssiBuffer.put(rawRSSI);
|
m_rssiBuffer.put(rawRSSI);
|
||||||
|
|
||||||
m_watchdog++;
|
m_watchdog++;
|
||||||
@@ -441,6 +462,27 @@ void CIO::setNXDNInt(bool on)
|
|||||||
#endif
|
#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)
|
void CIO::setPOCSAGInt(bool on)
|
||||||
{
|
{
|
||||||
#if defined(MODE_LEDS)
|
#if defined(MODE_LEDS)
|
||||||
@@ -509,4 +551,21 @@ 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
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|||||||
-476
@@ -1,476 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2016 by Jim McLaughlin KI6ZUM
|
|
||||||
* Copyright (C) 2016, 2017 by Andy Uribe CA6JAU
|
|
||||||
* Copyright (C) 2017,2018,2020 by Jonathan Naylor G4KLX
|
|
||||||
* Copyright (C) 2017 by Wojciech Krutnik N0CALL
|
|
||||||
*
|
|
||||||
* 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 "Globals.h"
|
|
||||||
#include "IO.h"
|
|
||||||
|
|
||||||
|
|
||||||
#if defined(STM32F1)
|
|
||||||
|
|
||||||
#if defined(STM32F1_POG)
|
|
||||||
/*
|
|
||||||
Pin definitions for STM32F1 POG Board:
|
|
||||||
|
|
||||||
PTT PB12 output
|
|
||||||
COSLED PB5 output
|
|
||||||
LED PB4 output
|
|
||||||
COS PB13 input/PD
|
|
||||||
|
|
||||||
DSTAR PB7 output
|
|
||||||
DMR PB6 output
|
|
||||||
YSF PB8 output
|
|
||||||
P25 PB9 output
|
|
||||||
NXDN PB10 output
|
|
||||||
POCSAG PB11 output
|
|
||||||
|
|
||||||
RX PB0 analog input (ADC1_8)
|
|
||||||
RSSI PB1 analog input (ADC2_9)
|
|
||||||
TX PA4 analog output (DAC_OUT1)
|
|
||||||
|
|
||||||
EXT_CLK PA15 input (AF: TIM2_CH1_ETR)
|
|
||||||
|
|
||||||
USART1_TXD PA9 output (AF)
|
|
||||||
USART1_RXD PA10 input (AF)
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define PIN_PTT 12
|
|
||||||
#define PORT_PTT GPIOB
|
|
||||||
#define BB_PTT *((bitband_t)BITBAND_PERIPH(&PORT_PTT->ODR, PIN_PTT))
|
|
||||||
#define PIN_COSLED 5
|
|
||||||
#define PORT_COSLED GPIOB
|
|
||||||
#define BB_COSLED *((bitband_t)BITBAND_PERIPH(&PORT_COSLED->ODR, PIN_COSLED))
|
|
||||||
#define PIN_LED 4
|
|
||||||
#define PORT_LED GPIOB
|
|
||||||
#define BB_LED *((bitband_t)BITBAND_PERIPH(&PORT_LED->ODR, PIN_LED))
|
|
||||||
#define PIN_COS 13
|
|
||||||
#define PORT_COS GPIOB
|
|
||||||
#define BB_COS *((bitband_t)BITBAND_PERIPH(&PORT_COS->IDR, PIN_COS))
|
|
||||||
|
|
||||||
#define PIN_DSTAR 7
|
|
||||||
#define PORT_DSTAR GPIOB
|
|
||||||
#define BB_DSTAR *((bitband_t)BITBAND_PERIPH(&PORT_DSTAR->ODR, PIN_DSTAR))
|
|
||||||
#define PIN_DMR 6
|
|
||||||
#define PORT_DMR GPIOB
|
|
||||||
#define BB_DMR *((bitband_t)BITBAND_PERIPH(&PORT_DMR->ODR, PIN_DMR))
|
|
||||||
#define PIN_YSF 8
|
|
||||||
#define PORT_YSF GPIOB
|
|
||||||
#define BB_YSF *((bitband_t)BITBAND_PERIPH(&PORT_YSF->ODR, PIN_YSF))
|
|
||||||
#define PIN_P25 9
|
|
||||||
#define PORT_P25 GPIOB
|
|
||||||
#define BB_P25 *((bitband_t)BITBAND_PERIPH(&PORT_P25->ODR, PIN_P25))
|
|
||||||
#define PIN_NXDN 10
|
|
||||||
#define PORT_NXDN GPIOB
|
|
||||||
#define BB_NXDN *((bitband_t)BITBAND_PERIPH(&PORT_NXDN->ODR, PIN_NXDN))
|
|
||||||
#define PIN_POCSAG 11
|
|
||||||
#define PORT_POCSAG GPIOB
|
|
||||||
#define BB_POCSAG *((bitband_t)BITBAND_PERIPH(&PORT_POCSAG->ODR, PIN_POCSAG))
|
|
||||||
|
|
||||||
#define PIN_RX 0
|
|
||||||
#define PIN_RX_ADC_CH 8
|
|
||||||
#define PORT_RX GPIOB
|
|
||||||
#define PIN_RSSI 1
|
|
||||||
#define PIN_RSSI_ADC_CH 9
|
|
||||||
#define PORT_RSSI GPIOB
|
|
||||||
#define PIN_TX 4
|
|
||||||
#define PIN_TX_DAC_CH 1
|
|
||||||
#define PORT_TX GPIOA
|
|
||||||
|
|
||||||
#define PIN_EXT_CLK 15
|
|
||||||
#define SRC_EXT_CLK 15
|
|
||||||
#define PORT_EXT_CLK GPIOA
|
|
||||||
|
|
||||||
#define PIN_USART1_TXD 9
|
|
||||||
#define PORT_USART1_TXD GPIOA
|
|
||||||
#define PIN_USART1_RXD 10
|
|
||||||
#define PORT_USART1_RXD GPIOA
|
|
||||||
|
|
||||||
#else // defined(STM32F1_POG)
|
|
||||||
#error "Either STM32F1_POG, or sth need to be defined"
|
|
||||||
#endif // defined(STM32F1_POG)
|
|
||||||
|
|
||||||
const uint16_t DC_OFFSET = 2048U;
|
|
||||||
|
|
||||||
// Sampling frequency
|
|
||||||
#define SAMP_FREQ 24000
|
|
||||||
|
|
||||||
extern "C" {
|
|
||||||
void TIM2_IRQHandler() {
|
|
||||||
if ((TIM2->SR & TIM_SR_UIF) == TIM_SR_UIF) {
|
|
||||||
TIM2->SR = ~TIM_SR_UIF; // clear UI flag
|
|
||||||
io.interrupt();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void delay(uint32_t cnt)
|
|
||||||
{
|
|
||||||
while(cnt--)
|
|
||||||
asm("nop");
|
|
||||||
}
|
|
||||||
|
|
||||||
// source: http://www.freddiechopin.info/
|
|
||||||
void GPIOConfigPin(GPIO_TypeDef *port_ptr, uint32_t pin, uint32_t mode_cnf_value)
|
|
||||||
{
|
|
||||||
volatile uint32_t *cr_ptr;
|
|
||||||
uint32_t cr_value;
|
|
||||||
|
|
||||||
cr_ptr = &port_ptr->CRL; // configuration of pins [0,7] is in CRL
|
|
||||||
|
|
||||||
if (pin >= 8) // is pin in [8; 15]?
|
|
||||||
{ // configuration of pins [8,15] is in CRH
|
|
||||||
cr_ptr++; // advance to next struct element CRL -> CRH
|
|
||||||
pin -= 8; // crop the pin number
|
|
||||||
}
|
|
||||||
|
|
||||||
cr_value = *cr_ptr; // localize the CRL / CRH value
|
|
||||||
|
|
||||||
cr_value &= ~(0xF << (pin * 4)); // clear the MODE and CNF fields (now that pin is an analog input)
|
|
||||||
cr_value |= (mode_cnf_value << (pin * 4)); // save new MODE and CNF value for desired pin
|
|
||||||
|
|
||||||
*cr_ptr = cr_value; // save localized value to CRL / CRL
|
|
||||||
}
|
|
||||||
|
|
||||||
#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;
|
|
||||||
}
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
*((bitband_t)BITBAND_PERIPH(&PORT_USART1_TXD->ODR, PIN_USART1_TXD)) = 0x01;
|
|
||||||
delay(SystemCoreClock/1000*20);
|
|
||||||
*((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;
|
|
||||||
|
|
||||||
*foo[0] = 0x01;
|
|
||||||
for(int i=1; i<7; i++){
|
|
||||||
delay(SystemCoreClock/1000*10);
|
|
||||||
*foo[i-1] = 0x00;
|
|
||||||
*foo[i] = 0x01;
|
|
||||||
}
|
|
||||||
for(int i=5; i>=0; i--){
|
|
||||||
delay(SystemCoreClock/1000*10);
|
|
||||||
*foo[i+1] = 0x00;
|
|
||||||
*foo[i] = 0x01;
|
|
||||||
}
|
|
||||||
delay(SystemCoreClock/1000*10);
|
|
||||||
*foo[5+1-6] = 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;
|
|
||||||
GPIOConfigPin(PORT_USART1_TXD, PIN_USART1_TXD, GPIO_CRL_MODE0_1|GPIO_CRL_CNF0_1);
|
|
||||||
delay(SystemCoreClock/1000*50);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static inline void GPIOInit()
|
|
||||||
{
|
|
||||||
RCC->APB2ENR |= RCC_APB2ENR_IOPAEN | RCC_APB2ENR_IOPBEN
|
|
||||||
| RCC_APB2ENR_IOPCEN | RCC_APB2ENR_IOPDEN
|
|
||||||
| RCC_APB2ENR_AFIOEN; // enable all GPIOs
|
|
||||||
|
|
||||||
// set all ports to input with pull-down
|
|
||||||
GPIOA->CRL = 0x88888888;
|
|
||||||
GPIOA->CRH = 0x88888888;
|
|
||||||
GPIOA->ODR = 0;
|
|
||||||
GPIOB->CRL = 0x88888888;
|
|
||||||
GPIOB->CRH = 0x88888888;
|
|
||||||
GPIOB->ODR = 0;
|
|
||||||
GPIOC->CRL = 0x88888888;
|
|
||||||
GPIOC->CRH = 0x88888888;
|
|
||||||
GPIOC->ODR = 0;
|
|
||||||
GPIOD->CRL = 0x88888888;
|
|
||||||
GPIOD->CRH = 0x88888888;
|
|
||||||
GPIOD->ODR = 0;
|
|
||||||
|
|
||||||
// configure ports
|
|
||||||
GPIOConfigPin(PORT_PTT, PIN_PTT, GPIO_CRL_MODE0_1);
|
|
||||||
GPIOConfigPin(PORT_COSLED, PIN_COSLED, GPIO_CRL_MODE0_1);
|
|
||||||
GPIOConfigPin(PORT_LED, PIN_LED, GPIO_CRL_MODE0_1);
|
|
||||||
GPIOConfigPin(PORT_COS, PIN_COS, GPIO_CRL_CNF0_1);
|
|
||||||
|
|
||||||
GPIOConfigPin(PORT_DSTAR, PIN_DSTAR, GPIO_CRL_MODE0_1);
|
|
||||||
GPIOConfigPin(PORT_DMR, PIN_DMR, GPIO_CRL_MODE0_1);
|
|
||||||
GPIOConfigPin(PORT_YSF, PIN_YSF, GPIO_CRL_MODE0_1);
|
|
||||||
GPIOConfigPin(PORT_P25, PIN_P25, GPIO_CRL_MODE0_1);
|
|
||||||
#if !defined(USE_ALTERNATE_NXDN_LEDS)
|
|
||||||
GPIOConfigPin(PORT_NXDN, PIN_NXDN, GPIO_CRL_MODE0_1);
|
|
||||||
#endif
|
|
||||||
#if !defined(USE_ALTERNATE_POCSAG_LEDS)
|
|
||||||
GPIOConfigPin(PORT_POCSAG, PIN_POCSAG, GPIO_CRL_MODE0_1);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
GPIOConfigPin(PORT_RX, PIN_RX, 0);
|
|
||||||
#if defined(SEND_RSSI_DATA)
|
|
||||||
GPIOConfigPin(PORT_RSSI, PIN_RSSI, 0);
|
|
||||||
#endif
|
|
||||||
GPIOConfigPin(PORT_TX, PIN_TX, 0);
|
|
||||||
|
|
||||||
#if defined(EXTERNAL_OSC)
|
|
||||||
#if defined(STM32F1_POG)
|
|
||||||
GPIOConfigPin(PORT_EXT_CLK, PIN_EXT_CLK, GPIO_CRL_CNF0_0);
|
|
||||||
AFIO->MAPR = (AFIO->MAPR & ~AFIO_MAPR_TIM2_REMAP) | AFIO_MAPR_TIM2_REMAP_0;
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
GPIOConfigPin(PORT_USART1_TXD, PIN_USART1_TXD, GPIO_CRL_MODE0_1|GPIO_CRL_CNF0_1);
|
|
||||||
GPIOConfigPin(PORT_USART1_RXD, PIN_USART1_RXD, GPIO_CRL_CNF0_0);
|
|
||||||
|
|
||||||
AFIO->MAPR = (AFIO->MAPR & ~AFIO_MAPR_SWJ_CFG) | AFIO_MAPR_SWJ_CFG_1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static inline void ADCInit()
|
|
||||||
{
|
|
||||||
RCC->CFGR = (RCC->CFGR & ~RCC_CFGR_ADCPRE_Msk)
|
|
||||||
| RCC_CFGR_ADCPRE_DIV6; // ADC clock divided by 6 (72MHz/6 = 12MHz)
|
|
||||||
RCC->APB2ENR |= RCC_APB2ENR_ADC1EN;
|
|
||||||
#if defined(SEND_RSSI_DATA)
|
|
||||||
RCC->APB2ENR |= RCC_APB2ENR_ADC2EN;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Init ADCs in dual mode (RSSI)
|
|
||||||
#if defined(SEND_RSSI_DATA)
|
|
||||||
ADC1->CR1 = ADC_CR1_DUALMOD_1|ADC_CR1_DUALMOD_2; // Regular simultaneous mode
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Set sampling time to 7.5 cycles
|
|
||||||
if (PIN_RX_ADC_CH < 10) {
|
|
||||||
ADC1->SMPR2 = ADC_SMPR2_SMP0_0 << (3*PIN_RX_ADC_CH);
|
|
||||||
} else {
|
|
||||||
ADC1->SMPR1 = ADC_SMPR1_SMP10_0 << (3*PIN_RX_ADC_CH);
|
|
||||||
}
|
|
||||||
#if defined(SEND_RSSI_DATA)
|
|
||||||
if (PIN_RSSI_ADC_CH < 10) {
|
|
||||||
ADC2->SMPR2 = ADC_SMPR2_SMP0_0 << (3*PIN_RSSI_ADC_CH);
|
|
||||||
} else {
|
|
||||||
ADC2->SMPR1 = ADC_SMPR1_SMP10_0 << (3*PIN_RSSI_ADC_CH);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Set conversion channel (single conversion)
|
|
||||||
ADC1->SQR3 = PIN_RX_ADC_CH;
|
|
||||||
#if defined(SEND_RSSI_DATA)
|
|
||||||
ADC2->SQR3 = PIN_RSSI_ADC_CH;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Enable ADC
|
|
||||||
ADC1->CR2 |= ADC_CR2_ADON;
|
|
||||||
|
|
||||||
#if defined(SEND_RSSI_DATA)
|
|
||||||
// Enable ADC2
|
|
||||||
ADC2->CR2 |= ADC_CR2_ADON;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Start calibration
|
|
||||||
delay(6*2);
|
|
||||||
ADC1->CR2 |= ADC_CR2_CAL;
|
|
||||||
while((ADC1->CR2 & ADC_CR2_CAL) == ADC_CR2_CAL)
|
|
||||||
;
|
|
||||||
#if defined(SEND_RSSI_DATA)
|
|
||||||
ADC2->CR2 |= ADC_CR2_CAL;
|
|
||||||
while((ADC2->CR2 & ADC_CR2_CAL) == ADC_CR2_CAL)
|
|
||||||
;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Trigger first conversion
|
|
||||||
ADC1->CR2 |= ADC_CR2_ADON;
|
|
||||||
#if defined(SEND_RSSI_DATA)
|
|
||||||
ADC2->CR2 |= ADC_CR2_ADON;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static inline void DACInit()
|
|
||||||
{
|
|
||||||
RCC->APB1ENR |= RCC_APB1ENR_DACEN;
|
|
||||||
|
|
||||||
DAC->CR = DAC_CR_EN1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static inline void TimerInit()
|
|
||||||
{
|
|
||||||
RCC->APB1ENR |= RCC_APB1ENR_TIM2EN;
|
|
||||||
|
|
||||||
#if defined(EXTERNAL_OSC)
|
|
||||||
// Enable external clock, prescaler /4
|
|
||||||
TIM2->SMCR = TIM_SMCR_ECE | TIM_SMCR_ETPS_1;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// TIM2 output frequency
|
|
||||||
TIM2->PSC = 0;
|
|
||||||
#if defined(EXTERNAL_OSC)
|
|
||||||
// TimerCount = ExternalOsc
|
|
||||||
// /4 (external clock prescaler)
|
|
||||||
// /SAMP_FREQ
|
|
||||||
TIM2->ARR = (uint16_t) ((EXTERNAL_OSC/(4*SAMP_FREQ)) - 1);
|
|
||||||
#else
|
|
||||||
TIM2->ARR = (uint16_t) ((SystemCoreClock/(SAMP_FREQ)) - 1);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Enable TIse 1%-tolerance comM2 interrupt
|
|
||||||
TIM2->DIER = TIM_DIER_UIE;
|
|
||||||
NVIC_EnableIRQ(TIM2_IRQn);
|
|
||||||
|
|
||||||
// Enable TIM2
|
|
||||||
TIM2->CR1 |= TIM_CR1_CEN;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void CIO::initInt()
|
|
||||||
{
|
|
||||||
GPIOInit();
|
|
||||||
ADCInit();
|
|
||||||
DACInit();
|
|
||||||
#if defined(STM32F1_POG)
|
|
||||||
FancyLEDEffect();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void CIO::startInt()
|
|
||||||
{
|
|
||||||
TimerInit();
|
|
||||||
|
|
||||||
BB_COSLED = 0;
|
|
||||||
BB_LED = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CIO::interrupt()
|
|
||||||
{
|
|
||||||
uint8_t control = MARK_NONE;
|
|
||||||
uint16_t sample = DC_OFFSET;
|
|
||||||
#if defined(SEND_RSSI_DATA)
|
|
||||||
uint16_t rawRSSI = 0U;
|
|
||||||
#endif
|
|
||||||
bitband_t eoc = (bitband_t)BITBAND_PERIPH(&ADC1->SR, ADC_SR_EOS_Pos);
|
|
||||||
bitband_t adon = (bitband_t)BITBAND_PERIPH(&ADC1->CR2, ADC_CR2_ADON_Pos);
|
|
||||||
#if defined(SEND_RSSI_DATA)
|
|
||||||
bitband_t rssi_adon = (bitband_t)BITBAND_PERIPH(&ADC2->CR2, ADC_CR2_ADON_Pos);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (*eoc) {
|
|
||||||
// trigger next conversion
|
|
||||||
*adon = 1;
|
|
||||||
#if defined(SEND_RSSI_DATA)
|
|
||||||
*rssi_adon = 1;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
m_txBuffer.get(sample, control);
|
|
||||||
DAC->DHR12R1 = sample; // Send the value to the DAC
|
|
||||||
|
|
||||||
// Read value from ADC1 and ADC2
|
|
||||||
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);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
m_watchdog++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CIO::getCOSInt()
|
|
||||||
{
|
|
||||||
return BB_COS;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CIO::setLEDInt(bool on)
|
|
||||||
{
|
|
||||||
BB_LED = !!on;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CIO::setPTTInt(bool on)
|
|
||||||
{
|
|
||||||
BB_PTT = !!on;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CIO::setCOSInt(bool on)
|
|
||||||
{
|
|
||||||
BB_COSLED = !!on;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CIO::setDStarInt(bool on)
|
|
||||||
{
|
|
||||||
BB_DSTAR = !!on;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CIO::setDMRInt(bool on)
|
|
||||||
{
|
|
||||||
BB_DMR = !!on;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CIO::setYSFInt(bool on)
|
|
||||||
{
|
|
||||||
BB_YSF = !!on;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CIO::setP25Int(bool on)
|
|
||||||
{
|
|
||||||
BB_P25 = !!on;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CIO::setNXDNInt(bool on)
|
|
||||||
{
|
|
||||||
#if defined(USE_ALTERNATE_NXDN_LEDS)
|
|
||||||
BB_YSF = !!on;
|
|
||||||
BB_P25 = !!on;
|
|
||||||
#else
|
|
||||||
BB_NXDN = !!on;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void CIO::setPOCSAGInt(bool on)
|
|
||||||
{
|
|
||||||
#if defined(USE_ALTERNATE_POCSAG_LEDS)
|
|
||||||
BB_DSTAR = !!on;
|
|
||||||
BB_DMR = !!on;
|
|
||||||
#else
|
|
||||||
BB_POCSAG = !!on;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void CIO::setFMInt(bool on)
|
|
||||||
{
|
|
||||||
#if defined(USE_ALTERNATE_FM_LEDS)
|
|
||||||
BB_DSTAR = !!on;
|
|
||||||
BB_YSF = !!on;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void CIO::delayInt(unsigned int dly)
|
|
||||||
{
|
|
||||||
delay(dly);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
-266
@@ -1,266 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2016,2017,2018,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"
|
|
||||||
#include "Globals.h"
|
|
||||||
#include "IO.h"
|
|
||||||
|
|
||||||
#if defined(__MK20DX256__) || defined(__MK64FX512__) || defined(__MK66FX1M0__)
|
|
||||||
|
|
||||||
#if defined(EXTERNAL_OSC)
|
|
||||||
#define PIN_LED 3
|
|
||||||
#else
|
|
||||||
#define PIN_LED 13
|
|
||||||
#endif
|
|
||||||
#define PIN_COS 4
|
|
||||||
#define PIN_PTT 5
|
|
||||||
#define PIN_COSLED 6
|
|
||||||
#define PIN_DSTAR 9
|
|
||||||
#define PIN_DMR 10
|
|
||||||
#define PIN_YSF 11
|
|
||||||
#define PIN_P25 12
|
|
||||||
#if defined(__MK20DX256__)
|
|
||||||
#define PIN_NXDN 2
|
|
||||||
#define PIN_POCSAG 3
|
|
||||||
#define PIN_FM 4
|
|
||||||
#else
|
|
||||||
#define PIN_NXDN 24
|
|
||||||
#define PIN_POCSAG 25
|
|
||||||
#define PIN_FM 26
|
|
||||||
#endif
|
|
||||||
#define PIN_ADC 5 // A0, Pin 14
|
|
||||||
#define PIN_RSSI 4 // Teensy 3.5/3.6, A16, Pin 35. Teensy 3.1/3.2, A17, Pin 28
|
|
||||||
|
|
||||||
#define PDB_CHnC1_TOS 0x0100
|
|
||||||
#define PDB_CHnC1_EN 0x0001
|
|
||||||
|
|
||||||
const uint16_t DC_OFFSET = 2048U;
|
|
||||||
|
|
||||||
extern "C" {
|
|
||||||
void adc0_isr()
|
|
||||||
{
|
|
||||||
io.interrupt();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CIO::initInt()
|
|
||||||
{
|
|
||||||
// Set up the TX, COS and LED pins
|
|
||||||
pinMode(PIN_PTT, OUTPUT);
|
|
||||||
pinMode(PIN_COSLED, OUTPUT);
|
|
||||||
pinMode(PIN_LED, OUTPUT);
|
|
||||||
pinMode(PIN_COS, INPUT);
|
|
||||||
|
|
||||||
#if defined(MODE_LEDS)
|
|
||||||
// Set up the mode output pins
|
|
||||||
pinMode(PIN_DSTAR, OUTPUT);
|
|
||||||
pinMode(PIN_DMR, OUTPUT);
|
|
||||||
pinMode(PIN_YSF, OUTPUT);
|
|
||||||
pinMode(PIN_P25, OUTPUT);
|
|
||||||
#if !defined(USE_ALTERNATE_NXDN_LEDS)
|
|
||||||
pinMode(PIN_NXDN, OUTPUT);
|
|
||||||
#endif
|
|
||||||
#if !defined(USE_ALTERNATE_POCSAG_LEDS)
|
|
||||||
pinMode(PIN_POCSAG, OUTPUT);
|
|
||||||
#endif
|
|
||||||
#if !defined(USE_ALTERNATE_FM_LEDS)
|
|
||||||
pinMode(PIN_FM, OUTPUT);
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void CIO::startInt()
|
|
||||||
{
|
|
||||||
// Initialise the DAC
|
|
||||||
SIM_SCGC2 |= SIM_SCGC2_DAC0;
|
|
||||||
DAC0_C0 = DAC_C0_DACEN | DAC_C0_DACRFS; // 3.3V VDDA is DACREF_2
|
|
||||||
|
|
||||||
// Initialise ADC0
|
|
||||||
SIM_SCGC6 |= SIM_SCGC6_ADC0;
|
|
||||||
ADC0_CFG1 = ADC_CFG1_ADIV(1) | ADC_CFG1_ADICLK(1) | // Single-ended 12 bits, long sample time
|
|
||||||
ADC_CFG1_MODE(1) | ADC_CFG1_ADLSMP;
|
|
||||||
ADC0_CFG2 = ADC_CFG2_MUXSEL | ADC_CFG2_ADLSTS(2); // Select channels ADxxxb
|
|
||||||
ADC0_SC2 = ADC_SC2_REFSEL(0) | ADC_SC2_ADTRG; // Voltage ref external, hardware trigger
|
|
||||||
ADC0_SC3 = ADC_SC3_AVGE | ADC_SC3_AVGS(0); // Enable averaging, 4 samples
|
|
||||||
|
|
||||||
ADC0_SC3 |= ADC_SC3_CAL;
|
|
||||||
while (ADC0_SC3 & ADC_SC3_CAL) // Wait for calibration
|
|
||||||
;
|
|
||||||
|
|
||||||
uint16_t sum0 = ADC0_CLPS + ADC0_CLP4 + ADC0_CLP3 + // Plus side gain
|
|
||||||
ADC0_CLP2 + ADC0_CLP1 + ADC0_CLP0;
|
|
||||||
sum0 = (sum0 / 2U) | 0x8000U;
|
|
||||||
ADC0_PG = sum0;
|
|
||||||
|
|
||||||
ADC0_SC1A = ADC_SC1_AIEN | PIN_ADC; // Enable ADC interrupt, use A0
|
|
||||||
NVIC_ENABLE_IRQ(IRQ_ADC0);
|
|
||||||
|
|
||||||
#if defined(SEND_RSSI_DATA)
|
|
||||||
// Initialise ADC1
|
|
||||||
SIM_SCGC3 |= SIM_SCGC3_ADC1;
|
|
||||||
ADC1_CFG1 = ADC_CFG1_ADIV(1) | ADC_CFG1_ADICLK(1) | // Single-ended 12 bits, long sample time
|
|
||||||
ADC_CFG1_MODE(1) | ADC_CFG1_ADLSMP;
|
|
||||||
ADC1_CFG2 = ADC_CFG2_MUXSEL | ADC_CFG2_ADLSTS(2); // Select channels ADxxxb
|
|
||||||
ADC1_SC2 = ADC_SC2_REFSEL(0); // Voltage ref external, software trigger
|
|
||||||
ADC1_SC3 = ADC_SC3_AVGE | ADC_SC3_AVGS(0); // Enable averaging, 4 samples
|
|
||||||
|
|
||||||
ADC1_SC3 |= ADC_SC3_CAL;
|
|
||||||
while (ADC1_SC3 & ADC_SC3_CAL) // Wait for calibration
|
|
||||||
;
|
|
||||||
|
|
||||||
uint16_t sum1 = ADC1_CLPS + ADC1_CLP4 + ADC1_CLP3 + // Plus side gain
|
|
||||||
ADC1_CLP2 + ADC1_CLP1 + ADC1_CLP0;
|
|
||||||
sum1 = (sum1 / 2U) | 0x8000U;
|
|
||||||
ADC1_PG = sum1;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(EXTERNAL_OSC)
|
|
||||||
// Set ADC0 to trigger from the LPTMR at 24 kHz
|
|
||||||
SIM_SOPT7 = SIM_SOPT7_ADC0ALTTRGEN | // Enable ADC0 alternate trigger
|
|
||||||
SIM_SOPT7_ADC0TRGSEL(14); // Trigger ADC0 by LPTMR0
|
|
||||||
|
|
||||||
CORE_PIN13_CONFIG = PORT_PCR_MUX(3);
|
|
||||||
|
|
||||||
SIM_SCGC5 |= SIM_SCGC5_LPTIMER; // Enable Low Power Timer Access
|
|
||||||
LPTMR0_CSR = 0; // Disable
|
|
||||||
LPTMR0_PSR = LPTMR_PSR_PBYP; // Bypass prescaler/filter
|
|
||||||
LPTMR0_CMR = (EXTERNAL_OSC / 24000) - 1; // Frequency divided by CMR + 1
|
|
||||||
LPTMR0_CSR = LPTMR_CSR_TPS(2) | // Pin: 0=CMP0, 1=xtal, 2=pin13
|
|
||||||
LPTMR_CSR_TMS; // Mode Select, 0=timer, 1=counter
|
|
||||||
LPTMR0_CSR |= LPTMR_CSR_TEN; // Enable
|
|
||||||
#else
|
|
||||||
// Setup PDB for ADC0 at 24 kHz
|
|
||||||
SIM_SCGC6 |= SIM_SCGC6_PDB; // Enable PDB clock
|
|
||||||
PDB0_MOD = (F_BUS / 24000) - 1; // Timer period - 1
|
|
||||||
PDB0_IDLY = 0; // Interrupt delay
|
|
||||||
PDB0_CH0C1 = PDB_CHnC1_TOS | PDB_CHnC1_EN; // Enable pre-trigger for ADC0
|
|
||||||
PDB0_SC = PDB_SC_TRGSEL(15) | PDB_SC_PDBEN | // SW trigger, enable interrupts, continuous mode
|
|
||||||
PDB_SC_PDBIE | PDB_SC_CONT | PDB_SC_LDOK; // No prescaling
|
|
||||||
PDB0_SC |= PDB_SC_SWTRIG; // Software trigger (reset and restart counter)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
digitalWrite(PIN_PTT, m_pttInvert ? HIGH : LOW);
|
|
||||||
digitalWrite(PIN_COSLED, LOW);
|
|
||||||
digitalWrite(PIN_LED, HIGH);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CIO::interrupt()
|
|
||||||
{
|
|
||||||
uint8_t control = MARK_NONE;
|
|
||||||
uint16_t sample = DC_OFFSET;
|
|
||||||
|
|
||||||
m_txBuffer.get(sample, control);
|
|
||||||
*(int16_t *)&(DAC0_DAT0L) = sample;
|
|
||||||
|
|
||||||
if ((ADC0_SC1A & ADC_SC1_COCO) == ADC_SC1_COCO) {
|
|
||||||
sample = ADC0_RA;
|
|
||||||
m_rxBuffer.put(sample, control);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(SEND_RSSI_DATA)
|
|
||||||
if ((ADC1_SC1A & ADC_SC1_COCO) == ADC_SC1_COCO) {
|
|
||||||
uint16_t rssi = ADC1_RA;
|
|
||||||
m_rssiBuffer.put(rssi);
|
|
||||||
} else {
|
|
||||||
m_rssiBuffer.put(0U);
|
|
||||||
}
|
|
||||||
|
|
||||||
ADC1_SC1A = PIN_RSSI; // Start the next RSSI conversion
|
|
||||||
#else
|
|
||||||
m_rssiBuffer.put(0U);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
m_watchdog++;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CIO::getCOSInt()
|
|
||||||
{
|
|
||||||
return digitalRead(PIN_COS) == HIGH;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CIO::setLEDInt(bool on)
|
|
||||||
{
|
|
||||||
digitalWrite(PIN_LED, on ? HIGH : LOW);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CIO::setPTTInt(bool on)
|
|
||||||
{
|
|
||||||
digitalWrite(PIN_PTT, on ? HIGH : LOW);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CIO::setCOSInt(bool on)
|
|
||||||
{
|
|
||||||
digitalWrite(PIN_COSLED, on ? HIGH : LOW);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CIO::setDStarInt(bool on)
|
|
||||||
{
|
|
||||||
digitalWrite(PIN_DSTAR, on ? HIGH : LOW);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CIO::setDMRInt(bool on)
|
|
||||||
{
|
|
||||||
digitalWrite(PIN_DMR, on ? HIGH : LOW);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CIO::setYSFInt(bool on)
|
|
||||||
{
|
|
||||||
digitalWrite(PIN_YSF, on ? HIGH : LOW);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CIO::setP25Int(bool on)
|
|
||||||
{
|
|
||||||
digitalWrite(PIN_P25, on ? HIGH : LOW);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CIO::setNXDNInt(bool on)
|
|
||||||
{
|
|
||||||
#if defined(USE_ALTERNATE_NXDN_LEDS)
|
|
||||||
digitalWrite(PIN_YSF, on ? HIGH : LOW);
|
|
||||||
digitalWrite(PIN_P25, on ? HIGH : LOW);
|
|
||||||
#else
|
|
||||||
digitalWrite(PIN_NXDN, on ? HIGH : LOW);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void CIO::setPOCSAGInt(bool on)
|
|
||||||
{
|
|
||||||
#if defined(USE_ALTERNATE_POCSAG_LEDS)
|
|
||||||
digitalWrite(PIN_DSTAR, on ? HIGH : LOW);
|
|
||||||
digitalWrite(PIN_DMR, on ? HIGH : LOW);
|
|
||||||
#else
|
|
||||||
digitalWrite(PIN_POCSAG, on ? HIGH : LOW);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void CIO::setFMInt(bool on)
|
|
||||||
{
|
|
||||||
#if defined(USE_ALTERNATE_FM_LEDS)
|
|
||||||
digitalWrite(PIN_DSTAR, on ? HIGH : LOW);
|
|
||||||
digitalWrite(PIN_YSF, on ? HIGH : LOW);
|
|
||||||
#else
|
|
||||||
digitalWrite(PIN_FM, on ? HIGH : LOW);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void CIO::delayInt(unsigned int dly)
|
|
||||||
{
|
|
||||||
delay(dly);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
||||||
|
|
||||||
@@ -0,0 +1,485 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
||||||
|
|
||||||
@@ -0,0 +1,77 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
||||||
|
|
||||||
@@ -0,0 +1,190 @@
|
|||||||
|
/*
|
||||||
|
* 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] = {0, 0, 0, 0};
|
||||||
|
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
|
||||||
|
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
||||||
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2015,2016,2017,2018,2020 by Jonathan Naylor G4KLX
|
* Copyright (C) 2015,2016,2017,2018,2020,2021 by Jonathan Naylor G4KLX
|
||||||
* Copyright (C) 2016 by Mathis Schmieder DB9MAT
|
* Copyright (C) 2016 by Mathis Schmieder DB9MAT
|
||||||
* Copyright (C) 2016 by Colin Durbridge G4EML
|
* Copyright (C) 2016 by Colin Durbridge G4EML
|
||||||
*
|
*
|
||||||
@@ -31,6 +31,7 @@ bool m_dmrEnable = true;
|
|||||||
bool m_ysfEnable = true;
|
bool m_ysfEnable = true;
|
||||||
bool m_p25Enable = true;
|
bool m_p25Enable = true;
|
||||||
bool m_nxdnEnable = true;
|
bool m_nxdnEnable = true;
|
||||||
|
bool m_m17Enable = true;
|
||||||
bool m_pocsagEnable = true;
|
bool m_pocsagEnable = true;
|
||||||
bool m_fmEnable = true;
|
bool m_fmEnable = true;
|
||||||
bool m_ax25Enable = true;
|
bool m_ax25Enable = true;
|
||||||
@@ -40,39 +41,67 @@ bool m_duplex = true;
|
|||||||
bool m_tx = false;
|
bool m_tx = false;
|
||||||
bool m_dcd = false;
|
bool m_dcd = false;
|
||||||
|
|
||||||
CDStarRX dstarRX;
|
#if defined(MODE_DSTAR)
|
||||||
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;
|
|
||||||
CAX25RX ax25RX;
|
|
||||||
CAX25TX ax25TX;
|
|
||||||
|
|
||||||
CCalDStarRX calDStarRX;
|
CCalDStarRX calDStarRX;
|
||||||
CCalDStarTX calDStarTX;
|
CCalDStarTX calDStarTX;
|
||||||
CCalDMR calDMR;
|
#endif
|
||||||
CCalP25 calP25;
|
|
||||||
CCalNXDN calNXDN;
|
#if defined(MODE_DMR)
|
||||||
CCalFM calFM;
|
CDMRIdleRX dmrIdleRX;
|
||||||
CCalPOCSAG calPOCSAG;
|
CDMRRX dmrRX;
|
||||||
CCalRSSI calRSSI;
|
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;
|
||||||
|
|
||||||
|
CCalM17 calM17;
|
||||||
|
#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;
|
||||||
|
|
||||||
CCWIdTX cwIdTX;
|
CCWIdTX cwIdTX;
|
||||||
|
|
||||||
@@ -91,51 +120,89 @@ void loop()
|
|||||||
io.process();
|
io.process();
|
||||||
|
|
||||||
// The following is for transmitting
|
// The following is for transmitting
|
||||||
|
#if defined(MODE_DSTAR)
|
||||||
if (m_dstarEnable && m_modemState == STATE_DSTAR)
|
if (m_dstarEnable && m_modemState == STATE_DSTAR)
|
||||||
dstarTX.process();
|
dstarTX.process();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(MODE_DMR)
|
||||||
if (m_dmrEnable && m_modemState == STATE_DMR) {
|
if (m_dmrEnable && m_modemState == STATE_DMR) {
|
||||||
if (m_duplex)
|
if (m_duplex)
|
||||||
dmrTX.process();
|
dmrTX.process();
|
||||||
else
|
else
|
||||||
dmrDMOTX.process();
|
dmrDMOTX.process();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(MODE_YSF)
|
||||||
if (m_ysfEnable && m_modemState == STATE_YSF)
|
if (m_ysfEnable && m_modemState == STATE_YSF)
|
||||||
ysfTX.process();
|
ysfTX.process();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(MODE_P25)
|
||||||
if (m_p25Enable && m_modemState == STATE_P25)
|
if (m_p25Enable && m_modemState == STATE_P25)
|
||||||
p25TX.process();
|
p25TX.process();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(MODE_NXDN)
|
||||||
if (m_nxdnEnable && m_modemState == STATE_NXDN)
|
if (m_nxdnEnable && m_modemState == STATE_NXDN)
|
||||||
nxdnTX.process();
|
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()))
|
if (m_pocsagEnable && (m_modemState == STATE_POCSAG || pocsagTX.busy()))
|
||||||
pocsagTX.process();
|
pocsagTX.process();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(MODE_AX25)
|
||||||
if (m_ax25Enable && (m_modemState == STATE_IDLE || m_modemState == STATE_FM))
|
if (m_ax25Enable && (m_modemState == STATE_IDLE || m_modemState == STATE_FM))
|
||||||
ax25TX.process();
|
ax25TX.process();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(MODE_FM)
|
||||||
if (m_fmEnable && m_modemState == STATE_FM)
|
if (m_fmEnable && m_modemState == STATE_FM)
|
||||||
fm.process();
|
fm.process();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(MODE_DSTAR)
|
||||||
if (m_modemState == STATE_DSTARCAL)
|
if (m_modemState == STATE_DSTARCAL)
|
||||||
calDStarTX.process();
|
calDStarTX.process();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(MODE_DMR)
|
||||||
if (m_modemState == STATE_DMRCAL || m_modemState == STATE_LFCAL || m_modemState == STATE_DMRCAL1K || m_modemState == STATE_DMRDMO1K)
|
if (m_modemState == STATE_DMRCAL || m_modemState == STATE_LFCAL || m_modemState == STATE_DMRCAL1K || m_modemState == STATE_DMRDMO1K)
|
||||||
calDMR.process();
|
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)
|
if (m_modemState == STATE_P25CAL1K)
|
||||||
calP25.process();
|
calP25.process();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(MODE_NXDN)
|
||||||
if (m_modemState == STATE_NXDNCAL1K)
|
if (m_modemState == STATE_NXDNCAL1K)
|
||||||
calNXDN.process();
|
calNXDN.process();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(MODE_M17)
|
||||||
|
if (m_modemState == STATE_M17CAL)
|
||||||
|
calM17.process();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(MODE_POCSAG)
|
||||||
if (m_modemState == STATE_POCSAGCAL)
|
if (m_modemState == STATE_POCSAGCAL)
|
||||||
calPOCSAG.process();
|
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)
|
if (m_modemState == STATE_IDLE)
|
||||||
cwIdTX.process();
|
cwIdTX.process();
|
||||||
|
|||||||
@@ -1,139 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2015,2016,2017,2018,2020 by Jonathan Naylor G4KLX
|
|
||||||
* 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
|
|
||||||
* 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 "Globals.h"
|
|
||||||
|
|
||||||
// Global variables
|
|
||||||
MMDVM_STATE m_modemState = STATE_IDLE;
|
|
||||||
|
|
||||||
bool m_dstarEnable = true;
|
|
||||||
bool m_dmrEnable = true;
|
|
||||||
bool m_ysfEnable = true;
|
|
||||||
bool m_p25Enable = true;
|
|
||||||
bool m_nxdnEnable = 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;
|
|
||||||
|
|
||||||
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;
|
|
||||||
CAX25RX ax25RX;
|
|
||||||
CAX25 ax25TX;
|
|
||||||
|
|
||||||
CCalDStarRX calDStarRX;
|
|
||||||
CCalDStarTX calDStarTX;
|
|
||||||
CCalDMR calDMR;
|
|
||||||
CCalFM calFM;
|
|
||||||
CCalP25 calP25;
|
|
||||||
CCalNXDN calNXDN;
|
|
||||||
CCalPOCSAG calPOCSAG;
|
|
||||||
CCalRSSI calRSSI;
|
|
||||||
|
|
||||||
CCWIdTX cwIdTX;
|
|
||||||
|
|
||||||
CSerialPort serial;
|
|
||||||
CIO io;
|
|
||||||
|
|
||||||
void setup()
|
|
||||||
{
|
|
||||||
serial.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
void loop()
|
|
||||||
{
|
|
||||||
serial.process();
|
|
||||||
|
|
||||||
io.process();
|
|
||||||
|
|
||||||
// The following is for transmitting
|
|
||||||
if (m_dstarEnable && m_modemState == STATE_DSTAR)
|
|
||||||
dstarTX.process();
|
|
||||||
|
|
||||||
if (m_dmrEnable && m_modemState == STATE_DMR) {
|
|
||||||
if (m_duplex)
|
|
||||||
dmrTX.process();
|
|
||||||
else
|
|
||||||
dmrDMOTX.process();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_ysfEnable && m_modemState == STATE_YSF)
|
|
||||||
ysfTX.process();
|
|
||||||
|
|
||||||
if (m_p25Enable && m_modemState == STATE_P25)
|
|
||||||
p25TX.process();
|
|
||||||
|
|
||||||
if (m_nxdnEnable && m_modemState == STATE_NXDN)
|
|
||||||
nxdnTX.process();
|
|
||||||
|
|
||||||
if (m_pocsagEnable && (m_modemState == STATE_POCSAG || pocsagTX.busy()))
|
|
||||||
pocsagTX.process();
|
|
||||||
|
|
||||||
if (m_ax25Enable && (m_modemState == STATE_IDLE || m_modemState == STATE_FM))
|
|
||||||
ax25TX.process();
|
|
||||||
|
|
||||||
if (m_fmEnable && m_modemState == STATE_FM)
|
|
||||||
fm.process();
|
|
||||||
|
|
||||||
if (m_modemState == STATE_DSTARCAL)
|
|
||||||
calDStarTX.process();
|
|
||||||
|
|
||||||
if (m_modemState == STATE_DMRCAL || m_modemState == STATE_LFCAL || m_modemState == STATE_DMRCAL1K || m_modemState == STATE_DMRDMO1K)
|
|
||||||
calDMR.process();
|
|
||||||
|
|
||||||
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_P25CAL1K)
|
|
||||||
calP25.process();
|
|
||||||
|
|
||||||
if (m_modemState == STATE_NXDNCAL1K)
|
|
||||||
calNXDN.process();
|
|
||||||
|
|
||||||
if (m_modemState == STATE_POCSAGCAL)
|
|
||||||
calPOCSAG.process();
|
|
||||||
|
|
||||||
if (m_modemState == STATE_IDLE)
|
|
||||||
cwIdTX.process();
|
|
||||||
}
|
|
||||||
@@ -133,8 +133,10 @@ 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
|
DEFS_F7M=-DUSE_HAL_DRIVER -DSTM32F722xx -DSTM32F7XX -DSTM32F722_F7M -DHSE_VALUE=$(OSC) -DMADEBYMAKEFILE
|
||||||
# MMDVM_RPT_Hat F0DEI, DB9MAT, DF2ET board:
|
# MMDVM_RPT_Hat F0DEI, DB9MAT, DF2ET board:
|
||||||
DEFS_RPT_HAT=-DUSE_HAL_DRIVER -DSTM32F722xx -DSTM32F7XX -DSTM32F722_RPT_HAT -DHSE_VALUE=$(OSC) -DMADEBYMAKEFILE
|
DEFS_RPT_HAT=-DUSE_HAL_DRIVER -DSTM32F722xx -DSTM32F7XX -DSTM32F722_RPT_HAT -DHSE_VALUE=$(OSC) -DMADEBYMAKEFILE
|
||||||
# STM32F4 DVM board:
|
# RB STM32F4_DVM board:
|
||||||
DEFS_DVM=-DUSE_STDPERIPH_DRIVER -DSTM32F4XX -DSTM32F446xx -DSTM32F4_DVM -DHSE_VALUE=$(OSC) -DMADEBYMAKEFILE
|
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:
|
# MMDVM_RPT_Hat BG4TGO, BG5HHP board:
|
||||||
DEFS_RPT_HAT_TGO=-DUSE_STDPERIPH_DRIVER -DSTM32F4XX -DSTM32F40_41xxx -DSTM32F4_RPT_HAT_TGO -DHSE_VALUE=$(OSC) -DMADEBYMAKEFILE
|
DEFS_RPT_HAT_TGO=-DUSE_STDPERIPH_DRIVER -DSTM32F4XX -DSTM32F40_41xxx -DSTM32F4_RPT_HAT_TGO -DHSE_VALUE=$(OSC) -DMADEBYMAKEFILE
|
||||||
# DRCC_DVM BG7NQF board:
|
# DRCC_DVM BG7NQF board:
|
||||||
@@ -222,17 +224,29 @@ f767: LDFLAGS+=$(LDFLAGS_F767)
|
|||||||
f767: release_f7
|
f767: release_f7
|
||||||
|
|
||||||
dvm: GitVersion.h
|
dvm: GitVersion.h
|
||||||
dvm: CFLAGS+=$(CFLAGS_F4) $(DEFS_DVM)
|
dvm: CFLAGS+=$(CFLAGS_F4) $(DEFS_DVM) -DDRCC_DVM_446
|
||||||
dvm: CXXFLAGS+=$(CXXFLAGS_F4) $(DEFS_DVM)
|
dvm: CXXFLAGS+=$(CXXFLAGS_F4) $(DEFS_DVM) -DDRCC_DVM_446
|
||||||
dvm: LDFLAGS+=$(LDFLAGS_F4)
|
dvm: LDFLAGS+=$(LDFLAGS_F4)
|
||||||
dvm: release_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: GitVersion.h
|
||||||
drcc_nqf: CFLAGS+=$(CFLAGS_F4) $(DEFS_DRCC_DVM) -DDRCC_DVM_NQF
|
drcc_nqf: CFLAGS+=$(CFLAGS_F4) $(DEFS_DRCC_DVM) -DDRCC_DVM_NQF
|
||||||
drcc_nqf: CXXFLAGS+=$(CXXFLAGS_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: LDFLAGS+=$(LDFLAGS_F4)
|
||||||
drcc_nqf: release_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: GitVersion.h
|
||||||
eda405: CFLAGS+=$(CFLAGS_F4) $(DEFS_EDA_405)
|
eda405: CFLAGS+=$(CFLAGS_F4) $(DEFS_EDA_405)
|
||||||
eda405: CXXFLAGS+=$(CXXFLAGS_F4) $(DEFS_EDA_405)
|
eda405: CXXFLAGS+=$(CXXFLAGS_F4) $(DEFS_EDA_405)
|
||||||
@@ -354,14 +368,12 @@ endif
|
|||||||
deploy-pi:
|
deploy-pi:
|
||||||
ifneq ($(wildcard /usr/local/bin/stm32flash),)
|
ifneq ($(wildcard /usr/local/bin/stm32flash),)
|
||||||
-/usr/local/bin/stm32flash -i 20,-21,21:-20,21 /dev/ttyAMA0
|
-/usr/local/bin/stm32flash -i 20,-21,21:-20,21 /dev/ttyAMA0
|
||||||
-/usr/local/bin/stm32ld /dev/ttyAMA0 57600 bin/$(BINBIN_F4)
|
/usr/local/bin/stm32flash -v -w bin/$(BINBIN_F4) -g 0x0 -R /dev/ttyAMA0
|
||||||
/usr/local/bin/stm32flash -v -w bin/$(BINBIN_F4) -g 0x0 -R -c /dev/ttyAMA0
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifneq ($(wildcard /usr/bin/stm32flash),)
|
ifneq ($(wildcard /usr/bin/stm32flash),)
|
||||||
-/usr/bin/stm32flash -i 20,-21,21:-20,21 /dev/ttyAMA0
|
-/usr/bin/stm32flash -i 20,-21,21:-20,21 /dev/ttyAMA0
|
||||||
-/usr/bin/stm32ld /dev/ttyAMA0 57600 bin/$(BINBIN_F4)
|
/usr/bin/stm32flash -v -w bin/$(BINBIN_F4) -g 0x0 -R /dev/ttyAMA0
|
||||||
/usr/bin/stm32flash -v -w bin/$(BINBIN_F4) -g 0x0 -R -c /dev/ttyAMA0
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
deploy-f4m: deploy-pi
|
deploy-f4m: deploy-pi
|
||||||
@@ -372,11 +384,11 @@ deploy-eda446: deploy-pi
|
|||||||
deploy-pi-f7:
|
deploy-pi-f7:
|
||||||
ifneq ($(wildcard /usr/local/bin/stm32flash),)
|
ifneq ($(wildcard /usr/local/bin/stm32flash),)
|
||||||
-/usr/local/bin/stm32flash -i 20,-21,21:-20,21 /dev/ttyAMA0
|
-/usr/local/bin/stm32flash -i 20,-21,21:-20,21 /dev/ttyAMA0
|
||||||
/usr/local/bin/stm32flash -v -w bin/$(BINBIN_F7) -g 0x0 -R -c /dev/ttyAMA0
|
/usr/local/bin/stm32flash -v -w bin/$(BINBIN_F7) -g 0x0 -R /dev/ttyAMA0
|
||||||
|
|
||||||
else ifneq ($(wildcard /usr/bin/stm32flash),)
|
else ifneq ($(wildcard /usr/bin/stm32flash),)
|
||||||
-/usr/bin/stm32flash -i 20,-21,21:-20,21 /dev/ttyAMA0
|
-/usr/bin/stm32flash -i 20,-21,21:-20,21 /dev/ttyAMA0
|
||||||
/usr/bin/stm32flash -v -w bin/$(BINBIN_F7) -g 0x0 -R -c /dev/ttyAMA0
|
/usr/bin/stm32flash -v -w bin/$(BINBIN_F7) -g 0x0 -R /dev/ttyAMA0
|
||||||
endif
|
endif
|
||||||
|
|
||||||
deploy-f7m: deploy-pi-f7
|
deploy-f7m: deploy-pi-f7
|
||||||
|
|||||||
@@ -1,189 +0,0 @@
|
|||||||
#!/usr/bin/make
|
|
||||||
# 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
|
|
||||||
#
|
|
||||||
# USAGE: put this file in the same dir as your .ino file is.
|
|
||||||
# configure the PORT variable and ADIR at the top of the file
|
|
||||||
# to match your local configuration.
|
|
||||||
# Type make upload to compile and upload.
|
|
||||||
#
|
|
||||||
|
|
||||||
#user specific settings:
|
|
||||||
#where to find the IDE
|
|
||||||
ADIR:=$(HOME)/.arduino15
|
|
||||||
#which serial port to use (add a file with SUBSYSTEMS=="usb",
|
|
||||||
#ATTRS{product}=="Arduino Due Prog. Port", ATTRS{idProduct}=="003d",
|
|
||||||
#ATTRS{idVendor}=="2341", SYMLINK+="arduino_due" in /etc/udev/rules.d/
|
|
||||||
#to get this working). Do not prefix the port with /dev/, just take
|
|
||||||
#the basename.
|
|
||||||
PORT:=ttyACM0
|
|
||||||
#if you want to verify the bossac upload, define this to -v
|
|
||||||
VERIFY:=-v
|
|
||||||
|
|
||||||
|
|
||||||
#end of user configuration.
|
|
||||||
|
|
||||||
|
|
||||||
#then some general settings. They should not be necessary to modify.
|
|
||||||
#CXX:=$(ADIR)/tools/g++_arm_none_eabi/bin/arm-none-eabi-g++
|
|
||||||
CXX:=$(ADIR)/packages/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/arm-none-eabi-g++
|
|
||||||
#CC:=$(ADIR)/tools/g++_arm_none_eabi/bin/arm-none-eabi-gcc
|
|
||||||
CC:=$(ADIR)/packages/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/arm-none-eabi-gcc
|
|
||||||
OBJCOPY:=$(ADIR)/packages/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/arm-none-eabi-objcopy
|
|
||||||
|
|
||||||
C:=$(CC)
|
|
||||||
#SAM:=arduino/sam/
|
|
||||||
SAM:=$(ADIR)/packages/arduino/hardware/sam/1.6.11
|
|
||||||
#CMSIS:=arduino/sam/system/CMSIS/
|
|
||||||
#LIBSAM:=arduino/sam/system/libsam
|
|
||||||
TMPDIR:=$(PWD)/build
|
|
||||||
AR:=$(ADIR)/tools/g++_arm_none_eabi/bin/arm-none-eabi-ar
|
|
||||||
AR:=$(ADIR)/packages/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/arm-none-eabi-ar
|
|
||||||
|
|
||||||
|
|
||||||
#all these values are hard coded and should maybe be configured somehow else,
|
|
||||||
#like olikraus does in his makefile.
|
|
||||||
DEFINES:=-Dprintf=iprintf -DF_CPU=84000000 -DARDUINO=10611 -D__SAM3X8E__ -DUSB_PID=0x003e -DUSB_VID=0x2341 -DUSBCON \
|
|
||||||
-DARDUINO_SAM_DUE -DARDUINO_ARCH_SAM '-DUSB_MANUFACTURER="Arduino LLC"' '-DUSB_PRODUCT="Arduino Due"' \
|
|
||||||
-DMADEBYMAKEFILE
|
|
||||||
|
|
||||||
INCLUDES:=-I$(SAM)/system/libsam -I$(SAM)/system/CMSIS/CMSIS/Include/ \
|
|
||||||
-I$(SAM)/system/CMSIS/Device/ATMEL/ -I$(SAM)/cores/arduino \
|
|
||||||
-I$(SAM)/variants/arduino_due_x
|
|
||||||
|
|
||||||
#also include the current dir for convenience
|
|
||||||
INCLUDES += -I.
|
|
||||||
|
|
||||||
#compilation flags common to both c and c++
|
|
||||||
COMMON_FLAGS:=-g -Os -w -ffunction-sections -fdata-sections -nostdlib \
|
|
||||||
--param max-inline-insns-single=500 -mcpu=cortex-m3 -mthumb \
|
|
||||||
-fno-threadsafe-statics
|
|
||||||
#for compiling c (do not warn, this is not our code)
|
|
||||||
CFLAGS:=$(COMMON_FLAGS) -std=gnu11
|
|
||||||
#for compiling c++
|
|
||||||
CXXFLAGS:=$(COMMON_FLAGS) -fno-rtti -fno-exceptions -std=gnu++11 -Wall -Wextra
|
|
||||||
|
|
||||||
#let the results be named after the project
|
|
||||||
PROJNAME:=$(shell basename *.ino .ino)
|
|
||||||
|
|
||||||
#we will make a new mainfile from the ino file.
|
|
||||||
NEWMAINFILE:=$(TMPDIR)/$(PROJNAME).ino.cpp
|
|
||||||
|
|
||||||
#our own sourcefiles is the (converted) ino file and any local cpp files
|
|
||||||
MYSRCFILES:=$(NEWMAINFILE) $(shell ls *.cpp 2>/dev/null)
|
|
||||||
MYOBJFILES:=$(addsuffix .o,$(addprefix $(TMPDIR)/,$(notdir $(MYSRCFILES))))
|
|
||||||
|
|
||||||
#These source files are the ones forming core.a
|
|
||||||
CORESRCXX:=$(shell ls ${SAM}/cores/arduino/*.cpp ${SAM}/cores/arduino/USB/*.cpp ${SAM}/variants/arduino_due_x/variant.cpp)
|
|
||||||
CORESRC:=$(shell ls ${SAM}/cores/arduino/*.c)
|
|
||||||
|
|
||||||
#hey this one is needed too: $(SAM)/cores/arduino/wiring_pulse_asm.S" add -x assembler-with-cpp
|
|
||||||
#and this one: /1.6.11/cores/arduino/avr/dtostrf.c but it seems to work
|
|
||||||
#anyway, probably because I do not use that functionality.
|
|
||||||
|
|
||||||
#convert the core source files to object files. assume no clashes.
|
|
||||||
COREOBJSXX:=$(addprefix $(TMPDIR)/core/,$(notdir $(CORESRCXX)) )
|
|
||||||
COREOBJSXX:=$(addsuffix .o,$(COREOBJSXX))
|
|
||||||
COREOBJS:=$(addprefix $(TMPDIR)/core/,$(notdir $(CORESRC)) )
|
|
||||||
COREOBJS:=$(addsuffix .o,$(COREOBJS))
|
|
||||||
|
|
||||||
default:
|
|
||||||
@echo default rule, does nothing. Try make compile or make upload.
|
|
||||||
|
|
||||||
#This rule is good to just make sure stuff compiles, without having to wait
|
|
||||||
#for bossac.
|
|
||||||
compile: GitVersion.h $(TMPDIR)/$(PROJNAME).elf $(TMPDIR)/$(PROJNAME).bin
|
|
||||||
|
|
||||||
#This is a make rule template to create object files from the source files.
|
|
||||||
# arg 1=src file
|
|
||||||
# arg 2=object file
|
|
||||||
# arg 3= XX if c++, empty if c
|
|
||||||
define OBJ_template
|
|
||||||
$(2): $(1)
|
|
||||||
$(C$(3)) -MD -c $(C$(3)FLAGS) $(DEFINES) $(INCLUDES) $(1) -o $(2)
|
|
||||||
endef
|
|
||||||
#now invoke the template both for c++ sources
|
|
||||||
$(foreach src,$(CORESRCXX), $(eval $(call OBJ_template,$(src),$(addsuffix .o,$(addprefix $(TMPDIR)/core/,$(notdir $(src)))),XX) ) )
|
|
||||||
#...and for c sources:
|
|
||||||
$(foreach src,$(CORESRC), $(eval $(call OBJ_template,$(src),$(addsuffix .o,$(addprefix $(TMPDIR)/core/,$(notdir $(src)))),) ) )
|
|
||||||
|
|
||||||
#and our own c++ sources
|
|
||||||
$(foreach src,$(MYSRCFILES), $(eval $(call OBJ_template,$(src),$(addsuffix .o,$(addprefix $(TMPDIR)/,$(notdir $(src)))),XX) ) )
|
|
||||||
|
|
||||||
|
|
||||||
clean:
|
|
||||||
test ! -d $(TMPDIR) || rm -rf $(TMPDIR)
|
|
||||||
$(RM) GitVersion.h
|
|
||||||
|
|
||||||
.PHONY: .FORCE upload default
|
|
||||||
|
|
||||||
$(TMPDIR):
|
|
||||||
mkdir -p $(TMPDIR)
|
|
||||||
|
|
||||||
$(TMPDIR)/core:
|
|
||||||
mkdir -p $(TMPDIR)/core
|
|
||||||
|
|
||||||
#creates the cpp file from the .ino file
|
|
||||||
$(NEWMAINFILE): $(PROJNAME).ino
|
|
||||||
cat $(SAM)/cores/arduino/main.cpp > $(NEWMAINFILE)
|
|
||||||
cat $(PROJNAME).ino >> $(NEWMAINFILE)
|
|
||||||
echo 'extern "C" void __cxa_pure_virtual() {while (true);}' >> $(NEWMAINFILE)
|
|
||||||
|
|
||||||
#include the dependencies for our own files
|
|
||||||
-include $(MYOBJFILES:.o=.d)
|
|
||||||
|
|
||||||
#create the core library from the core objects. Do this EXACTLY as the
|
|
||||||
#arduino IDE does it, seems *really* picky about this.
|
|
||||||
#Sorry for the hard coding.
|
|
||||||
$(TMPDIR)/core.a: $(TMPDIR)/core $(COREOBJS) $(COREOBJSXX)
|
|
||||||
$(AR) rcs $(TMPDIR)/core.a $(TMPDIR)/core/wiring_shift.c.o
|
|
||||||
$(AR) rcs $(TMPDIR)/core.a $(TMPDIR)/core/wiring_analog.c.o
|
|
||||||
$(AR) rcs $(TMPDIR)/core.a $(TMPDIR)/core/itoa.c.o
|
|
||||||
$(AR) rcs $(TMPDIR)/core.a $(TMPDIR)/core/cortex_handlers.c.o
|
|
||||||
$(AR) rcs $(TMPDIR)/core.a $(TMPDIR)/core/hooks.c.o
|
|
||||||
$(AR) rcs $(TMPDIR)/core.a $(TMPDIR)/core/wiring.c.o
|
|
||||||
$(AR) rcs $(TMPDIR)/core.a $(TMPDIR)/core/WInterrupts.c.o
|
|
||||||
$(AR) rcs $(TMPDIR)/core.a $(TMPDIR)/core/syscalls_sam3.c.o
|
|
||||||
$(AR) rcs $(TMPDIR)/core.a $(TMPDIR)/core/iar_calls_sam3.c.o
|
|
||||||
$(AR) rcs $(TMPDIR)/core.a $(TMPDIR)/core/wiring_digital.c.o
|
|
||||||
$(AR) rcs $(TMPDIR)/core.a $(TMPDIR)/core/Print.cpp.o
|
|
||||||
$(AR) rcs $(TMPDIR)/core.a $(TMPDIR)/core/USARTClass.cpp.o
|
|
||||||
$(AR) rcs $(TMPDIR)/core.a $(TMPDIR)/core/WString.cpp.o
|
|
||||||
$(AR) rcs $(TMPDIR)/core.a $(TMPDIR)/core/PluggableUSB.cpp.o
|
|
||||||
$(AR) rcs $(TMPDIR)/core.a $(TMPDIR)/core/USBCore.cpp.o
|
|
||||||
$(AR) rcs $(TMPDIR)/core.a $(TMPDIR)/core/CDC.cpp.o
|
|
||||||
$(AR) rcs $(TMPDIR)/core.a $(TMPDIR)/core/wiring_pulse.cpp.o
|
|
||||||
$(AR) rcs $(TMPDIR)/core.a $(TMPDIR)/core/UARTClass.cpp.o
|
|
||||||
$(AR) rcs $(TMPDIR)/core.a $(TMPDIR)/core/main.cpp.o
|
|
||||||
$(AR) rcs $(TMPDIR)/core.a $(TMPDIR)/core/new.cpp.o
|
|
||||||
$(AR) rcs $(TMPDIR)/core.a $(TMPDIR)/core/watchdog.cpp.o
|
|
||||||
$(AR) rcs $(TMPDIR)/core.a $(TMPDIR)/core/Stream.cpp.o
|
|
||||||
$(AR) rcs $(TMPDIR)/core.a $(TMPDIR)/core/RingBuffer.cpp.o
|
|
||||||
$(AR) rcs $(TMPDIR)/core.a $(TMPDIR)/core/IPAddress.cpp.o
|
|
||||||
$(AR) rcs $(TMPDIR)/core.a $(TMPDIR)/core/Reset.cpp.o
|
|
||||||
$(AR) rcs $(TMPDIR)/core.a $(TMPDIR)/core/WMath.cpp.o
|
|
||||||
$(AR) rcs $(TMPDIR)/core.a $(TMPDIR)/core/variant.cpp.o
|
|
||||||
|
|
||||||
#link our own object files with core to form the elf file
|
|
||||||
$(TMPDIR)/$(PROJNAME).elf: $(TMPDIR)/core.a $(TMPDIR)/core/syscalls_sam3.c.o $(MYOBJFILES)
|
|
||||||
$(CC) -mcpu=cortex-m3 -mthumb -Os -Wl,--gc-sections -T$(SAM)/variants/arduino_due_x/linker_scripts/gcc/flash.ld -Wl,-Map,$(NEWMAINFILE).map -o $@ -L$(TMPDIR) -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--entry=Reset_Handler -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align -Wl,--start-group -u _sbrk -u link -u _close -u _fstat -u _isatty -u _lseek -u _read -u _write -u _exit -u kill -u _getpid $(MYOBJFILES) $(TMPDIR)/core/variant.cpp.o $(SAM)/variants/arduino_due_x/libsam_sam3x8e_gcc_rel.a $(SAM)/system/CMSIS/CMSIS/Lib/GCC/libarm_cortexM3l_math.a $(TMPDIR)/core.a -Wl,--end-group -lm -gcc
|
|
||||||
|
|
||||||
#copy from the hex to our bin file (why?)
|
|
||||||
$(TMPDIR)/$(PROJNAME).bin: $(TMPDIR)/$(PROJNAME).elf
|
|
||||||
$(OBJCOPY) -O binary $< $@
|
|
||||||
|
|
||||||
#upload to the arduino by first resetting it (stty) and the running bossac
|
|
||||||
upload: compile
|
|
||||||
stty -F /dev/$(PORT) cs8 1200 hupcl
|
|
||||||
$(ADIR)/packages/arduino/tools/bossac/1.6.1-arduino/bossac -i --port=$(PORT) -U false -e -w $(VERIFY) -b $(TMPDIR)/$(PROJNAME).bin -R
|
|
||||||
|
|
||||||
# Export the current git version if the index file exists, else 000...
|
|
||||||
GitVersion.h: .FORCE
|
|
||||||
ifneq ("$(wildcard .git/index)","")
|
|
||||||
echo "#define GITVERSION \"$(shell git rev-parse --short HEAD)\"" > $@
|
|
||||||
else
|
|
||||||
echo "#define GITVERSION \"0000000\"" > $@
|
|
||||||
endif
|
|
||||||
|
|
||||||
.FORCE:
|
|
||||||
-165
@@ -1,165 +0,0 @@
|
|||||||
# The name for the project
|
|
||||||
TARGET:=mmdvm
|
|
||||||
|
|
||||||
# The CPU architecture (will be used for -mcpu)
|
|
||||||
MCPU:=cortex-m3
|
|
||||||
MCU:=STM32F105xC
|
|
||||||
|
|
||||||
# The source files of the project
|
|
||||||
CSRC:=
|
|
||||||
CXXSRC:=$(wildcard *.cpp)
|
|
||||||
|
|
||||||
# Include directory for the system include files and system source file
|
|
||||||
SYSDIR:=system_stm32f1xx
|
|
||||||
SYSSRC:=$(SYSDIR)/system_stm32f1xx.c
|
|
||||||
|
|
||||||
# Other include directories
|
|
||||||
INCDIR:=
|
|
||||||
|
|
||||||
# Definitions
|
|
||||||
CDEFS:=
|
|
||||||
CXXDEFS:=
|
|
||||||
|
|
||||||
# The name of the startup file which matches to the architecture (MCPU)
|
|
||||||
STARTUP:=$(SYSDIR)/startup_stm32f105xc.S
|
|
||||||
STARTUP_DEFS=
|
|
||||||
|
|
||||||
# Include directory for CMSIS
|
|
||||||
CMSISDIR:=STM32F10X_Lib/CMSIS
|
|
||||||
|
|
||||||
# Libraries
|
|
||||||
LIBDIR:=
|
|
||||||
LIBS:=-larm_cortexM3l_math
|
|
||||||
|
|
||||||
# Name of the linker script
|
|
||||||
LDSCRIPT:=$(SYSDIR)/gcc.ld
|
|
||||||
|
|
||||||
# Target objects and binaries directory
|
|
||||||
OBJDIR:=obj
|
|
||||||
BINDIR:=bin
|
|
||||||
|
|
||||||
# Port definition for programming via bootloader (using stm32flash)
|
|
||||||
BL_PORT:=ttyUSB0
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Internal Variables
|
|
||||||
ELF:=$(BINDIR)/$(TARGET).elf
|
|
||||||
HEX:=$(BINDIR)/$(TARGET).hex
|
|
||||||
DIS:=$(BINDIR)/$(TARGET).dis
|
|
||||||
MAP:=$(BINDIR)/$(TARGET).map
|
|
||||||
OBJ:=$(CSRC:%.c=$(OBJDIR)/%.o) $(CXXSRC:%.cpp=$(OBJDIR)/%.o)
|
|
||||||
OBJ+=$(SYSSRC:$(SYSDIR)/%.c=$(OBJDIR)/%.o) $(STARTUP:$(SYSDIR)/%.S=$(OBJDIR)/%.o)
|
|
||||||
|
|
||||||
# Replace standard build tools by arm tools
|
|
||||||
CC:=arm-none-eabi-gcc
|
|
||||||
CXX:=arm-none-eabi-g++
|
|
||||||
AS:=arm-none-eabi-gcc
|
|
||||||
LD:=arm-none-eabi-g++
|
|
||||||
OBJCOPY:=arm-none-eabi-objcopy
|
|
||||||
OBJDUMP:=arm-none-eabi-objdump
|
|
||||||
SIZE:=arm-none-eabi-size
|
|
||||||
|
|
||||||
# Common flags
|
|
||||||
COMMON_FLAGS =-mthumb -mlittle-endian -mcpu=$(MCPU)
|
|
||||||
COMMON_FLAGS+= -Wall
|
|
||||||
COMMON_FLAGS+= -I. -I$(CMSISDIR)/Include -I$(CMSISDIR)/Device/ST/STM32F1xx/Include -I$(SYSDIR)
|
|
||||||
COMMON_FLAGS+= $(addprefix -I,$(INCDIR))
|
|
||||||
COMMON_FLAGS+= -D$(MCU) -DMADEBYMAKEFILE -DSTM32F1
|
|
||||||
COMMON_FLAGS+= -Os -flto -ffunction-sections -fdata-sections
|
|
||||||
COMMON_FLAGS+= -g
|
|
||||||
# Assembler flags
|
|
||||||
ASFLAGS:=$(COMMON_FLAGS)
|
|
||||||
# C flags
|
|
||||||
CFLAGS:=$(COMMON_FLAGS) $(addprefix -D,$(CDEFS))
|
|
||||||
CFLAGS+= -std=gnu11 -nostdlib
|
|
||||||
# CXX flags
|
|
||||||
CXXFLAGS:=$(COMMON_FLAGS) $(addprefix -D,$(CXXDEFS))
|
|
||||||
CXXFLAGS+= -nostdlib -fno-exceptions -fno-rtti
|
|
||||||
# LD flags
|
|
||||||
LDFLAGS:=$(COMMON_FLAGS) -Wl,--gc-sections -Wl,-Map=$(MAP) -Wl,--no-wchar-size-warning
|
|
||||||
LDFLAGS+= --specs=nosys.specs --specs=nano.specs
|
|
||||||
LDFLAGS+= -L$(CMSISDIR)/Lib/GCC/ $(addprefix -L,$(LIBDIR))
|
|
||||||
LDLIBS:=-T$(LDSCRIPT) $(LIBS)
|
|
||||||
|
|
||||||
# Dependecies
|
|
||||||
DEPENDS:=$(CSRC:%.c=$(OBJDIR)/%.d) $(CXXSRC:%.cpp=$(OBJDIR)/%.d)
|
|
||||||
|
|
||||||
|
|
||||||
# Additional Suffixes
|
|
||||||
.SUFFIXES: .elf .hex
|
|
||||||
|
|
||||||
# Targets
|
|
||||||
.PHONY: all
|
|
||||||
all: GitVersion.h $(DIS) $(HEX)
|
|
||||||
$(SIZE) $(ELF)
|
|
||||||
|
|
||||||
.PHONY: program
|
|
||||||
program: $(HEX) $(ELF)
|
|
||||||
openocd -f openocd.cfg \
|
|
||||||
-c "program $(HEX) verify reset exit"
|
|
||||||
$(SIZE) $(ELF)
|
|
||||||
|
|
||||||
.PHONY: program_bl
|
|
||||||
program_bl: $(HEX) $(ELF)
|
|
||||||
stm32flash -w $(HEX) -v /dev/$(BL_PORT)
|
|
||||||
$(SIZE) $(ELF)
|
|
||||||
|
|
||||||
.PHONY: run
|
|
||||||
run: $(HEX) $(ELF)
|
|
||||||
openocd -f openocd.cfg \
|
|
||||||
-c "init" -c "reset" -c "exit"
|
|
||||||
|
|
||||||
.PHONY: debug
|
|
||||||
debug: $(ELF)
|
|
||||||
./debug.sh $(ELF)
|
|
||||||
|
|
||||||
.PHONY: clean
|
|
||||||
clean:
|
|
||||||
$(RM) $(OBJ) $(HEX) $(ELF) $(DIS) $(MAP) $(DEPENDS) GitVersion.h
|
|
||||||
|
|
||||||
# implicit rules
|
|
||||||
.elf.hex:
|
|
||||||
$(OBJCOPY) -O ihex $< $@
|
|
||||||
|
|
||||||
$(OBJDIR)/%.o: %.c
|
|
||||||
$(CC) -MMD $(CFLAGS) -c $< -o $@
|
|
||||||
|
|
||||||
$(OBJDIR)/%.o: %.cpp
|
|
||||||
$(CXX) -MMD $(CXXFLAGS) -c $< -o $@
|
|
||||||
|
|
||||||
$(OBJDIR)/%.o: $(SYSDIR)/%.c
|
|
||||||
$(CC) $(CFLAGS) -c $< -o $@
|
|
||||||
|
|
||||||
$(OBJDIR)/%.o: $(SYSDIR)/%.S
|
|
||||||
$(AS) $(ASFLAGS) -c $< -o $@
|
|
||||||
|
|
||||||
# explicit rules
|
|
||||||
$(OBJDIR):
|
|
||||||
mkdir -p $(OBJDIR)
|
|
||||||
|
|
||||||
$(BINDIR):
|
|
||||||
mkdir -p $(BINDIR)
|
|
||||||
|
|
||||||
$(ELF): $(OBJDIR) $(BINDIR) $(OBJ)
|
|
||||||
$(LD) $(OBJ) $(LDFLAGS) $(LDLIBS) -o $@
|
|
||||||
|
|
||||||
$(DIS): $(ELF)
|
|
||||||
$(OBJDUMP) -S $< > $@
|
|
||||||
|
|
||||||
# include dependecies
|
|
||||||
-include $(DEPENDS)
|
|
||||||
|
|
||||||
# Export the current git version if the index file exists, else 000...
|
|
||||||
GitVersion.h:
|
|
||||||
ifdef SYSTEMROOT
|
|
||||||
echo #define GITVERSION "0000000" > $@
|
|
||||||
else ifdef SystemRoot
|
|
||||||
echo #define GITVERSION "0000000" > $@
|
|
||||||
else
|
|
||||||
ifneq ("$(wildcard .git/index)","")
|
|
||||||
echo "#define GITVERSION \"$(shell git rev-parse --short HEAD)\"" > $@
|
|
||||||
else
|
|
||||||
echo "#define GITVERSION \"0000000\"" > $@
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
+6
-1
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2009-2018 by Jonathan Naylor G4KLX
|
* Copyright (C) 2009-2018,2020 by Jonathan Naylor G4KLX
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -17,6 +17,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
|
|
||||||
|
#if defined(MODE_NXDN)
|
||||||
|
|
||||||
#include "Globals.h"
|
#include "Globals.h"
|
||||||
#include "NXDNRX.h"
|
#include "NXDNRX.h"
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
@@ -403,3 +406,5 @@ void CNXDNRX::writeRSSIData(uint8_t* data)
|
|||||||
m_rssiCount = 0U;
|
m_rssiCount = 0U;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2015,2016,2017,2018 by Jonathan Naylor G4KLX
|
* Copyright (C) 2015,2016,2017,2018,2020 by Jonathan Naylor G4KLX
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -16,10 +16,13 @@
|
|||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "Config.h"
|
||||||
|
|
||||||
|
#if defined(MODE_NXDN)
|
||||||
|
|
||||||
#if !defined(NXDNRX_H)
|
#if !defined(NXDNRX_H)
|
||||||
#define NXDNRX_H
|
#define NXDNRX_H
|
||||||
|
|
||||||
#include "Config.h"
|
|
||||||
#include "NXDNDefines.h"
|
#include "NXDNDefines.h"
|
||||||
|
|
||||||
enum NXDNRX_STATE {
|
enum NXDNRX_STATE {
|
||||||
@@ -67,3 +70,5 @@ private:
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|||||||
+9
-2
@@ -18,6 +18,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
|
|
||||||
|
#if defined(MODE_NXDN)
|
||||||
|
|
||||||
#include "Globals.h"
|
#include "Globals.h"
|
||||||
#include "NXDNTX.h"
|
#include "NXDNTX.h"
|
||||||
|
|
||||||
@@ -81,7 +84,8 @@ void CNXDNTX::process()
|
|||||||
m_poBuffer[m_poLen++] = NXDN_PREAMBLE[2U];
|
m_poBuffer[m_poLen++] = NXDN_PREAMBLE[2U];
|
||||||
} else {
|
} else {
|
||||||
for (uint8_t i = 0U; i < NXDN_FRAME_LENGTH_BYTES; i++) {
|
for (uint8_t i = 0U; i < NXDN_FRAME_LENGTH_BYTES; i++) {
|
||||||
uint8_t c = m_buffer.get();
|
uint8_t c = 0U;
|
||||||
|
m_buffer.get(c);
|
||||||
m_poBuffer[m_poLen++] = c;
|
m_poBuffer[m_poLen++] = c;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -171,7 +175,7 @@ void CNXDNTX::writeByte(uint8_t c)
|
|||||||
|
|
||||||
void CNXDNTX::writeSilence()
|
void CNXDNTX::writeSilence()
|
||||||
{
|
{
|
||||||
q15_t inBuffer[4U] = {0x00U, 0x00U, 0x00U, 0x00U};
|
q15_t inBuffer[4U] = {0, 0, 0, 0};
|
||||||
q15_t intBuffer[NXDN_RADIO_SYMBOL_LENGTH * 4U];
|
q15_t intBuffer[NXDN_RADIO_SYMBOL_LENGTH * 4U];
|
||||||
q15_t outBuffer[NXDN_RADIO_SYMBOL_LENGTH * 4U];
|
q15_t outBuffer[NXDN_RADIO_SYMBOL_LENGTH * 4U];
|
||||||
|
|
||||||
@@ -199,3 +203,6 @@ void CNXDNTX::setParams(uint8_t txHang)
|
|||||||
{
|
{
|
||||||
m_txHang = txHang * 600U;
|
m_txHang = txHang * 600U;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -16,12 +16,14 @@
|
|||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "Config.h"
|
||||||
|
|
||||||
|
#if defined(MODE_NXDN)
|
||||||
|
|
||||||
#if !defined(NXDNTX_H)
|
#if !defined(NXDNTX_H)
|
||||||
#define NXDNTX_H
|
#define NXDNTX_H
|
||||||
|
|
||||||
#include "Config.h"
|
#include "RingBuffer.h"
|
||||||
|
|
||||||
#include "SerialRB.h"
|
|
||||||
|
|
||||||
class CNXDNTX {
|
class CNXDNTX {
|
||||||
public:
|
public:
|
||||||
@@ -38,7 +40,7 @@ public:
|
|||||||
void setParams(uint8_t txHang);
|
void setParams(uint8_t txHang);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CSerialRB m_buffer;
|
CRingBuffer<uint8_t> m_buffer;
|
||||||
arm_fir_interpolate_instance_q15 m_modFilter;
|
arm_fir_interpolate_instance_q15 m_modFilter;
|
||||||
arm_fir_instance_q15 m_sincFilter;
|
arm_fir_instance_q15 m_sincFilter;
|
||||||
q15_t m_modState[16U]; // blockSize + phaseLength - 1, 4 + 9 - 1 plus some spare
|
q15_t m_modState[16U]; // blockSize + phaseLength - 1, 4 + 9 - 1 plus some spare
|
||||||
@@ -55,3 +57,6 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2009-2017 by Jonathan Naylor G4KLX
|
* Copyright (C) 2009-2017,2020 by Jonathan Naylor G4KLX
|
||||||
* Copyright (C) 2018 by Bryan Biedenkapp <gatekeep@gmail.com>
|
* Copyright (C) 2018 by Bryan Biedenkapp <gatekeep@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@@ -18,6 +18,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
|
|
||||||
|
#if defined(MODE_P25)
|
||||||
|
|
||||||
#include "Globals.h"
|
#include "Globals.h"
|
||||||
#include "P25RX.h"
|
#include "P25RX.h"
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
@@ -535,3 +538,6 @@ void CP25RX::writeRSSILdu(uint8_t* ldu)
|
|||||||
m_rssiAccum = 0U;
|
m_rssiAccum = 0U;
|
||||||
m_rssiCount = 0U;
|
m_rssiCount = 0U;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2015,2016,2017 by Jonathan Naylor G4KLX
|
* Copyright (C) 2015,2016,2017,2020 by Jonathan Naylor G4KLX
|
||||||
* Copyright (C) 2018 by Bryan Biedenkapp <gatekeep@gmail.com>
|
* Copyright (C) 2018 by Bryan Biedenkapp <gatekeep@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@@ -17,10 +17,13 @@
|
|||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "Config.h"
|
||||||
|
|
||||||
|
#if defined(MODE_P25)
|
||||||
|
|
||||||
#if !defined(P25RX_H)
|
#if !defined(P25RX_H)
|
||||||
#define P25RX_H
|
#define P25RX_H
|
||||||
|
|
||||||
#include "Config.h"
|
|
||||||
#include "P25Defines.h"
|
#include "P25Defines.h"
|
||||||
|
|
||||||
enum P25RX_STATE {
|
enum P25RX_STATE {
|
||||||
@@ -72,3 +75,6 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
|
|
||||||
|
#if defined(MODE_P25)
|
||||||
|
|
||||||
#include "Globals.h"
|
#include "Globals.h"
|
||||||
#include "P25TX.h"
|
#include "P25TX.h"
|
||||||
|
|
||||||
@@ -75,9 +78,11 @@ void CP25TX::process()
|
|||||||
for (uint16_t i = 0U; i < m_txDelay; i++)
|
for (uint16_t i = 0U; i < m_txDelay; i++)
|
||||||
m_poBuffer[m_poLen++] = P25_START_SYNC;
|
m_poBuffer[m_poLen++] = P25_START_SYNC;
|
||||||
} else {
|
} else {
|
||||||
uint8_t length = m_buffer.get();
|
uint8_t length;
|
||||||
|
m_buffer.get(length);
|
||||||
for (uint8_t i = 0U; i < length; i++) {
|
for (uint8_t i = 0U; i < length; i++) {
|
||||||
uint8_t c = m_buffer.get();
|
uint8_t c = 0U;
|
||||||
|
m_buffer.get(c);
|
||||||
m_poBuffer[m_poLen++] = c;
|
m_poBuffer[m_poLen++] = c;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -168,7 +173,7 @@ void CP25TX::writeByte(uint8_t c)
|
|||||||
|
|
||||||
void CP25TX::writeSilence()
|
void CP25TX::writeSilence()
|
||||||
{
|
{
|
||||||
q15_t inBuffer[4U] = {0x00U, 0x00U, 0x00U, 0x00U};
|
q15_t inBuffer[4U] = {0, 0, 0, 0};
|
||||||
q15_t intBuffer[P25_RADIO_SYMBOL_LENGTH * 4U];
|
q15_t intBuffer[P25_RADIO_SYMBOL_LENGTH * 4U];
|
||||||
q15_t outBuffer[P25_RADIO_SYMBOL_LENGTH * 4U];
|
q15_t outBuffer[P25_RADIO_SYMBOL_LENGTH * 4U];
|
||||||
|
|
||||||
@@ -196,3 +201,6 @@ void CP25TX::setParams(uint8_t txHang)
|
|||||||
{
|
{
|
||||||
m_txHang = txHang * 1200U;
|
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