GNU Radio's TEST Package

bladerf_compat.h
Go to the documentation of this file.
1/* -*- c++ -*- */
2/*
3 * Copyright 2017 Nuand LLC
4 *
5 * GNU Radio 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 3, or (at your option)
8 * any later version.
9 *
10 * GNU Radio 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 GNU Radio; see the file COPYING. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street,
18 * Boston, MA 02110-1301, USA.
19 */
20#ifndef INCLUDED_BLADERF_COMPAT_H
21#define INCLUDED_BLADERF_COMPAT_H
22
23#if defined(LIBBLADERF_API_VERSION) && (LIBBLADERF_API_VERSION < 0x01080100)
24 #warning Old libbladeRF detected: using compatibility workarounds.
25
26 #define BLADERF_COMPATIBILITY
27
28 /* New libbladeRF supports multiple channels, via various enums. */
29 typedef bladerf_module bladerf_channel;
30 #define BLADERF_CHANNEL_RX(ch) BLADERF_MODULE_RX
31 #define BLADERF_CHANNEL_TX(ch) BLADERF_MODULE_TX
32 #define BLADERF_CHANNEL_INVALID BLADERF_MODULE_INVALID
33
34 typedef bladerf_module bladerf_channel_layout;
35 #define BLADERF_RX_X1 BLADERF_MODULE_RX
36 #define BLADERF_TX_X1 BLADERF_MODULE_TX
37 #define BLADERF_RX_X2 BLADERF_MODULE_INVALID
38 #define BLADERF_TX_X2 BLADERF_MODULE_INVALID
39
40 typedef bladerf_module bladerf_direction;
41 #define BLADERF_RX BLADERF_MODULE_RX
42 #define BLADERF_TX BLADERF_MODULE_TX
43 #define BLADERF_DIRECTION_MASK (0x1)
44
45 /* Changed API calls */
46 static
47 int bladerf_get_frequency(struct bladerf *dev,
48 bladerf_channel ch,
49 uint64_t *freq) // was unsigned int *frequency
50 {
51 unsigned int f32 = 0;
52 int status = bladerf_get_frequency(dev, ch, &f32);
53 *freq = static_cast<uint64_t>(f32);
54 return status;
55 }
56
57 static
58 int bladerf_sync_tx(struct bladerf *dev,
59 void const *samples, // was void *samples
60 unsigned int num_samples,
61 struct bladerf_metadata *metadata,
62 unsigned int timeout_ms)
63 {
64 void *s = const_cast<void *>(samples);
65 return bladerf_sync_tx(dev, s, num_samples, metadata, timeout_ms);
66 }
67
68 /* Changed enums/defines */
69 #define BLADERF_GAIN_DEFAULT BLADERF_GAIN_MANUAL
70 #define BLADERF_GAIN_MGC BLADERF_GAIN_MANUAL
71 #define BLADERF_RX_MUX_BASEBAND BLADERF_RX_MUX_BASEBAND_LMS
72
73 /* New functionality with no equivalent */
74 #define BLADERF_LB_AD9361_BIST BLADERF_LB_NONE
75 #define bladerf_get_board_name(name) "bladerf1"
76
77#endif // libbladeRF < 1.8.1
78#endif // INCLUDED_BLADERF_COMPAT_H