-
Notifications
You must be signed in to change notification settings - Fork 7
/
IO.h
142 lines (107 loc) · 4.03 KB
/
IO.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
/*
* Copyright (C) 2015,2016,2017,2018 by Jonathan Naylor G4KLX
*
* GNU radio integration code written by Adrian Musceac YO8RZZ 2021
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#if !defined(IO_H)
#define IO_H
#include "Globals.h"
#include "SampleRB.h"
#include "RSSIRB.h"
#include <zmq.hpp>
class CIO {
public:
CIO();
void start();
void process();
void write(MMDVM_STATE mode, q15_t* samples, uint16_t length, const uint8_t* control = NULL);
uint16_t getSpace();
void setDecode(bool dcd);
void setADCDetection(bool detect);
void setMode(MMDVM_STATE state);
void interrupt();
void interruptRX();
void setParameters(bool rxInvert, bool txInvert, bool pttInvert, uint8_t rxLevel, uint8_t cwIdTXLevel, uint8_t dstarTXLevel, uint8_t dmrTXLevel, uint8_t ysfTXLevel, uint8_t p25TXLevel, uint8_t nxdnLevel, int16_t txDCOffset, int16_t rxDCOffset);
void getOverflow(bool& adcOverflow, bool& dacOverflow);
bool hasTXOverflow();
bool hasRXOverflow();
bool hasLockout() const;
void resetWatchdog();
uint32_t getWatchdog();
void selfTest();
private:
bool m_started;
pthread_t m_thread;
pthread_t m_threadRX;
CSampleRB m_rxBuffer;
CSampleRB m_txBuffer;
CRSSIRB m_rssiBuffer;
arm_biquad_casd_df1_inst_q31 m_dcFilter;
q31_t m_dcState[4];
arm_fir_instance_q15 m_rrcFilter;
arm_fir_instance_q15 m_gaussianFilter;
arm_fir_instance_q15 m_boxcarFilter;
arm_fir_instance_q15 m_nxdnFilter;
arm_fir_instance_q15 m_nxdnISincFilter;
q15_t m_rrcState[70U]; // NoTaps + BlockSize - 1, 42 + 20 - 1 plus some spare
q15_t m_gaussianState[40U]; // NoTaps + BlockSize - 1, 12 + 20 - 1 plus some spare
q15_t m_boxcarState[30U]; // NoTaps + BlockSize - 1, 6 + 20 - 1 plus some spare
q15_t m_nxdnState[110U]; // NoTaps + BlockSize - 1, 82 + 20 - 1 plus some spare
q15_t m_nxdnISincState[60U]; // NoTaps + BlockSize - 1, 32 + 20 - 1 plus some spare
bool m_pttInvert;
q15_t m_rxLevel;
q15_t m_cwIdTXLevel;
q15_t m_dstarTXLevel;
q15_t m_dmrTXLevel;
q15_t m_ysfTXLevel;
q15_t m_p25TXLevel;
q15_t m_nxdnTXLevel;
uint16_t m_rxDCOffset;
uint16_t m_txDCOffset;
uint32_t m_ledCount;
bool m_ledValue;
bool m_detect;
uint16_t m_adcOverflow;
uint16_t m_dacOverflow;
volatile uint32_t m_watchdog;
bool m_lockout;
zmq::context_t m_zmqcontext;
zmq::socket_t m_zmqsocket;
std::vector<short> m_audiobuf;
zmq::context_t m_zmqcontextRX;
zmq::socket_t m_zmqsocketRX;
std::vector<short> m_audiobufRX;
pthread_mutex_t m_TXlock;
pthread_mutex_t m_RXlock;
bool m_COSint;
// Hardware specific routines
void initInt();
void startInt();
static void* helper(void* arg);
static void* helperRX(void* arg);
bool getCOSInt();
void setLEDInt(bool on);
void setPTTInt(bool on);
void setCOSInt(bool on);
void setDStarInt(bool on);
void setDMRInt(bool on);
void setYSFInt(bool on);
void setP25Int(bool on);
void setNXDNInt(bool on);
void delayInt(unsigned int dly);
};
#endif