SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
bladerf2inputthread.h
Go to the documentation of this file.
1 // Copyright (C) 2018 Edouard Griffiths, F4EXB //
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 as version 3 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 V3 for more details. //
13 // //
14 // You should have received a copy of the GNU General Public License //
15 // along with this program. If not, see <http://www.gnu.org/licenses/>. //
17 
18 #ifndef PLUGINS_SAMPLESOURCE_BLADERF2INPUT_BLADERF2INPUTTHREAD_H_
19 #define PLUGINS_SAMPLESOURCE_BLADERF2INPUT_BLADERF2INPUTTHREAD_H_
20 
21 // BladerRF2 is a SISO/MIMO device with a single stream supporting one or two Rx
22 // Therefore only one thread can be allocated for the Rx side
23 // All FIFOs must be registered before calling startWork() else SISO/MIMO switch will not work properly
24 // with unpredicatable results
25 
26 #include <QThread>
27 #include <QMutex>
28 #include <QWaitCondition>
29 
30 #include <libbladeRF.h>
31 
33 #include "dsp/decimators.h"
34 
35 class SampleSinkFifo;
36 
37 class BladeRF2InputThread : public QThread {
38  Q_OBJECT
39 
40 public:
41  BladeRF2InputThread(struct bladerf* dev, unsigned int nbRxChannels, QObject* parent = NULL);
43 
44  void startWork();
45  void stopWork();
46  bool isRunning() const { return m_running; }
47  unsigned int getNbChannels() const { return m_nbChannels; }
48  void setLog2Decimation(unsigned int channel, unsigned int log2_decim);
49  unsigned int getLog2Decimation(unsigned int channel) const;
50  void setFcPos(unsigned int channel, int fcPos);
51  int getFcPos(unsigned int channel) const;
52  void setFifo(unsigned int channel, SampleSinkFifo *sampleFifo);
53  SampleSinkFifo *getFifo(unsigned int channel);
54 
55 private:
56  struct Channel
57  {
60  unsigned int m_log2Decim;
61  int m_fcPos;
63 
64  Channel() :
65  m_sampleFifo(0),
66  m_log2Decim(0),
67  m_fcPos(0)
68  {}
69 
71  {}
72  };
73 
75  QWaitCondition m_startWaiter;
76  bool m_running;
77  struct bladerf* m_dev;
78 
80  qint16 *m_buf;
81  unsigned int m_nbChannels;
82 
83  void run();
84  unsigned int getNbFifos();
85  void callbackSI(const qint16* buf, qint32 len, unsigned int channel = 0);
86  void callbackMI(const qint16* buf, qint32 samplesPerChannel);
87 };
88 
89 
90 
91 #endif /* PLUGINS_SAMPLESOURCE_BLADERF2INPUT_BLADERF2INPUTTHREAD_H_ */
unsigned int getLog2Decimation(unsigned int channel) const
std::vector< Sample > SampleVector
Definition: dsptypes.h:96
Channel * m_channels
Array of channels dynamically allocated for the given number of Rx channels.
void callbackSI(const qint16 *buf, qint32 len, unsigned int channel=0)
void setFcPos(unsigned int channel, int fcPos)
unsigned int getNbChannels() const
void callbackMI(const qint16 *buf, qint32 samplesPerChannel)
qint16 * m_buf
Full buffer for SISO or MIMO operation.
int getFcPos(unsigned int channel) const
struct bladerf * m_dev
void setFifo(unsigned int channel, SampleSinkFifo *sampleFifo)
QWaitCondition m_startWaiter
void setLog2Decimation(unsigned int channel, unsigned int log2_decim)
Decimators< qint32, qint16, SDR_RX_SAMP_SZ, 12 > m_decimators
BladeRF2InputThread(struct bladerf *dev, unsigned int nbRxChannels, QObject *parent=NULL)
SampleSinkFifo * getFifo(unsigned int channel)