├── .gitignore ├── openocd.cfg ├── MMDVM_Specification_20151222.pdf ├── .gitmodules ├── Version.h ├── FMSamplePairPack.h ├── CalRSSI.h ├── Tools ├── emphasis.txt └── FMGenerateFilterCoefficients.py ├── FMCTCSSTX.h ├── Utils.h ├── CalDStarTX.h ├── FMTimeout.h ├── CWIdTX.h ├── CalPOCSAG.h ├── FMBlanking.h ├── Debug.h ├── CalDStarRX.h ├── CalNXDN.h ├── DMRRX.h ├── DMRSlotType.h ├── CalP25.h ├── FMTimer.h ├── FMCTCSSRX.h ├── FMNoiseSquelch.h ├── FMUpSampler.h ├── CalPOCSAG.cpp ├── CalFM.h ├── FMDownSampler.h ├── FMKeyer.h ├── CalDMR.h ├── POCSAGTX.h ├── DMRIdleRX.h ├── DMRDMOTX.h ├── FMTimer.cpp ├── DStarTX.h ├── CalRSSI.cpp ├── YSFTX.h ├── Utils.cpp ├── DMRRX.cpp ├── P25TX.h ├── STM32Utils.h ├── NXDNTX.h ├── RingBuffer.h ├── NXDNDefines.h ├── DMRSlotRX.h ├── YSFRX.h ├── NXDNRX.h ├── DMRDMORX.h ├── FMDownSampler.cpp ├── FMBlanking.cpp ├── STMUART.h ├── FMTimeout.cpp ├── P25RX.h ├── README.md ├── YSFDefines.h ├── IOPins.h ├── DStarRX.h ├── STMUART.cpp ├── FMUpSampler.cpp ├── DMRTX.h ├── SerialArduino.cpp ├── RingBuffer.impl.h ├── pins ├── pins_f4_discovery.h ├── pins_f4_pi.h ├── pins_f7_pi.h ├── pins_f4_f4m.h ├── pins_f7_f7m.h ├── pins_f4_stm32eda.h ├── pins_f4_stm32dvm_v3.h ├── pins_f7_stm32dvm_v5.h ├── pins_f4_nucleo_arduino.h ├── pins_f7_nucleo.h ├── pins_f4_drcc_hhp446.h ├── pins_f4_drcc_nqf.h ├── pins_f7_rpt_hat.h └── pins_f4_rpt_tgo.h ├── DStarDefines.h ├── CalFM.cpp ├── FMDirectForm1.h ├── CalDStarRX.cpp ├── FMCTCSSTX.cpp ├── FMNoiseSquelch.cpp ├── stm32f722_link.ld ├── stm32f767_link.ld ├── stm32f4xx_link.ld ├── CalNXDN.cpp ├── SerialPort.h ├── MMDVM.ino ├── Config.h └── MMDVM.cpp /.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | obj/ 3 | bin/ 4 | GitVersion.h 5 | build/ 6 | -------------------------------------------------------------------------------- /openocd.cfg: -------------------------------------------------------------------------------- 1 | source [find interface/stlink-v2.cfg] 2 | source [find target/stm32f1x.cfg] 3 | -------------------------------------------------------------------------------- /MMDVM_Specification_20151222.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g4klx/MMDVM/HEAD/MMDVM_Specification_20151222.pdf -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "STM32F4XX_Lib"] 2 | path = STM32F4XX_Lib 3 | url = https://github.com/juribeparada/STM32F4XX_Lib.git 4 | [submodule "STM32F7XX_Lib"] 5 | path = STM32F7XX_Lib 6 | url = https://github.com/juribeparada/STM32F7XX_Lib.git 7 | -------------------------------------------------------------------------------- /Version.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020,2021,2022,2025 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #if !defined(VERSION_H) 20 | #define VERSION_H 21 | 22 | #define VERSION "20240113" 23 | 24 | #endif 25 | 26 | -------------------------------------------------------------------------------- /FMSamplePairPack.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 by Jonathan Naylor G4KLX 3 | * Copyright (C) 2020 by Geoffrey Merck F4FXL - KC3FRA 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 | */ 19 | 20 | #include "Config.h" 21 | 22 | #if defined(MODE_FM) 23 | 24 | #if !defined(TSAMPLEPACK_H) 25 | #define TSAMPLEPACK_H 26 | 27 | struct TSamplePairPack { 28 | uint8_t byte0; 29 | uint8_t byte1; 30 | uint8_t byte2; 31 | }; 32 | 33 | #endif 34 | 35 | #endif 36 | 37 | -------------------------------------------------------------------------------- /CalRSSI.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #if !defined(CALRSSI_H) 20 | #define CALRSSI_H 21 | 22 | #include "Config.h" 23 | 24 | class CCalRSSI { 25 | public: 26 | CCalRSSI(); 27 | 28 | void samples(const uint16_t* rssi, uint8_t length); 29 | 30 | private: 31 | uint32_t m_count; 32 | uint32_t m_accum; 33 | uint16_t m_min; 34 | uint16_t m_max; 35 | }; 36 | 37 | #endif 38 | 39 | -------------------------------------------------------------------------------- /Tools/emphasis.txt: -------------------------------------------------------------------------------- 1 | % GNU Octave script to generate pre and deemphasis filters 2 | % https://dsp.stackexchange.com/questions/34605/biquad-cookbook-formula-for-broadcast-fm-de-emphasis 3 | % PACKAGES 4 | 5 | pkg load control 6 | pkg load signal 7 | 8 | clear all; 9 | clc; 10 | 11 | fs = 24000; 12 | samplingtime = 1/fs; 13 | 14 | % analog prototype 15 | A2 = [1]; 16 | B2 = [0.000075 1]; 17 | 18 | % Pre 19 | Ds = tf(B2, A2); 20 | % De 21 | % Ds = tf(A2, B2); 22 | 23 | Ds = Ds/dcgain(Ds); 24 | 25 | % MZT 26 | T1 = 0.000075; % 75us 27 | z1 = -exp(-1.0/(fs*T1)); 28 | p1 = 1+z1; 29 | 30 | a0 = 1.0; 31 | a1 = p1; 32 | a2 = 0; 33 | 34 | b0 = 1.0; 35 | b1 = z1; 36 | b2 = 0; 37 | 38 | % swap between a1, b1 to select pre- or de-emphasis 39 | 40 | # Pre 41 | Bmzt = [b0 a1 b2] 42 | Amzt = [a0 b1 a2] 43 | % De 44 | % Bmzt = [b0 b1 b2] 45 | % Amzt = [a0 a1 a2] 46 | 47 | DzMZT = tf(Amzt, Bmzt, samplingtime); 48 | DzMZT = DzMZT/dcgain(DzMZT); 49 | 50 | %% Plot 51 | wmin = 2 * pi * 20.0; % 20Hz 52 | wmax = 2 * pi * ((fs/2.0) - (fs/2 - 20000)); %20kHz 53 | 54 | figure(1); 55 | bode(Ds, 'b', DzMZT, 'c', {wmin, wmax}); 56 | legend('Analog prototype', 'MZT 2nd order','location', 'northwest'); 57 | grid on; 58 | pause(); 59 | -------------------------------------------------------------------------------- /FMCTCSSTX.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #include "Config.h" 20 | 21 | #if defined(MODE_FM) 22 | 23 | #if !defined(FMCTCSSTX_H) 24 | #define FMCTCSSTX_H 25 | 26 | class CFMCTCSSTX { 27 | public: 28 | CFMCTCSSTX(); 29 | 30 | uint8_t setParams(uint8_t frequency, uint8_t level); 31 | 32 | q15_t getAudio(bool reverse); 33 | 34 | private: 35 | q15_t* m_values; 36 | uint16_t m_length; 37 | uint16_t m_n; 38 | }; 39 | 40 | #endif 41 | 42 | #endif 43 | 44 | -------------------------------------------------------------------------------- /Utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015,2016,2020 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #if !defined(UTILS_H) 20 | #define UTILS_H 21 | 22 | #if defined(STM32F4XX) 23 | #include "stm32f4xx.h" 24 | #elif defined(STM32F7XX) 25 | #include "stm32f7xx.h" 26 | #else 27 | #include 28 | #endif 29 | 30 | uint8_t countBits8(uint8_t bits); 31 | 32 | uint8_t countBits16(uint16_t bits); 33 | 34 | uint8_t countBits32(uint32_t bits); 35 | 36 | uint8_t countBits64(uint64_t bits); 37 | 38 | #endif 39 | 40 | -------------------------------------------------------------------------------- /CalDStarTX.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015,2016,2020 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #include "Config.h" 20 | 21 | #if defined(MODE_DSTAR) 22 | 23 | #if !defined(CALDSTARTX_H) 24 | #define CALDSTARTX_H 25 | 26 | #include "DStarDefines.h" 27 | 28 | class CCalDStarTX { 29 | public: 30 | CCalDStarTX(); 31 | 32 | uint8_t write(const uint8_t* data, uint16_t length); 33 | 34 | void process(); 35 | 36 | private: 37 | bool m_transmit; 38 | uint16_t m_count; 39 | }; 40 | 41 | #endif 42 | 43 | #endif 44 | 45 | -------------------------------------------------------------------------------- /FMTimeout.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #include "Config.h" 20 | 21 | #if defined(MODE_FM) 22 | 23 | #if !defined(FMTimeout_H) 24 | #define FMTimeout_H 25 | 26 | class CFMTimeout { 27 | public: 28 | CFMTimeout(); 29 | 30 | void setParams(uint8_t level); 31 | 32 | void start(); 33 | void stop(); 34 | 35 | q15_t getAudio(); 36 | 37 | private: 38 | q15_t m_level; 39 | bool m_running; 40 | uint32_t m_pos; 41 | uint8_t m_n; 42 | }; 43 | 44 | #endif 45 | 46 | #endif 47 | 48 | -------------------------------------------------------------------------------- /CWIdTX.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 by Jonathan Naylor G4KLX 3 | * Copyright (C) 2016,2020 by Colin Durbridge G4EML 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 | */ 19 | 20 | #if !defined(CWIDTX_H) 21 | #define CWIDTX_H 22 | 23 | #include "Config.h" 24 | 25 | class CCWIdTX { 26 | public: 27 | CCWIdTX(); 28 | 29 | void process(); 30 | 31 | uint8_t write(const uint8_t* data, uint16_t length); 32 | 33 | void reset(); 34 | 35 | private: 36 | uint8_t m_poBuffer[1000U]; 37 | uint16_t m_poLen; 38 | uint16_t m_poPtr; 39 | uint8_t m_n; 40 | }; 41 | 42 | #endif 43 | 44 | -------------------------------------------------------------------------------- /CalPOCSAG.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 by Florian Wolters DF2ET 3 | * Copyright (C) 2020 by Jonathan Naylor G4KLX 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 | */ 19 | 20 | #include "Config.h" 21 | 22 | #if defined(MODE_POCSAG) 23 | 24 | #if !defined(CALPOCSAG_H) 25 | #define CALPOCSAG_H 26 | 27 | enum POCSAGCAL { 28 | POCSAGCAL_IDLE, 29 | POCSAGCAL_TX 30 | }; 31 | 32 | class CCalPOCSAG { 33 | public: 34 | CCalPOCSAG(); 35 | 36 | void process(); 37 | 38 | uint8_t write(const uint8_t* data, uint16_t length); 39 | 40 | private: 41 | POCSAGCAL m_state; 42 | }; 43 | 44 | #endif 45 | 46 | #endif 47 | 48 | -------------------------------------------------------------------------------- /FMBlanking.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #include "Config.h" 20 | 21 | #if defined(MODE_FM) 22 | 23 | #if !defined(FMBlanking_H) 24 | #define FMBlanking_H 25 | 26 | class CFMBlanking { 27 | public: 28 | CFMBlanking(); 29 | 30 | void setParams(uint8_t value, uint8_t level); 31 | 32 | q15_t process(q15_t sample); 33 | 34 | private: 35 | q15_t m_posValue; 36 | q15_t m_negValue; 37 | q15_t m_level; 38 | bool m_running; 39 | uint32_t m_pos; 40 | uint8_t m_n; 41 | }; 42 | 43 | #endif 44 | 45 | #endif 46 | 47 | -------------------------------------------------------------------------------- /Debug.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015,2016,2017,2021 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #if !defined(DEBUG_H) 20 | #define DEBUG_H 21 | 22 | #include "Config.h" 23 | #include "Globals.h" 24 | 25 | #define DEBUG1(a) serial.writeDebug((a)) 26 | #define DEBUG2(a,b) serial.writeDebug((a),(b)) 27 | #define DEBUG3(a,b,c) serial.writeDebug((a),(b),(c)) 28 | #define DEBUG4(a,b,c,d) serial.writeDebug((a),(b),(c),(d)) 29 | #define DEBUG5(a,b,c,d,e) serial.writeDebug((a),(b),(c),(d),(e)) 30 | #define DEBUG_DUMP(a,b) serial.writeDebugDump((a),(b)) 31 | 32 | #endif 33 | 34 | -------------------------------------------------------------------------------- /Tools/FMGenerateFilterCoefficients.py: -------------------------------------------------------------------------------- 1 | # based on https://github.com/berndporr/iir_fixed_point/blob/master/gen_coeff.py 2 | 3 | import numpy as np 4 | import scipy.signal as signal 5 | import pylab as pl 6 | 7 | # Calculate the coefficients for a pure fixed point 8 | # integer filter 9 | 10 | # sampling rate 11 | fs = 24000 12 | 13 | # cutoffs 14 | f1 = 300 15 | f2 = 2700 16 | # ripple 17 | rp = 0.2 18 | 19 | # scaling factor in bits, do not change ! 20 | q = 15 21 | # scaling factor as facor... 22 | scaling_factor = 2**q 23 | 24 | # let's generate a sequence of 2nd order IIR filters 25 | sos = signal.cheby1(3,rp,[f1, f2],'bandpass', output='sos', fs=fs) 26 | #os = signal.cheby1(4, rp, f2, 'lowpass', output='sos', fs=fs) #deemphasis filter 27 | #sos = signal.cheby1(1, rp, 2122, 'highpass', output='sos', fs=fs) #deemphasis filter 28 | 29 | sosrounded = np.round((sos) * scaling_factor) 30 | 31 | # print coefficients 32 | for biquad in sosrounded: 33 | for coeff in biquad: 34 | print(int(coeff),",",sep="",end="") 35 | #print((coeff),",",sep="",end="") 36 | print("") 37 | 38 | # plot the frequency response 39 | b,a = signal.sos2tf(sos) 40 | w,h = signal.freqz(b,a, worN=2048) 41 | pl.plot(w/np.pi/2*fs,20*np.log(np.abs(h))) 42 | pl.xlabel('frequency/Hz'); 43 | pl.ylabel('gain/dB'); 44 | pl.ylim(top=1,bottom=-30); 45 | pl.xlim(left=250, right=12000); 46 | pl.show() -------------------------------------------------------------------------------- /CalDStarRX.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015,2016,2020 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #include "Config.h" 20 | 21 | #if defined(MODE_DSTAR) 22 | 23 | #if !defined(CALDSTARRX_H) 24 | #define CALDSTARRX_H 25 | 26 | #include "DStarDefines.h" 27 | 28 | class CCalDStarRX { 29 | public: 30 | CCalDStarRX(); 31 | 32 | void samples(const q15_t* samples, uint8_t length); 33 | 34 | private: 35 | uint32_t m_pll; 36 | bool m_prev; 37 | uint32_t m_patternBuffer; 38 | q15_t m_rxBuffer[3U * 8U]; 39 | uint8_t m_ptr; 40 | 41 | void process(q15_t value); 42 | }; 43 | 44 | #endif 45 | 46 | #endif 47 | 48 | -------------------------------------------------------------------------------- /CalNXDN.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 by Andy Uribe CA6JAU 3 | * Copyright (C) 2020 by Jonathan Naylor G4KLX 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 | */ 19 | 20 | #include "Config.h" 21 | 22 | #if defined(MODE_NXDN) 23 | 24 | #if !defined(CALNXDN_H) 25 | #define CALNXDN_H 26 | 27 | enum NXDNCAL1K { 28 | NXDNCAL1K_IDLE, 29 | NXDNCAL1K_TX 30 | }; 31 | 32 | class CCalNXDN { 33 | public: 34 | CCalNXDN(); 35 | 36 | void process(); 37 | 38 | uint8_t write(const uint8_t* data, uint16_t length); 39 | 40 | private: 41 | bool m_transmit; 42 | NXDNCAL1K m_state; 43 | uint8_t m_audioSeq; 44 | }; 45 | 46 | #endif 47 | 48 | #endif 49 | 50 | -------------------------------------------------------------------------------- /DMRRX.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015,2016,2020 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #include "Config.h" 20 | 21 | #if defined(MODE_DMR) 22 | 23 | #if !defined(DMRRX_H) 24 | #define DMRRX_H 25 | 26 | #include "DMRSlotRX.h" 27 | 28 | class CDMRRX { 29 | public: 30 | CDMRRX(); 31 | 32 | void samples(const q15_t* samples, const uint16_t* rssi, const uint8_t* control, uint8_t length); 33 | 34 | void setColorCode(uint8_t colorCode); 35 | void setDelay(uint8_t delay); 36 | 37 | void reset(); 38 | 39 | private: 40 | CDMRSlotRX m_slot1RX; 41 | CDMRSlotRX m_slot2RX; 42 | }; 43 | 44 | #endif 45 | 46 | #endif 47 | 48 | -------------------------------------------------------------------------------- /DMRSlotType.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015,2020 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #include "Config.h" 20 | 21 | #if defined(MODE_DMR) 22 | 23 | #if !defined(DMRSLOTTYPE_H) 24 | #define DMRSLOTTYPE_H 25 | 26 | class CDMRSlotType { 27 | public: 28 | CDMRSlotType(); 29 | 30 | void decode(const uint8_t* frame, uint8_t& colorCode, uint8_t& dataType) const; 31 | 32 | void encode(uint8_t colorCode, uint8_t dataType, uint8_t* frame) const; 33 | 34 | private: 35 | 36 | uint8_t decode2087(const uint8_t* data) const; 37 | uint32_t getSyndrome1987(uint32_t pattern) const; 38 | }; 39 | 40 | #endif 41 | 42 | #endif 43 | 44 | -------------------------------------------------------------------------------- /CalP25.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 by Andy Uribe CA6JAU 3 | * Copyright (C) 2020 by Jonathan Naylor G4KLX 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 | */ 19 | 20 | #include "Config.h" 21 | 22 | #if defined(MODE_P25) 23 | 24 | #if !defined(CALP25_H) 25 | #define CALP25_H 26 | 27 | #include "P25Defines.h" 28 | 29 | enum P25CAL1K { 30 | P25CAL1K_IDLE, 31 | P25CAL1K_LDU1, 32 | P25CAL1K_LDU2 33 | }; 34 | 35 | class CCalP25 { 36 | public: 37 | CCalP25(); 38 | 39 | void process(); 40 | 41 | uint8_t write(const uint8_t* data, uint16_t length); 42 | 43 | private: 44 | bool m_transmit; 45 | P25CAL1K m_state; 46 | }; 47 | 48 | #endif 49 | 50 | #endif 51 | 52 | -------------------------------------------------------------------------------- /FMTimer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009,2010,2015,2020 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #include "Config.h" 20 | 21 | #if defined(MODE_FM) 22 | 23 | #if !defined(FMTimer_H) 24 | #define FMTimer_H 25 | 26 | class CFMTimer { 27 | public: 28 | CFMTimer(); 29 | 30 | void setTimeout(uint16_t secs, uint32_t msecs); 31 | 32 | uint32_t getTimeout() const; 33 | 34 | void start(); 35 | 36 | void stop(); 37 | 38 | void clock(uint8_t length); 39 | 40 | bool isRunning() const; 41 | 42 | bool hasExpired() const; 43 | 44 | private: 45 | uint32_t m_timeout; 46 | uint32_t m_timer; 47 | }; 48 | 49 | #endif 50 | 51 | #endif 52 | 53 | -------------------------------------------------------------------------------- /FMCTCSSRX.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #include "Config.h" 20 | 21 | #if defined(MODE_FM) 22 | 23 | #if !defined(FMCTCSSRX_H) 24 | #define FMCTCSSRX_H 25 | 26 | class CFMCTCSSRX { 27 | public: 28 | CFMCTCSSRX(); 29 | 30 | uint8_t setParams(uint8_t frequency, uint8_t highThreshold, uint8_t lowThreshold); 31 | 32 | bool process(q15_t sample); 33 | 34 | void reset(); 35 | 36 | private: 37 | q63_t m_coeffDivTwo; 38 | q31_t m_highThreshold; 39 | q31_t m_lowThreshold; 40 | uint16_t m_count; 41 | q31_t m_q0; 42 | q31_t m_q1; 43 | bool m_state; 44 | }; 45 | 46 | #endif 47 | 48 | #endif 49 | 50 | -------------------------------------------------------------------------------- /FMNoiseSquelch.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #include "Config.h" 20 | 21 | #if defined(MODE_FM) 22 | 23 | #if !defined(FMNOISESQUELCH_H) 24 | #define FMNOISESQUELCH_H 25 | 26 | class CFMNoiseSquelch { 27 | public: 28 | CFMNoiseSquelch(); 29 | 30 | void setParams(uint8_t highThreshold, uint8_t lowThreshold); 31 | 32 | bool process(q15_t sample); 33 | 34 | void reset(); 35 | 36 | private: 37 | q31_t m_highThreshold; 38 | q31_t m_lowThreshold; 39 | uint16_t m_count; 40 | q31_t m_q0; 41 | q31_t m_q1; 42 | bool m_state; 43 | uint8_t m_validCount; 44 | uint8_t m_invalidCount; 45 | }; 46 | 47 | #endif 48 | 49 | #endif 50 | 51 | -------------------------------------------------------------------------------- /FMUpSampler.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 by Jonathan Naylor G4KLX 3 | * Copyright (C) 2020 by Geoffrey Merck F4FXL - KC3FRA 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 | */ 19 | 20 | 21 | #include "Config.h" 22 | 23 | #if defined(MODE_FM) 24 | 25 | #if !defined(FMUPSAMPLER_H) 26 | #define FMUPSAMPLER_H 27 | 28 | #include "RingBuffer.h" 29 | #include "FMSamplePairPack.h" 30 | 31 | class CFMUpSampler { 32 | public: 33 | CFMUpSampler(); 34 | 35 | void reset(); 36 | 37 | void addData(const uint8_t* data, uint16_t length); 38 | 39 | bool getSample(q15_t& sample); 40 | 41 | uint16_t getSpace() const; 42 | 43 | private: 44 | uint8_t m_upSampleIndex; 45 | uint32_t m_pack; 46 | uint8_t * m_packPointer; 47 | CRingBuffer m_samples; 48 | bool m_running; 49 | }; 50 | 51 | #endif 52 | 53 | #endif 54 | 55 | -------------------------------------------------------------------------------- /CalPOCSAG.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 by Florian Wolters DF2ET 3 | * Copyright (C) 2020 by Jonathan Naylor G4KLX 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 | */ 19 | 20 | #include "Config.h" 21 | 22 | #if defined(MODE_POCSAG) 23 | 24 | #include "Globals.h" 25 | #include "CalPOCSAG.h" 26 | 27 | CCalPOCSAG::CCalPOCSAG() : 28 | m_state(POCSAGCAL_IDLE) 29 | { 30 | } 31 | 32 | void CCalPOCSAG::process() 33 | { 34 | if (m_state == POCSAGCAL_IDLE) 35 | return; 36 | 37 | uint16_t space = io.getSpace(); 38 | if (space <= 165U) 39 | return; 40 | 41 | pocsagTX.writeByte(0xAAU); 42 | } 43 | 44 | uint8_t CCalPOCSAG::write(const uint8_t* data, uint16_t length) 45 | { 46 | if (length != 1U) 47 | return 4U; 48 | 49 | m_state = data[0U] == 1U ? POCSAGCAL_TX : POCSAGCAL_IDLE; 50 | 51 | return 0U; 52 | } 53 | 54 | #endif 55 | 56 | -------------------------------------------------------------------------------- /CalFM.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015,2020 by Jonathan Naylor G4KLX 3 | * Copyright (C) 2016 by Colin Durbridge G4EML 4 | * Copyright (C) 2020 by Phil Taylor M0VSE 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | #include "Config.h" 22 | 23 | #if defined(MODE_FM) 24 | 25 | #if !defined(CALFM_H) 26 | #define CALFM_H 27 | 28 | class CCalFM { 29 | public: 30 | CCalFM(); 31 | 32 | void process(); 33 | void fm10kcal(); 34 | void fm12k5cal(); 35 | void fm15kcal(); 36 | void fm20kcal(); 37 | void fm25kcal(); 38 | void fm30kcal(); 39 | 40 | uint8_t write(const uint8_t* data, uint16_t length); 41 | 42 | private: 43 | uint16_t m_frequency; 44 | uint16_t m_length; 45 | q15_t* m_tone; 46 | q15_t m_level; 47 | bool m_transmit; 48 | uint8_t m_audioSeq; 49 | uint8_t m_lastState; 50 | }; 51 | 52 | #endif 53 | 54 | #endif 55 | 56 | -------------------------------------------------------------------------------- /FMDownSampler.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 by Jonathan Naylor G4KLX 3 | * Copyright (C) 2020 by Geoffrey Merck F4FXL - KC3FRA 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 | */ 19 | 20 | #include "Config.h" 21 | 22 | #if defined(MODE_FM) 23 | 24 | #if !defined(FMDOWNSAMPLER_H) 25 | #define FMDOWNSAMPLER_H 26 | 27 | #include "RingBuffer.h" 28 | #include "FMSamplePairPack.h" 29 | 30 | class CFMDownSampler { 31 | public: 32 | CFMDownSampler(uint16_t length); 33 | 34 | void addSample(q15_t sample); 35 | 36 | bool getPackedData(TSamplePairPack& data); 37 | 38 | uint16_t getData(); 39 | 40 | void reset(); 41 | 42 | private: 43 | CRingBuffer m_ringBuffer; 44 | uint32_t m_samplePack; 45 | uint8_t* m_samplePackPointer; 46 | uint8_t m_sampleIndex; 47 | }; 48 | 49 | #endif 50 | 51 | #endif 52 | 53 | -------------------------------------------------------------------------------- /FMKeyer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #include "Config.h" 20 | 21 | #if defined(MODE_FM) 22 | 23 | #if !defined(FMKeyer_H) 24 | #define FMKeyer_H 25 | 26 | class CFMKeyer { 27 | public: 28 | CFMKeyer(); 29 | 30 | uint8_t setParams(const char* text, uint8_t speed, uint16_t frequency, uint8_t highLevel, uint8_t lowLevel); 31 | 32 | q15_t getHighAudio(); 33 | q15_t getLowAudio(); 34 | 35 | void start(); 36 | void stop(); 37 | 38 | bool isRunning() const; 39 | 40 | bool isWanted() const; 41 | 42 | private: 43 | bool m_wanted; 44 | uint8_t m_poBuffer[1000U]; 45 | uint16_t m_poLen; 46 | uint16_t m_poPos; 47 | uint16_t m_dotLen; 48 | uint16_t m_dotPos; 49 | bool* m_audio; 50 | uint16_t m_audioLen; 51 | uint16_t m_audioPos; 52 | q15_t m_highLevel; 53 | q15_t m_lowLevel; 54 | }; 55 | 56 | #endif 57 | 58 | #endif 59 | 60 | -------------------------------------------------------------------------------- /CalDMR.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015,2020 by Jonathan Naylor G4KLX 3 | * Copyright (C) 2016 by Colin Durbridge G4EML 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 | */ 19 | 20 | #include "Config.h" 21 | 22 | #if defined(MODE_DMR) 23 | 24 | #if !defined(CALDMR_H) 25 | #define CALDMR_H 26 | 27 | #include "DMRDefines.h" 28 | 29 | enum DMRCAL1K { 30 | DMRCAL1K_IDLE, 31 | DMRCAL1K_VH, 32 | DMRCAL1K_VOICE, 33 | DMRCAL1K_VT, 34 | DMRCAL1K_WAIT 35 | }; 36 | 37 | class CCalDMR { 38 | public: 39 | CCalDMR(); 40 | 41 | void process(); 42 | void dmr1kcal(); 43 | void dmrdmo1k(); 44 | void createData1k(uint8_t n); 45 | void createDataDMO1k(uint8_t n); 46 | 47 | uint8_t write(const uint8_t* data, uint16_t length); 48 | 49 | private: 50 | bool m_transmit; 51 | DMRCAL1K m_state; 52 | uint32_t m_frame_start; 53 | uint8_t m_dmr1k[DMR_FRAME_LENGTH_BYTES + 1U]; 54 | uint8_t m_audioSeq; 55 | }; 56 | 57 | #endif 58 | 59 | #endif 60 | 61 | -------------------------------------------------------------------------------- /POCSAGTX.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015-2020 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #include "Config.h" 20 | 21 | #if defined(MODE_POCSAG) 22 | 23 | #if !defined(POCSAGTX_H) 24 | #define POCSAGTX_H 25 | 26 | #include "RingBuffer.h" 27 | 28 | class CPOCSAGTX { 29 | public: 30 | CPOCSAGTX(); 31 | 32 | uint8_t writeData(const uint8_t* data, uint16_t length); 33 | 34 | void writeByte(uint8_t c); 35 | 36 | void process(); 37 | 38 | void setTXDelay(uint8_t delay); 39 | 40 | uint8_t getSpace() const; 41 | 42 | bool busy(); 43 | 44 | private: 45 | CRingBuffer m_buffer; 46 | arm_fir_instance_q15 m_modFilter; 47 | q15_t m_modState[170U]; // NoTaps + BlockSize - 1, 6 + 160 - 1 plus some spare 48 | uint8_t m_poBuffer[200U]; 49 | uint16_t m_poLen; 50 | uint16_t m_poPtr; 51 | uint16_t m_txDelay; 52 | }; 53 | 54 | #endif 55 | 56 | #endif 57 | 58 | -------------------------------------------------------------------------------- /DMRIdleRX.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015,2020 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #include "Config.h" 20 | 21 | #if defined(MODE_DMR) 22 | 23 | #if !defined(DMRIDLERX_H) 24 | #define DMRIDLERX_H 25 | 26 | #include "DMRDefines.h" 27 | 28 | class CDMRIdleRX { 29 | public: 30 | CDMRIdleRX(); 31 | 32 | void samples(const q15_t* samples, uint8_t length); 33 | 34 | void setColorCode(uint8_t colorCode); 35 | 36 | void reset(); 37 | 38 | private: 39 | uint32_t m_bitBuffer[DMR_RADIO_SYMBOL_LENGTH]; 40 | q15_t m_buffer[DMR_FRAME_LENGTH_SAMPLES]; 41 | uint16_t m_bitPtr; 42 | uint16_t m_dataPtr; 43 | uint16_t m_endPtr; 44 | q31_t m_maxCorr; 45 | q15_t m_centre; 46 | q15_t m_threshold; 47 | uint8_t m_colorCode; 48 | 49 | void processSample(q15_t sample); 50 | void samplesToBits(uint16_t start, uint8_t count, uint8_t* buffer, uint16_t offset, q15_t centre, q15_t threshold); 51 | }; 52 | 53 | #endif 54 | 55 | #endif 56 | 57 | -------------------------------------------------------------------------------- /DMRDMOTX.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015,2016,2017,2020 by Jonathan Naylor G4KLX 3 | * Copyright (C) 2016 by Colin Durbridge G4EML 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 | */ 19 | 20 | #include "Config.h" 21 | 22 | #if defined(MODE_DMR) 23 | 24 | #if !defined(DMRDMOTX_H) 25 | #define DMRDMOTX_H 26 | 27 | #include "DMRDefines.h" 28 | 29 | #include "RingBuffer.h" 30 | 31 | class CDMRDMOTX { 32 | public: 33 | CDMRDMOTX(); 34 | 35 | uint8_t writeData(const uint8_t* data, uint16_t length); 36 | 37 | void process(); 38 | 39 | void setTXDelay(uint8_t delay); 40 | 41 | uint8_t getSpace() const; 42 | 43 | private: 44 | CRingBuffer m_fifo; 45 | arm_fir_interpolate_instance_q15 m_modFilter; 46 | q15_t m_modState[16U]; // blockSize + phaseLength - 1, 4 + 9 - 1 plus some spare 47 | uint8_t m_poBuffer[1200U]; 48 | uint16_t m_poLen; 49 | uint16_t m_poPtr; 50 | uint32_t m_txDelay; 51 | 52 | void writeByte(uint8_t c); 53 | }; 54 | 55 | #endif 56 | 57 | #endif 58 | 59 | -------------------------------------------------------------------------------- /FMTimer.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009,2010,2015,2020 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #include "Config.h" 20 | 21 | #if defined(MODE_FM) 22 | 23 | #include "Globals.h" 24 | #include "FMTimer.h" 25 | 26 | CFMTimer::CFMTimer() : 27 | m_timeout(0U), 28 | m_timer(0U) 29 | { 30 | } 31 | 32 | void CFMTimer::setTimeout(uint16_t secs, uint32_t msecs) 33 | { 34 | m_timeout = (secs * 24000U) + (msecs * 24U); 35 | } 36 | 37 | uint32_t CFMTimer::getTimeout() const 38 | { 39 | return m_timeout / 24U; 40 | } 41 | 42 | void CFMTimer::start() 43 | { 44 | if (m_timeout > 0U) 45 | m_timer = 1U; 46 | } 47 | 48 | void CFMTimer::stop() 49 | { 50 | m_timer = 0U; 51 | } 52 | 53 | void CFMTimer::clock(uint8_t length) 54 | { 55 | if (m_timer > 0U && m_timeout > 0U) 56 | m_timer += length; 57 | } 58 | 59 | bool CFMTimer::isRunning() const 60 | { 61 | return m_timer > 0U; 62 | } 63 | 64 | bool CFMTimer::hasExpired() const 65 | { 66 | if (m_timeout == 0U || m_timer == 0U) 67 | return false; 68 | 69 | if (m_timer > m_timeout) 70 | return true; 71 | 72 | return false; 73 | } 74 | 75 | #endif 76 | 77 | -------------------------------------------------------------------------------- /DStarTX.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015,2016,2017,2020 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #include "Config.h" 20 | 21 | #if defined(MODE_DSTAR) 22 | 23 | #if !defined(DSTARTX_H) 24 | #define DSTARTX_H 25 | 26 | #include "RingBuffer.h" 27 | 28 | class CDStarTX { 29 | public: 30 | CDStarTX(); 31 | 32 | uint8_t writeHeader(const uint8_t* header, uint16_t length); 33 | uint8_t writeData(const uint8_t* data, uint16_t length); 34 | uint8_t writeEOT(); 35 | 36 | void process(); 37 | 38 | void setTXDelay(uint8_t delay); 39 | 40 | uint8_t getSpace() const; 41 | 42 | private: 43 | CRingBuffer m_buffer; 44 | arm_fir_interpolate_instance_q15 m_modFilter; 45 | q15_t m_modState[20U]; // blockSize + phaseLength - 1, 8 + 9 - 1 plus some spare 46 | uint8_t m_poBuffer[600U]; 47 | uint16_t m_poLen; 48 | uint16_t m_poPtr; 49 | uint16_t m_txDelay; // In bytes 50 | 51 | void txHeader(const uint8_t* in, uint8_t* out) const; 52 | void writeByte(uint8_t c); 53 | }; 54 | 55 | #endif 56 | 57 | #endif 58 | 59 | -------------------------------------------------------------------------------- /CalRSSI.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #include "Config.h" 20 | #include "Globals.h" 21 | #include "CalRSSI.h" 22 | #include "Utils.h" 23 | 24 | CCalRSSI::CCalRSSI() : 25 | m_count(0U), 26 | m_accum(0U), 27 | m_min(0xFFFFU), 28 | m_max(0x0000U) 29 | { 30 | } 31 | 32 | void CCalRSSI::samples(const uint16_t* rssi, uint8_t length) 33 | { 34 | for (uint16_t i = 0U; i < length; i++) { 35 | uint16_t ss = rssi[i]; 36 | 37 | m_accum += ss; 38 | 39 | if (ss > m_max) 40 | m_max = ss; 41 | if (ss < m_min) 42 | m_min = ss; 43 | 44 | m_count++; 45 | if (m_count >= 24000U) { 46 | uint16_t ave = m_accum / m_count; 47 | 48 | uint8_t buffer[6U]; 49 | buffer[0U] = (m_max >> 8) & 0xFFU; 50 | buffer[1U] = (m_max >> 0) & 0xFFU; 51 | buffer[2U] = (m_min >> 8) & 0xFFU; 52 | buffer[3U] = (m_min >> 0) & 0xFFU; 53 | buffer[4U] = (ave >> 8) & 0xFFU; 54 | buffer[5U] = (ave >> 0) & 0xFFU; 55 | 56 | serial.writeRSSIData(buffer, 6U); 57 | 58 | m_count = 0U; 59 | m_accum = 0U; 60 | m_min = 0xFFFFU; 61 | m_max = 0x0000U; 62 | } 63 | } 64 | } 65 | 66 | -------------------------------------------------------------------------------- /YSFTX.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015,2016,2017,2020 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #include "Config.h" 20 | 21 | #if defined(MODE_YSF) 22 | 23 | #if !defined(YSFTX_H) 24 | #define YSFTX_H 25 | 26 | #include "RingBuffer.h" 27 | 28 | class CYSFTX { 29 | public: 30 | CYSFTX(); 31 | 32 | uint8_t writeData(const uint8_t* data, uint16_t length); 33 | 34 | void process(); 35 | 36 | void setTXDelay(uint8_t delay); 37 | 38 | uint8_t getSpace() const; 39 | 40 | void setParams(bool on, uint8_t txHang); 41 | 42 | private: 43 | CRingBuffer m_buffer; 44 | arm_fir_interpolate_instance_q15 m_modFilter; 45 | q15_t m_modState[16U]; // blockSize + phaseLength - 1, 4 + 9 - 1 plus some spare 46 | uint8_t m_poBuffer[1200U]; 47 | uint16_t m_poLen; 48 | uint16_t m_poPtr; 49 | uint16_t m_txDelay; 50 | bool m_loDev; 51 | uint32_t m_txHang; 52 | uint32_t m_txCount; 53 | 54 | void writeByte(uint8_t c); 55 | void writeSilence(); 56 | }; 57 | 58 | #endif 59 | 60 | #endif 61 | 62 | -------------------------------------------------------------------------------- /Utils.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #include "Utils.h" 20 | 21 | const uint8_t BITS_TABLE[] = { 22 | # define B2(n) n, n+1, n+1, n+2 23 | # define B4(n) B2(n), B2(n+1), B2(n+1), B2(n+2) 24 | # define B6(n) B4(n), B4(n+1), B4(n+1), B4(n+2) 25 | B6(0), B6(1), B6(1), B6(2) 26 | }; 27 | 28 | uint8_t countBits8(uint8_t bits) 29 | { 30 | return BITS_TABLE[bits]; 31 | } 32 | 33 | uint8_t countBits16(uint16_t bits) 34 | { 35 | uint8_t* p = (uint8_t*)&bits; 36 | uint8_t n = 0U; 37 | n += BITS_TABLE[p[0U]]; 38 | n += BITS_TABLE[p[1U]]; 39 | return n; 40 | } 41 | 42 | uint8_t countBits32(uint32_t bits) 43 | { 44 | uint8_t* p = (uint8_t*)&bits; 45 | uint8_t n = 0U; 46 | n += BITS_TABLE[p[0U]]; 47 | n += BITS_TABLE[p[1U]]; 48 | n += BITS_TABLE[p[2U]]; 49 | n += BITS_TABLE[p[3U]]; 50 | return n; 51 | } 52 | 53 | uint8_t countBits64(uint64_t bits) 54 | { 55 | uint8_t* p = (uint8_t*)&bits; 56 | uint8_t n = 0U; 57 | n += BITS_TABLE[p[0U]]; 58 | n += BITS_TABLE[p[1U]]; 59 | n += BITS_TABLE[p[2U]]; 60 | n += BITS_TABLE[p[3U]]; 61 | n += BITS_TABLE[p[4U]]; 62 | n += BITS_TABLE[p[5U]]; 63 | n += BITS_TABLE[p[6U]]; 64 | n += BITS_TABLE[p[7U]]; 65 | return n; 66 | } 67 | 68 | 69 | -------------------------------------------------------------------------------- /DMRRX.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015,2016,2020 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #include "Config.h" 20 | 21 | #if defined(MODE_DMR) 22 | 23 | #include "Globals.h" 24 | #include "DMRRX.h" 25 | 26 | CDMRRX::CDMRRX() : 27 | m_slot1RX(false), 28 | m_slot2RX(true) 29 | { 30 | } 31 | 32 | void CDMRRX::samples(const q15_t* samples, const uint16_t* rssi, const uint8_t* control, uint8_t length) 33 | { 34 | bool dcd1 = false; 35 | bool dcd2 = false; 36 | 37 | for (uint16_t i = 0U; i < length; i++) { 38 | switch (control[i]) { 39 | case MARK_SLOT1: 40 | m_slot1RX.start(); 41 | break; 42 | case MARK_SLOT2: 43 | m_slot2RX.start(); 44 | break; 45 | default: 46 | break; 47 | } 48 | 49 | dcd1 = m_slot1RX.processSample(samples[i], rssi[i]); 50 | dcd2 = m_slot2RX.processSample(samples[i], rssi[i]); 51 | } 52 | 53 | io.setDecode(dcd1 || dcd2); 54 | } 55 | 56 | void CDMRRX::setColorCode(uint8_t colorCode) 57 | { 58 | m_slot1RX.setColorCode(colorCode); 59 | m_slot2RX.setColorCode(colorCode); 60 | } 61 | 62 | void CDMRRX::setDelay(uint8_t delay) 63 | { 64 | m_slot1RX.setDelay(delay); 65 | m_slot2RX.setDelay(delay); 66 | } 67 | 68 | void CDMRRX::reset() 69 | { 70 | m_slot1RX.reset(); 71 | m_slot2RX.reset(); 72 | } 73 | 74 | #endif 75 | 76 | -------------------------------------------------------------------------------- /P25TX.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016,2017,2020 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #include "Config.h" 20 | 21 | #if defined(MODE_P25) 22 | 23 | #if !defined(P25TX_H) 24 | #define P25TX_H 25 | 26 | #include "RingBuffer.h" 27 | 28 | class CP25TX { 29 | public: 30 | CP25TX(); 31 | 32 | uint8_t writeData(const uint8_t* data, uint16_t length); 33 | 34 | void process(); 35 | 36 | void setTXDelay(uint8_t delay); 37 | 38 | uint8_t getSpace() const; 39 | 40 | void setParams(uint8_t txHang); 41 | 42 | private: 43 | CRingBuffer m_buffer; 44 | arm_fir_interpolate_instance_q15 m_modFilter; 45 | arm_fir_instance_q15 m_lpFilter; 46 | q15_t m_modState[16U]; // blockSize + phaseLength - 1, 4 + 9 - 1 plus some spare 47 | q15_t m_lpState[60U]; // NoTaps + BlockSize - 1, 32 + 20 - 1 plus some spare 48 | uint8_t m_poBuffer[1200U]; 49 | uint16_t m_poLen; 50 | uint16_t m_poPtr; 51 | uint16_t m_txDelay; 52 | uint32_t m_txHang; 53 | uint32_t m_txCount; 54 | 55 | void writeByte(uint8_t c); 56 | void writeSilence(); 57 | }; 58 | 59 | #endif 60 | 61 | #endif 62 | 63 | -------------------------------------------------------------------------------- /STM32Utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 by Wojciech Krutnik N0CALL 3 | * 4 | * Source: http://mightydevices.com/?p=144 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | #if !defined(STM32UTILS_H) 22 | #define STM32UTILS_H 23 | 24 | #include 25 | 26 | /* ram function */ 27 | #define RAMFUNC __attribute__ ((long_call, section (".data"))) 28 | /* eeprom data */ 29 | /* for placing variables in eeprom memory */ 30 | #define EEMEM __attribute__((section(".eeprom"))) 31 | 32 | /* bitband type */ 33 | typedef volatile uint32_t * const bitband_t; 34 | 35 | /* base address for bit banding */ 36 | #define BITBAND_SRAM_REF (0x20000000) 37 | /* base address for bit banding */ 38 | #define BITBAND_SRAM_BASE (0x22000000) 39 | /* base address for bit banding */ 40 | #define BITBAND_PERIPH_REF (0x40000000) 41 | /* base address for bit banding */ 42 | #define BITBAND_PERIPH_BASE (0x42000000) 43 | 44 | /* sram bit band */ 45 | #define BITBAND_SRAM(address, bit) ((void*)(BITBAND_SRAM_BASE + \ 46 | (((uint32_t)address) - BITBAND_SRAM_REF) * 32 + (bit) * 4)) 47 | 48 | /* periph bit band */ 49 | #define BITBAND_PERIPH(address, bit) ((void *)(BITBAND_PERIPH_BASE + \ 50 | (((uint32_t)address) - BITBAND_PERIPH_REF) * 32 + (bit) * 4)) 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /NXDNTX.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015,2016,2017,2018,2020 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #include "Config.h" 20 | 21 | #if defined(MODE_NXDN) 22 | 23 | #if !defined(NXDNTX_H) 24 | #define NXDNTX_H 25 | 26 | #include "RingBuffer.h" 27 | 28 | class CNXDNTX { 29 | public: 30 | CNXDNTX(); 31 | 32 | uint8_t writeData(const uint8_t* data, uint16_t length); 33 | 34 | void process(); 35 | 36 | void setTXDelay(uint8_t delay); 37 | 38 | uint8_t getSpace() const; 39 | 40 | void setParams(uint8_t txHang); 41 | 42 | private: 43 | CRingBuffer m_buffer; 44 | arm_fir_interpolate_instance_q15 m_modFilter; 45 | arm_fir_instance_q15 m_sincFilter; 46 | q15_t m_modState[16U]; // blockSize + phaseLength - 1, 4 + 9 - 1 plus some spare 47 | q15_t m_sincState[70U]; // NoTaps + BlockSize - 1, 22 + 40 - 1 plus some spare 48 | uint8_t m_poBuffer[1200U]; 49 | uint16_t m_poLen; 50 | uint16_t m_poPtr; 51 | uint16_t m_txDelay; 52 | uint32_t m_txHang; 53 | uint32_t m_txCount; 54 | 55 | void writeByte(uint8_t c); 56 | void writeSilence(); 57 | }; 58 | 59 | #endif 60 | 61 | #endif 62 | 63 | -------------------------------------------------------------------------------- /RingBuffer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 by Jonathan Naylor G4KLX 3 | * Copyright (C) 2020 by Geoffrey Merck F4FXL - KC3FRA 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 | */ 19 | 20 | #if !defined(RINGBUFFER_H) 21 | #define RINGBUFFER_H 22 | 23 | #if defined(STM32F4XX) 24 | #include "stm32f4xx.h" 25 | #elif defined(STM32F7XX) 26 | #include "stm32f7xx.h" 27 | #else 28 | #include 29 | #undef PI 30 | #endif 31 | 32 | #if defined(__SAM3X8E__) 33 | #define ARM_MATH_CM3 34 | #elif defined(STM32F7XX) 35 | #define ARM_MATH_CM7 36 | #elif defined(STM32F4XX) || defined(__MK20DX256__) || defined(__MK64FX512__) || defined(__MK66FX1M0__) 37 | #define ARM_MATH_CM4 38 | #else 39 | #error "Unknown processor type" 40 | #endif 41 | 42 | #include 43 | 44 | template 45 | class CRingBuffer { 46 | public: 47 | CRingBuffer(uint16_t length = 370U); 48 | 49 | uint16_t getSpace() const; 50 | 51 | uint16_t getData() const; 52 | 53 | bool put(TDATATYPE item) volatile; 54 | 55 | bool get(TDATATYPE& item) volatile; 56 | 57 | TDATATYPE peek() const; 58 | 59 | bool hasOverflowed(); 60 | 61 | void reset(); 62 | 63 | private: 64 | uint16_t m_length; 65 | TDATATYPE* m_buffer; 66 | volatile uint16_t m_head; 67 | volatile uint16_t m_tail; 68 | volatile bool m_full; 69 | bool m_overflow; 70 | }; 71 | 72 | #include "RingBuffer.impl.h" 73 | 74 | #endif 75 | -------------------------------------------------------------------------------- /NXDNDefines.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016,2017,2018 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #if !defined(NXDNDEFINES_H) 20 | #define NXDNDEFINES_H 21 | 22 | const unsigned int NXDN_RADIO_SYMBOL_LENGTH = 10U; // At 24 kHz sample rate 23 | 24 | const unsigned int NXDN_FRAME_LENGTH_BITS = 384U; 25 | const unsigned int NXDN_FRAME_LENGTH_BYTES = NXDN_FRAME_LENGTH_BITS / 8U; 26 | const unsigned int NXDN_FRAME_LENGTH_SYMBOLS = NXDN_FRAME_LENGTH_BITS / 2U; 27 | const unsigned int NXDN_FRAME_LENGTH_SAMPLES = NXDN_FRAME_LENGTH_SYMBOLS * NXDN_RADIO_SYMBOL_LENGTH; 28 | 29 | const unsigned int NXDN_FSW_LENGTH_BITS = 20U; 30 | const unsigned int NXDN_FSW_LENGTH_SYMBOLS = NXDN_FSW_LENGTH_BITS / 2U; 31 | const unsigned int NXDN_FSW_LENGTH_SAMPLES = NXDN_FSW_LENGTH_SYMBOLS * NXDN_RADIO_SYMBOL_LENGTH; 32 | 33 | const uint8_t NXDN_FSW_BYTES[] = {0xCDU, 0xF5U, 0x90U}; 34 | const uint8_t NXDN_FSW_BYTES_MASK[] = {0xFFU, 0xFFU, 0xF0U}; 35 | const uint8_t NXDN_FSW_BYTES_LENGTH = 3U; 36 | 37 | const uint32_t NXDN_FSW_BITS = 0x000CDF59U; 38 | const uint32_t NXDN_FSW_BITS_MASK = 0x000FFFFFU; 39 | 40 | // C D F 5 9 41 | // 11 00 11 01 11 11 01 01 10 01 42 | // -3 +1 -3 +3 -3 -3 +3 +3 -1 +3 43 | 44 | const int8_t NXDN_FSW_SYMBOLS_VALUES[] = {-3, +1, -3, +3, -3, -3, +3, +3, -1, +3}; 45 | 46 | const uint16_t NXDN_FSW_SYMBOLS = 0x014DU; 47 | const uint16_t NXDN_FSW_SYMBOLS_MASK = 0x03FFU; 48 | 49 | #endif 50 | 51 | -------------------------------------------------------------------------------- /DMRSlotRX.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015,2016,2017,2020 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #include "Config.h" 20 | 21 | #if defined(MODE_DMR) 22 | 23 | #if !defined(DMRSLOTRX_H) 24 | #define DMRSLOTRX_H 25 | 26 | #include "DMRDefines.h" 27 | 28 | enum DMRRX_STATE { 29 | DMRRXS_NONE, 30 | DMRRXS_VOICE, 31 | DMRRXS_DATA 32 | }; 33 | 34 | class CDMRSlotRX { 35 | public: 36 | CDMRSlotRX(bool slot); 37 | 38 | void start(); 39 | 40 | bool processSample(q15_t sample, uint16_t rssi); 41 | 42 | void setColorCode(uint8_t colorCode); 43 | void setDelay(uint8_t delay); 44 | 45 | void reset(); 46 | 47 | private: 48 | bool m_slot; 49 | uint32_t m_bitBuffer[DMR_RADIO_SYMBOL_LENGTH]; 50 | q15_t m_buffer[900U]; 51 | uint16_t m_bitPtr; 52 | uint16_t m_dataPtr; 53 | uint16_t m_syncPtr; 54 | uint16_t m_startPtr; 55 | uint16_t m_endPtr; 56 | uint16_t m_delayPtr; 57 | q31_t m_maxCorr; 58 | q15_t m_centre[4U]; 59 | q15_t m_threshold[4U]; 60 | uint8_t m_averagePtr; 61 | uint8_t m_control; 62 | uint8_t m_syncCount; 63 | uint8_t m_colorCode; 64 | uint16_t m_delay; 65 | DMRRX_STATE m_state; 66 | uint8_t m_n; 67 | uint8_t m_type; 68 | uint16_t m_rssi[900U]; 69 | 70 | void correlateSync(bool first); 71 | void samplesToBits(uint16_t start, uint8_t count, uint8_t* buffer, uint16_t offset, q15_t centre, q15_t threshold); 72 | void writeRSSIData(uint8_t* frame); 73 | }; 74 | 75 | #endif 76 | 77 | #endif 78 | 79 | -------------------------------------------------------------------------------- /YSFRX.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015,2016,2017,2020 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #include "Config.h" 20 | 21 | #if defined(MODE_YSF) 22 | 23 | #if !defined(YSFRX_H) 24 | #define YSFRX_H 25 | 26 | #include "YSFDefines.h" 27 | 28 | enum YSFRX_STATE { 29 | YSFRXS_NONE, 30 | YSFRXS_DATA 31 | }; 32 | 33 | class CYSFRX { 34 | public: 35 | CYSFRX(); 36 | 37 | void samples(const q15_t* samples, uint16_t* rssi, uint8_t length); 38 | 39 | void reset(); 40 | 41 | private: 42 | YSFRX_STATE m_state; 43 | uint32_t m_bitBuffer[YSF_RADIO_SYMBOL_LENGTH]; 44 | q15_t m_buffer[YSF_FRAME_LENGTH_SAMPLES]; 45 | uint16_t m_bitPtr; 46 | uint16_t m_dataPtr; 47 | uint16_t m_startPtr; 48 | uint16_t m_endPtr; 49 | uint16_t m_syncPtr; 50 | uint16_t m_minSyncPtr; 51 | uint16_t m_maxSyncPtr; 52 | q31_t m_maxCorr; 53 | uint16_t m_lostCount; 54 | uint8_t m_countdown; 55 | q15_t m_centre[16U]; 56 | q15_t m_centreVal; 57 | q15_t m_threshold[16U]; 58 | q15_t m_thresholdVal; 59 | uint8_t m_averagePtr; 60 | uint32_t m_rssiAccum; 61 | uint16_t m_rssiCount; 62 | 63 | void processNone(q15_t sample); 64 | void processData(q15_t sample); 65 | bool correlateSync(); 66 | void calculateLevels(uint16_t start, uint16_t count); 67 | void samplesToBits(uint16_t start, uint16_t count, uint8_t* buffer, uint16_t offset, q15_t centre, q15_t threshold); 68 | void writeRSSIData(uint8_t* data); 69 | }; 70 | 71 | #endif 72 | 73 | #endif 74 | 75 | -------------------------------------------------------------------------------- /NXDNRX.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015,2016,2017,2018,2020 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #include "Config.h" 20 | 21 | #if defined(MODE_NXDN) 22 | 23 | #if !defined(NXDNRX_H) 24 | #define NXDNRX_H 25 | 26 | #include "NXDNDefines.h" 27 | 28 | enum NXDNRX_STATE { 29 | NXDNRXS_NONE, 30 | NXDNRXS_DATA 31 | }; 32 | 33 | class CNXDNRX { 34 | public: 35 | CNXDNRX(); 36 | 37 | void samples(const q15_t* samples, uint16_t* rssi, uint8_t length); 38 | 39 | void reset(); 40 | 41 | private: 42 | NXDNRX_STATE m_state; 43 | uint16_t m_bitBuffer[NXDN_RADIO_SYMBOL_LENGTH]; 44 | q15_t m_buffer[NXDN_FRAME_LENGTH_SAMPLES]; 45 | uint16_t m_bitPtr; 46 | uint16_t m_dataPtr; 47 | uint16_t m_startPtr; 48 | uint16_t m_endPtr; 49 | uint16_t m_fswPtr; 50 | uint16_t m_minFSWPtr; 51 | uint16_t m_maxFSWPtr; 52 | q31_t m_maxCorr; 53 | uint16_t m_lostCount; 54 | uint8_t m_countdown; 55 | q15_t m_centre[16U]; 56 | q15_t m_centreVal; 57 | q15_t m_threshold[16U]; 58 | q15_t m_thresholdVal; 59 | uint8_t m_averagePtr; 60 | uint32_t m_rssiAccum; 61 | uint16_t m_rssiCount; 62 | 63 | void processNone(q15_t sample); 64 | void processData(q15_t sample); 65 | bool correlateFSW(); 66 | void calculateLevels(uint16_t start, uint16_t count); 67 | void samplesToBits(uint16_t start, uint16_t count, uint8_t* buffer, uint16_t offset, q15_t centre, q15_t threshold); 68 | void writeRSSIData(uint8_t* data); 69 | }; 70 | 71 | #endif 72 | 73 | #endif 74 | 75 | -------------------------------------------------------------------------------- /DMRDMORX.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015,2016,2017,2020 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #include "Config.h" 20 | 21 | #if defined(MODE_DMR) 22 | 23 | #if !defined(DMRDMORX_H) 24 | #define DMRDMORX_H 25 | 26 | #include "DMRDefines.h" 27 | 28 | const uint16_t DMO_BUFFER_LENGTH_SAMPLES = 1440U; // 60ms at 24 kHz 29 | 30 | enum DMORX_STATE { 31 | DMORXS_NONE, 32 | DMORXS_VOICE, 33 | DMORXS_DATA 34 | }; 35 | 36 | class CDMRDMORX { 37 | public: 38 | CDMRDMORX(); 39 | 40 | void samples(const q15_t* samples, const uint16_t* rssi, uint8_t length); 41 | 42 | void setColorCode(uint8_t colorCode); 43 | 44 | void reset(); 45 | 46 | private: 47 | uint32_t m_bitBuffer[DMR_RADIO_SYMBOL_LENGTH]; 48 | q15_t m_buffer[DMO_BUFFER_LENGTH_SAMPLES]; 49 | uint16_t m_bitPtr; 50 | uint16_t m_dataPtr; 51 | uint16_t m_syncPtr; 52 | uint16_t m_startPtr; 53 | uint16_t m_endPtr; 54 | q31_t m_maxCorr; 55 | q15_t m_centre[4U]; 56 | q15_t m_threshold[4U]; 57 | uint8_t m_averagePtr; 58 | uint8_t m_control; 59 | uint8_t m_syncCount; 60 | uint8_t m_colorCode; 61 | DMORX_STATE m_state; 62 | uint8_t m_n; 63 | uint8_t m_type; 64 | uint16_t m_rssi[DMO_BUFFER_LENGTH_SAMPLES]; 65 | 66 | bool processSample(q15_t sample, uint16_t rssi); 67 | void correlateSync(bool first); 68 | void samplesToBits(uint16_t start, uint8_t count, uint8_t* buffer, uint16_t offset, q15_t centre, q15_t threshold); 69 | void writeRSSIData(uint8_t* frame); 70 | }; 71 | 72 | #endif 73 | 74 | #endif 75 | 76 | -------------------------------------------------------------------------------- /FMDownSampler.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 by Jonathan Naylor G4KLX 3 | * Copyright (C) 2020 by Geoffrey Merck F4FXL - KC3FRA 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 | */ 19 | 20 | #include "Config.h" 21 | 22 | #if defined(MODE_FM) 23 | 24 | #include "FMDownSampler.h" 25 | 26 | CFMDownSampler::CFMDownSampler(uint16_t length) : 27 | m_ringBuffer(length), 28 | m_samplePack(0U), 29 | m_samplePackPointer(NULL), 30 | m_sampleIndex(0U) 31 | { 32 | m_samplePackPointer = (uint8_t*)&m_samplePack; 33 | } 34 | 35 | void CFMDownSampler::addSample(q15_t sample) 36 | { 37 | uint32_t usample = uint32_t(int32_t(sample) + 2048); 38 | //only take one of three samples 39 | switch(m_sampleIndex){ 40 | case 0: 41 | m_samplePack = usample << 12; 42 | break; 43 | case 3:{ 44 | m_samplePack |= usample; 45 | 46 | //we did not use MSB; skip it 47 | TSamplePairPack pair{m_samplePackPointer[0U], m_samplePackPointer[1U], m_samplePackPointer[2U]}; 48 | 49 | m_ringBuffer.put(pair); 50 | 51 | m_samplePack = 0U;//reset the sample pack 52 | } 53 | break; 54 | default: 55 | //Just skip this sample 56 | break; 57 | } 58 | 59 | m_sampleIndex++; 60 | if (m_sampleIndex >= 6U)//did we pack two samples ? 61 | m_sampleIndex = 0U; 62 | } 63 | 64 | bool CFMDownSampler::getPackedData(TSamplePairPack& data) 65 | { 66 | return m_ringBuffer.get(data); 67 | } 68 | 69 | uint16_t CFMDownSampler::getData() 70 | { 71 | return m_ringBuffer.getData(); 72 | } 73 | 74 | void CFMDownSampler::reset() 75 | { 76 | m_sampleIndex = 0U; 77 | } 78 | 79 | #endif 80 | 81 | -------------------------------------------------------------------------------- /FMBlanking.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #include "Config.h" 20 | 21 | #if defined(MODE_FM) 22 | 23 | #include "Globals.h" 24 | #include "FMBlanking.h" 25 | 26 | // 2000 Hz sine wave at 24000 Hz sample rate 27 | const q31_t TONE[] = {0, 16384, 28378, 32767, 28378, 16384, 0, -16383, -28377, -32767, -28377, -16383}; 28 | 29 | const uint8_t TONE_LEN = 12U; 30 | 31 | const uint32_t BLEEP_LEN = 2400U; // 100ms 32 | 33 | CFMBlanking::CFMBlanking() : 34 | m_posValue(0), 35 | m_negValue(0), 36 | m_level(128 * 128), 37 | m_running(false), 38 | m_pos(0U), 39 | m_n(0U) 40 | { 41 | } 42 | 43 | void CFMBlanking::setParams(uint8_t value, uint8_t level) 44 | { 45 | m_posValue = q15_t(value * 128); 46 | m_negValue = -m_posValue; 47 | 48 | m_level = q15_t(level * 128); 49 | } 50 | 51 | q15_t CFMBlanking::process(q15_t sample) 52 | { 53 | if (m_posValue == 0) 54 | return sample; 55 | 56 | if (!m_running) { 57 | if (sample >= m_posValue) { 58 | m_running = true; 59 | m_pos = 0U; 60 | m_n = 0U; 61 | } else if (sample <= m_negValue) { 62 | m_running = true; 63 | m_pos = 0U; 64 | m_n = 0U; 65 | } 66 | } 67 | 68 | if (!m_running) 69 | return sample; 70 | 71 | if (m_pos <= BLEEP_LEN) { 72 | q31_t value = TONE[m_n++] * m_level; 73 | sample = q15_t(__SSAT((value >> 15), 16)); 74 | if (m_n >= TONE_LEN) 75 | m_n = 0U; 76 | } else { 77 | sample = 0; 78 | } 79 | 80 | m_pos++; 81 | if (m_pos >= 12000U) 82 | m_running = false; 83 | 84 | return sample; 85 | } 86 | 87 | #endif 88 | 89 | -------------------------------------------------------------------------------- /STMUART.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 by Jonathan Naylor G4KLX 3 | * Copyright (c) 2020 by Geoffrey Merck F4FXL - KC3FRA 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 | */ 19 | 20 | #if defined(STM32F4XX) || defined(STM32F7XX) 21 | #if !defined(STMUART_H) 22 | #define STMUART_H 23 | 24 | #if defined(STM32F4XX) 25 | #include "stm32f4xx.h" 26 | #elif defined(STM32F7XX) 27 | #include "stm32f7xx.h" 28 | #endif 29 | 30 | const uint16_t BUFFER_SIZE = 2048U; //needs to be a power of 2 ! 31 | const uint16_t BUFFER_MASK = BUFFER_SIZE - 1; 32 | 33 | class CSTMUARTFIFO { 34 | public: 35 | CSTMUARTFIFO() : 36 | m_head(0U), 37 | m_tail(0U) 38 | { 39 | } 40 | 41 | void put(uint8_t data) 42 | { 43 | m_buffer[BUFFER_MASK & (m_head++)] = data; 44 | } 45 | 46 | uint8_t get() 47 | { 48 | return m_buffer[BUFFER_MASK & (m_tail++)]; 49 | } 50 | 51 | void reset() 52 | { 53 | m_tail = 0U; 54 | m_head = 0U; 55 | } 56 | 57 | bool isEmpty() 58 | { 59 | return m_tail == m_head; 60 | } 61 | 62 | bool isFull() 63 | { 64 | return ((m_head + 1U) & BUFFER_MASK) == (m_tail & BUFFER_MASK); 65 | } 66 | 67 | private: 68 | volatile uint8_t m_buffer[BUFFER_SIZE]; 69 | volatile uint16_t m_head; 70 | volatile uint16_t m_tail; 71 | }; 72 | 73 | class CSTMUART { 74 | public: 75 | CSTMUART(); 76 | void init(USART_TypeDef* usart); 77 | void write(const uint8_t * data, uint16_t length); 78 | uint8_t read(); 79 | void handleIRQ(); 80 | void flush(); 81 | uint16_t available(); 82 | uint16_t availableForWrite(); 83 | 84 | private: 85 | USART_TypeDef * m_usart; 86 | CSTMUARTFIFO m_rxFifo; 87 | CSTMUARTFIFO m_txFifo; 88 | }; 89 | 90 | #endif 91 | #endif -------------------------------------------------------------------------------- /FMTimeout.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #include "Config.h" 20 | 21 | #if defined(MODE_FM) 22 | 23 | #include "Globals.h" 24 | #include "FMTimeout.h" 25 | 26 | // 400 Hz sine wave at 24000 Hz sample rate 27 | const q15_t BUSY_AUDIO[] = {0, 3426, 6813, 10126, 13328, 16384, 19261, 21926, 24351, 26510, 28378, 29935, 31164, 32052, 32588, 32767, 32588, 32052, 31164, 29935, 28378, 26510, 24351, 28 | 21926, 19261, 16384, 13328, 10126, 6813, 3425, 0, -3425, -6813, -10126, -13328, -16384, -19261, -21926, -24351, -26510, -28378, -29935, -31164, -32052, 29 | -32588, -32768, -32588, -32052, -31164, -29935, -28378, -26510, -24351, -21926, -19261, -16384, -13328, -10126, -6813, -3425}; 30 | const uint8_t BUSY_AUDIO_LEN = 60U; 31 | 32 | CFMTimeout::CFMTimeout() : 33 | m_level(128 * 128), 34 | m_running(false), 35 | m_pos(0U), 36 | m_n(0U) 37 | { 38 | } 39 | 40 | void CFMTimeout::setParams(uint8_t level) 41 | { 42 | m_level = q15_t(level * 5); 43 | } 44 | 45 | q15_t CFMTimeout::getAudio() 46 | { 47 | q15_t sample = 0; 48 | if (!m_running) 49 | return sample; 50 | 51 | if (m_pos >= 12000U) { 52 | q31_t sample31 = BUSY_AUDIO[m_n] * m_level; 53 | sample = q15_t(__SSAT((sample31 >> 15), 16)); 54 | 55 | m_n++; 56 | if (m_n >= BUSY_AUDIO_LEN) 57 | m_n = 0U; 58 | } 59 | 60 | m_pos++; 61 | if (m_pos >= 24000U) 62 | m_pos = 0U; 63 | 64 | return sample; 65 | } 66 | 67 | void CFMTimeout::start() 68 | { 69 | m_running = true; 70 | m_pos = 0U; 71 | m_n = 0U; 72 | } 73 | 74 | void CFMTimeout::stop() 75 | { 76 | m_running = false; 77 | } 78 | 79 | #endif 80 | 81 | -------------------------------------------------------------------------------- /P25RX.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015,2016,2017,2020 by Jonathan Naylor G4KLX 3 | * Copyright (C) 2018 by Bryan Biedenkapp 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 | */ 19 | 20 | #include "Config.h" 21 | 22 | #if defined(MODE_P25) 23 | 24 | #if !defined(P25RX_H) 25 | #define P25RX_H 26 | 27 | #include "P25Defines.h" 28 | 29 | enum P25RX_STATE { 30 | P25RXS_NONE, 31 | P25RXS_HDR, 32 | P25RXS_LDU 33 | }; 34 | 35 | class CP25RX { 36 | public: 37 | CP25RX(); 38 | 39 | void samples(const q15_t* samples, uint16_t* rssi, uint8_t length); 40 | 41 | void reset(); 42 | 43 | private: 44 | P25RX_STATE m_state; 45 | uint32_t m_bitBuffer[P25_RADIO_SYMBOL_LENGTH]; 46 | q15_t m_buffer[P25_LDU_FRAME_LENGTH_SAMPLES]; 47 | uint16_t m_bitPtr; 48 | uint16_t m_dataPtr; 49 | uint16_t m_hdrStartPtr; 50 | uint16_t m_lduStartPtr; 51 | uint16_t m_lduEndPtr; 52 | uint16_t m_minSyncPtr; 53 | uint16_t m_maxSyncPtr; 54 | uint16_t m_hdrSyncPtr; 55 | uint16_t m_lduSyncPtr; 56 | q31_t m_maxCorr; 57 | uint16_t m_lostCount; 58 | uint8_t m_countdown; 59 | q15_t m_centre[16U]; 60 | q15_t m_centreVal; 61 | q15_t m_threshold[16U]; 62 | q15_t m_thresholdVal; 63 | uint8_t m_averagePtr; 64 | uint32_t m_rssiAccum; 65 | uint16_t m_rssiCount; 66 | uint8_t m_duid; 67 | 68 | void processNone(q15_t sample); 69 | void processHdr(q15_t sample); 70 | void processLdu(q15_t sample); 71 | bool correlateSync(); 72 | void calculateLevels(uint16_t start, uint16_t count); 73 | void samplesToBits(uint16_t start, uint16_t count, uint8_t* buffer, uint16_t offset, q15_t centre, q15_t threshold); 74 | void writeRSSILdu(uint8_t* ldu); 75 | }; 76 | 77 | #endif 78 | 79 | #endif 80 | 81 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | This is the source code of the MMDVM firmware that supports D-Star, DMR, System Fusion, P25, NXDN, POCSAG, and FM modes. 2 | 3 | It runs on the Arduino Due, the ST-Micro STM32F4xxx and STM32F7xxx processors, as well as the Teensy 3.5/3.6. What these platforms have in common is the use of an ARM Cortex-M3, M4, or M7 processors with a minimum clock speed greater of 80 MHz, and access to at least one analogue to digital converter, one digital to analogue converter, as well as a number of GPIO pins. 4 | 5 | In order to build this software for the Arduino Due, you will need to edit a file within the Arduino GUI and that is detailed in the BUILD.txt file. The STM32 support is supplied via the ARM GCC compiler. The Teensy support uses Teensyduino. 6 | 7 | This software is licenced under the GPL v2 and is primarily intended for amateur and educational use. 8 | 9 | Portions of the ARM support code include the following copyright: 10 | 11 | Copyright (c) 2011 - 2013 ARM LIMITED 12 | 13 | All rights reserved. 14 | Redistribution and use in source and binary forms, with or without 15 | modification, are permitted provided that the following conditions are met: 16 | - Redistributions of source code must retain the above copyright 17 | notice, this list of conditions and the following disclaimer. 18 | - Redistributions in binary form must reproduce the above copyright 19 | notice, this list of conditions and the following disclaimer in the 20 | documentation and/or other materials provided with the distribution. 21 | - Neither the name of ARM nor the names of its contributors may be used 22 | to endorse or promote products derived from this software without 23 | specific prior written permission. 24 | 25 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 26 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 28 | ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE 29 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 30 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 31 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 32 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 33 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 | POSSIBILITY OF SUCH DAMAGE. 36 | -------------------------------------------------------------------------------- /YSFDefines.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016,2017 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #if !defined(YSFDEFINES_H) 20 | #define YSFDEFINES_H 21 | 22 | const unsigned int YSF_RADIO_SYMBOL_LENGTH = 5U; // At 24 kHz sample rate 23 | 24 | const unsigned int YSF_FRAME_LENGTH_BYTES = 120U; 25 | const unsigned int YSF_FRAME_LENGTH_BITS = YSF_FRAME_LENGTH_BYTES * 8U; 26 | const unsigned int YSF_FRAME_LENGTH_SYMBOLS = YSF_FRAME_LENGTH_BYTES * 4U; 27 | const unsigned int YSF_FRAME_LENGTH_SAMPLES = YSF_FRAME_LENGTH_SYMBOLS * YSF_RADIO_SYMBOL_LENGTH; 28 | 29 | const unsigned int YSF_SYNC_LENGTH_BYTES = 5U; 30 | const unsigned int YSF_SYNC_LENGTH_BITS = YSF_SYNC_LENGTH_BYTES * 8U; 31 | const unsigned int YSF_SYNC_LENGTH_SYMBOLS = YSF_SYNC_LENGTH_BYTES * 4U; 32 | const unsigned int YSF_SYNC_LENGTH_SAMPLES = YSF_SYNC_LENGTH_SYMBOLS * YSF_RADIO_SYMBOL_LENGTH; 33 | 34 | const unsigned int YSF_FICH_LENGTH_BITS = 200U; 35 | const unsigned int YSF_FICH_LENGTH_SYMBOLS = 100U; 36 | const unsigned int YSF_FICH_LENGTH_SAMPLES = YSF_FICH_LENGTH_SYMBOLS * YSF_RADIO_SYMBOL_LENGTH; 37 | 38 | const uint8_t YSF_SYNC_BYTES[] = {0xD4U, 0x71U, 0xC9U, 0x63U, 0x4DU}; 39 | const uint8_t YSF_SYNC_BYTES_LENGTH = 5U; 40 | 41 | const uint64_t YSF_SYNC_BITS = 0x000000D471C9634DU; 42 | const uint64_t YSF_SYNC_BITS_MASK = 0x000000FFFFFFFFFFU; 43 | 44 | // D 4 7 1 C 9 6 3 4 D 45 | // 11 01 01 00 01 11 00 01 11 00 10 01 01 10 00 11 01 00 11 01 46 | // -3 +3 +3 +1 +3 -3 +1 +3 -3 +1 -1 +3 +3 -1 +3 -3 +3 +1 -3 +3 47 | 48 | const int8_t YSF_SYNC_SYMBOLS_VALUES[] = {-3, +3, +3, +1, +3, -3, +1, +3, -3, +1, -1, +3, +3, -1, +3, -3, +3, +1, -3, +3}; 49 | 50 | const uint32_t YSF_SYNC_SYMBOLS = 0x0007B5ADU; 51 | const uint32_t YSF_SYNC_SYMBOLS_MASK = 0x000FFFFFU; 52 | 53 | #endif 54 | 55 | -------------------------------------------------------------------------------- /IOPins.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019,2020 by BG5HHP 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef _IO_PINS_H 20 | #define _IO_PINS_H 21 | 22 | #if !defined(CONFIG_H) 23 | #error "Requires Config.h to be included first!" 24 | #endif 25 | 26 | #if defined(STM32F4_RPT_HAT_TGO) 27 | #include "pins/pins_f4_rpt_tgo.h" 28 | 29 | #elif defined(STM32F4_DISCOVERY) 30 | #include "pins/pins_f4_discovery.h" 31 | 32 | #elif defined(STM32F4_PI) 33 | #include "pins/pins_f4_pi.h" 34 | 35 | #elif defined(STM32F722_PI) 36 | #include "pins/pins_f7_pi.h" 37 | 38 | #elif defined(STM32F4_F4M) 39 | #include "pins/pins_f4_f4m.h" 40 | 41 | #elif defined(STM32F722_F7M) 42 | #include "pins/pins_f7_f7m.h" 43 | 44 | #elif defined(STM32F722_RPT_HAT) 45 | #include "pins/pins_f7_rpt_hat.h" 46 | 47 | #elif defined(STM32F4_NUCLEO) 48 | #if defined(STM32F4_NUCLEO_MORPHO_HEADER) 49 | #include "pins/pins_f4_nucleo_morpho.h" 50 | #elif defined(STM32F4_NUCLEO_ARDUINO_HEADER) 51 | #include "pins/pins_f4_nucleo_arduino.h" 52 | #else 53 | #error "Either STM32F4_NUCLEO_MORPHO_HEADER or STM32F4_NUCLEO_ARDUINO_HEADER need to be defined" 54 | #endif 55 | 56 | #elif defined(STM32F7_NUCLEO) 57 | #include "pins/pins_f7_nucleo.h" 58 | 59 | #elif defined(STM32F4_DVM) 60 | #include "pins/pins_f4_stm32dvm_v3.h" 61 | 62 | #elif defined(STM32F7_DVM) 63 | #include "pins/pins_f7_stm32dvm_v5.h" 64 | 65 | #elif defined(DRCC_DVM_NQF) 66 | #include "pins/pins_f4_drcc_nqf.h" 67 | 68 | #elif defined(DRCC_DVM_HHP446) 69 | #include "pins/pins_f4_drcc_hhp446.h" 70 | 71 | #elif defined(STM32F4_EDA_405) || defined(STM32F4_EDA_446) 72 | #include "pins/pins_f4_stm32eda.h" 73 | 74 | #else 75 | #error "A valid board type macro need to be defined." 76 | 77 | #endif 78 | 79 | #endif //#ifndef _IO_PINS_H 80 | -------------------------------------------------------------------------------- /DStarRX.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015,2016,2017,2020 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #include "Config.h" 20 | 21 | #if defined(MODE_DSTAR) 22 | 23 | #if !defined(DSTARRX_H) 24 | #define DSTARRX_H 25 | 26 | #include "DStarDefines.h" 27 | 28 | enum DSRX_STATE { 29 | DSRXS_NONE, 30 | DSRXS_HEADER, 31 | DSRXS_DATA 32 | }; 33 | 34 | class CDStarRX { 35 | public: 36 | CDStarRX(); 37 | 38 | void samples(const q15_t* samples, const uint16_t* rssi, uint8_t length); 39 | 40 | void reset(); 41 | 42 | private: 43 | DSRX_STATE m_rxState; 44 | uint64_t m_bitBuffer[DSTAR_RADIO_SYMBOL_LENGTH]; 45 | q15_t m_headerBuffer[DSTAR_FEC_SECTION_LENGTH_SAMPLES + 2U * DSTAR_RADIO_SYMBOL_LENGTH]; 46 | q15_t m_dataBuffer[DSTAR_DATA_LENGTH_SAMPLES]; 47 | uint16_t m_bitPtr; 48 | uint16_t m_headerPtr; 49 | uint16_t m_dataPtr; 50 | uint16_t m_startPtr; 51 | uint16_t m_syncPtr; 52 | uint16_t m_minSyncPtr; 53 | uint16_t m_maxSyncPtr; 54 | q31_t m_maxFrameCorr; 55 | q31_t m_maxDataCorr; 56 | uint16_t m_frameCount; 57 | uint8_t m_countdown; 58 | unsigned int m_mar; 59 | int m_pathMetric[4U]; 60 | unsigned int m_pathMemory0[42U]; 61 | unsigned int m_pathMemory1[42U]; 62 | unsigned int m_pathMemory2[42U]; 63 | unsigned int m_pathMemory3[42U]; 64 | uint8_t m_fecOutput[42U]; 65 | uint32_t m_rssiAccum; 66 | uint16_t m_rssiCount; 67 | 68 | void processNone(q15_t sample); 69 | void processHeader(q15_t sample); 70 | void processData(); 71 | bool correlateFrameSync(); 72 | bool correlateDataSync(); 73 | void samplesToBits(const q15_t* inBuffer, uint16_t start, uint16_t count, uint8_t* outBuffer, uint16_t limit); 74 | void writeRSSIHeader(unsigned char* header); 75 | void writeRSSIData(unsigned char* data); 76 | bool rxHeader(uint8_t* in, uint8_t* out); 77 | void acs(int* metric); 78 | void viterbiDecode(int* data); 79 | void traceBack(); 80 | bool checksum(const uint8_t* header) const; 81 | }; 82 | 83 | #endif 84 | 85 | #endif 86 | 87 | -------------------------------------------------------------------------------- /STMUART.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 by Jonathan Naylor G4KLX 3 | * Copyright (c) 2020 by Geoffrey Merck F4FXL - KC3FRA 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 | */ 19 | 20 | #if defined(STM32F4XX) || defined(STM32F7XX) 21 | 22 | #include "STMUART.h" 23 | 24 | CSTMUART::CSTMUART() : 25 | m_usart(NULL) 26 | { 27 | 28 | } 29 | 30 | void CSTMUART::init(USART_TypeDef* usart) 31 | { 32 | m_usart = usart; 33 | } 34 | 35 | void CSTMUART::write(const uint8_t * data, uint16_t length) 36 | { 37 | if(length == 0U || m_usart == NULL) 38 | return; 39 | 40 | 41 | m_txFifo.put(data[0]); 42 | USART_ITConfig(m_usart, USART_IT_TXE, ENABLE);//switch TX IRQ is on 43 | 44 | for(uint16_t i = 1U; i < length; i++) { 45 | m_txFifo.put(data[i]); 46 | } 47 | 48 | USART_ITConfig(m_usart, USART_IT_TXE, ENABLE);//make sure TX IRQ is on 49 | } 50 | 51 | uint8_t CSTMUART::read() 52 | { 53 | return m_rxFifo.get(); 54 | } 55 | 56 | void CSTMUART::handleIRQ() 57 | { 58 | if(m_usart == NULL) 59 | return; 60 | 61 | if (USART_GetITStatus(m_usart, USART_IT_RXNE)) { 62 | if(!m_rxFifo.isFull()) 63 | m_rxFifo.put((uint8_t) USART_ReceiveData(m_usart)); 64 | USART_ClearITPendingBit(USART1, USART_IT_RXNE); 65 | } 66 | 67 | if (USART_GetITStatus(m_usart, USART_IT_TXE)) { 68 | if(!m_txFifo.isEmpty()) 69 | USART_SendData(m_usart, m_txFifo.get()); 70 | 71 | USART_ClearITPendingBit(m_usart, USART_IT_TXE); 72 | 73 | if (m_txFifo.isEmpty()) // if there's no more data to transmit then turn off TX interrupts 74 | USART_ITConfig(m_usart, USART_IT_TXE, DISABLE); 75 | } 76 | } 77 | 78 | // Flushes the transmit shift register 79 | // warning: this call is blocking 80 | void CSTMUART::flush() 81 | { 82 | if(m_usart == NULL) 83 | return; 84 | 85 | // wait until the TXE shows the shift register is empty 86 | while (USART_GetITStatus(m_usart, USART_FLAG_TXE)) 87 | ; 88 | } 89 | 90 | uint16_t CSTMUART::available() 91 | { 92 | return m_rxFifo.isEmpty() ? 0U : 1U; 93 | } 94 | 95 | uint16_t CSTMUART::availableForWrite() 96 | { 97 | return m_txFifo.isFull() ? 0U : 1U; 98 | } 99 | 100 | #endif -------------------------------------------------------------------------------- /FMUpSampler.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 by Jonathan Naylor G4KLX 3 | * Copyright (C) 2020 by Geoffrey Merck F4FXL - KC3FRA 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 | */ 19 | 20 | #include "Config.h" 21 | 22 | #if defined(MODE_FM) 23 | 24 | #include "FMUpSampler.h" 25 | 26 | const uint32_t FM_UPSAMPLE_MASK = 0x00000FFFU; 27 | 28 | CFMUpSampler::CFMUpSampler() : 29 | m_upSampleIndex(0), 30 | m_pack(0U), 31 | m_packPointer(NULL), 32 | m_samples(3600U), //300ms of 12 bit 8kHz audio 33 | m_running(false) 34 | { 35 | m_packPointer = (uint8_t*)&m_pack; 36 | } 37 | 38 | void CFMUpSampler::reset() 39 | { 40 | m_upSampleIndex = 0U; 41 | m_pack = 0U; 42 | m_samples.reset(); 43 | m_running = false; 44 | } 45 | 46 | void CFMUpSampler::addData(const uint8_t* data, uint16_t length) 47 | { 48 | TSamplePairPack* packPointer = (TSamplePairPack*)data; 49 | TSamplePairPack* packPointerEnd = packPointer + (length / 3U); 50 | while(packPointer != packPointerEnd) { 51 | m_samples.put(*packPointer); 52 | packPointer++; 53 | } 54 | if(!m_running) 55 | m_running = m_samples.getData() > 300U;//75ms of audio 56 | } 57 | 58 | bool CFMUpSampler::getSample(q15_t& sample) 59 | { 60 | if(!m_running) 61 | return false; 62 | 63 | switch (m_upSampleIndex) 64 | { 65 | case 0: { 66 | TSamplePairPack pairPack; 67 | if(!m_samples.get(pairPack)) { 68 | m_running = false; 69 | return false; 70 | } 71 | 72 | m_pack = 0U; 73 | m_packPointer = (uint8_t*)&m_pack; 74 | 75 | m_packPointer[0U] = pairPack.byte0; 76 | m_packPointer[1U] = pairPack.byte1; 77 | m_packPointer[2U] = pairPack.byte2; 78 | 79 | sample = q15_t(m_pack >> 12) - 2048; 80 | break; 81 | } 82 | case 3: 83 | sample = q15_t(m_pack & FM_UPSAMPLE_MASK) - 2048; 84 | break; 85 | default: 86 | sample = 0; 87 | break; 88 | } 89 | 90 | m_upSampleIndex++; 91 | if(m_upSampleIndex >= 6U) 92 | m_upSampleIndex = 0U; 93 | 94 | return true; 95 | } 96 | 97 | uint16_t CFMUpSampler::getSpace() const 98 | { 99 | //return available space in bytes 100 | return m_samples.getSpace() * sizeof(TSamplePairPack); 101 | } 102 | 103 | #endif 104 | 105 | -------------------------------------------------------------------------------- /DMRTX.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015,2016,2017,2020 by Jonathan Naylor G4KLX 3 | * Copyright (C) 2016 by Colin Durbridge G4EML 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 | */ 19 | 20 | #include "Config.h" 21 | 22 | #if defined(MODE_DMR) 23 | 24 | #if !defined(DMRTX_H) 25 | #define DMRTX_H 26 | 27 | #include "DMRDefines.h" 28 | 29 | #include "RingBuffer.h" 30 | 31 | enum DMRTXSTATE { 32 | DMRTXSTATE_IDLE, 33 | DMRTXSTATE_SLOT1, 34 | DMRTXSTATE_CACH1, 35 | DMRTXSTATE_SLOT2, 36 | DMRTXSTATE_CACH2, 37 | DMRTXSTATE_CAL 38 | }; 39 | 40 | class CDMRTX { 41 | public: 42 | CDMRTX(); 43 | 44 | uint8_t writeData1(const uint8_t* data, uint16_t length); 45 | uint8_t writeData2(const uint8_t* data, uint16_t length); 46 | 47 | uint8_t writeShortLC(const uint8_t* data, uint16_t length); 48 | uint8_t writeAbort(const uint8_t* data, uint16_t length); 49 | 50 | void setStart(bool start); 51 | void setCal(bool start); 52 | 53 | void process(); 54 | 55 | void resetFifo1(); 56 | void resetFifo2(); 57 | uint32_t getFrameCount(); 58 | 59 | uint8_t getSpace1() const; 60 | uint8_t getSpace2() const; 61 | 62 | void setColorCode(uint8_t colorCode); 63 | 64 | private: 65 | CRingBuffer m_fifo[2U]; 66 | arm_fir_interpolate_instance_q15 m_modFilter; 67 | q15_t m_modState[16U]; // blockSize + phaseLength - 1, 4 + 9 - 1 plus some spare 68 | DMRTXSTATE m_state; 69 | uint8_t m_idle[DMR_FRAME_LENGTH_BYTES]; 70 | uint8_t m_cachPtr; 71 | uint8_t m_shortLC[12U]; 72 | uint8_t m_newShortLC[12U]; 73 | uint8_t m_markBuffer[40U]; 74 | uint8_t m_poBuffer[40U]; 75 | uint16_t m_poLen; 76 | uint16_t m_poPtr; 77 | uint32_t m_frameCount; 78 | uint32_t m_abortCount[2U]; 79 | bool m_abort[2U]; 80 | 81 | void createData(uint8_t slotIndex); 82 | void createCACH(uint8_t txSlotIndex, uint8_t rxSlotIndex); 83 | void createCal(); 84 | void writeByte(uint8_t c, uint8_t control); 85 | }; 86 | 87 | #endif 88 | 89 | #endif 90 | 91 | -------------------------------------------------------------------------------- /SerialArduino.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016,2017 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #include "Config.h" 20 | #include "Globals.h" 21 | 22 | #include "SerialPort.h" 23 | 24 | #if defined(VK6MST_TEENSY_PI3_SHIELD_I2C) 25 | //it will load I2CTeensy.cpp 26 | 27 | #elif defined(__SAM3X8E__) || defined(__MK20DX256__) || defined(__MK64FX512__) || defined(__MK66FX1M0__) 28 | 29 | void CSerialPort::beginInt(uint8_t n, int speed) 30 | { 31 | switch (n) { 32 | case 1U: 33 | Serial.begin(speed); 34 | break; 35 | case 2U: 36 | Serial2.begin(speed); 37 | break; 38 | case 3U: 39 | Serial3.begin(speed); 40 | break; 41 | default: 42 | break; 43 | } 44 | } 45 | 46 | int CSerialPort::availableForReadInt(uint8_t n) 47 | { 48 | switch (n) { 49 | case 1U: 50 | return Serial.available(); 51 | case 2U: 52 | return Serial2.available(); 53 | case 3U: 54 | return Serial3.available(); 55 | default: 56 | return false; 57 | } 58 | } 59 | 60 | int CSerialPort::availableForWriteInt(uint8_t n) 61 | { 62 | switch (n) { 63 | case 1U: 64 | return Serial.availableForWrite(); 65 | case 2U: 66 | return Serial2.availableForWrite(); 67 | case 3U: 68 | return Serial3.availableForWrite(); 69 | default: 70 | return false; 71 | } 72 | } 73 | 74 | uint8_t CSerialPort::readInt(uint8_t n) 75 | { 76 | switch (n) { 77 | case 1U: 78 | return Serial.read(); 79 | case 2U: 80 | return Serial2.read(); 81 | case 3U: 82 | return Serial3.read(); 83 | default: 84 | return 0U; 85 | } 86 | } 87 | 88 | void CSerialPort::writeInt(uint8_t n, const uint8_t* data, uint16_t length, bool flush) 89 | { 90 | switch (n) { 91 | case 1U: 92 | Serial.write(data, length); 93 | if (flush) 94 | Serial.flush(); 95 | break; 96 | case 2U: 97 | Serial2.write(data, length); 98 | if (flush) 99 | Serial2.flush(); 100 | break; 101 | case 3U: 102 | Serial3.write(data, length); 103 | if (flush) 104 | Serial3.flush(); 105 | break; 106 | default: 107 | break; 108 | } 109 | } 110 | 111 | #endif 112 | 113 | -------------------------------------------------------------------------------- /RingBuffer.impl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 by Jonathan Naylor G4KLX 3 | * Copyright (C) 2020 by Geoffrey Merck F4FXL - KC3FRA 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 | */ 19 | 20 | #include "RingBuffer.h" 21 | 22 | template CRingBuffer::CRingBuffer(uint16_t length) : 23 | m_length(length), 24 | m_head(0U), 25 | m_tail(0U), 26 | m_full(false), 27 | m_overflow(false) 28 | { 29 | m_buffer = new TDATATYPE[length]; 30 | } 31 | 32 | template uint16_t CRingBuffer::getSpace() const 33 | { 34 | uint16_t n = 0U; 35 | 36 | if (m_tail == m_head) 37 | n = m_full ? 0U : m_length; 38 | else if (m_tail < m_head) 39 | n = m_length - m_head + m_tail; 40 | else 41 | n = m_tail - m_head; 42 | 43 | if (n > m_length) 44 | n = 0U; 45 | 46 | return n; 47 | } 48 | 49 | template uint16_t CRingBuffer::getData() const 50 | { 51 | if (m_tail == m_head) 52 | return m_full ? m_length : 0U; 53 | else if (m_tail < m_head) 54 | return m_head - m_tail; 55 | else 56 | return m_length - m_tail + m_head; 57 | } 58 | 59 | template bool CRingBuffer::put(TDATATYPE item) volatile 60 | { 61 | if (m_full) { 62 | m_overflow = true; 63 | return false; 64 | } 65 | 66 | m_buffer[m_head] = item; 67 | 68 | m_head++; 69 | if (m_head >= m_length) 70 | m_head = 0U; 71 | 72 | if (m_head == m_tail) 73 | m_full = true; 74 | 75 | return true; 76 | } 77 | 78 | template TDATATYPE CRingBuffer::peek() const 79 | { 80 | return m_buffer[m_tail]; 81 | } 82 | 83 | template bool CRingBuffer::get(TDATATYPE& item) volatile 84 | { 85 | if (m_head == m_tail && !m_full) 86 | return false; 87 | 88 | item = m_buffer[m_tail]; 89 | 90 | m_full = false; 91 | 92 | m_tail++; 93 | if (m_tail >= m_length) 94 | m_tail = 0U; 95 | 96 | return true; 97 | } 98 | 99 | template bool CRingBuffer::hasOverflowed() 100 | { 101 | bool overflow = m_overflow; 102 | 103 | m_overflow = false; 104 | 105 | return overflow; 106 | } 107 | 108 | template void CRingBuffer::reset() 109 | { 110 | m_head = 0U; 111 | m_tail = 0U; 112 | m_full = false; 113 | m_overflow = false; 114 | } 115 | -------------------------------------------------------------------------------- /pins/pins_f4_discovery.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019,2020 by BG5HHP 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef _PINS_F4_DISCOVERY_H 20 | #define _PINS_F4_DISCOVERY_H 21 | 22 | /* 23 | Pin definitions for STM32F4 Discovery Board: 24 | 25 | PTT PB13 output P1 Pin37 26 | COSLED PA7 output P1 Pin17 27 | LED PD15 output P1 Pin47 28 | COS PA5 input P1 Pin15 29 | 30 | DSTAR PD12 output P1 Pin44 31 | DMR PD13 output P1 Pin45 32 | YSF PD14 output P1 Pin46 33 | P25 PD11 output P1 Pin43 34 | NXDN PD10 output P1 Pin42 35 | 36 | RX PA0 analog input P1 Pin12 37 | RSSI PA1 analog input P1 Pin11 38 | TX PA4 analog output P1 Pin16 39 | 40 | EXT_CLK PA15 input P2 Pin40 41 | */ 42 | 43 | #define PIN_COS GPIO_Pin_5 44 | #define PORT_COS GPIOA 45 | #define RCC_Per_COS RCC_AHB1Periph_GPIOA 46 | 47 | #define PIN_PTT GPIO_Pin_13 48 | #define PORT_PTT GPIOB 49 | #define RCC_Per_PTT RCC_AHB1Periph_GPIOB 50 | 51 | #define PIN_COSLED GPIO_Pin_7 52 | #define PORT_COSLED GPIOA 53 | #define RCC_Per_COSLED RCC_AHB1Periph_GPIOA 54 | 55 | #define PIN_LED GPIO_Pin_15 56 | #define PORT_LED GPIOD 57 | #define RCC_Per_LED RCC_AHB1Periph_GPIOD 58 | 59 | #define PIN_P25 GPIO_Pin_11 60 | #define PORT_P25 GPIOD 61 | #define RCC_Per_P25 RCC_AHB1Periph_GPIOD 62 | 63 | #define PIN_NXDN GPIO_Pin_10 64 | #define PORT_NXDN GPIOD 65 | #define RCC_Per_NXDN RCC_AHB1Periph_GPIOD 66 | 67 | #define PIN_DSTAR GPIO_Pin_12 68 | #define PORT_DSTAR GPIOD 69 | #define RCC_Per_DSTAR RCC_AHB1Periph_GPIOD 70 | 71 | #define PIN_DMR GPIO_Pin_13 72 | #define PORT_DMR GPIOD 73 | #define RCC_Per_DMR RCC_AHB1Periph_GPIOD 74 | 75 | #define PIN_YSF GPIO_Pin_14 76 | #define PORT_YSF GPIOD 77 | #define RCC_Per_YSF RCC_AHB1Periph_GPIOD 78 | 79 | #define PIN_EXT_CLK GPIO_Pin_15 80 | #define SRC_EXT_CLK GPIO_PinSource15 81 | #define PORT_EXT_CLK GPIOA 82 | 83 | #define PIN_RX GPIO_Pin_0 84 | #define PIN_RX_CH ADC_Channel_0 85 | #define PORT_RX GPIOA 86 | #define RCC_Per_RX RCC_AHB1Periph_GPIOA 87 | 88 | #define PIN_RSSI GPIO_Pin_1 89 | #define PIN_RSSI_CH ADC_Channel_1 90 | #define PORT_RSSI GPIOA 91 | #define RCC_Per_RSSI RCC_AHB1Periph_GPIOA 92 | 93 | #define PIN_TX GPIO_Pin_4 94 | #define PIN_TX_CH DAC_Channel_1 95 | 96 | #endif -------------------------------------------------------------------------------- /pins/pins_f4_pi.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019,2020 by BG5HHP 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef _PINS_F4_PI_H 20 | #define _PINS_F4_PI_H 21 | 22 | /* 23 | Pin definitions for STM32F4 Pi Board: 24 | 25 | PTT PB13 output 26 | COSLED PB14 output 27 | LED PB15 output 28 | COS PC0 input 29 | 30 | DSTAR PC7 output 31 | DMR PC8 output 32 | YSF PA8 output 33 | P25 PC9 output 34 | NXDN PB1 output 35 | POCSAG PB12 output 36 | 37 | RX PA0 analog input 38 | RSSI PA7 analog input 39 | TX PA4 analog output 40 | 41 | EXT_CLK PA15 input 42 | */ 43 | 44 | #define PIN_COS GPIO_Pin_0 45 | #define PORT_COS GPIOC 46 | #define RCC_Per_COS RCC_AHB1Periph_GPIOC 47 | 48 | #define PIN_PTT GPIO_Pin_13 49 | #define PORT_PTT GPIOB 50 | #define RCC_Per_PTT RCC_AHB1Periph_GPIOB 51 | 52 | #define PIN_COSLED GPIO_Pin_14 53 | #define PORT_COSLED GPIOB 54 | #define RCC_Per_COSLED RCC_AHB1Periph_GPIOB 55 | 56 | #define PIN_LED GPIO_Pin_15 57 | #define PORT_LED GPIOB 58 | #define RCC_Per_LED RCC_AHB1Periph_GPIOB 59 | 60 | #define PIN_P25 GPIO_Pin_9 61 | #define PORT_P25 GPIOC 62 | #define RCC_Per_P25 RCC_AHB1Periph_GPIOC 63 | 64 | #define PIN_NXDN GPIO_Pin_1 65 | #define PORT_NXDN GPIOB 66 | #define RCC_Per_NXDN RCC_AHB1Periph_GPIOB 67 | 68 | #define PIN_POCSAG GPIO_Pin_12 69 | #define PORT_POCSAG GPIOB 70 | #define RCC_Per_POCSAG RCC_AHB1Periph_GPIOB 71 | 72 | #define PIN_DSTAR GPIO_Pin_7 73 | #define PORT_DSTAR GPIOC 74 | #define RCC_Per_DSTAR RCC_AHB1Periph_GPIOC 75 | 76 | #define PIN_DMR GPIO_Pin_8 77 | #define PORT_DMR GPIOC 78 | #define RCC_Per_DMR RCC_AHB1Periph_GPIOC 79 | 80 | #define PIN_YSF GPIO_Pin_8 81 | #define PORT_YSF GPIOA 82 | #define RCC_Per_YSF RCC_AHB1Periph_GPIOA 83 | 84 | #define PIN_EXT_CLK GPIO_Pin_15 85 | #define SRC_EXT_CLK GPIO_PinSource15 86 | #define PORT_EXT_CLK GPIOA 87 | 88 | #define PIN_RX GPIO_Pin_0 89 | #define PIN_RX_CH ADC_Channel_0 90 | #define PORT_RX GPIOA 91 | #define RCC_Per_RX RCC_AHB1Periph_GPIOA 92 | 93 | #define PIN_RSSI GPIO_Pin_7 94 | #define PIN_RSSI_CH ADC_Channel_7 95 | #define PORT_RSSI GPIOA 96 | #define RCC_Per_RSSI RCC_AHB1Periph_GPIOA 97 | 98 | #define PIN_TX GPIO_Pin_4 99 | #define PIN_TX_CH DAC_Channel_1 100 | 101 | #endif -------------------------------------------------------------------------------- /pins/pins_f7_pi.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019,2020 by BG5HHP 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef _PINS_F7_PI_H 20 | #define _PINS_F7_PI_H 21 | 22 | /* 23 | Pin definitions for STM32F722 Pi Board: 24 | 25 | PTT PB13 output 26 | COSLED PB14 output 27 | LED PB15 output 28 | COS PC0 input 29 | 30 | DSTAR PC7 output 31 | DMR PC8 output 32 | YSF PA8 output 33 | P25 PC9 output 34 | NXDN PB1 output 35 | POCSAG PB12 output 36 | 37 | RX PA0 analog input 38 | RSSI PA7 analog input 39 | TX PA4 analog output 40 | 41 | EXT_CLK PA15 input 42 | */ 43 | 44 | #define PIN_COS GPIO_Pin_0 45 | #define PORT_COS GPIOC 46 | #define RCC_Per_COS RCC_AHB1Periph_GPIOC 47 | 48 | #define PIN_PTT GPIO_Pin_13 49 | #define PORT_PTT GPIOB 50 | #define RCC_Per_PTT RCC_AHB1Periph_GPIOB 51 | 52 | #define PIN_COSLED GPIO_Pin_14 53 | #define PORT_COSLED GPIOB 54 | #define RCC_Per_COSLED RCC_AHB1Periph_GPIOB 55 | 56 | #define PIN_LED GPIO_Pin_15 57 | #define PORT_LED GPIOB 58 | #define RCC_Per_LED RCC_AHB1Periph_GPIOB 59 | 60 | #define PIN_P25 GPIO_Pin_9 61 | #define PORT_P25 GPIOC 62 | #define RCC_Per_P25 RCC_AHB1Periph_GPIOC 63 | 64 | #define PIN_NXDN GPIO_Pin_1 65 | #define PORT_NXDN GPIOB 66 | #define RCC_Per_NXDN RCC_AHB1Periph_GPIOB 67 | 68 | #define PIN_POCSAG GPIO_Pin_12 69 | #define PORT_POCSAG GPIOB 70 | #define RCC_Per_POCSAG RCC_AHB1Periph_GPIOB 71 | 72 | #define PIN_DSTAR GPIO_Pin_7 73 | #define PORT_DSTAR GPIOC 74 | #define RCC_Per_DSTAR RCC_AHB1Periph_GPIOC 75 | 76 | #define PIN_DMR GPIO_Pin_8 77 | #define PORT_DMR GPIOC 78 | #define RCC_Per_DMR RCC_AHB1Periph_GPIOC 79 | 80 | #define PIN_YSF GPIO_Pin_8 81 | #define PORT_YSF GPIOA 82 | #define RCC_Per_YSF RCC_AHB1Periph_GPIOA 83 | 84 | #define PIN_EXT_CLK GPIO_Pin_15 85 | #define SRC_EXT_CLK GPIO_PinSource15 86 | #define PORT_EXT_CLK GPIOA 87 | 88 | #define PIN_RX GPIO_Pin_0 89 | #define PIN_RX_CH ADC_Channel_0 90 | #define PORT_RX GPIOA 91 | #define RCC_Per_RX RCC_AHB1Periph_GPIOA 92 | 93 | #define PIN_RSSI GPIO_Pin_7 94 | #define PIN_RSSI_CH ADC_Channel_7 95 | #define PORT_RSSI GPIOA 96 | #define RCC_Per_RSSI RCC_AHB1Periph_GPIOA 97 | 98 | #define PIN_TX GPIO_Pin_4 99 | #define PIN_TX_CH DAC_Channel_1 100 | 101 | #endif -------------------------------------------------------------------------------- /pins/pins_f4_f4m.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019,2020 by BG5HHP 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef _PINS_F4_F4M_H 20 | #define _PINS_F4_F4M_H 21 | 22 | /* 23 | Pin definitions for MMDVM-F4M Pi-Hat F0DEI board: 24 | 25 | PTT PB13 output 26 | COSLED PB14 output 27 | LED PB15 output 28 | COS PC0 input 29 | 30 | DSTAR PC7 output 31 | DMR PC8 output 32 | YSF PA8 output 33 | P25 PC9 output 34 | NXDN PB1 output 35 | POCSAG PB12 output 36 | 37 | RX PA0 analog input 38 | RSSI PA7 analog input 39 | TX PA4 analog output 40 | 41 | EXT_CLK PA15 input 42 | */ 43 | 44 | #define PIN_COS GPIO_Pin_0 45 | #define PORT_COS GPIOC 46 | #define RCC_Per_COS RCC_AHB1Periph_GPIOC 47 | 48 | #define PIN_PTT GPIO_Pin_13 49 | #define PORT_PTT GPIOB 50 | #define RCC_Per_PTT RCC_AHB1Periph_GPIOB 51 | 52 | #define PIN_COSLED GPIO_Pin_14 53 | #define PORT_COSLED GPIOB 54 | #define RCC_Per_COSLED RCC_AHB1Periph_GPIOB 55 | 56 | #define PIN_LED GPIO_Pin_15 57 | #define PORT_LED GPIOB 58 | #define RCC_Per_LED RCC_AHB1Periph_GPIOB 59 | 60 | #define PIN_P25 GPIO_Pin_9 61 | #define PORT_P25 GPIOC 62 | #define RCC_Per_P25 RCC_AHB1Periph_GPIOC 63 | 64 | #define PIN_NXDN GPIO_Pin_1 65 | #define PORT_NXDN GPIOB 66 | #define RCC_Per_NXDN RCC_AHB1Periph_GPIOB 67 | 68 | #define PIN_POCSAG GPIO_Pin_12 69 | #define PORT_POCSAG GPIOB 70 | #define RCC_Per_POCSAG RCC_AHB1Periph_GPIOB 71 | 72 | #define PIN_DSTAR GPIO_Pin_7 73 | #define PORT_DSTAR GPIOC 74 | #define RCC_Per_DSTAR RCC_AHB1Periph_GPIOC 75 | 76 | #define PIN_DMR GPIO_Pin_8 77 | #define PORT_DMR GPIOC 78 | #define RCC_Per_DMR RCC_AHB1Periph_GPIOC 79 | 80 | #define PIN_YSF GPIO_Pin_8 81 | #define PORT_YSF GPIOA 82 | #define RCC_Per_YSF RCC_AHB1Periph_GPIOA 83 | 84 | #define PIN_EXT_CLK GPIO_Pin_15 85 | #define SRC_EXT_CLK GPIO_PinSource15 86 | #define PORT_EXT_CLK GPIOA 87 | 88 | #define PIN_RX GPIO_Pin_0 89 | #define PIN_RX_CH ADC_Channel_0 90 | #define PORT_RX GPIOA 91 | #define RCC_Per_RX RCC_AHB1Periph_GPIOA 92 | 93 | #define PIN_RSSI GPIO_Pin_7 94 | #define PIN_RSSI_CH ADC_Channel_7 95 | #define PORT_RSSI GPIOA 96 | #define RCC_Per_RSSI RCC_AHB1Periph_GPIOA 97 | 98 | #define PIN_TX GPIO_Pin_4 99 | #define PIN_TX_CH DAC_Channel_1 100 | 101 | #endif -------------------------------------------------------------------------------- /pins/pins_f7_f7m.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019,2020 by BG5HHP 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef _PINS_F7_F7M_H 20 | #define _PINS_F7_F7M_H 21 | 22 | /* 23 | Pin definitions for MMDVM-F7M Pi-Hat F0DEI board: 24 | 25 | PTT PB13 output 26 | COSLED PB14 output 27 | LED PB15 output 28 | COS PC0 input 29 | 30 | DSTAR PC7 output 31 | DMR PC8 output 32 | YSF PA8 output 33 | P25 PC9 output 34 | NXDN PB1 output 35 | POCSAG PB12 output 36 | 37 | RX PA0 analog input 38 | RSSI PA7 analog input 39 | TX PA4 analog output 40 | 41 | EXT_CLK PA15 input 42 | */ 43 | 44 | #define PIN_COS GPIO_Pin_0 45 | #define PORT_COS GPIOC 46 | #define RCC_Per_COS RCC_AHB1Periph_GPIOC 47 | 48 | #define PIN_PTT GPIO_Pin_13 49 | #define PORT_PTT GPIOB 50 | #define RCC_Per_PTT RCC_AHB1Periph_GPIOB 51 | 52 | #define PIN_COSLED GPIO_Pin_14 53 | #define PORT_COSLED GPIOB 54 | #define RCC_Per_COSLED RCC_AHB1Periph_GPIOB 55 | 56 | #define PIN_LED GPIO_Pin_15 57 | #define PORT_LED GPIOB 58 | #define RCC_Per_LED RCC_AHB1Periph_GPIOB 59 | 60 | #define PIN_P25 GPIO_Pin_9 61 | #define PORT_P25 GPIOC 62 | #define RCC_Per_P25 RCC_AHB1Periph_GPIOC 63 | 64 | #define PIN_NXDN GPIO_Pin_1 65 | #define PORT_NXDN GPIOB 66 | #define RCC_Per_NXDN RCC_AHB1Periph_GPIOB 67 | 68 | #define PIN_POCSAG GPIO_Pin_12 69 | #define PORT_POCSAG GPIOB 70 | #define RCC_Per_POCSAG RCC_AHB1Periph_GPIOB 71 | 72 | #define PIN_DSTAR GPIO_Pin_7 73 | #define PORT_DSTAR GPIOC 74 | #define RCC_Per_DSTAR RCC_AHB1Periph_GPIOC 75 | 76 | #define PIN_DMR GPIO_Pin_8 77 | #define PORT_DMR GPIOC 78 | #define RCC_Per_DMR RCC_AHB1Periph_GPIOC 79 | 80 | #define PIN_YSF GPIO_Pin_8 81 | #define PORT_YSF GPIOA 82 | #define RCC_Per_YSF RCC_AHB1Periph_GPIOA 83 | 84 | #define PIN_EXT_CLK GPIO_Pin_15 85 | #define SRC_EXT_CLK GPIO_PinSource15 86 | #define PORT_EXT_CLK GPIOA 87 | 88 | #define PIN_RX GPIO_Pin_0 89 | #define PIN_RX_CH ADC_Channel_0 90 | #define PORT_RX GPIOA 91 | #define RCC_Per_RX RCC_AHB1Periph_GPIOA 92 | 93 | #define PIN_RSSI GPIO_Pin_7 94 | #define PIN_RSSI_CH ADC_Channel_7 95 | #define PORT_RSSI GPIOA 96 | #define RCC_Per_RSSI RCC_AHB1Periph_GPIOA 97 | 98 | #define PIN_TX GPIO_Pin_4 99 | #define PIN_TX_CH DAC_Channel_1 100 | 101 | #endif -------------------------------------------------------------------------------- /DStarDefines.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015,2017,2020 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #if !defined(DSTARDEFINES_H) 20 | #define DSTARDEFINES_H 21 | 22 | const unsigned int DSTAR_RADIO_SYMBOL_LENGTH = 5U; // At 24 kHz sample rate 23 | 24 | const unsigned int DSTAR_HEADER_LENGTH_BYTES = 41U; 25 | 26 | const unsigned int DSTAR_FEC_SECTION_LENGTH_BYTES = 83U; 27 | const unsigned int DSTAR_FEC_SECTION_LENGTH_SYMBOLS = 660U; 28 | const unsigned int DSTAR_FEC_SECTION_LENGTH_SAMPLES = DSTAR_FEC_SECTION_LENGTH_SYMBOLS * DSTAR_RADIO_SYMBOL_LENGTH; 29 | 30 | const unsigned int DSTAR_DATA_LENGTH_BYTES = 12U; 31 | const unsigned int DSTAR_DATA_LENGTH_SYMBOLS = DSTAR_DATA_LENGTH_BYTES * 8U; 32 | const unsigned int DSTAR_DATA_LENGTH_SAMPLES = DSTAR_DATA_LENGTH_SYMBOLS * DSTAR_RADIO_SYMBOL_LENGTH; 33 | 34 | const unsigned int DSTAR_END_SYNC_LENGTH_BYTES = 6U; 35 | const unsigned int DSTAR_END_SYNC_LENGTH_BITS = DSTAR_END_SYNC_LENGTH_BYTES * 8U; 36 | 37 | const unsigned int DSTAR_FRAME_SYNC_LENGTH_BYTES = 3U; 38 | const unsigned int DSTAR_FRAME_SYNC_LENGTH_SYMBOLS = DSTAR_FRAME_SYNC_LENGTH_BYTES * 8U; 39 | const unsigned int DSTAR_FRAME_SYNC_LENGTH_SAMPLES = DSTAR_FRAME_SYNC_LENGTH_SYMBOLS * DSTAR_RADIO_SYMBOL_LENGTH; 40 | 41 | const unsigned int DSTAR_DATA_SYNC_LENGTH_BYTES = 3U; 42 | const unsigned int DSTAR_DATA_SYNC_LENGTH_SYMBOLS = DSTAR_DATA_SYNC_LENGTH_BYTES * 8U; 43 | const unsigned int DSTAR_DATA_SYNC_LENGTH_SAMPLES = DSTAR_DATA_SYNC_LENGTH_SYMBOLS * DSTAR_RADIO_SYMBOL_LENGTH; 44 | 45 | const uint8_t DSTAR_DATA_SYNC_BYTES[] = {0x9E, 0x8D, 0x32, 0x88, 0x26, 0x1A, 0x3F, 0x61, 0xE8, 0x55, 0x2D, 0x16}; 46 | 47 | // D-Star bit order version of 0x55 0x6E 0x0A 48 | const uint32_t DSTAR_FRAME_SYNC_DATA = 0x00557650U; 49 | const uint32_t DSTAR_FRAME_SYNC_MASK = 0x00FFFFFFU; 50 | 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}; 51 | 52 | // D-Star bit order version of 0x55 0x2D 0x16 53 | const uint32_t DSTAR_DATA_SYNC_DATA = 0x00AAB468U; 54 | const uint32_t DSTAR_DATA_SYNC_MASK = 0x00FFFFFFU; 55 | 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}; 56 | 57 | // D-Star bit order version of 0x55 0x55 0xC8 0x7A 58 | const uint32_t DSTAR_END_SYNC_DATA = 0xAAAA135EU; 59 | const uint32_t DSTAR_END_SYNC_MASK = 0xFFFFFFFFU; 60 | const uint8_t DSTAR_END_SYNC_BYTES[] = {0x55, 0x55, 0x55, 0x55, 0xC8, 0x7A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; 61 | 62 | const uint8_t DSTAR_SLOW_DATA_TYPE_TEXT = 0x40U; 63 | const uint8_t DSTAR_SLOW_DATA_TYPE_HEADER = 0x50U; 64 | 65 | const uint8_t DSTAR_SCRAMBLER_BYTES[] = {0x70U, 0x4FU, 0x93U}; 66 | 67 | #endif 68 | 69 | -------------------------------------------------------------------------------- /pins/pins_f4_stm32eda.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019,2020 by BG5HHP 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef _PINS_F4_STM32EDA 20 | #define _PINS_F4_STM32EDA 21 | 22 | /* 23 | Pin definitions for STM32F4 STM32-DVM-MTR2K & STM32-DVM-MASTR3: 24 | 25 | COS PB13 input 26 | PTT PB12 output 27 | COSLED PB4 output 28 | LED PB3 output 29 | 30 | P25 PB8 output 31 | NXDN PB9 output 32 | DSTAR PB6 output 33 | DMR PB5 output 34 | YSF PB7 output 35 | POCSAG PC10 output 36 | FM PB14 output 37 | 38 | RX PB0 analog input 39 | RSSI PB1 analog input 40 | TX PA4 analog output 41 | 42 | EXT_CLK PA15 input 43 | */ 44 | 45 | #define PIN_COS GPIO_Pin_13 46 | #define PORT_COS GPIOB 47 | #define RCC_Per_COS RCC_AHB1Periph_GPIOB 48 | 49 | 50 | #define PIN_PTT GPIO_Pin_12 51 | #define PORT_PTT GPIOB 52 | #define RCC_Per_PTT RCC_AHB1Periph_GPIOB 53 | 54 | #define PIN_COSLED GPIO_Pin_4 55 | #define PORT_COSLED GPIOB 56 | #define RCC_Per_COSLED RCC_AHB1Periph_GPIOB 57 | 58 | #define PIN_LED GPIO_Pin_3 59 | #define PORT_LED GPIOB 60 | #define RCC_Per_LED RCC_AHB1Periph_GPIOB 61 | 62 | #define PIN_P25 GPIO_Pin_8 63 | #define PORT_P25 GPIOB 64 | #define RCC_Per_P25 RCC_AHB1Periph_GPIOB 65 | 66 | #define PIN_NXDN GPIO_Pin_9 67 | #define PORT_NXDN GPIOB 68 | #define RCC_Per_NXDN RCC_AHB1Periph_GPIOB 69 | 70 | #define PIN_DSTAR GPIO_Pin_6 71 | #define PORT_DSTAR GPIOB 72 | #define RCC_Per_DSTAR RCC_AHB1Periph_GPIOB 73 | 74 | #define PIN_DMR GPIO_Pin_5 75 | #define PORT_DMR GPIOB 76 | #define RCC_Per_DMR RCC_AHB1Periph_GPIOB 77 | 78 | #define PIN_YSF GPIO_Pin_7 79 | #define PORT_YSF GPIOB 80 | #define RCC_Per_YSF RCC_AHB1Periph_GPIOB 81 | 82 | #define PIN_POCSAG GPIO_Pin_10 83 | #define PORT_POCSAG GPIOC 84 | #define RCC_Per_POCSAG RCC_AHB1Periph_GPIOC 85 | 86 | #define PIN_FM GPIO_Pin_14 87 | #define PORT_FM GPIOB 88 | #define RCC_Per_FM RCC_AHB1Periph_GPIOB 89 | 90 | #define PIN_EXT_CLK GPIO_Pin_15 91 | #define SRC_EXT_CLK GPIO_PinSource15 92 | #define PORT_EXT_CLK GPIOA 93 | 94 | #define PIN_RX GPIO_Pin_0 95 | #define PIN_RX_CH ADC_Channel_8 96 | #define PORT_RX GPIOB 97 | #define RCC_Per_RX RCC_AHB1Periph_GPIOB 98 | 99 | #define PIN_RSSI GPIO_Pin_1 100 | #define PIN_RSSI_CH ADC_Channel_9 101 | #define PORT_RSSI GPIOB 102 | #define RCC_Per_RSSI RCC_AHB1Periph_GPIOB 103 | 104 | #define PIN_TX GPIO_Pin_4 105 | #define PIN_TX_CH DAC_Channel_1 106 | 107 | #endif 108 | 109 | -------------------------------------------------------------------------------- /pins/pins_f4_stm32dvm_v3.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019,2020 by BG5HHP 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef _PINS_F4_STM32DVM_V3_H 20 | #define _PINS_F4_STM32DVM_V3_H 21 | 22 | /* 23 | Pin definitions for STM32F4 STM32-DVM rev 3 Board: 24 | 25 | COS PB13 input 26 | PTT PB12 output 27 | COSLED PB4 output 28 | LED PB3 output 29 | 30 | P25 PB8 output 31 | NXDN PB9 output 32 | DSTAR PB6 output 33 | DMR PB5 output 34 | YSF PB7 output 35 | POCSAG PC10 output (Not Valid) 36 | FM PB14 output 37 | 38 | RX PB0 analog input 39 | RSSI PB1 analog input 40 | TX PA4 analog output 41 | 42 | EXT_CLK PA15 input 43 | */ 44 | 45 | #define PIN_COS GPIO_Pin_13 46 | #define PORT_COS GPIOB 47 | #define RCC_Per_COS RCC_AHB1Periph_GPIOB 48 | 49 | #define PIN_PTT GPIO_Pin_12 50 | #define PORT_PTT GPIOB 51 | #define RCC_Per_PTT RCC_AHB1Periph_GPIOB 52 | 53 | #define PIN_COSLED GPIO_Pin_4 54 | #define PORT_COSLED GPIOB 55 | #define RCC_Per_COSLED RCC_AHB1Periph_GPIOB 56 | 57 | #define PIN_LED GPIO_Pin_3 58 | #define PORT_LED GPIOB 59 | #define RCC_Per_LED RCC_AHB1Periph_GPIOB 60 | 61 | #define PIN_P25 GPIO_Pin_8 62 | #define PORT_P25 GPIOB 63 | #define RCC_Per_P25 RCC_AHB1Periph_GPIOB 64 | 65 | #define PIN_NXDN GPIO_Pin_9 66 | #define PORT_NXDN GPIOB 67 | #define RCC_Per_NXDN RCC_AHB1Periph_GPIOB 68 | 69 | #define PIN_DSTAR GPIO_Pin_6 70 | #define PORT_DSTAR GPIOB 71 | #define RCC_Per_DSTAR RCC_AHB1Periph_GPIOB 72 | 73 | #define PIN_DMR GPIO_Pin_5 74 | #define PORT_DMR GPIOB 75 | #define RCC_Per_DMR RCC_AHB1Periph_GPIOB 76 | 77 | #define PIN_YSF GPIO_Pin_7 78 | #define PORT_YSF GPIOB 79 | #define RCC_Per_YSF RCC_AHB1Periph_GPIOB 80 | 81 | /* 82 | #define PIN_POCSAG GPIO_Pin_10 83 | #define PORT_POCSAG GPIOC 84 | #define RCC_Per_POCSAG RCC_AHB1Periph_GPIOC 85 | */ 86 | 87 | #define PIN_FM GPIO_Pin_14 88 | #define PORT_FM GPIOB 89 | #define RCC_Per_FM RCC_AHB1Periph_GPIOB 90 | 91 | #define PIN_EXT_CLK GPIO_Pin_15 92 | #define SRC_EXT_CLK GPIO_PinSource15 93 | #define PORT_EXT_CLK GPIOA 94 | 95 | #define PIN_RX GPIO_Pin_0 96 | #define PIN_RX_CH ADC_Channel_8 97 | #define PORT_RX GPIOB 98 | #define RCC_Per_RX RCC_AHB1Periph_GPIOB 99 | 100 | #define PIN_RSSI GPIO_Pin_1 101 | #define PIN_RSSI_CH ADC_Channel_9 102 | #define PORT_RSSI GPIOB 103 | #define RCC_Per_RSSI RCC_AHB1Periph_GPIOB 104 | 105 | #define PIN_TX GPIO_Pin_4 106 | #define PIN_TX_CH DAC_Channel_1 107 | 108 | #endif 109 | -------------------------------------------------------------------------------- /pins/pins_f7_stm32dvm_v5.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019,2020 by BG5HHP 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef _PINS_F7_STM32DVM_V5_H 20 | #define _PINS_F7_STM32DVM_V5_H 21 | 22 | /* 23 | Pin definitions for STM32F7 STM32-DVM rev 5 Board: 24 | 25 | COS PB13 input 26 | PTT PB12 output 27 | COSLED PB4 output 28 | LED PB3 output 29 | 30 | P25 PB8 output 31 | NXDN PB9 output 32 | DSTAR PB6 output 33 | DMR PB5 output 34 | YSF PB7 output 35 | POCSAG PC10 output (Not Valid) 36 | FM PB14 output 37 | 38 | RX PB0 analog input 39 | RSSI PB1 analog input 40 | TX PA4 analog output 41 | 42 | EXT_CLK PA15 input 43 | */ 44 | 45 | #define PIN_COS GPIO_Pin_13 46 | #define PORT_COS GPIOB 47 | #define RCC_Per_COS RCC_AHB1Periph_GPIOB 48 | 49 | #define PIN_PTT GPIO_Pin_12 50 | #define PORT_PTT GPIOB 51 | #define RCC_Per_PTT RCC_AHB1Periph_GPIOB 52 | 53 | #define PIN_COSLED GPIO_Pin_4 54 | #define PORT_COSLED GPIOB 55 | #define RCC_Per_COSLED RCC_AHB1Periph_GPIOB 56 | 57 | #define PIN_LED GPIO_Pin_3 58 | #define PORT_LED GPIOB 59 | #define RCC_Per_LED RCC_AHB1Periph_GPIOB 60 | 61 | #define PIN_P25 GPIO_Pin_8 62 | #define PORT_P25 GPIOB 63 | #define RCC_Per_P25 RCC_AHB1Periph_GPIOB 64 | 65 | #define PIN_NXDN GPIO_Pin_9 66 | #define PORT_NXDN GPIOB 67 | #define RCC_Per_NXDN RCC_AHB1Periph_GPIOB 68 | 69 | #define PIN_DSTAR GPIO_Pin_6 70 | #define PORT_DSTAR GPIOB 71 | #define RCC_Per_DSTAR RCC_AHB1Periph_GPIOB 72 | 73 | #define PIN_DMR GPIO_Pin_5 74 | #define PORT_DMR GPIOB 75 | #define RCC_Per_DMR RCC_AHB1Periph_GPIOB 76 | 77 | #define PIN_YSF GPIO_Pin_7 78 | #define PORT_YSF GPIOB 79 | #define RCC_Per_YSF RCC_AHB1Periph_GPIOB 80 | 81 | /* 82 | #define PIN_POCSAG GPIO_Pin_10 83 | #define PORT_POCSAG GPIOC 84 | #define RCC_Per_POCSAG RCC_AHB1Periph_GPIOC 85 | */ 86 | 87 | #define PIN_FM GPIO_Pin_14 88 | #define PORT_FM GPIOB 89 | #define RCC_Per_FM RCC_AHB1Periph_GPIOB 90 | 91 | #define PIN_EXT_CLK GPIO_Pin_15 92 | #define SRC_EXT_CLK GPIO_PinSource15 93 | #define PORT_EXT_CLK GPIOA 94 | 95 | #define PIN_RX GPIO_Pin_0 96 | #define PIN_RX_CH ADC_Channel_8 97 | #define PORT_RX GPIOB 98 | #define RCC_Per_RX RCC_AHB1Periph_GPIOB 99 | 100 | #define PIN_RSSI GPIO_Pin_1 101 | #define PIN_RSSI_CH ADC_Channel_9 102 | #define PORT_RSSI GPIOB 103 | #define RCC_Per_RSSI RCC_AHB1Periph_GPIOB 104 | 105 | #define PIN_TX GPIO_Pin_4 106 | #define PIN_TX_CH DAC_Channel_1 107 | 108 | #endif 109 | -------------------------------------------------------------------------------- /CalFM.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015,2020 by Jonathan Naylor G4KLX 3 | * Copyright (C) 2016 by Colin Durbridge G4EML 4 | * Copyright (C) 2020 by Phil Taylor M0VSE 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | #include "Config.h" 22 | 23 | #if defined(MODE_FM) 24 | 25 | #include "Globals.h" 26 | #include "CalFM.h" 27 | 28 | 29 | const struct TONE_TABLE { 30 | uint16_t frequency; 31 | uint16_t length; 32 | q31_t increment; 33 | } TONE_TABLE_DATA[] = { 34 | {2495U, 10U, 223248821}, 35 | {2079U, 12U, 186025772}, 36 | {1633U, 15U, 146118367}, 37 | {1247U, 19U, 111579672}, 38 | {1039U, 23U, 93012886}, 39 | {956U, 25U, 85541432}}; 40 | 41 | const uint8_t TONE_TABLE_DATA_LEN = 6U; 42 | 43 | CCalFM::CCalFM() : 44 | m_frequency(0), 45 | m_length(0), 46 | m_tone(NULL), 47 | m_level(128 * 12), 48 | m_transmit(false), 49 | m_audioSeq(0), 50 | m_lastState(STATE_IDLE) 51 | { 52 | } 53 | 54 | void CCalFM::process() 55 | { 56 | const TONE_TABLE* entry = NULL; 57 | 58 | if (m_modemState != m_lastState) 59 | { 60 | switch (m_modemState) { 61 | case STATE_FMCAL10K: 62 | m_frequency = 956U; 63 | break; 64 | case STATE_FMCAL12K: 65 | m_frequency = 1039U; 66 | break; 67 | case STATE_FMCAL15K: 68 | m_frequency = 1247U; 69 | break; 70 | case STATE_FMCAL20K: 71 | m_frequency = 1633U; 72 | break; 73 | case STATE_FMCAL25K: 74 | m_frequency = 2079U; 75 | break; 76 | case STATE_FMCAL30K: 77 | m_frequency = 2495U; 78 | break; 79 | default: 80 | m_frequency = 0U; 81 | break; 82 | } 83 | 84 | for (uint8_t i = 0U; i < TONE_TABLE_DATA_LEN; i++) { 85 | if (TONE_TABLE_DATA[i].frequency == m_frequency) { 86 | entry = TONE_TABLE_DATA + i; 87 | break; 88 | } 89 | } 90 | 91 | if (entry == NULL) 92 | return; 93 | 94 | m_length = entry->length; 95 | 96 | delete[] m_tone; 97 | m_tone = new q15_t[m_length]; 98 | 99 | q31_t arg = 0; 100 | for (uint16_t i = 0U; i < m_length; i++) { 101 | q63_t value = ::arm_sin_q31(arg) * q63_t(m_level); 102 | m_tone[i] = q15_t(__SSAT((value >> 31), 16)); 103 | 104 | arg += entry->increment; 105 | } 106 | 107 | m_lastState=m_modemState; 108 | } 109 | 110 | if (m_transmit) 111 | { 112 | uint16_t space = io.getSpace(); 113 | while (space > m_length) 114 | { 115 | io.write(m_modemState,m_tone,m_length); 116 | space -= m_length; 117 | } 118 | } 119 | } 120 | 121 | 122 | uint8_t CCalFM::write(const uint8_t* data, uint16_t length) 123 | { 124 | if (length != 1U) 125 | return 4U; 126 | 127 | m_transmit = data[0U] == 1U; 128 | 129 | return 0U; 130 | } 131 | 132 | #endif 133 | 134 | -------------------------------------------------------------------------------- /pins/pins_f4_nucleo_arduino.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019,2020 by BG5HHP 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef _PINS_F4_NUCLEO_ARDUINO_H 20 | #define _PINS_F4_NUCLEO_ARDUINO_H 21 | 22 | /* 23 | Pin definitions for STM32F4 Nucleo boards (Arduino header): 24 | 25 | PTT PB10 output CN9 Pin7 26 | COSLED PB3 output CN9 Pin4 27 | LED PB5 output CN9 Pin5 28 | COS PB4 input CN9 Pin6 29 | 30 | DSTAR PA1 output CN8 Pin2 31 | DMR PA4 output CN8 Pin3 32 | YSF PB0 output CN8 Pin4 33 | P25 PC1 output CN8 Pin5 34 | NXDN PA3 output CN9 Pin1 35 | POCSAG PB12 output 36 | 37 | RX PA0 analog input CN8 Pin1 38 | RSSI PC0 analog input CN8 Pin6 39 | TX PA5 analog output CN5 Pin6 40 | 41 | EXT_CLK PB8 input CN5 Pin10 42 | */ 43 | 44 | #define PIN_COS GPIO_Pin_4 45 | #define PORT_COS GPIOB 46 | #define RCC_Per_COS RCC_AHB1Periph_GPIOB 47 | 48 | #define PIN_PTT GPIO_Pin_10 49 | #define PORT_PTT GPIOB 50 | #define RCC_Per_PTT RCC_AHB1Periph_GPIOB 51 | 52 | #define PIN_COSLED GPIO_Pin_3 53 | #define PORT_COSLED GPIOB 54 | #define RCC_Per_COSLED RCC_AHB1Periph_GPIOB 55 | 56 | #define PIN_LED GPIO_Pin_5 57 | #define PORT_LED GPIOB 58 | #define RCC_Per_LED RCC_AHB1Periph_GPIOB 59 | 60 | #define PIN_P25 GPIO_Pin_1 61 | #define PORT_P25 GPIOC 62 | #define RCC_Per_P25 RCC_AHB1Periph_GPIOC 63 | 64 | #define PIN_NXDN GPIO_Pin_3 65 | #define PORT_NXDN GPIOA 66 | #define RCC_Per_NXDN RCC_AHB1Periph_GPIOA 67 | 68 | #define PIN_POCSAG GPIO_Pin_12 69 | #define PORT_POCSAG GPIOB 70 | #define RCC_Per_POCSAG RCC_AHB1Periph_GPIOB 71 | 72 | #define PIN_DSTAR GPIO_Pin_1 73 | #define PORT_DSTAR GPIOA 74 | #define RCC_Per_DSTAR RCC_AHB1Periph_GPIOA 75 | 76 | #define PIN_DMR GPIO_Pin_4 77 | #define PORT_DMR GPIOA 78 | #define RCC_Per_DMR RCC_AHB1Periph_GPIOA 79 | 80 | #define PIN_YSF GPIO_Pin_0 81 | #define PORT_YSF GPIOB 82 | #define RCC_Per_YSF RCC_AHB1Periph_GPIOB 83 | 84 | #define PIN_EXT_CLK GPIO_Pin_8 85 | #define SRC_EXT_CLK GPIO_PinSource8 86 | #define PORT_EXT_CLK GPIOB 87 | 88 | #define PIN_RX GPIO_Pin_0 89 | #define PIN_RX_CH ADC_Channel_0 90 | #define PORT_RX GPIOA 91 | #define RCC_Per_RX RCC_AHB1Periph_GPIOA 92 | 93 | #define PIN_RSSI GPIO_Pin_0 94 | #define PIN_RSSI_CH ADC_Channel_10 95 | #define PORT_RSSI GPIOC 96 | #define RCC_Per_RSSI RCC_AHB1Periph_GPIOC 97 | 98 | #define PIN_TX GPIO_Pin_5 99 | #define PIN_TX_CH DAC_Channel_2 100 | 101 | #endif -------------------------------------------------------------------------------- /FMDirectForm1.h: -------------------------------------------------------------------------------- 1 | 2 | /******************************************************************************* 3 | This header file has been taken from: 4 | "A Collection of Useful C++ Classes for Digital Signal Processing" 5 | By Vinnie Falco 6 | Bernd Porr adapted it for Linux and turned it into a filter using 7 | fixed point arithmetic. 8 | -------------------------------------------------------------------------------- 9 | License: MIT License (http://www.opensource.org/licenses/mit-license.php) 10 | Copyright (c) 2009 by Vinnie Falco 11 | Copyright (C) 2013-2017, Bernd Porr, mail@berndporr.me.uk 12 | Copyright (C) 2020 , Mario Molitor , mario_molitor@web.de 13 | Permission is hereby granted, free of charge, to any person obtaining a copy 14 | of this software and associated documentation files (the "Software"), to deal 15 | in the Software without restriction, including without limitation the rights 16 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 17 | copies of the Software, and to permit persons to whom the Software is 18 | furnished to do so, subject to the following conditions: 19 | The above copyright notice and this permission notice shall be included in 20 | all copies or substantial portions of the Software. 21 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 27 | THE SOFTWARE. 28 | *******************************************************************************/ 29 | 30 | // based on https://raw.githubusercontent.com/berndporr/iir_fixed_point/master/DirectFormI.h 31 | 32 | #include "Config.h" 33 | 34 | #if defined(MODE_FM) 35 | 36 | #include 37 | 38 | #ifndef DIRECTFORMI_H_ 39 | #define DIRECTFORMI_H_ 40 | class CFMDirectFormI 41 | { 42 | public: 43 | 44 | // convenience function which takes the a0 argument but ignores it! 45 | CFMDirectFormI(const q31_t b0, const q31_t b1, const q31_t b2, const q31_t, const q31_t a1, const q31_t a2) 46 | { 47 | // FIR coefficients 48 | c_b0 = b0; 49 | c_b1 = b1; 50 | c_b2 = b2; 51 | // IIR coefficients 52 | c_a1 = a1; 53 | c_a2 = a2; 54 | reset(); 55 | } 56 | 57 | CFMDirectFormI(const CFMDirectFormI &my) 58 | { 59 | // delay line 60 | m_x2 = my.m_x2; // x[n-2] 61 | m_y2 = my.m_y2; // y[n-2] 62 | m_x1 = my.m_x1; // x[n-1] 63 | m_y1 = my.m_y1; // y[n-1] 64 | 65 | // coefficients 66 | c_b0 = my.c_b0; 67 | c_b1 = my.c_b1; 68 | c_b2 = my.c_b2; // FIR 69 | c_a1 = my.c_a1; 70 | c_a2 = my.c_a2; // IIR 71 | } 72 | 73 | void reset() 74 | { 75 | m_x1 = 0; 76 | m_x2 = 0; 77 | m_y1 = 0; 78 | m_y2 = 0; 79 | } 80 | 81 | // filtering operation: one sample in and one out 82 | inline q15_t filter(const q15_t in) 83 | { 84 | // calculate the output 85 | q31_t out_upscaled = c_b0 * in + c_b1 * m_x1 + c_b2 * m_x2 - c_a1 * m_y1 - c_a2 * m_y2; 86 | 87 | q15_t out = __SSAT(out_upscaled >> 15, 15); 88 | 89 | // update the delay lines 90 | m_x2 = m_x1; 91 | m_y2 = m_y1; 92 | m_x1 = in; 93 | m_y1 = out; 94 | 95 | return out; 96 | } 97 | 98 | private: 99 | // delay line 100 | q31_t m_x2; // x[n-2] 101 | q31_t m_y2; // y[n-2] 102 | q31_t m_x1; // x[n-1] 103 | q31_t m_y1; // y[n-1] 104 | 105 | // coefficients 106 | q31_t c_b0,c_b1,c_b2; // FIR 107 | q31_t c_a1,c_a2; // IIR 108 | }; 109 | 110 | #endif /* DIRECTFORMI_H */ 111 | 112 | #endif 113 | 114 | -------------------------------------------------------------------------------- /CalDStarRX.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2016,2020 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #include "Config.h" 20 | 21 | #if defined(MODE_DSTAR) 22 | 23 | #include "Globals.h" 24 | #include "CalDStarRX.h" 25 | #include "Utils.h" 26 | 27 | const unsigned int BUFFER_LENGTH = 200U; 28 | 29 | const uint32_t PLLMAX = 0x10000U; 30 | const uint32_t PLLINC = PLLMAX / DSTAR_RADIO_SYMBOL_LENGTH; 31 | const uint32_t INC = PLLINC / 32U; 32 | 33 | // D-Star bit order version of 0x55 0x2D 0x16 34 | const uint32_t DATA_SYNC_DATA1 = 0x00AAB468U; 35 | const uint32_t DATA_SYNC_DATA2 = 0x00554B97U; 36 | const uint32_t DATA_SYNC_MASK = 0x00FFFFFFU; 37 | const uint8_t DATA_SYNC_ERRS = 2U; 38 | 39 | CCalDStarRX::CCalDStarRX() : 40 | m_pll(0U), 41 | m_prev(false), 42 | m_patternBuffer(0x00U), 43 | m_rxBuffer(), 44 | m_ptr(0U) 45 | { 46 | } 47 | 48 | void CCalDStarRX::samples(const q15_t* samples, uint8_t length) 49 | { 50 | for (uint16_t i = 0U; i < length; i++) { 51 | bool bit = samples[i] < 0; 52 | 53 | if (bit != m_prev) { 54 | if (m_pll < (PLLMAX / 2U)) 55 | m_pll += INC; 56 | else 57 | m_pll -= INC; 58 | } 59 | 60 | m_prev = bit; 61 | 62 | m_pll += PLLINC; 63 | 64 | if (m_pll >= PLLMAX) { 65 | m_pll -= PLLMAX; 66 | process(samples[i]); 67 | } 68 | } 69 | } 70 | 71 | void CCalDStarRX::process(q15_t value) 72 | { 73 | m_patternBuffer <<= 1; 74 | if (value < 0) 75 | m_patternBuffer |= 0x01U; 76 | 77 | m_rxBuffer[m_ptr++] = value; 78 | if (m_ptr >= 24U) 79 | m_ptr = 0U; 80 | 81 | if (countBits32((m_patternBuffer & DATA_SYNC_MASK) ^ DATA_SYNC_DATA1) <= DATA_SYNC_ERRS) { 82 | q15_t max = -16000; 83 | q15_t min = 16000; 84 | 85 | for (uint8_t i = 0U; i < 24U; i++) { 86 | q15_t value = m_rxBuffer[i]; 87 | 88 | if (value > max) 89 | max = value; 90 | if (value < min) 91 | min = value; 92 | } 93 | 94 | if ((max - min) > 5) { 95 | uint8_t buffer[5U]; 96 | buffer[0U] = 0x00U; 97 | buffer[1U] = (max >> 8) & 0xFFU; 98 | buffer[2U] = (max >> 0) & 0xFFU; 99 | buffer[3U] = (min >> 8) & 0xFFU; 100 | buffer[4U] = (min >> 0) & 0xFFU; 101 | 102 | serial.writeCalData(buffer, 5U); 103 | } 104 | } 105 | 106 | if (countBits32((m_patternBuffer & DATA_SYNC_MASK) ^ DATA_SYNC_DATA2) <= DATA_SYNC_ERRS) { 107 | q15_t max = -16000; 108 | q15_t min = 16000; 109 | 110 | for (uint8_t i = 0U; i < 24U; i++) { 111 | q15_t value = m_rxBuffer[i]; 112 | 113 | if (value > max) 114 | max = value; 115 | if (value < min) 116 | min = value; 117 | } 118 | 119 | if ((max - min) > 5) { 120 | uint8_t buffer[5U]; 121 | buffer[0U] = 0x80U; 122 | buffer[1U] = (max >> 8) & 0xFFU; 123 | buffer[2U] = (max >> 0) & 0xFFU; 124 | buffer[3U] = (min >> 8) & 0xFFU; 125 | buffer[4U] = (min >> 0) & 0xFFU; 126 | 127 | serial.writeCalData(buffer, 5U); 128 | } 129 | } 130 | } 131 | 132 | #endif 133 | 134 | -------------------------------------------------------------------------------- /FMCTCSSTX.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #include "Config.h" 20 | 21 | #if defined(MODE_FM) 22 | 23 | #include "Globals.h" 24 | #include "FMCTCSSTX.h" 25 | 26 | const struct TX_CTCSS_TABLE { 27 | uint8_t frequency; 28 | uint16_t length; 29 | q31_t increment; 30 | } TX_CTCSS_TABLE_DATA[] = { 31 | { 67U, 358U, 5995059}, 32 | { 69U, 346U, 6200860}, 33 | { 71U, 334U, 6433504}, 34 | { 74U, 323U, 6657200}, 35 | { 77U, 312U, 6889844}, 36 | { 79U, 301U, 7131436}, 37 | { 82U, 291U, 7381976}, 38 | { 85U, 281U, 7641463}, 39 | { 88U, 271U, 7918846}, 40 | { 91U, 262U, 8187282}, 41 | { 94U, 253U, 8482561}, 42 | { 97U, 246U, 8715205}, 43 | {100U, 240U, 8947849}, 44 | {103U, 232U, 9261024}, 45 | {107U, 224U, 9592094}, 46 | {110U, 216U, 9923165}, 47 | {114U, 209U, 10272131}, 48 | {118U, 202U, 10630045}, 49 | {123U, 195U, 11005854}, 50 | {127U, 189U, 11390612}, 51 | {131U, 182U, 11793265}, 52 | {136U, 176U, 12213814}, 53 | {141U, 170U, 12643310}, 54 | {146U, 164U, 13081755}, 55 | {151U, 159U, 13547043}, 56 | {156U, 153U, 14021279}, 57 | {159U, 150U, 14298662}, 58 | {162U, 148U, 14513411}, 59 | {165U, 145U, 14808690}, 60 | {167U, 143U, 15023438}, 61 | {171U, 140U, 15327665}, 62 | {173U, 138U, 15551361}, 63 | {177U, 135U, 15864536}, 64 | {179U, 133U, 16097180}, 65 | {183U, 131U, 16419303}, 66 | {186U, 129U, 16660894}, 67 | {189U, 126U, 16991965}, 68 | {192U, 124U, 17251452}, 69 | {196U, 122U, 17591471}, 70 | {199U, 120U, 17850958}, 71 | {203U, 118U, 18208872}, 72 | {206U, 116U, 18477308}, 73 | {210U, 114U, 18853117}, 74 | {218U, 110U, 19515258}, 75 | {225U, 106U, 20195295}, 76 | {229U, 105U, 20499521}, 77 | {233U, 103U, 20902175}, 78 | {241U, 99U, 21635898}, 79 | {250U, 96U, 22396465}, 80 | {254U, 94U, 22736484}}; 81 | 82 | const uint8_t CTCSS_TABLE_DATA_LEN = 50U; 83 | 84 | CFMCTCSSTX::CFMCTCSSTX() : 85 | m_values(NULL), 86 | m_length(0U), 87 | m_n(0U) 88 | { 89 | } 90 | 91 | uint8_t CFMCTCSSTX::setParams(uint8_t frequency, uint8_t level) 92 | { 93 | const TX_CTCSS_TABLE* entry = NULL; 94 | 95 | for (uint8_t i = 0U; i < CTCSS_TABLE_DATA_LEN; i++) { 96 | if (TX_CTCSS_TABLE_DATA[i].frequency == frequency) { 97 | entry = TX_CTCSS_TABLE_DATA + i; 98 | break; 99 | } 100 | } 101 | 102 | if (entry == NULL) 103 | return 4U; 104 | 105 | m_length = entry->length; 106 | 107 | delete[] m_values; 108 | m_values = new q15_t[m_length]; 109 | 110 | q31_t arg = 0; 111 | for (uint16_t i = 0U; i < m_length; i++) { 112 | q63_t value = ::arm_sin_q31(arg) * q63_t(level * 13); 113 | m_values[i] = q15_t(__SSAT((value >> 31), 16)); 114 | 115 | arg += entry->increment; 116 | } 117 | 118 | return 0U; 119 | } 120 | 121 | q15_t CFMCTCSSTX::getAudio(bool reverse) 122 | { 123 | q15_t sample = m_values[m_n++]; 124 | if (m_n >= m_length) 125 | m_n = 0U; 126 | 127 | if (reverse) 128 | return -sample; 129 | else 130 | return sample; 131 | } 132 | 133 | #endif 134 | 135 | -------------------------------------------------------------------------------- /FMNoiseSquelch.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #include "Config.h" 20 | 21 | #if defined(MODE_FM) 22 | 23 | #include "Globals.h" 24 | #include "FMNoiseSquelch.h" 25 | 26 | // 4500Hz centre frequency 27 | const q31_t COEFF_DIV_TWO = 821806413; 28 | 29 | // 400Hz bandwidth 30 | const uint16_t N = 24000U / 400U; 31 | 32 | CFMNoiseSquelch::CFMNoiseSquelch() : 33 | m_highThreshold(0), 34 | m_lowThreshold(0), 35 | m_count(0U), 36 | m_q0(0), 37 | m_q1(0), 38 | m_state(false), 39 | m_validCount(0U) 40 | { 41 | 42 | } 43 | 44 | void CFMNoiseSquelch::setParams(uint8_t highThreshold, uint8_t lowThreshold) 45 | { 46 | m_highThreshold = q31_t(highThreshold); 47 | m_lowThreshold = q31_t(lowThreshold); 48 | } 49 | 50 | bool CFMNoiseSquelch::process(q15_t sample) 51 | { 52 | //get more dynamic into the decoder by multiplying the sample by 64 53 | q31_t sample31 = q31_t(sample) << 6; //+ (q31_t(sample) >> 1); 54 | 55 | q31_t q2 = m_q1; 56 | m_q1 = m_q0; 57 | 58 | // Q31 multiplication, t3 = m_coeffDivTwo * 2 * m_q1 59 | q63_t t1 = COEFF_DIV_TWO * m_q1; 60 | q31_t t2 = __SSAT((t1 >> 31), 31); 61 | q31_t t3 = t2 * 2; 62 | 63 | // m_q0 = m_coeffDivTwo * m_q1 * 2 - q2 + sample 64 | m_q0 = t3 - q2 + sample31; 65 | 66 | m_count++; 67 | if (m_count == N) { 68 | // Q31 multiplication, t2 = m_q0 * m_q0 69 | q63_t t1 = q63_t(m_q0) * q63_t(m_q0); 70 | q31_t t2 = __SSAT((t1 >> 31), 31); 71 | 72 | // Q31 multiplication, t4 = m_q0 * m_q0 73 | q63_t t3 = q63_t(m_q1) * q63_t(m_q1); 74 | q31_t t4 = __SSAT((t3 >> 31), 31); 75 | 76 | // Q31 multiplication, t9 = m_q0 * m_q1 * m_coeffDivTwo * 2 77 | q63_t t5 = q63_t(m_q0) * q63_t(m_q1); 78 | q31_t t6 = __SSAT((t5 >> 31), 31); 79 | q63_t t7 = t6 * COEFF_DIV_TWO; 80 | q31_t t8 = __SSAT((t7 >> 31), 31); 81 | q31_t t9 = t8 * 2; 82 | 83 | // value = m_q0 * m_q0 + m_q1 * m_q1 - m_q0 * m_q1 * m_coeffDivTwo * 2 84 | q31_t value = t2 + t4 - t9; 85 | 86 | bool previousState = m_state; 87 | 88 | q31_t threshold = m_highThreshold; 89 | if (previousState) 90 | threshold = m_lowThreshold; 91 | 92 | if (!m_state) { 93 | if (value < threshold) 94 | m_validCount++; 95 | else 96 | m_validCount = 0U; 97 | } 98 | 99 | if (m_state) { 100 | if (value >= threshold) 101 | m_invalidCount++; 102 | else 103 | m_invalidCount = 0U; 104 | } 105 | 106 | m_state = m_validCount >= 10U && m_invalidCount < 10U; 107 | 108 | if(previousState && !m_state) 109 | m_invalidCount = 0U; 110 | 111 | if (previousState != m_state) { 112 | DEBUG4("Noise Squelch Value / Threshold / Valid", value, threshold, m_state); 113 | DEBUG3("Valid Count / Invalid Count", m_validCount, m_invalidCount); 114 | } 115 | 116 | m_count = 0U; 117 | m_q0 = 0; 118 | m_q1 = 0; 119 | } 120 | 121 | return m_state; 122 | } 123 | 124 | void CFMNoiseSquelch::reset() 125 | { 126 | m_q0 = 0; 127 | m_q1 = 0; 128 | m_state = false; 129 | m_count = 0U; 130 | } 131 | 132 | #endif 133 | 134 | -------------------------------------------------------------------------------- /stm32f722_link.ld: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 by Andy Uribe CA6JAU 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | /* Required amount of heap and stack */ 20 | _min_heap_size = 0x1000; 21 | _min_stack_size = 0x0800; 22 | 23 | /* The entry point in the interrupt vector table */ 24 | ENTRY(Reset_Handler) 25 | 26 | /* Memory areas */ 27 | MEMORY 28 | { 29 | ROM (rx) : ORIGIN = 0x08000000, LENGTH = 512K /* FLASH */ 30 | RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 256K /* Main RAM */ 31 | } 32 | 33 | /* Stack start address (end of 256K RAM) */ 34 | _estack = ORIGIN(RAM) + LENGTH(RAM); 35 | 36 | SECTIONS 37 | { 38 | .text : 39 | { 40 | /* The interrupt vector table */ 41 | . = ALIGN(4); 42 | KEEP(*(.isr_vector .isr_vector.*)) 43 | 44 | /* The program code */ 45 | . = ALIGN(4); 46 | *(.text .text*) 47 | *(.rodata .rodata*) 48 | 49 | /* ARM-Thumb code */ 50 | *(.glue_7) *(.glue_7t) 51 | 52 | . = ALIGN(4); 53 | KEEP(*(.init)) 54 | KEEP(*(.fini)) 55 | 56 | /* EABI C++ global constructors support */ 57 | . = ALIGN(4); 58 | __preinit_array_start = .; 59 | KEEP (*(.preinit_array)) 60 | __preinit_array_end = .; 61 | 62 | /* EABI C++ global constructors support */ 63 | . = ALIGN(4); 64 | __init_array_start = .; 65 | KEEP (*(SORT(.init_array.*))) 66 | KEEP (*(.init_array)) 67 | __init_array_end = .; 68 | 69 | /* EABI C++ global constructors support */ 70 | . = ALIGN(4); 71 | __fini_array_start = .; 72 | KEEP (*(.fini_array)) 73 | KEEP (*(SORT(.fini_array.*))) 74 | __fini_array_end = .; 75 | 76 | } > ROM 77 | 78 | /* ARM sections containing exception unwinding information */ 79 | .ARM.extab : { 80 | __extab_start = .; 81 | *(.ARM.extab* .gnu.linkonce.armextab.*) 82 | __extab_end = .; 83 | } > ROM 84 | 85 | /* ARM index entries for section unwinding */ 86 | .ARM.exidx : { 87 | __exidx_start = .; 88 | *(.ARM.exidx*) 89 | __exidx_end = .; 90 | } > ROM 91 | 92 | /* Start address for the initialization values of the .data section */ 93 | _sidata = .; 94 | 95 | /* The .data section (initialized data) */ 96 | .data : AT ( _sidata ) 97 | { 98 | . = ALIGN(4); 99 | _sdata = . ; /* Start address for the .data section */ 100 | *(.data .data*) 101 | 102 | . = ALIGN(4); 103 | _edata = . ; /* End address for the .data section */ 104 | } > RAM 105 | 106 | /* The .bss section (uninitialized data) */ 107 | .bss : 108 | { 109 | . = ALIGN(4); 110 | _sbss = .; /* Start address for the .bss section */ 111 | __bss_start__ = _sbss; 112 | *(.bss) 113 | *(.bss*) 114 | *(COMMON) 115 | 116 | . = ALIGN(4); 117 | _ebss = . ; /* End address for the .bss section */ 118 | __bss_end__ = _ebss; 119 | } > RAM 120 | 121 | /* Space for heap and stack */ 122 | .heap_stack : 123 | { 124 | end = . ; /* 'end' symbol defines heap location */ 125 | _end = end ; 126 | . = . + _min_heap_size; /* Additional space for heap and stack */ 127 | . = . + _min_stack_size; 128 | } > RAM 129 | 130 | /* Remove information from the standard libraries */ 131 | /DISCARD/ : 132 | { 133 | libc.a ( * ) 134 | libm.a ( * ) 135 | libgcc.a ( * ) 136 | } 137 | } 138 | -------------------------------------------------------------------------------- /stm32f767_link.ld: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 by Andy Uribe CA6JAU 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | /* Required amount of heap and stack */ 20 | _min_heap_size = 0x1000; 21 | _min_stack_size = 0x0800; 22 | 23 | /* The entry point in the interrupt vector table */ 24 | ENTRY(Reset_Handler) 25 | 26 | /* Memory areas */ 27 | MEMORY 28 | { 29 | ROM (rx) : ORIGIN = 0x08000000, LENGTH = 2048K /* FLASH */ 30 | RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 512K /* Main RAM */ 31 | } 32 | 33 | /* Stack start address (end of 512K RAM) */ 34 | _estack = ORIGIN(RAM) + LENGTH(RAM); 35 | 36 | SECTIONS 37 | { 38 | .text : 39 | { 40 | /* The interrupt vector table */ 41 | . = ALIGN(4); 42 | KEEP(*(.isr_vector .isr_vector.*)) 43 | 44 | /* The program code */ 45 | . = ALIGN(4); 46 | *(.text .text*) 47 | *(.rodata .rodata*) 48 | 49 | /* ARM-Thumb code */ 50 | *(.glue_7) *(.glue_7t) 51 | 52 | . = ALIGN(4); 53 | KEEP(*(.init)) 54 | KEEP(*(.fini)) 55 | 56 | /* EABI C++ global constructors support */ 57 | . = ALIGN(4); 58 | __preinit_array_start = .; 59 | KEEP (*(.preinit_array)) 60 | __preinit_array_end = .; 61 | 62 | /* EABI C++ global constructors support */ 63 | . = ALIGN(4); 64 | __init_array_start = .; 65 | KEEP (*(SORT(.init_array.*))) 66 | KEEP (*(.init_array)) 67 | __init_array_end = .; 68 | 69 | /* EABI C++ global constructors support */ 70 | . = ALIGN(4); 71 | __fini_array_start = .; 72 | KEEP (*(.fini_array)) 73 | KEEP (*(SORT(.fini_array.*))) 74 | __fini_array_end = .; 75 | 76 | } > ROM 77 | 78 | /* ARM sections containing exception unwinding information */ 79 | .ARM.extab : { 80 | __extab_start = .; 81 | *(.ARM.extab* .gnu.linkonce.armextab.*) 82 | __extab_end = .; 83 | } > ROM 84 | 85 | /* ARM index entries for section unwinding */ 86 | .ARM.exidx : { 87 | __exidx_start = .; 88 | *(.ARM.exidx*) 89 | __exidx_end = .; 90 | } > ROM 91 | 92 | /* Start address for the initialization values of the .data section */ 93 | _sidata = .; 94 | 95 | /* The .data section (initialized data) */ 96 | .data : AT ( _sidata ) 97 | { 98 | . = ALIGN(4); 99 | _sdata = . ; /* Start address for the .data section */ 100 | *(.data .data*) 101 | 102 | . = ALIGN(4); 103 | _edata = . ; /* End address for the .data section */ 104 | } > RAM 105 | 106 | /* The .bss section (uninitialized data) */ 107 | .bss : 108 | { 109 | . = ALIGN(4); 110 | _sbss = .; /* Start address for the .bss section */ 111 | __bss_start__ = _sbss; 112 | *(.bss) 113 | *(.bss*) 114 | *(COMMON) 115 | 116 | . = ALIGN(4); 117 | _ebss = . ; /* End address for the .bss section */ 118 | __bss_end__ = _ebss; 119 | } > RAM 120 | 121 | /* Space for heap and stack */ 122 | .heap_stack : 123 | { 124 | end = . ; /* 'end' symbol defines heap location */ 125 | _end = end ; 126 | . = . + _min_heap_size; /* Additional space for heap and stack */ 127 | . = . + _min_stack_size; 128 | } > RAM 129 | 130 | /* Remove information from the standard libraries */ 131 | /DISCARD/ : 132 | { 133 | libc.a ( * ) 134 | libm.a ( * ) 135 | libgcc.a ( * ) 136 | } 137 | } 138 | -------------------------------------------------------------------------------- /stm32f4xx_link.ld: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 by Andy Uribe CA6JAU 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | /* Required amount of heap and stack */ 20 | _min_heap_size = 0x1000; 21 | _min_stack_size = 0x0800; 22 | 23 | /* The entry point in the interrupt vector table */ 24 | ENTRY(Reset_Handler) 25 | 26 | /* Memory areas */ 27 | MEMORY 28 | { 29 | ROM (rx) : ORIGIN = 0x08000000, LENGTH = 1024K /* FLASH */ 30 | CCMRAM (xrw) : ORIGIN = 0x10000000, LENGTH = 64K /* Core Coupled Memory (CPU only access) */ 31 | RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K /* Main RAM (bus matrix)*/ 32 | } 33 | 34 | /* Stack start address (end of 128K RAM) */ 35 | _estack = ORIGIN(RAM) + LENGTH(RAM); 36 | 37 | SECTIONS 38 | { 39 | .text : 40 | { 41 | /* The interrupt vector table */ 42 | . = ALIGN(4); 43 | KEEP(*(.isr_vector .isr_vector.*)) 44 | 45 | /* The program code */ 46 | . = ALIGN(4); 47 | *(.text .text*) 48 | *(.rodata .rodata*) 49 | 50 | /* ARM-Thumb code */ 51 | *(.glue_7) *(.glue_7t) 52 | 53 | . = ALIGN(4); 54 | KEEP(*(.init)) 55 | KEEP(*(.fini)) 56 | 57 | /* EABI C++ global constructors support */ 58 | . = ALIGN(4); 59 | __preinit_array_start = .; 60 | KEEP (*(.preinit_array)) 61 | __preinit_array_end = .; 62 | 63 | /* EABI C++ global constructors support */ 64 | . = ALIGN(4); 65 | __init_array_start = .; 66 | KEEP (*(SORT(.init_array.*))) 67 | KEEP (*(.init_array)) 68 | __init_array_end = .; 69 | 70 | /* EABI C++ global constructors support */ 71 | . = ALIGN(4); 72 | __fini_array_start = .; 73 | KEEP (*(.fini_array)) 74 | KEEP (*(SORT(.fini_array.*))) 75 | __fini_array_end = .; 76 | 77 | } > ROM 78 | 79 | /* ARM sections containing exception unwinding information */ 80 | .ARM.extab : { 81 | __extab_start = .; 82 | *(.ARM.extab* .gnu.linkonce.armextab.*) 83 | __extab_end = .; 84 | } > ROM 85 | 86 | /* ARM index entries for section unwinding */ 87 | .ARM.exidx : { 88 | __exidx_start = .; 89 | *(.ARM.exidx*) 90 | __exidx_end = .; 91 | } > ROM 92 | 93 | /* Start address for the initialization values of the .data section */ 94 | _sidata = .; 95 | 96 | /* The .data section (initialized data) */ 97 | .data : AT ( _sidata ) 98 | { 99 | . = ALIGN(4); 100 | _sdata = . ; /* Start address for the .data section */ 101 | *(.data .data*) 102 | 103 | . = ALIGN(4); 104 | _edata = . ; /* End address for the .data section */ 105 | } > RAM 106 | 107 | /* The .bss section (uninitialized data) */ 108 | .bss : 109 | { 110 | . = ALIGN(4); 111 | _sbss = .; /* Start address for the .bss section */ 112 | __bss_start__ = _sbss; 113 | *(.bss) 114 | *(.bss*) 115 | *(COMMON) 116 | 117 | . = ALIGN(4); 118 | _ebss = . ; /* End address for the .bss section */ 119 | __bss_end__ = _ebss; 120 | } > RAM 121 | 122 | /* Space for heap and stack */ 123 | .heap_stack : 124 | { 125 | end = . ; /* 'end' symbol defines heap location */ 126 | _end = end ; 127 | . = . + _min_heap_size; /* Additional space for heap and stack */ 128 | . = . + _min_stack_size; 129 | } > RAM 130 | 131 | /* Remove information from the standard libraries */ 132 | /DISCARD/ : 133 | { 134 | libc.a ( * ) 135 | libm.a ( * ) 136 | libgcc.a ( * ) 137 | } 138 | } 139 | -------------------------------------------------------------------------------- /CalNXDN.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 by Andy Uribe CA6JAU 3 | * Copyright (C) 2020 by Jonathan Naylor G4KLX 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 | */ 19 | 20 | #include "Config.h" 21 | 22 | #if defined(MODE_NXDN) 23 | 24 | #include "Globals.h" 25 | #include "CalNXDN.h" 26 | 27 | // NXDN 1031 Hz Test Pattern, RAN: 1, Unit ID: 1, Dst Group ID: 1, Outbound Direction 28 | const uint8_t NXDN_CAL1K[4][49] = { 29 | {0x00U, 30 | 0xCDU, 0xF5U, 0x9DU, 0x5DU, 0x7CU, 0xFAU, 0x0AU, 0x6EU, 0x8AU, 0x23U, 0x56U, 0xE8U, 31 | 0x4CU, 0xAAU, 0xDEU, 0x8BU, 0x26U, 0xE4U, 0xF2U, 0x82U, 0x88U, 32 | 0xC6U, 0x8AU, 0x74U, 0x29U, 0xA4U, 0xECU, 0xD0U, 0x08U, 0x22U, 33 | 0xCEU, 0xA2U, 0xFCU, 0x01U, 0x8CU, 0xECU, 0xDAU, 0x0AU, 0xA0U, 34 | 0xEEU, 0x8AU, 0x7EU, 0x2BU, 0x26U, 0xCCU, 0xF8U, 0x8AU, 0x08U}, 35 | 36 | {0x00U, 37 | 0xCDU, 0xF5U, 0x9DU, 0x5DU, 0x7CU, 0x6DU, 0xBBU, 0x0EU, 0xB3U, 0xA4U, 0x26U, 0xA8U, 38 | 0x4CU, 0xAAU, 0xDEU, 0x8BU, 0x26U, 0xE4U, 0xF2U, 0x82U, 0x88U, 39 | 0xC6U, 0x8AU, 0x74U, 0x29U, 0xA4U, 0xECU, 0xD0U, 0x08U, 0x22U, 40 | 0xCEU, 0xA2U, 0xFCU, 0x01U, 0x8CU, 0xECU, 0xDAU, 0x0AU, 0xA0U, 41 | 0xEEU, 0x8AU, 0x7EU, 0x2BU, 0x26U, 0xCCU, 0xF8U, 0x8AU, 0x08U}, 42 | 43 | {0x00U, 44 | 0xCDU, 0xF5U, 0x9DU, 0x5DU, 0x76U, 0x3AU, 0x1BU, 0x4AU, 0x81U, 0xA8U, 0xE2U, 0x80U, 45 | 0x4CU, 0xAAU, 0xDEU, 0x8BU, 0x26U, 0xE4U, 0xF2U, 0x82U, 0x88U, 46 | 0xC6U, 0x8AU, 0x74U, 0x29U, 0xA4U, 0xECU, 0xD0U, 0x08U, 0x22U, 47 | 0xCEU, 0xA2U, 0xFCU, 0x01U, 0x8CU, 0xECU, 0xDAU, 0x0AU, 0xA0U, 48 | 0xEEU, 0x8AU, 0x7EU, 0x2BU, 0x26U, 0xCCU, 0xF8U, 0x8AU, 0x08U}, 49 | 50 | {0x00U, 51 | 0xCDU, 0xF5U, 0x9DU, 0x5DU, 0x74U, 0x28U, 0x83U, 0x02U, 0xB0U, 0x2DU, 0x07U, 0xE2U, 52 | 0x4CU, 0xAAU, 0xDEU, 0x8BU, 0x26U, 0xE4U, 0xF2U, 0x82U, 0x88U, 53 | 0xC6U, 0x8AU, 0x74U, 0x29U, 0xA4U, 0xECU, 0xD0U, 0x08U, 0x22U, 54 | 0xCEU, 0xA2U, 0xFCU, 0x01U, 0x8CU, 0xECU, 0xDAU, 0x0AU, 0xA0U, 55 | 0xEEU, 0x8AU, 0x7EU, 0x2BU, 0x26U, 0xCCU, 0xF8U, 0x8AU, 0x08U}}; 56 | 57 | CCalNXDN::CCalNXDN() : 58 | m_transmit(false), 59 | m_state(NXDNCAL1K_IDLE), 60 | m_audioSeq(0U) 61 | { 62 | } 63 | 64 | void CCalNXDN::process() 65 | { 66 | nxdnTX.process(); 67 | 68 | uint16_t space = nxdnTX.getSpace(); 69 | if (space < 1U) 70 | return; 71 | 72 | switch (m_state) { 73 | case NXDNCAL1K_TX: 74 | nxdnTX.writeData(NXDN_CAL1K[m_audioSeq], NXDN_FRAME_LENGTH_BYTES + 1U); 75 | m_audioSeq = (m_audioSeq + 1U) % 4U; 76 | if(!m_transmit) 77 | m_state = NXDNCAL1K_IDLE; 78 | break; 79 | default: 80 | m_state = NXDNCAL1K_IDLE; 81 | m_audioSeq = 0U; 82 | break; 83 | } 84 | } 85 | 86 | uint8_t CCalNXDN::write(const uint8_t* data, uint16_t length) 87 | { 88 | if (length != 1U) 89 | return 4U; 90 | 91 | m_transmit = data[0U] == 1U; 92 | 93 | if(m_transmit && m_state == NXDNCAL1K_IDLE) 94 | m_state = NXDNCAL1K_TX; 95 | 96 | return 0U; 97 | } 98 | 99 | #endif 100 | 101 | -------------------------------------------------------------------------------- /SerialPort.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015,2016,2017,2018,2020,2021,2025 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #if !defined(SERIALPORT_H) 20 | #define SERIALPORT_H 21 | 22 | #include "Config.h" 23 | #include "Globals.h" 24 | #include "RingBuffer.h" 25 | 26 | #if !defined(SERIAL_SPEED) 27 | #define SERIAL_SPEED 115200 28 | #endif 29 | 30 | 31 | class CSerialPort { 32 | public: 33 | CSerialPort(); 34 | 35 | void start(); 36 | 37 | void process(); 38 | 39 | #if defined(MODE_DSTAR) 40 | void writeDStarHeader(const uint8_t* header, uint8_t length); 41 | void writeDStarData(const uint8_t* data, uint8_t length); 42 | void writeDStarLost(); 43 | void writeDStarEOT(); 44 | #endif 45 | 46 | #if defined(MODE_DMR) 47 | void writeDMRData(bool slot, const uint8_t* data, uint8_t length); 48 | void writeDMRLost(bool slot); 49 | #endif 50 | 51 | #if defined(MODE_YSF) 52 | void writeYSFData(const uint8_t* data, uint8_t length); 53 | void writeYSFLost(); 54 | #endif 55 | 56 | #if defined(MODE_P25) 57 | void writeP25Hdr(const uint8_t* data, uint8_t length); 58 | void writeP25Ldu(const uint8_t* data, uint8_t length); 59 | void writeP25Lost(); 60 | #endif 61 | 62 | #if defined(MODE_NXDN) 63 | void writeNXDNData(const uint8_t* data, uint8_t length); 64 | void writeNXDNLost(); 65 | #endif 66 | 67 | #if defined(MODE_FM) 68 | void writeFMData(const uint8_t* data, uint16_t length); 69 | void writeFMStatus(uint8_t status); 70 | void writeFMEOT(); 71 | #endif 72 | 73 | #if defined(SERIAL_REPEATER) 74 | void writeSerialData(const uint8_t* data, uint8_t length); 75 | #endif 76 | 77 | #if defined(I2C_REPEATER) 78 | void writeI2CData(const uint8_t* data, uint8_t length); 79 | #endif 80 | 81 | void writeCalData(const uint8_t* data, uint8_t length); 82 | void writeRSSIData(const uint8_t* data, uint8_t length); 83 | 84 | void writeDebug(const char* text); 85 | void writeDebug(const char* text, int16_t n1); 86 | void writeDebug(const char* text, int16_t n1, int16_t n2); 87 | void writeDebug(const char* text, int16_t n1, int16_t n2, int16_t n3); 88 | void writeDebug(const char* text, int16_t n1, int16_t n2, int16_t n3, int16_t n4); 89 | void writeDebugDump(const uint8_t* data, uint16_t length); 90 | 91 | private: 92 | uint8_t m_buffer[512U]; 93 | uint16_t m_ptr; 94 | uint16_t m_len; 95 | bool m_debug; 96 | CRingBuffer m_serialData; 97 | int m_lastSerialAvail; 98 | uint16_t m_lastSerialAvailCount; 99 | CRingBuffer m_i2CData; 100 | 101 | void sendACK(uint8_t type); 102 | void sendNAK(uint8_t type, uint8_t err); 103 | void getStatus(); 104 | void getVersion(); 105 | uint8_t setConfig(const uint8_t* data, uint16_t length); 106 | uint8_t setMode(const uint8_t* data, uint16_t length); 107 | void setMode(MMDVM_STATE modemState); 108 | void processMessage(uint8_t type, const uint8_t* data, uint16_t length); 109 | 110 | #if defined(MODE_FM) 111 | uint8_t setFMParams1(const uint8_t* data, uint16_t length); 112 | uint8_t setFMParams2(const uint8_t* data, uint16_t length); 113 | uint8_t setFMParams3(const uint8_t* data, uint16_t length); 114 | uint8_t setFMParams4(const uint8_t* data, uint16_t length); 115 | #endif 116 | 117 | // Hardware versions 118 | void beginInt(uint8_t n, int speed); 119 | int availableForReadInt(uint8_t n); 120 | int availableForWriteInt(uint8_t n); 121 | uint8_t readInt(uint8_t n); 122 | void writeInt(uint8_t n, const uint8_t* data, uint16_t length, bool flush = false); 123 | }; 124 | 125 | #endif 126 | 127 | -------------------------------------------------------------------------------- /MMDVM.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015,2016,2017,2018,2020,2021,2025 by Jonathan Naylor G4KLX 3 | * Copyright (C) 2016 by Colin Durbridge G4EML 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 | */ 19 | 20 | #include "Config.h" 21 | #include "Globals.h" 22 | 23 | // Global variables 24 | MMDVM_STATE m_modemState = STATE_IDLE; 25 | 26 | bool m_dstarEnable = true; 27 | bool m_dmrEnable = true; 28 | bool m_ysfEnable = true; 29 | bool m_p25Enable = true; 30 | bool m_nxdnEnable = true; 31 | bool m_pocsagEnable = true; 32 | bool m_fmEnable = true; 33 | 34 | bool m_duplex = true; 35 | 36 | bool m_tx = false; 37 | bool m_dcd = false; 38 | 39 | #if defined(MODE_DSTAR) 40 | CDStarRX dstarRX; 41 | CDStarTX dstarTX; 42 | 43 | CCalDStarRX calDStarRX; 44 | CCalDStarTX calDStarTX; 45 | #endif 46 | 47 | #if defined(MODE_DMR) 48 | CDMRIdleRX dmrIdleRX; 49 | CDMRRX dmrRX; 50 | CDMRTX dmrTX; 51 | 52 | CDMRDMORX dmrDMORX; 53 | CDMRDMOTX dmrDMOTX; 54 | 55 | CCalDMR calDMR; 56 | #endif 57 | 58 | #if defined(MODE_YSF) 59 | CYSFRX ysfRX; 60 | CYSFTX ysfTX; 61 | #endif 62 | 63 | #if defined(MODE_P25) 64 | CP25RX p25RX; 65 | CP25TX p25TX; 66 | 67 | CCalP25 calP25; 68 | #endif 69 | 70 | #if defined(MODE_NXDN) 71 | CNXDNRX nxdnRX; 72 | CNXDNTX nxdnTX; 73 | 74 | CCalNXDN calNXDN; 75 | #endif 76 | 77 | #if defined(MODE_POCSAG) 78 | CPOCSAGTX pocsagTX; 79 | CCalPOCSAG calPOCSAG; 80 | #endif 81 | 82 | #if defined(MODE_FM) 83 | CFM fm; 84 | CCalFM calFM; 85 | #endif 86 | 87 | CCalRSSI calRSSI; 88 | 89 | CCWIdTX cwIdTX; 90 | 91 | CSerialPort serial; 92 | CIO io; 93 | 94 | void setup() 95 | { 96 | serial.start(); 97 | } 98 | 99 | void loop() 100 | { 101 | serial.process(); 102 | 103 | io.process(); 104 | 105 | // The following is for transmitting 106 | #if defined(MODE_DSTAR) 107 | if (m_dstarEnable && m_modemState == STATE_DSTAR) 108 | dstarTX.process(); 109 | #endif 110 | 111 | #if defined(MODE_DMR) 112 | if (m_dmrEnable && m_modemState == STATE_DMR) { 113 | if (m_duplex) 114 | dmrTX.process(); 115 | else 116 | dmrDMOTX.process(); 117 | } 118 | #endif 119 | 120 | #if defined(MODE_YSF) 121 | if (m_ysfEnable && m_modemState == STATE_YSF) 122 | ysfTX.process(); 123 | #endif 124 | 125 | #if defined(MODE_P25) 126 | if (m_p25Enable && m_modemState == STATE_P25) 127 | p25TX.process(); 128 | #endif 129 | 130 | #if defined(MODE_NXDN) 131 | if (m_nxdnEnable && m_modemState == STATE_NXDN) 132 | nxdnTX.process(); 133 | #endif 134 | 135 | #if defined(MODE_POCSAG) 136 | if (m_pocsagEnable && (m_modemState == STATE_POCSAG || pocsagTX.busy())) 137 | pocsagTX.process(); 138 | #endif 139 | 140 | #if defined(MODE_FM) 141 | if (m_fmEnable && m_modemState == STATE_FM) 142 | fm.process(); 143 | #endif 144 | 145 | #if defined(MODE_DSTAR) 146 | if (m_modemState == STATE_DSTARCAL) 147 | calDStarTX.process(); 148 | #endif 149 | 150 | #if defined(MODE_DMR) 151 | if (m_modemState == STATE_DMRCAL || m_modemState == STATE_LFCAL || m_modemState == STATE_DMRCAL1K || m_modemState == STATE_DMRDMO1K) 152 | calDMR.process(); 153 | #endif 154 | 155 | #if defined(MODE_FM) 156 | 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) 157 | calFM.process(); 158 | #endif 159 | 160 | #if defined(MODE_P25) 161 | if (m_modemState == STATE_P25CAL1K) 162 | calP25.process(); 163 | #endif 164 | 165 | #if defined(MODE_NXDN) 166 | if (m_modemState == STATE_NXDNCAL1K) 167 | calNXDN.process(); 168 | #endif 169 | 170 | #if defined(MODE_POCSAG) 171 | if (m_modemState == STATE_POCSAGCAL) 172 | calPOCSAG.process(); 173 | #endif 174 | 175 | if (m_modemState == STATE_IDLE) 176 | cwIdTX.process(); 177 | } 178 | 179 | -------------------------------------------------------------------------------- /Config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015,2016,2017,2018,2020,2025 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #if !defined(CONFIG_H) 20 | #define CONFIG_H 21 | 22 | // Allow for the selection of which modes to compile into the firmware. This is particularly useful for processors 23 | // which have limited code space and processing power. 24 | 25 | // Enable D-Star support. 26 | #define MODE_DSTAR 27 | 28 | // Enable DMR support. 29 | #define MODE_DMR 30 | 31 | // Enable System Fusion support. 32 | #define MODE_YSF 33 | 34 | // Enable P25 phase 1 support. 35 | #define MODE_P25 36 | 37 | // Enable NXDN support, the boxcar filter sometimes improves the performance of NXDN receive on some systems. 38 | #define MODE_NXDN 39 | #define USE_NXDN_BOXCAR 40 | 41 | // Enable POCSAG support. 42 | #define MODE_POCSAG 43 | 44 | // Enable FM support. 45 | #define MODE_FM 46 | 47 | // Allow for the use of high quality external clock oscillators 48 | // The number is the frequency of the oscillator in Hertz. 49 | // 50 | // The frequency of the TCXO must be an integer multiple of 48000. 51 | // Frequencies such as 12.0 Mhz (48000 * 250) and 14.4 Mhz (48000 * 300) are suitable. 52 | // Frequencies such as 10.0 Mhz (48000 * 208.333) or 20 Mhz (48000 * 416.666) are not suitable. 53 | // 54 | // For 12 MHz 55 | #define EXTERNAL_OSC 12000000 56 | // For 12.288 MHz 57 | // #define EXTERNAL_OSC 12288000 58 | // For 14.4 MHz 59 | // #define EXTERNAL_OSC 14400000 60 | // For 19.2 MHz 61 | // #define EXTERNAL_OSC 19200000 62 | 63 | // Select a baud rate for host communication. The faster speeds are needed for external FM to work. 64 | // #define SERIAL_SPEED 115200 // Suitable for most older boards (Arduino Due, etc). External FM will NOT work with this! 65 | // #define SERIAL_SPEED 230400 // Only works on newer boards like fast M4, M7, Teensy 3.x. External FM might work with this 66 | #define SERIAL_SPEED 460800 // Only works on newer boards like fast M4, M7, Teensy 3.x. External FM should work with this 67 | //#define SERIAL_SPEED 500000 // Used with newer boards and Armbian on AllWinner SOCs (H2, H3) that do not support 460800 68 | 69 | // Use pins to output the current mode via LEDs 70 | #define MODE_LEDS 71 | 72 | // For the original Arduino Due pin layout 73 | // #define ARDUINO_DUE_PAPA 74 | 75 | // For the ZUM V1.0 and V1.0.1 boards pin layout 76 | // #define ARDUINO_DUE_ZUM_V10 77 | 78 | // For the SP8NTH board 79 | // #define ARDUINO_DUE_NTH 80 | 81 | // For ST Nucleo-64 STM32F446RE board 82 | // #define STM32F4_NUCLEO_MORPHO_HEADER 83 | // #define STM32F4_NUCLEO_ARDUINO_HEADER 84 | 85 | // Use separate mode pins to switch external channel/filters/bandwidth for example 86 | // #define MODE_PINS 87 | 88 | // For the VK6MST Pi3 Shield communicating over i2c. i2c address & speed defined in i2cTeensy.cpp 89 | // #define VK6MST_TEENSY_PI3_SHIELD_I2C 90 | 91 | // Pass RSSI information to the host 92 | #define SEND_RSSI_DATA 93 | 94 | // Use the modem as a serial repeater for Nextion displays 95 | #define SERIAL_REPEATER 96 | 97 | // Set the baud rate of the modem serial repeater for Nextion displays 98 | #define SERIAL_REPEATER_BAUD_RATE 9600 99 | 100 | // Use the modem as an I2C repeater for OLED displays 101 | // #define I2C_REPEATER 102 | 103 | // To reduce CPU load, you can remove the DC blocker by commenting out the next line 104 | #define USE_DCBLOCKER 105 | 106 | // Constant Service LED once repeater is running 107 | // Do not use if employing an external hardware watchdog 108 | // #define CONSTANT_SRV_LED 109 | 110 | // Use the YSF and P25 LEDs for NXDN 111 | // #define USE_ALTERNATE_NXDN_LEDS 112 | 113 | // Use the D-Star and DMR LEDs for POCSAG 114 | #define USE_ALTERNATE_POCSAG_LEDS 115 | 116 | // Use the D-Star and YSF LEDs for FM 117 | #define USE_ALTERNATE_FM_LEDS 118 | 119 | #endif 120 | 121 | -------------------------------------------------------------------------------- /pins/pins_f7_nucleo.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019,2020 by BG5HHP 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef _PINS_F7_NUCLEO_H 20 | #define _PINS_F7_NUCLEO_H 21 | 22 | /* 23 | Pin definitions for STM32F7 Nucleo boards (ST Morpho header): 24 | 25 | PTT PB13 output CN12 Pin30 26 | COSLED PB14 output CN12 Pin28 27 | LED PA5 output CN12 Pin11 28 | COS PB15 input CN12 Pin26 29 | 30 | DSTAR PB10 output CN12 Pin25 31 | DMR PB4 output CN12 Pin27 32 | YSF PB5 output CN12 Pin29 33 | P25 PB3 output CN12 Pin31 34 | NXDN PA10 output CN12 Pin33 35 | POCSAG PB12 output CN12 Pin16 36 | 37 | MDSTAR PC4 output CN12 Pin34 38 | MDMR PC5 output CN12 Pin6 39 | MYSF PC2 output CN11 Pin35 40 | MP25 PC3 output CN11 Pin37 41 | MNXDN PC6 output CN12 Pin4 42 | 43 | RX PA0 analog input CN11 Pin28 44 | RSSI PA1 analog input CN11 Pin30 45 | TX PA4 analog output CN11 Pin32 46 | 47 | EXT_CLK PA15 input CN11 Pin17 48 | */ 49 | 50 | #define PIN_COS GPIO_Pin_15 51 | #define PORT_COS GPIOB 52 | #define RCC_Per_COS RCC_AHB1Periph_GPIOB 53 | 54 | #define PIN_PTT GPIO_Pin_13 55 | #define PORT_PTT GPIOB 56 | #define RCC_Per_PTT RCC_AHB1Periph_GPIOB 57 | 58 | #define PIN_COSLED GPIO_Pin_14 59 | #define PORT_COSLED GPIOB 60 | #define RCC_Per_COSLED RCC_AHB1Periph_GPIOB 61 | 62 | #define PIN_LED GPIO_Pin_5 63 | #define PORT_LED GPIOA 64 | #define RCC_Per_LED RCC_AHB1Periph_GPIOA 65 | 66 | #define PIN_P25 GPIO_Pin_3 67 | #define PORT_P25 GPIOB 68 | #define RCC_Per_P25 RCC_AHB1Periph_GPIOB 69 | 70 | #define PIN_NXDN GPIO_Pin_10 71 | #define PORT_NXDN GPIOA 72 | #define RCC_Per_NXDN RCC_AHB1Periph_GPIOA 73 | 74 | #define PIN_POCSAG GPIO_Pin_12 75 | #define PORT_POCSAG GPIOB 76 | #define RCC_Per_POCSAG RCC_AHB1Periph_GPIOB 77 | 78 | #define PIN_DSTAR GPIO_Pin_10 79 | #define PORT_DSTAR GPIOB 80 | #define RCC_Per_DSTAR RCC_AHB1Periph_GPIOB 81 | 82 | #define PIN_DMR GPIO_Pin_4 83 | #define PORT_DMR GPIOB 84 | #define RCC_Per_DMR RCC_AHB1Periph_GPIOB 85 | 86 | #define PIN_YSF GPIO_Pin_5 87 | #define PORT_YSF GPIOB 88 | #define RCC_Per_YSF RCC_AHB1Periph_GPIOB 89 | 90 | #if defined(MODE_PINS) 91 | #define PIN_MP25 GPIO_Pin_3 92 | #define PORT_MP25 GPIOC 93 | #define RCC_Per_MP25 RCC_AHB1Periph_GPIOC 94 | 95 | #define PIN_MNXDN GPIO_Pin_6 96 | #define PORT_MNXDN GPIOC 97 | #define RCC_Per_MNXDN RCC_AHB1Periph_GPIOC 98 | 99 | #define PIN_MDSTAR GPIO_Pin_4 100 | #define PORT_MDSTAR GPIOC 101 | #define RCC_Per_MDSTAR RCC_AHB1Periph_GPIOC 102 | 103 | #define PIN_MDMR GPIO_Pin_5 104 | #define PORT_MDMR GPIOC 105 | #define RCC_Per_MDMR RCC_AHB1Periph_GPIOC 106 | 107 | #define PIN_MYSF GPIO_Pin_2 108 | #define PORT_MYSF GPIOC 109 | #define RCC_Per_MYSF RCC_AHB1Periph_GPIOC 110 | #endif 111 | 112 | #define PIN_EXT_CLK GPIO_Pin_15 113 | #define SRC_EXT_CLK GPIO_PinSource15 114 | #define PORT_EXT_CLK GPIOA 115 | 116 | #define PIN_RX GPIO_Pin_0 117 | #define PIN_RX_CH ADC_Channel_0 118 | #define PORT_RX GPIOA 119 | #define RCC_Per_RX RCC_AHB1Periph_GPIOA 120 | 121 | #define PIN_RSSI GPIO_Pin_1 122 | #define PIN_RSSI_CH ADC_Channel_1 123 | #define PORT_RSSI GPIOA 124 | #define RCC_Per_RSSI RCC_AHB1Periph_GPIOA 125 | 126 | #define PIN_TX GPIO_Pin_4 127 | #define PIN_TX_CH DAC_Channel_1 128 | 129 | #endif -------------------------------------------------------------------------------- /pins/pins_f4_drcc_hhp446.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019,2020 by BG5HHP 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef _PINS_F4_DRCC_HHP446_H 20 | #define _PINS_F4_DRCC_HHP446_H 21 | 22 | /* 23 | Pin definitions for DRCC_DVM BG5HHP F446 board rev1 24 | 25 | TX/PTT_LED PB12 output 26 | RX/COS_LED PB5 output 27 | STATUS_LED PB10 output 28 | 29 | COS_IN PB13 input 30 | 31 | DSTAR N/A 32 | DMR N/A 33 | YSF N/A 34 | P25 N/A 35 | NXDN N/A 36 | POCSAG N/A 37 | 38 | MDMR/BIT0 PB8 output 39 | MYSF/BIT1 PB9 output 40 | MDSTAR/BIT2 PB14 output 41 | MP25/BIT3 PB15 output Generic Mode Pins 42 | MNXDN N/A 43 | MPOCSAG N/A 44 | 45 | RX PA0 analog input 46 | RSSI PA1 analog input 47 | TX PA4 analog output 48 | 49 | EXT_CLK N/A 50 | 51 | UART1_TX PA9 output 52 | UART1_RX PA10 output Host Data Communication 53 | 54 | UART2_TX PA2 output 55 | UART2_RX PA3 output Nextion Data Communication 56 | 57 | I2C1_SCL PB6 output 58 | I2C1_SDA PB7 output OLED Data Communication as master 59 | 60 | */ 61 | 62 | #define PIN_COS GPIO_Pin_13 63 | #define PORT_COS GPIOB 64 | #define RCC_Per_COS RCC_AHB1Periph_GPIOB 65 | 66 | #define PIN_PTT GPIO_Pin_12 67 | #define PORT_PTT GPIOB 68 | #define RCC_Per_PTT RCC_AHB1Periph_GPIOB 69 | 70 | #define PIN_COSLED GPIO_Pin_5 71 | #define PORT_COSLED GPIOB 72 | #define RCC_Per_COSLED RCC_AHB1Periph_GPIOB 73 | 74 | #define PIN_LED GPIO_Pin_10 75 | #define PORT_LED GPIOB 76 | #define RCC_Per_LED RCC_AHB1Periph_GPIOB 77 | 78 | #define PIN_TXLED GPIO_Pin_4 79 | #define PORT_TXLED GPIOB 80 | #define RCC_Per_TXLED RCC_AHB1Periph_GPIOB 81 | 82 | // #define PIN_P25 GPIO_Pin_3 83 | // #define PORT_P25 GPIOB 84 | // #define RCC_Per_P25 RCC_AHB1Periph_GPIOB 85 | 86 | // #define PIN_NXDN GPIO_Pin_10 87 | // #define PORT_NXDN GPIOA 88 | // #define RCC_Per_NXDN RCC_AHB1Periph_GPIOA 89 | 90 | // #define PIN_POCSAG GPIO_Pin_12 91 | // #define PORT_POCSAG GPIOB 92 | // #define RCC_Per_POCSAG RCC_AHB1Periph_GPIOB 93 | 94 | // #define PIN_DSTAR GPIO_Pin_10 95 | // #define PORT_DSTAR GPIOB 96 | // #define RCC_Per_DSTAR RCC_AHB1Periph_GPIOB 97 | 98 | // #define PIN_DMR GPIO_Pin_4 99 | // #define PORT_DMR GPIOB 100 | // #define RCC_Per_DMR RCC_AHB1Periph_GPIOB 101 | 102 | // #define PIN_YSF GPIO_Pin_5 103 | // #define PORT_YSF GPIOB 104 | // #define RCC_Per_YSF RCC_AHB1Periph_GPIOB 105 | 106 | #if defined(MODE_PINS) 107 | #define PIN_MP25 GPIO_Pin_15 108 | #define PORT_MP25 GPIOB 109 | #define RCC_Per_MP25 RCC_AHB1Periph_GPIOB 110 | 111 | #define PIN_MDSTAR GPIO_Pin_9 112 | #define PORT_MDSTAR GPIOB 113 | #define RCC_Per_MDSTAR RCC_AHB1Periph_GPIOB 114 | 115 | #define PIN_MDMR GPIO_Pin_8 116 | #define PORT_MDMR GPIOB 117 | #define RCC_Per_MDMR RCC_AHB1Periph_GPIOB 118 | 119 | #define PIN_MYSF GPIO_Pin_14 120 | #define PORT_MYSF GPIOB 121 | #define RCC_Per_MYSF RCC_AHB1Periph_GPIOB 122 | #endif 123 | 124 | #define PIN_EXT_CLK GPIO_Pin_15 125 | #define SRC_EXT_CLK GPIO_PinSource15 126 | #define PORT_EXT_CLK GPIOA 127 | 128 | #define PIN_RX GPIO_Pin_0 129 | #define PIN_RX_CH ADC_Channel_0 130 | #define PORT_RX GPIOA 131 | #define RCC_Per_RX RCC_AHB1Periph_GPIOA 132 | 133 | #define PIN_RSSI GPIO_Pin_1 134 | #define PIN_RSSI_CH ADC_Channel_1 135 | #define PORT_RSSI GPIOA 136 | #define RCC_Per_RSSI RCC_AHB1Periph_GPIOA 137 | 138 | #define PIN_TX GPIO_Pin_4 139 | #define PIN_TX_CH DAC_Channel_1 140 | #define PORT_TX GPIOA 141 | #define RCC_Per_TX RCC_AHB1Periph_GPIOA 142 | 143 | #endif -------------------------------------------------------------------------------- /pins/pins_f4_drcc_nqf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019,2020 by BG5HHP 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef _PINS_F4_DRCC_NQF_H 20 | #define _PINS_F4_DRCC_NQF_H 21 | 22 | /* 23 | Pin definitions for DRCC_DVM BG7NQF board rev1 24 | 25 | TX/PTT_LED PB12 output 26 | RX/COS_LED PB5 output 27 | STATUS_LED PB10 output 28 | 29 | COS_IN PB13 input 30 | 31 | DSTAR N/A 32 | DMR N/A 33 | YSF N/A 34 | P25 N/A 35 | NXDN N/A 36 | POCSAG N/A 37 | 38 | MDMR/BIT0 PB8 output 39 | MYSF/BIT1 PB9 output 40 | MDSTAR/BIT2 PB14 output 41 | MP25/BIT3 PB15 output Generic Mode Pins 42 | MNXDN N/A 43 | MPOCSAG N/A 44 | 45 | RX PA0 analog input 46 | RSSI PA1 analog input 47 | TX PA4 analog output 48 | 49 | EXT_CLK PA15 input 50 | 51 | UART1_TX PA9 output 52 | UART1_RX PA10 output Host Data Communication 53 | 54 | UART2_TX PA2 output 55 | UART2_RX PA3 output Nextion Data Communication 56 | 57 | I2C1_SCL PB6 output 58 | I2C1_SDA PB7 output OLED Data Communication as master 59 | 60 | */ 61 | 62 | #define PIN_COS GPIO_Pin_13 63 | #define PORT_COS GPIOB 64 | #define RCC_Per_COS RCC_AHB1Periph_GPIOB 65 | 66 | #define PIN_PTT GPIO_Pin_12 67 | #define PORT_PTT GPIOB 68 | #define RCC_Per_PTT RCC_AHB1Periph_GPIOB 69 | 70 | #define PIN_COSLED GPIO_Pin_5 71 | #define PORT_COSLED GPIOB 72 | #define RCC_Per_COSLED RCC_AHB1Periph_GPIOB 73 | 74 | #define PIN_LED GPIO_Pin_10 75 | #define PORT_LED GPIOB 76 | #define RCC_Per_LED RCC_AHB1Periph_GPIOB 77 | 78 | #define PIN_TXLED GPIO_Pin_4 79 | #define PORT_TXLED GPIOB 80 | #define RCC_Per_TXLED RCC_AHB1Periph_GPIOB 81 | 82 | // #define PIN_P25 GPIO_Pin_3 83 | // #define PORT_P25 GPIOB 84 | // #define RCC_Per_P25 RCC_AHB1Periph_GPIOB 85 | 86 | // #define PIN_NXDN GPIO_Pin_10 87 | // #define PORT_NXDN GPIOA 88 | // #define RCC_Per_NXDN RCC_AHB1Periph_GPIOA 89 | 90 | // #define PIN_POCSAG GPIO_Pin_12 91 | // #define PORT_POCSAG GPIOB 92 | // #define RCC_Per_POCSAG RCC_AHB1Periph_GPIOB 93 | 94 | // #define PIN_DSTAR GPIO_Pin_10 95 | // #define PORT_DSTAR GPIOB 96 | // #define RCC_Per_DSTAR RCC_AHB1Periph_GPIOB 97 | 98 | // #define PIN_DMR GPIO_Pin_4 99 | // #define PORT_DMR GPIOB 100 | // #define RCC_Per_DMR RCC_AHB1Periph_GPIOB 101 | 102 | // #define PIN_YSF GPIO_Pin_5 103 | // #define PORT_YSF GPIOB 104 | // #define RCC_Per_YSF RCC_AHB1Periph_GPIOB 105 | 106 | #if defined(MODE_PINS) 107 | #define PIN_MP25 GPIO_Pin_15 108 | #define PORT_MP25 GPIOB 109 | #define RCC_Per_MP25 RCC_AHB1Periph_GPIOB 110 | 111 | #define PIN_MDSTAR GPIO_Pin_9 112 | #define PORT_MDSTAR GPIOB 113 | #define RCC_Per_MDSTAR RCC_AHB1Periph_GPIOB 114 | 115 | #define PIN_MDMR GPIO_Pin_8 116 | #define PORT_MDMR GPIOB 117 | #define RCC_Per_MDMR RCC_AHB1Periph_GPIOB 118 | 119 | #define PIN_MYSF GPIO_Pin_14 120 | #define PORT_MYSF GPIOB 121 | #define RCC_Per_MYSF RCC_AHB1Periph_GPIOB 122 | 123 | #endif 124 | 125 | #define PIN_EXT_CLK GPIO_Pin_15 126 | #define SRC_EXT_CLK GPIO_PinSource15 127 | #define PORT_EXT_CLK GPIOA 128 | 129 | #define PIN_RX GPIO_Pin_0 130 | #define PIN_RX_CH ADC_Channel_0 131 | #define PORT_RX GPIOA 132 | #define RCC_Per_RX RCC_AHB1Periph_GPIOA 133 | 134 | #define PIN_RSSI GPIO_Pin_1 135 | #define PIN_RSSI_CH ADC_Channel_1 136 | #define PORT_RSSI GPIOA 137 | #define RCC_Per_RSSI RCC_AHB1Periph_GPIOA 138 | 139 | #define PIN_TX GPIO_Pin_4 140 | #define PIN_TX_CH DAC_Channel_1 141 | #define PORT_TX GPIOA 142 | #define RCC_Per_TX RCC_AHB1Periph_GPIOA 143 | 144 | #endif -------------------------------------------------------------------------------- /pins/pins_f7_rpt_hat.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019,2020 by BG5HHP 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef _PINS_F7_RPT_HAT_H 20 | #define _PINS_F7_RPT_HAT_H 21 | 22 | /* 23 | Pin definitions for MMDVM_RPT_Hat Pi-Hat F0DEI DB9MAT DF2ET board: 24 | 25 | PTT PB14 output 26 | COSLED PB13 output 27 | LED PB12 output 28 | COS PC0 input 29 | 30 | DSTAR PB15 output 31 | DMR PC6 output 32 | YSF PC7 output 33 | P25 PC8 output 34 | NXDN PC9 output 35 | POCSAG PA8 output 36 | FM PA11 output 37 | 38 | MDSTAR PC1 output 39 | MDMR PC2 output 40 | MYSF PC3 output 41 | MP25 PC4 output 42 | MNXDN PC10 output 43 | MPOCSAG PC11 output 44 | MFM PC13 output 45 | 46 | RX PA0 analog input 47 | RSSI PA7 analog input 48 | TX PA4 analog output 49 | 50 | EXT_CLK PA15 input 51 | */ 52 | 53 | #define PIN_COS GPIO_Pin_0 54 | #define PORT_COS GPIOC 55 | #define RCC_Per_COS RCC_AHB1Periph_GPIOC 56 | 57 | #define PIN_PTT GPIO_Pin_14 58 | #define PORT_PTT GPIOB 59 | #define RCC_Per_PTT RCC_AHB1Periph_GPIOB 60 | 61 | #define PIN_COSLED GPIO_Pin_13 62 | #define PORT_COSLED GPIOB 63 | #define RCC_Per_COSLED RCC_AHB1Periph_GPIOB 64 | 65 | #define PIN_LED GPIO_Pin_12 66 | #define PORT_LED GPIOB 67 | #define RCC_Per_LED RCC_AHB1Periph_GPIOB 68 | 69 | #define PIN_P25 GPIO_Pin_8 70 | #define PORT_P25 GPIOC 71 | #define RCC_Per_P25 RCC_AHB1Periph_GPIOC 72 | 73 | #define PIN_NXDN GPIO_Pin_9 74 | #define PORT_NXDN GPIOC 75 | #define RCC_Per_NXDN RCC_AHB1Periph_GPIOC 76 | 77 | #define PIN_POCSAG GPIO_Pin_8 78 | #define PORT_POCSAG GPIOA 79 | #define RCC_Per_POCSAG RCC_AHB1Periph_GPIOA 80 | 81 | #define PIN_FM GPIO_Pin_11 82 | #define PORT_FM GPIOA 83 | #define RCC_Per_FM RCC_AHB1Periph_GPIOA 84 | 85 | #define PIN_DSTAR GPIO_Pin_15 86 | #define PORT_DSTAR GPIOB 87 | #define RCC_Per_DSTAR RCC_AHB1Periph_GPIOB 88 | 89 | #define PIN_DMR GPIO_Pin_6 90 | #define PORT_DMR GPIOC 91 | #define RCC_Per_DMR RCC_AHB1Periph_GPIOC 92 | 93 | #define PIN_YSF GPIO_Pin_7 94 | #define PORT_YSF GPIOC 95 | #define RCC_Per_YSF RCC_AHB1Periph_GPIOC 96 | 97 | #if defined(MODE_PINS) 98 | #define PIN_MP25 GPIO_Pin_4 99 | #define PORT_MP25 GPIOC 100 | #define RCC_Per_MP25 RCC_AHB1Periph_GPIOC 101 | 102 | #define PIN_MNXDN GPIO_Pin_10 103 | #define PORT_MNXDN GPIOC 104 | #define RCC_Per_MNXDN RCC_AHB1Periph_GPIOC 105 | 106 | #define PIN_MDSTAR GPIO_Pin_1 107 | #define PORT_MDSTAR GPIOC 108 | #define RCC_Per_MDSTAR RCC_AHB1Periph_GPIOC 109 | 110 | #define PIN_MDMR GPIO_Pin_2 111 | #define PORT_MDMR GPIOC 112 | #define RCC_Per_MDMR RCC_AHB1Periph_GPIOC 113 | 114 | #define PIN_MYSF GPIO_Pin_3 115 | #define PORT_MYSF GPIOC 116 | #define RCC_Per_MYSF RCC_AHB1Periph_GPIOC 117 | 118 | #define PIN_MPOCSAG GPIO_Pin_11 119 | #define PORT_MPOCSAG GPIOC 120 | #define RCC_Per_MPOCSAG RCC_AHB1Periph_GPIOC 121 | 122 | #define PIN_MFM GPIO_Pin_13 123 | #define PORT_MFM GPIOC 124 | #define RCC_Per_MFM RCC_AHB1Periph_GPIOC 125 | #endif 126 | 127 | #define PIN_EXT_CLK GPIO_Pin_15 128 | #define SRC_EXT_CLK GPIO_PinSource15 129 | #define PORT_EXT_CLK GPIOA 130 | 131 | #define PIN_RX GPIO_Pin_0 132 | #define PIN_RX_CH ADC_Channel_0 133 | #define PORT_RX GPIOA 134 | #define RCC_Per_RX RCC_AHB1Periph_GPIOA 135 | 136 | #define PIN_RSSI GPIO_Pin_7 137 | #define PIN_RSSI_CH ADC_Channel_7 138 | #define PORT_RSSI GPIOA 139 | #define RCC_Per_RSSI RCC_AHB1Periph_GPIOA 140 | 141 | #define PIN_TX GPIO_Pin_4 142 | #define PIN_TX_CH DAC_Channel_1 143 | 144 | #endif -------------------------------------------------------------------------------- /MMDVM.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015,2016,2017,2018,2020,2021,2025 by Jonathan Naylor G4KLX 3 | * Copyright (C) 2016 by Mathis Schmieder DB9MAT 4 | * Copyright (C) 2016 by Colin Durbridge G4EML 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | #if defined(STM32F4XX) || defined(STM32F7XX) 22 | 23 | #include "Config.h" 24 | #include "Globals.h" 25 | 26 | // Global variables 27 | MMDVM_STATE m_modemState = STATE_IDLE; 28 | 29 | bool m_dstarEnable = true; 30 | bool m_dmrEnable = true; 31 | bool m_ysfEnable = true; 32 | bool m_p25Enable = true; 33 | bool m_nxdnEnable = true; 34 | bool m_pocsagEnable = true; 35 | bool m_fmEnable = true; 36 | 37 | bool m_duplex = true; 38 | 39 | bool m_tx = false; 40 | bool m_dcd = false; 41 | 42 | #if defined(MODE_DSTAR) 43 | CDStarRX dstarRX; 44 | CDStarTX dstarTX; 45 | 46 | CCalDStarRX calDStarRX; 47 | CCalDStarTX calDStarTX; 48 | #endif 49 | 50 | #if defined(MODE_DMR) 51 | CDMRIdleRX dmrIdleRX; 52 | CDMRRX dmrRX; 53 | CDMRTX dmrTX; 54 | 55 | CDMRDMORX dmrDMORX; 56 | CDMRDMOTX dmrDMOTX; 57 | 58 | CCalDMR calDMR; 59 | #endif 60 | 61 | #if defined(MODE_YSF) 62 | CYSFRX ysfRX; 63 | CYSFTX ysfTX; 64 | #endif 65 | 66 | #if defined(MODE_P25) 67 | CP25RX p25RX; 68 | CP25TX p25TX; 69 | 70 | CCalP25 calP25; 71 | #endif 72 | 73 | #if defined(MODE_NXDN) 74 | CNXDNRX nxdnRX; 75 | CNXDNTX nxdnTX; 76 | 77 | CCalNXDN calNXDN; 78 | #endif 79 | 80 | #if defined(MODE_POCSAG) 81 | CPOCSAGTX pocsagTX; 82 | CCalPOCSAG calPOCSAG; 83 | #endif 84 | 85 | #if defined(MODE_FM) 86 | CFM fm; 87 | CCalFM calFM; 88 | #endif 89 | 90 | CCalRSSI calRSSI; 91 | 92 | CCWIdTX cwIdTX; 93 | 94 | CSerialPort serial; 95 | CIO io; 96 | 97 | void setup() 98 | { 99 | serial.start(); 100 | } 101 | 102 | void loop() 103 | { 104 | serial.process(); 105 | 106 | io.process(); 107 | 108 | // The following is for transmitting 109 | #if defined(MODE_DSTAR) 110 | if (m_dstarEnable && m_modemState == STATE_DSTAR) 111 | dstarTX.process(); 112 | #endif 113 | 114 | #if defined(MODE_DMR) 115 | if (m_dmrEnable && m_modemState == STATE_DMR) { 116 | if (m_duplex) 117 | dmrTX.process(); 118 | else 119 | dmrDMOTX.process(); 120 | } 121 | #endif 122 | 123 | #if defined(MODE_YSF) 124 | if (m_ysfEnable && m_modemState == STATE_YSF) 125 | ysfTX.process(); 126 | #endif 127 | 128 | #if defined(MODE_P25) 129 | if (m_p25Enable && m_modemState == STATE_P25) 130 | p25TX.process(); 131 | #endif 132 | 133 | #if defined(MODE_NXDN) 134 | if (m_nxdnEnable && m_modemState == STATE_NXDN) 135 | nxdnTX.process(); 136 | #endif 137 | 138 | #if defined(MODE_POCSAG) 139 | if (m_pocsagEnable && (m_modemState == STATE_POCSAG || pocsagTX.busy())) 140 | pocsagTX.process(); 141 | #endif 142 | 143 | #if defined(MODE_FM) 144 | if (m_fmEnable && m_modemState == STATE_FM) 145 | fm.process(); 146 | #endif 147 | 148 | #if defined(MODE_DSTAR) 149 | if (m_modemState == STATE_DSTARCAL) 150 | calDStarTX.process(); 151 | #endif 152 | 153 | #if defined(MODE_DMR) 154 | if (m_modemState == STATE_DMRCAL || m_modemState == STATE_LFCAL || m_modemState == STATE_DMRCAL1K || m_modemState == STATE_DMRDMO1K) 155 | calDMR.process(); 156 | #endif 157 | 158 | #if defined(MODE_FM) 159 | 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) 160 | calFM.process(); 161 | #endif 162 | 163 | #if defined(MODE_P25) 164 | if (m_modemState == STATE_P25CAL1K) 165 | calP25.process(); 166 | #endif 167 | 168 | #if defined(MODE_NXDN) 169 | if (m_modemState == STATE_NXDNCAL1K) 170 | calNXDN.process(); 171 | #endif 172 | 173 | #if defined(MODE_POCSAG) 174 | if (m_modemState == STATE_POCSAGCAL) 175 | calPOCSAG.process(); 176 | #endif 177 | 178 | if (m_modemState == STATE_IDLE) 179 | cwIdTX.process(); 180 | } 181 | 182 | int main() 183 | { 184 | setup(); 185 | 186 | for (;;) 187 | loop(); 188 | } 189 | 190 | #endif 191 | 192 | -------------------------------------------------------------------------------- /pins/pins_f4_rpt_tgo.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019,2020 by BG5HHP 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef _PINS_F4_RPT_TGO_H 20 | #define _PINS_F4_RPT_TGO_H 21 | 22 | /* 23 | Pin definitions for MMDVM_RPT_Hat Pi-Hat BG4TGO board:: 24 | 25 | PTT PB13 output CN10 Pin30 26 | COSLED PB14 output CN10 Pin28 27 | LED PA5 output CN10 Pin11 28 | COS PB15 input CN10 Pin26 29 | 30 | DSTAR PB10 output CN10 Pin25 31 | DMR PB4 output CN10 Pin27 32 | YSF PB5 output CN10 Pin29 33 | P25 PB3 output CN10 Pin31 34 | NXDN PA10 output CN10 Pin33 35 | POCSAG PB12 output CN10 Pin16 36 | 37 | MDSTAR PC4 output CN10 Pin34 38 | MDMR PC5 output CN10 Pin6 39 | MYSF PC2 output CN7 Pin35 40 | MP25 PC3 output CN7 Pin37 41 | MNXDN PC6 output CN10 Pin4 42 | MPOCSAG PC8 output CN10 Pin2 43 | 44 | RX PA0 analog input CN7 Pin28 45 | RSSI PA1 analog input CN7 Pin30 46 | TX PA4 analog output CN7 Pin32 47 | 48 | EXT_CLK PA15 input CN7 Pin17 49 | */ 50 | 51 | #define PIN_COS GPIO_Pin_15 52 | #define PORT_COS GPIOB 53 | #define RCC_Per_COS RCC_AHB1Periph_GPIOB 54 | 55 | #define PIN_PTT GPIO_Pin_13 56 | #define PORT_PTT GPIOB 57 | #define RCC_Per_PTT RCC_AHB1Periph_GPIOB 58 | 59 | #define PIN_COSLED GPIO_Pin_14 60 | #define PORT_COSLED GPIOB 61 | #define RCC_Per_COSLED RCC_AHB1Periph_GPIOB 62 | 63 | #define PIN_LED GPIO_Pin_5 64 | #define PORT_LED GPIOA 65 | #define RCC_Per_LED RCC_AHB1Periph_GPIOA 66 | 67 | #define PIN_P25 GPIO_Pin_3 68 | #define PORT_P25 GPIOB 69 | #define RCC_Per_P25 RCC_AHB1Periph_GPIOB 70 | 71 | #define PIN_NXDN GPIO_Pin_10 72 | #define PORT_NXDN GPIOA 73 | #define RCC_Per_NXDN RCC_AHB1Periph_GPIOA 74 | 75 | #define PIN_POCSAG GPIO_Pin_12 76 | #define PORT_POCSAG GPIOB 77 | #define RCC_Per_POCSAG RCC_AHB1Periph_GPIOB 78 | 79 | #define PIN_DSTAR GPIO_Pin_10 80 | #define PORT_DSTAR GPIOB 81 | #define RCC_Per_DSTAR RCC_AHB1Periph_GPIOB 82 | 83 | #define PIN_DMR GPIO_Pin_4 84 | #define PORT_DMR GPIOB 85 | #define RCC_Per_DMR RCC_AHB1Periph_GPIOB 86 | 87 | #define PIN_YSF GPIO_Pin_5 88 | #define PORT_YSF GPIOB 89 | #define RCC_Per_YSF RCC_AHB1Periph_GPIOB 90 | 91 | #if defined(MODE_PINS) 92 | #define PIN_MP25 GPIO_Pin_3 93 | #define PORT_MP25 GPIOC 94 | #define RCC_Per_MP25 RCC_AHB1Periph_GPIOC 95 | 96 | #define PIN_MNXDN GPIO_Pin_6 97 | #define PORT_MNXDN GPIOC 98 | #define RCC_Per_MNXDN RCC_AHB1Periph_GPIOC 99 | 100 | #define PIN_MDSTAR GPIO_Pin_4 101 | #define PORT_MDSTAR GPIOC 102 | #define RCC_Per_MDSTAR RCC_AHB1Periph_GPIOC 103 | 104 | #define PIN_MDMR GPIO_Pin_5 105 | #define PORT_MDMR GPIOC 106 | #define RCC_Per_MDMR RCC_AHB1Periph_GPIOC 107 | 108 | #define PIN_MYSF GPIO_Pin_2 109 | #define PORT_MYSF GPIOC 110 | #define RCC_Per_MYSF RCC_AHB1Periph_GPIOC 111 | 112 | #define PIN_MPOCSAG GPIO_Pin_8 113 | #define PORT_MPOCSAG GPIOC 114 | #define RCC_Per_MPOCSAG RCC_AHB1Periph_GPIOC 115 | #endif 116 | 117 | #define PIN_EXT_CLK GPIO_Pin_15 118 | #define SRC_EXT_CLK GPIO_PinSource15 119 | #define PORT_EXT_CLK GPIOA 120 | 121 | #define PIN_RX GPIO_Pin_0 122 | #define PIN_RX_CH ADC_Channel_0 123 | #define PORT_RX GPIOA 124 | #define RCC_Per_RX RCC_AHB1Periph_GPIOA 125 | 126 | #define PIN_RSSI GPIO_Pin_1 127 | #define PIN_RSSI_CH ADC_Channel_1 128 | #define PORT_RSSI GPIOA 129 | #define RCC_Per_RSSI RCC_AHB1Periph_GPIOA 130 | 131 | #define PIN_TX GPIO_Pin_4 132 | #define PIN_TX_CH DAC_Channel_1 133 | 134 | #endif --------------------------------------------------------------------------------