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
|
/*
* This file is part of the bladeRF project:
* http://www.github.com/nuand/bladeRF
*
* Copyright (C) 2018 Nuand LLC
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef FPGA_COMMON_AD936X_HELPERS_H_
#define FPGA_COMMON_AD936X_HELPERS_H_
#ifdef BLADERF_NIOS_BUILD
#include "devices.h"
#endif // BLADERF_NIOS_BUILD
#if !defined(BLADERF_NIOS_BUILD) || defined(BLADERF_NIOS_LIBAD936X)
#if !defined(BLADERF_NIOS_BUILD) && !defined(BLADERF_NIOS_PC_SIMULATION)
#include <libbladeRF.h>
#else
#include "libbladeRF_nios_compat.h"
#endif
#include "ad936x.h"
/**
* @brief Retrieve current value in TX attenuation cache.
*
* @param phy RFIC handle
* @param[in] ch Channel
*
* @return Cached attenuation value
*/
uint32_t txmute_get_cached(struct ad9361_rf_phy *phy, bladerf_channel ch);
/**
* @brief Save a new value to the TX attenuation cache.
*
* @param phy RFIC handle
* @param[in] ch Channel
* @param[in] atten Attenuation
*
* @return 0 on success, value from \ref RETCODES list on failure
*/
int txmute_set_cached(struct ad9361_rf_phy *phy,
bladerf_channel ch,
uint32_t atten);
/**
* @brief Get the transmit mute state
*
* @param phy RFIC handle
* @param[in] ch Channel
* @param[out] state Mute state: true for muted, false for unmuted
*
* @return 0 on success, value from \ref RETCODES list on failure
*/
int txmute_get(struct ad9361_rf_phy *phy, bladerf_channel ch, bool *state);
/**
* @brief Sets the transmit mute.
*
* If muted, the TX attenuation will be set to maximum to reduce leakage
* as much as possible.
*
* When unmuted, TX attenuation will be restored to its previous value.
*
* @param phy RFIC handle
* @param[in] ch Channel
* @param[in] state Mute state: true for muted, false for unmuted
*
* @return 0 on success, value from \ref RETCODES list on failure
*/
int txmute_set(struct ad9361_rf_phy *phy, bladerf_channel ch, bool state);
/**
* @brief Set AD9361 RFIC RF port
*
* @param phy RFIC handle
* @param[in] ch Channel
* @param[in] enabled True if the channel is enabled, false otherwise
* @param[in] freq Frequency
*
* @return 0 on success, value from \ref RETCODES list on failure
*/
int set_ad9361_port_by_freq(struct ad9361_rf_phy *phy,
bladerf_channel ch,
bool enabled,
bladerf_frequency freq);
/**
* @brief Translate bladerf_gain_mode to rf_gain_ctrl_mode
*
* @param[in] gainmode The libbladeRF gainmode
* @param[out] ok True if return value is valid, false otherwise
*
* @return rf_gain_ctrl_mode
*/
enum rf_gain_ctrl_mode gainmode_bladerf_to_ad9361(bladerf_gain_mode gainmode,
bool *ok);
/**
* @brief Translate rf_gain_ctrl_mode to bladerf_gain_mode
*
* @param[in] gainmode The RFIC gainmode
* @param[out] ok True if return value is valid, false otherwise
*
* @return bladerf_gain_mode
*/
bladerf_gain_mode gainmode_ad9361_to_bladerf(enum rf_gain_ctrl_mode gainmode,
bool *ok);
#endif // !defined(BLADERF_NIOS_BUILD) || defined(BLADERF_NIOS_LIBAD936X)
#endif // FPGA_COMMON_AD936X_HELPERS_H_
|