host: refactoring bladerf2.c
General documentation cleanup, function name adjustments, merging of
redundant structures, etc.
fpga_common/ad936x_helpers:
Contains wrappers for AD936x RFIC functionality.
fpga_common/bladerf2_common:
Contains bladeRF2-specific helper functions and constants.
fpga_common/ad936x_params:
Reformat (no more tabs, phew)
Move ina219 shunt const to bladerf2_common
host/common/range:
Move functions and macros for handling bladerf_range structs
../libbladeRF/include/bladeRF2.h:
Explicitly index RX/TX FIR enums
Update references to ad936x_params.c
../libbladeRF/src/board/bladerf2/common:
New macros for boilerplate:
- WITH_MUTEX: wrap around locked blocks
- CHECK_STATUS: calls function, checks return code
- CHECK_AD936X: calls function, checks return code, translates
from AD936x to libbladeRF error codes
- CHECK_*_LOCKED: above, but unlocks mutex before erroring
- NULL_CHECK: checks a var for null
Move helper functions into here
../libbladeRF/src/board/bladerf2/bladerf2.c:
Use new macros
Code style fixes
Remove redundant code
This commit is contained in:
parent
1c09cad506
commit
05f7fd571a
12 changed files with 3389 additions and 3494 deletions
120
fpga_common/include/ad936x_helpers.h
Normal file
120
fpga_common/include/ad936x_helpers.h
Normal file
|
|
@ -0,0 +1,120 @@
|
|||
/*
|
||||
* 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_
|
||||
|
||||
#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
|
||||
583
fpga_common/include/bladerf2_common.h
Normal file
583
fpga_common/include/bladerf2_common.h
Normal file
|
|
@ -0,0 +1,583 @@
|
|||
/* This file is part of the bladeRF project:
|
||||
* http://www.github.com/nuand/bladeRF
|
||||
*
|
||||
* Copyright (c) 2018 Nuand LLC
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef FPGA_COMMON_BLADERF2_COMMON_H_
|
||||
#define FPGA_COMMON_BLADERF2_COMMON_H_
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#if !defined(BLADERF_NIOS_BUILD) && !defined(BLADERF_NIOS_PC_SIMULATION)
|
||||
#include <libbladeRF.h>
|
||||
#else
|
||||
#include "libbladeRF_nios_compat.h"
|
||||
#endif
|
||||
|
||||
#include "ad936x.h"
|
||||
#include "host_config.h"
|
||||
#include "nios_pkt_retune2.h"
|
||||
#include "range.h"
|
||||
|
||||
/**
|
||||
* Number of modules (directions) present. 1 RX, 1 TX = 2.
|
||||
*/
|
||||
#define NUM_MODULES 2
|
||||
|
||||
/**
|
||||
* Frequency of the system VCTCXO, in Hz.
|
||||
*/
|
||||
static bladerf_frequency const BLADERF_VCTCXO_FREQUENCY = 38400000;
|
||||
|
||||
/**
|
||||
* Default reference input frequency, in Hz.
|
||||
*/
|
||||
static bladerf_frequency const BLADERF_REFIN_DEFAULT = 10000000;
|
||||
|
||||
/**
|
||||
* RFIC reset frequency (arbitrary)
|
||||
*/
|
||||
static bladerf_frequency const RESET_FREQUENCY = 70000000;
|
||||
|
||||
// clang-format off
|
||||
// Config GPIO
|
||||
#define CFG_GPIO_POWERSOURCE 0
|
||||
#define CFG_GPIO_PLL_EN 11
|
||||
#define CFG_GPIO_CLOCK_OUTPUT 17
|
||||
#define CFG_GPIO_CLOCK_SELECT 18
|
||||
|
||||
// RFFE control
|
||||
#define RFFE_CONTROL_RESET_N 0
|
||||
#define RFFE_CONTROL_ENABLE 1
|
||||
#define RFFE_CONTROL_TXNRX 2
|
||||
#define RFFE_CONTROL_EN_AGC 3
|
||||
#define RFFE_CONTROL_SYNC_IN 4
|
||||
#define RFFE_CONTROL_RX_BIAS_EN 5
|
||||
#define RFFE_CONTROL_RX_SPDT_1 6 // 6 and 7
|
||||
#define RFFE_CONTROL_RX_SPDT_2 8 // 8 and 9
|
||||
#define RFFE_CONTROL_TX_BIAS_EN 10
|
||||
#define RFFE_CONTROL_TX_SPDT_1 11 // 11 and 12
|
||||
#define RFFE_CONTROL_TX_SPDT_2 13 // 13 and 14
|
||||
#define RFFE_CONTROL_MIMO_RX_EN_0 15
|
||||
#define RFFE_CONTROL_MIMO_TX_EN_0 16
|
||||
#define RFFE_CONTROL_MIMO_RX_EN_1 17
|
||||
#define RFFE_CONTROL_MIMO_TX_EN_1 18
|
||||
#define RFFE_CONTROL_ADF_MUXOUT 19 // input only
|
||||
#define RFFE_CONTROL_CTRL_OUT 24 // input only, 24 through 31
|
||||
#define RFFE_CONTROL_SPDT_MASK 0x3
|
||||
#define RFFE_CONTROL_SPDT_SHUTDOWN 0x0 // no connection
|
||||
#define RFFE_CONTROL_SPDT_LOWBAND 0x2 // RF1 <-> RF3
|
||||
#define RFFE_CONTROL_SPDT_HIGHBAND 0x1 // RF1 <-> RF2
|
||||
|
||||
// Trim DAC control
|
||||
#define TRIMDAC_MASK 0x3FFC // 2 through 13
|
||||
#define TRIMDAC_EN 14 // 14 and 15
|
||||
#define TRIMDAC_EN_MASK 0x3
|
||||
#define TRIMDAC_EN_ACTIVE 0x0
|
||||
#define TRIMDAC_EN_HIGHZ 0x3
|
||||
|
||||
/* Number of fast lock profiles that can be stored in the Nios
|
||||
* Make sure this number matches that of the Nios' devices.h */
|
||||
#define NUM_BBP_FASTLOCK_PROFILES 256
|
||||
|
||||
/* Number of fast lock profiles that can be stored in the RFFE
|
||||
* Make sure this number matches that of the Nios' devices.h */
|
||||
#define NUM_RFFE_FASTLOCK_PROFILES 8
|
||||
// clang-format on
|
||||
|
||||
/**
|
||||
* @brief Round a value into an int
|
||||
*
|
||||
* @param x Value to round
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
#define __round_int(x) (x >= 0 ? (int)(x + 0.5) : (int)(x - 0.5))
|
||||
|
||||
/**
|
||||
* @brief Round a value into an int64
|
||||
*
|
||||
* @param x Value to round
|
||||
*
|
||||
* @return int64
|
||||
*/
|
||||
#define __round_int64(x) (x >= 0 ? (int64_t)(x + 0.5) : (int64_t)(x - 0.5))
|
||||
|
||||
/**
|
||||
* RF front end bands
|
||||
*/
|
||||
enum bladerf2_band {
|
||||
BAND_SHUTDOWN, /**< Inactive */
|
||||
BAND_LOW, /**< Low-band */
|
||||
BAND_HIGH, /**< High-band */
|
||||
};
|
||||
|
||||
/**
|
||||
* Mapping between libbladeRF gain modes and RFIC gain modes.
|
||||
*/
|
||||
struct bladerf_rfic_gain_mode_map {
|
||||
bladerf_gain_mode brf_mode; /**< libbladeRF gain mode */
|
||||
enum rf_gain_ctrl_mode rfic_mode; /**< RFIC gain mode */
|
||||
};
|
||||
|
||||
/**
|
||||
* Mapping between frequency ranges and gain ranges.
|
||||
*/
|
||||
struct bladerf_gain_range {
|
||||
char const *name; /**< Gain stage name */
|
||||
struct bladerf_range frequency; /**< Frequency range */
|
||||
struct bladerf_range gain; /**< Applicable stage gain range */
|
||||
float offset; /**< Offset in dB, for mapping dB gain to absolute dBm. */
|
||||
};
|
||||
|
||||
/**
|
||||
* Mapping between string names and RFIC port identifiers.
|
||||
*/
|
||||
struct bladerf_rfic_port_name_map {
|
||||
char const *name; /**< Port name */
|
||||
uint32_t id; /**< Port ID */
|
||||
};
|
||||
|
||||
/**
|
||||
* Mapping between RF front end bands, freqencies, and physical hardware
|
||||
* configurations
|
||||
*/
|
||||
struct band_port_map {
|
||||
struct bladerf_range const frequency; /**< Frequency range */
|
||||
enum bladerf2_band band; /**< RF front end band */
|
||||
uint32_t spdt; /**< RF switch configuration */
|
||||
uint32_t rfic_port; /**< RFIC port configuration */
|
||||
};
|
||||
|
||||
|
||||
/******************************************************************************/
|
||||
/* Constants */
|
||||
/******************************************************************************/
|
||||
// clang-format off
|
||||
|
||||
/* Gain mode mappings */
|
||||
static struct bladerf_rfic_gain_mode_map const bladerf2_rx_gain_mode_map[] = {
|
||||
{
|
||||
FIELD_INIT(.brf_mode, BLADERF_GAIN_MGC),
|
||||
FIELD_INIT(.rfic_mode, RF_GAIN_MGC)
|
||||
},
|
||||
{
|
||||
FIELD_INIT(.brf_mode, BLADERF_GAIN_FASTATTACK_AGC),
|
||||
FIELD_INIT(.rfic_mode, RF_GAIN_FASTATTACK_AGC)
|
||||
},
|
||||
{
|
||||
FIELD_INIT(.brf_mode, BLADERF_GAIN_SLOWATTACK_AGC),
|
||||
FIELD_INIT(.rfic_mode, RF_GAIN_SLOWATTACK_AGC)
|
||||
},
|
||||
{
|
||||
FIELD_INIT(.brf_mode, BLADERF_GAIN_HYBRID_AGC),
|
||||
FIELD_INIT(.rfic_mode, RF_GAIN_HYBRID_AGC)
|
||||
},
|
||||
};
|
||||
|
||||
/* RX gain ranges */
|
||||
/* Reference: ad9361.c, ad9361_gt_tableindex and ad9361_init_gain_tables */
|
||||
static struct bladerf_gain_range const bladerf2_rx_gain_ranges[] = {
|
||||
{
|
||||
FIELD_INIT(.name, NULL),
|
||||
FIELD_INIT(.frequency, {
|
||||
FIELD_INIT(.min, 0),
|
||||
FIELD_INIT(.max, 1300000000),
|
||||
FIELD_INIT(.step, 1),
|
||||
FIELD_INIT(.scale, 1),
|
||||
}),
|
||||
FIELD_INIT(.gain, {
|
||||
FIELD_INIT(.min, 1 - 17),
|
||||
FIELD_INIT(.max, 77 - 17),
|
||||
FIELD_INIT(.step, 1),
|
||||
FIELD_INIT(.scale, 1),
|
||||
}),
|
||||
FIELD_INIT(.offset, -17.0f),
|
||||
},
|
||||
{
|
||||
FIELD_INIT(.name, NULL),
|
||||
FIELD_INIT(.frequency, {
|
||||
FIELD_INIT(.min, 1300000000UL),
|
||||
FIELD_INIT(.max, 4000000000UL),
|
||||
FIELD_INIT(.step, 1),
|
||||
FIELD_INIT(.scale, 1),
|
||||
}),
|
||||
FIELD_INIT(.gain, {
|
||||
FIELD_INIT(.min, -4 - 11),
|
||||
FIELD_INIT(.max, 71 - 11),
|
||||
FIELD_INIT(.step, 1),
|
||||
FIELD_INIT(.scale, 1),
|
||||
}),
|
||||
FIELD_INIT(.offset, -11.0f),
|
||||
},
|
||||
{
|
||||
FIELD_INIT(.name, NULL),
|
||||
FIELD_INIT(.frequency, {
|
||||
FIELD_INIT(.min, 4000000000UL),
|
||||
FIELD_INIT(.max, 6000000000UL),
|
||||
FIELD_INIT(.step, 1),
|
||||
FIELD_INIT(.scale, 1),
|
||||
}),
|
||||
FIELD_INIT(.gain, {
|
||||
FIELD_INIT(.min, -10 - 2),
|
||||
FIELD_INIT(.max, 62 - 2),
|
||||
FIELD_INIT(.step, 1),
|
||||
FIELD_INIT(.scale, 1),
|
||||
}),
|
||||
FIELD_INIT(.offset, -2.0f),
|
||||
},
|
||||
{
|
||||
FIELD_INIT(.name, "full"),
|
||||
FIELD_INIT(.frequency, {
|
||||
FIELD_INIT(.min, 0),
|
||||
FIELD_INIT(.max, 1300000000),
|
||||
FIELD_INIT(.step, 1),
|
||||
FIELD_INIT(.scale, 1),
|
||||
}),
|
||||
FIELD_INIT(.gain, {
|
||||
FIELD_INIT(.min, 1),
|
||||
FIELD_INIT(.max, 77),
|
||||
FIELD_INIT(.step, 1),
|
||||
FIELD_INIT(.scale, 1),
|
||||
}),
|
||||
FIELD_INIT(.offset, 0),
|
||||
},
|
||||
{
|
||||
FIELD_INIT(.name, "full"),
|
||||
FIELD_INIT(.frequency, {
|
||||
FIELD_INIT(.min, 1300000000UL),
|
||||
FIELD_INIT(.max, 4000000000UL),
|
||||
FIELD_INIT(.step, 1),
|
||||
FIELD_INIT(.scale, 1),
|
||||
}),
|
||||
FIELD_INIT(.gain, {
|
||||
FIELD_INIT(.min, -4),
|
||||
FIELD_INIT(.max, 71),
|
||||
FIELD_INIT(.step, 1),
|
||||
FIELD_INIT(.scale, 1),
|
||||
}),
|
||||
FIELD_INIT(.offset, 0),
|
||||
},
|
||||
{
|
||||
FIELD_INIT(.name, "full"),
|
||||
FIELD_INIT(.frequency, {
|
||||
FIELD_INIT(.min, 4000000000UL),
|
||||
FIELD_INIT(.max, 6000000000UL),
|
||||
FIELD_INIT(.step, 1),
|
||||
FIELD_INIT(.scale, 1),
|
||||
}),
|
||||
FIELD_INIT(.gain, {
|
||||
FIELD_INIT(.min, -10),
|
||||
FIELD_INIT(.max, 62),
|
||||
FIELD_INIT(.step, 1),
|
||||
FIELD_INIT(.scale, 1),
|
||||
}),
|
||||
FIELD_INIT(.offset, 0),
|
||||
},
|
||||
};
|
||||
|
||||
/* Overall TX gain range */
|
||||
static struct bladerf_gain_range const bladerf2_tx_gain_ranges[] = {
|
||||
{
|
||||
/* TX gain offset: 60 dB system gain ~= 0 dBm output */
|
||||
FIELD_INIT(.name, NULL),
|
||||
FIELD_INIT(.frequency, {
|
||||
FIELD_INIT(.min, 47000000UL),
|
||||
FIELD_INIT(.max, 6000000000UL),
|
||||
FIELD_INIT(.step, 1),
|
||||
FIELD_INIT(.scale, 1),
|
||||
}),
|
||||
FIELD_INIT(.gain, {
|
||||
FIELD_INIT(.min, __round_int64(1000*(-89.750 + 66.0))),
|
||||
FIELD_INIT(.max, __round_int64(1000*(0 + 66.0))),
|
||||
FIELD_INIT(.step, 250),
|
||||
FIELD_INIT(.scale, 0.001F),
|
||||
}),
|
||||
FIELD_INIT(.offset, 66.0f),
|
||||
},
|
||||
{
|
||||
FIELD_INIT(.name, "dsa"),
|
||||
FIELD_INIT(.frequency, {
|
||||
FIELD_INIT(.min, 47000000UL),
|
||||
FIELD_INIT(.max, 6000000000UL),
|
||||
FIELD_INIT(.step, 1),
|
||||
FIELD_INIT(.scale, 1),
|
||||
}),
|
||||
FIELD_INIT(.gain, {
|
||||
FIELD_INIT(.min, -89750),
|
||||
FIELD_INIT(.max, 0),
|
||||
FIELD_INIT(.step, 250),
|
||||
FIELD_INIT(.scale, 0.001F),
|
||||
}),
|
||||
FIELD_INIT(.offset, 0),
|
||||
},
|
||||
};
|
||||
|
||||
/* RX gain modes */
|
||||
static struct bladerf_gain_modes const bladerf2_rx_gain_modes[] = {
|
||||
{
|
||||
FIELD_INIT(.name, "automatic"),
|
||||
FIELD_INIT(.mode, BLADERF_GAIN_DEFAULT)
|
||||
},
|
||||
{
|
||||
FIELD_INIT(.name, "manual"),
|
||||
FIELD_INIT(.mode, BLADERF_GAIN_MGC)
|
||||
},
|
||||
{
|
||||
FIELD_INIT(.name, "fast"),
|
||||
FIELD_INIT(.mode, BLADERF_GAIN_FASTATTACK_AGC)
|
||||
},
|
||||
{
|
||||
FIELD_INIT(.name, "slow"),
|
||||
FIELD_INIT(.mode, BLADERF_GAIN_SLOWATTACK_AGC)
|
||||
},
|
||||
{
|
||||
FIELD_INIT(.name, "hybrid"),
|
||||
FIELD_INIT(.mode, BLADERF_GAIN_HYBRID_AGC)
|
||||
}
|
||||
};
|
||||
|
||||
/* Sample Rate Range */
|
||||
static struct bladerf_range const bladerf2_sample_rate_range = {
|
||||
FIELD_INIT(.min, 520834),
|
||||
FIELD_INIT(.max, 61440000),
|
||||
FIELD_INIT(.step, 1),
|
||||
FIELD_INIT(.scale, 1),
|
||||
};
|
||||
|
||||
/* Sample rates requiring a 4x interpolation/decimation */
|
||||
static struct bladerf_range const bladerf2_sample_rate_range_4x = {
|
||||
FIELD_INIT(.min, 520834),
|
||||
FIELD_INIT(.max, 2083334),
|
||||
FIELD_INIT(.step, 1),
|
||||
FIELD_INIT(.scale, 1),
|
||||
};
|
||||
|
||||
/* Bandwidth Range */
|
||||
static struct bladerf_range const bladerf2_bandwidth_range = {
|
||||
FIELD_INIT(.min, 200000),
|
||||
FIELD_INIT(.max, 56000000),
|
||||
FIELD_INIT(.step, 1),
|
||||
FIELD_INIT(.scale, 1),
|
||||
};
|
||||
|
||||
/* Frequency Ranges */
|
||||
static struct bladerf_range const bladerf2_rx_frequency_range = {
|
||||
FIELD_INIT(.min, 70000000),
|
||||
FIELD_INIT(.max, 6000000000),
|
||||
FIELD_INIT(.step, 2),
|
||||
FIELD_INIT(.scale, 1),
|
||||
};
|
||||
|
||||
static struct bladerf_range const bladerf2_tx_frequency_range = {
|
||||
FIELD_INIT(.min, 47000000),
|
||||
FIELD_INIT(.max, 6000000000),
|
||||
FIELD_INIT(.step, 2),
|
||||
FIELD_INIT(.scale, 1),
|
||||
};
|
||||
|
||||
|
||||
/* RF Ports */
|
||||
static struct bladerf_rfic_port_name_map const bladerf2_rx_port_map[] = {
|
||||
{ FIELD_INIT(.name, "A_BALANCED"), FIELD_INIT(.id, AD936X_A_BALANCED), },
|
||||
{ FIELD_INIT(.name, "B_BALANCED"), FIELD_INIT(.id, AD936X_B_BALANCED), },
|
||||
{ FIELD_INIT(.name, "C_BALANCED"), FIELD_INIT(.id, AD936X_C_BALANCED), },
|
||||
{ FIELD_INIT(.name, "A_N"), FIELD_INIT(.id, AD936X_A_N), },
|
||||
{ FIELD_INIT(.name, "A_P"), FIELD_INIT(.id, AD936X_A_P), },
|
||||
{ FIELD_INIT(.name, "B_N"), FIELD_INIT(.id, AD936X_B_N), },
|
||||
{ FIELD_INIT(.name, "B_P"), FIELD_INIT(.id, AD936X_B_P), },
|
||||
{ FIELD_INIT(.name, "C_N"), FIELD_INIT(.id, AD936X_C_N), },
|
||||
{ FIELD_INIT(.name, "C_P"), FIELD_INIT(.id, AD936X_C_P), },
|
||||
{ FIELD_INIT(.name, "TX_MON1"), FIELD_INIT(.id, AD936X_TX_MON1), },
|
||||
{ FIELD_INIT(.name, "TX_MON2"), FIELD_INIT(.id, AD936X_TX_MON2), },
|
||||
{ FIELD_INIT(.name, "TX_MON1_2"), FIELD_INIT(.id, AD936X_TX_MON1_2), },
|
||||
};
|
||||
|
||||
static struct bladerf_rfic_port_name_map const bladerf2_tx_port_map[] = {
|
||||
{ FIELD_INIT(.name, "TXA"), FIELD_INIT(.id, AD936X_TXA), },
|
||||
{ FIELD_INIT(.name, "TXB"), FIELD_INIT(.id, AD936X_TXB), },
|
||||
};
|
||||
|
||||
static struct band_port_map const bladerf2_rx_band_port_map[] = {
|
||||
{
|
||||
FIELD_INIT(.frequency, {
|
||||
FIELD_INIT(.min, 0),
|
||||
FIELD_INIT(.max, 0),
|
||||
FIELD_INIT(.step, 1),
|
||||
FIELD_INIT(.scale, 1),
|
||||
}),
|
||||
FIELD_INIT(.band, BAND_SHUTDOWN),
|
||||
FIELD_INIT(.spdt, RFFE_CONTROL_SPDT_SHUTDOWN),
|
||||
FIELD_INIT(.rfic_port, 0),
|
||||
},
|
||||
{
|
||||
FIELD_INIT(.frequency, {
|
||||
FIELD_INIT(.min, 70000000UL),
|
||||
FIELD_INIT(.max, 3000000000UL),
|
||||
FIELD_INIT(.step, 2),
|
||||
FIELD_INIT(.scale, 1),
|
||||
}),
|
||||
FIELD_INIT(.band, BAND_LOW),
|
||||
FIELD_INIT(.spdt, RFFE_CONTROL_SPDT_LOWBAND),
|
||||
FIELD_INIT(.rfic_port, AD936X_B_BALANCED),
|
||||
},
|
||||
{
|
||||
FIELD_INIT(.frequency, {
|
||||
FIELD_INIT(.min, 3000000000UL),
|
||||
FIELD_INIT(.max, 6000000000UL),
|
||||
FIELD_INIT(.step, 2),
|
||||
FIELD_INIT(.scale, 1),
|
||||
}),
|
||||
FIELD_INIT(.band, BAND_HIGH),
|
||||
FIELD_INIT(.spdt, RFFE_CONTROL_SPDT_HIGHBAND),
|
||||
FIELD_INIT(.rfic_port, AD936X_A_BALANCED),
|
||||
},
|
||||
};
|
||||
|
||||
static struct band_port_map const bladerf2_tx_band_port_map[] = {
|
||||
{
|
||||
FIELD_INIT(.frequency, {
|
||||
FIELD_INIT(.min, 0),
|
||||
FIELD_INIT(.max, 0),
|
||||
FIELD_INIT(.step, 1),
|
||||
FIELD_INIT(.scale, 1),
|
||||
}),
|
||||
FIELD_INIT(.band, BAND_SHUTDOWN),
|
||||
FIELD_INIT(.spdt, RFFE_CONTROL_SPDT_SHUTDOWN),
|
||||
FIELD_INIT(.rfic_port, 0),
|
||||
},
|
||||
{
|
||||
FIELD_INIT(.frequency, {
|
||||
FIELD_INIT(.min, 46875000UL),
|
||||
FIELD_INIT(.max, 3000000000UL),
|
||||
FIELD_INIT(.step, 2),
|
||||
FIELD_INIT(.scale, 1),
|
||||
}),
|
||||
FIELD_INIT(.band, BAND_LOW),
|
||||
FIELD_INIT(.spdt, RFFE_CONTROL_SPDT_LOWBAND),
|
||||
FIELD_INIT(.rfic_port, AD936X_TXB),
|
||||
},
|
||||
{
|
||||
FIELD_INIT(.frequency, {
|
||||
FIELD_INIT(.min, 3000000000UL),
|
||||
FIELD_INIT(.max, 6000000000UL),
|
||||
FIELD_INIT(.step, 2),
|
||||
FIELD_INIT(.scale, 1),
|
||||
}),
|
||||
FIELD_INIT(.band, BAND_HIGH),
|
||||
FIELD_INIT(.spdt, RFFE_CONTROL_SPDT_HIGHBAND),
|
||||
FIELD_INIT(.rfic_port, AD936X_TXA),
|
||||
},
|
||||
};
|
||||
|
||||
// clang-format on
|
||||
|
||||
|
||||
/******************************************************************************/
|
||||
/* Helpers */
|
||||
/******************************************************************************/
|
||||
|
||||
/**
|
||||
* @brief Translate libad936x error codes to libbladeRF error codes
|
||||
*
|
||||
* @param[in] err The error
|
||||
*
|
||||
* @return value from \ref RETCODES list, or 0 if err is >= 0
|
||||
*/
|
||||
int errno_ad9361_to_bladerf(int err);
|
||||
|
||||
/**
|
||||
* @brief Gets the band port map by frequency.
|
||||
*
|
||||
* @param[in] ch Channel
|
||||
* @param[in] freq Frequency. Use 0 for the "disabled" state.
|
||||
*
|
||||
* @return pointer to band_port_map
|
||||
*/
|
||||
struct band_port_map const *_get_band_port_map_by_freq(bladerf_channel ch,
|
||||
bladerf_frequency freq);
|
||||
|
||||
/**
|
||||
* @brief Modifies reg to configure the RF switch SPDT bits
|
||||
*
|
||||
* @param reg RFFE control register ptr
|
||||
* @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 _modify_spdt_bits_by_freq(uint32_t *reg,
|
||||
bladerf_channel ch,
|
||||
bool enabled,
|
||||
bladerf_frequency freq);
|
||||
|
||||
/**
|
||||
* @brief Look up the RFFE control register bit for a bladerf_direction
|
||||
*
|
||||
* @param[in] dir Direction
|
||||
*
|
||||
* @return Bit index
|
||||
*/
|
||||
int _get_rffe_control_bit_for_dir(bladerf_direction dir);
|
||||
|
||||
/**
|
||||
* @brief Look up the RFFE control register bit for a bladerf_channel
|
||||
*
|
||||
* @param[in] ch Channel
|
||||
*
|
||||
* @return Bit index
|
||||
*/
|
||||
int _get_rffe_control_bit_for_ch(bladerf_channel ch);
|
||||
|
||||
/**
|
||||
* @brief Determine if a channel is active
|
||||
*
|
||||
* @param[in] reg RFFE control register
|
||||
* @param[in] ch Channel
|
||||
*
|
||||
* @return true if active, false otherwise
|
||||
*/
|
||||
bool _rffe_ch_enabled(uint32_t reg, bladerf_channel ch);
|
||||
|
||||
/**
|
||||
* @brief Determine if any channel in a direction is active
|
||||
*
|
||||
* @param[in] reg RFFE control register
|
||||
* @param[in] dir Direction
|
||||
*
|
||||
* @return true if any channel is active, false otherwise
|
||||
*/
|
||||
bool _rffe_dir_enabled(uint32_t reg, bladerf_direction dir);
|
||||
|
||||
/**
|
||||
* @brief Determine if any *other* channel in a direction is active
|
||||
*
|
||||
* @param[in] reg RFFE control register
|
||||
* @param[in] ch Channel
|
||||
*
|
||||
* @return true if any channel in the same direction as ch is active, false
|
||||
* otherwise
|
||||
*/
|
||||
bool _rffe_dir_otherwise_enabled(uint32_t reg, bladerf_channel ch);
|
||||
|
||||
#endif // FPGA_COMMON_BLADERF2_COMMON_H_
|
||||
186
fpga_common/src/ad936x_helpers.c
Normal file
186
fpga_common/src/ad936x_helpers.c
Normal file
|
|
@ -0,0 +1,186 @@
|
|||
/*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#if !defined(BLADERF_NIOS_BUILD) && !defined(BLADERF_NIOS_PC_SIMULATION)
|
||||
#include "log.h"
|
||||
#endif
|
||||
|
||||
#include "ad936x_helpers.h"
|
||||
#include "bladerf2_common.h"
|
||||
|
||||
static bool tx_mute_state[2] = { false };
|
||||
|
||||
|
||||
uint32_t txmute_get_cached(struct ad9361_rf_phy *phy, bladerf_channel ch)
|
||||
{
|
||||
switch (ch) {
|
||||
case BLADERF_CHANNEL_TX(0):
|
||||
return phy->tx1_atten_cached;
|
||||
case BLADERF_CHANNEL_TX(1):
|
||||
return phy->tx2_atten_cached;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int txmute_set_cached(struct ad9361_rf_phy *phy,
|
||||
bladerf_channel ch,
|
||||
uint32_t atten)
|
||||
{
|
||||
switch (ch) {
|
||||
case BLADERF_CHANNEL_TX(0):
|
||||
phy->tx1_atten_cached = atten;
|
||||
return 0;
|
||||
case BLADERF_CHANNEL_TX(1):
|
||||
phy->tx2_atten_cached = atten;
|
||||
return 0;
|
||||
default:
|
||||
return BLADERF_ERR_INVAL;
|
||||
}
|
||||
}
|
||||
|
||||
int txmute_get(struct ad9361_rf_phy *phy, bladerf_channel ch, bool *state)
|
||||
{
|
||||
int rfic_ch = (ch >> 1);
|
||||
|
||||
*state = tx_mute_state[rfic_ch];
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int txmute_set(struct ad9361_rf_phy *phy, bladerf_channel ch, bool state)
|
||||
{
|
||||
int rfic_ch = (ch >> 1);
|
||||
uint32_t const MUTED_ATTEN = 89750;
|
||||
uint32_t atten, cached;
|
||||
int status;
|
||||
|
||||
if (tx_mute_state[rfic_ch] == state) {
|
||||
// short circuit if there's no change
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (state) {
|
||||
// mute: save the existing value before muting
|
||||
uint32_t readval;
|
||||
|
||||
status = ad9361_get_tx_attenuation(phy, rfic_ch, &readval);
|
||||
if (status < 0) {
|
||||
return errno_ad9361_to_bladerf(status);
|
||||
}
|
||||
|
||||
cached = readval;
|
||||
atten = MUTED_ATTEN;
|
||||
} else {
|
||||
// unmute: restore the saved value
|
||||
cached = txmute_get_cached(phy, ch);
|
||||
atten = cached;
|
||||
}
|
||||
|
||||
status = ad9361_set_tx_attenuation(phy, rfic_ch, atten);
|
||||
if (status < 0) {
|
||||
return errno_ad9361_to_bladerf(status);
|
||||
}
|
||||
|
||||
status = txmute_set_cached(phy, ch, cached);
|
||||
if (status < 0) {
|
||||
return status;
|
||||
}
|
||||
|
||||
tx_mute_state[rfic_ch] = state;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int set_ad9361_port_by_freq(struct ad9361_rf_phy *phy,
|
||||
bladerf_channel ch,
|
||||
bool enabled,
|
||||
bladerf_frequency freq)
|
||||
{
|
||||
struct band_port_map const *port_map = NULL;
|
||||
int status;
|
||||
|
||||
/* Look up the port configuration for this frequency */
|
||||
port_map = _get_band_port_map_by_freq(ch, enabled ? freq : 0);
|
||||
|
||||
if (NULL == port_map) {
|
||||
return BLADERF_ERR_INVAL;
|
||||
}
|
||||
|
||||
/* Set the AD9361 port accordingly */
|
||||
if (BLADERF_CHANNEL_IS_TX(ch)) {
|
||||
status = ad9361_set_tx_rf_port_output(phy, port_map->rfic_port);
|
||||
} else {
|
||||
status = ad9361_set_rx_rf_port_input(phy, port_map->rfic_port);
|
||||
}
|
||||
|
||||
return errno_ad9361_to_bladerf(status);
|
||||
}
|
||||
|
||||
enum rf_gain_ctrl_mode gainmode_bladerf_to_ad9361(bladerf_gain_mode gainmode,
|
||||
bool *ok)
|
||||
{
|
||||
struct bladerf_rfic_gain_mode_map const *mode_map;
|
||||
size_t mode_map_len;
|
||||
|
||||
mode_map = bladerf2_rx_gain_mode_map;
|
||||
mode_map_len = ARRAY_SIZE(bladerf2_rx_gain_mode_map);
|
||||
|
||||
if (NULL != ok) {
|
||||
*ok = false;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < mode_map_len; ++i) {
|
||||
if (mode_map[i].brf_mode == gainmode) {
|
||||
if (NULL != ok) {
|
||||
*ok = true;
|
||||
}
|
||||
return mode_map[i].rfic_mode;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
};
|
||||
|
||||
bladerf_gain_mode gainmode_ad9361_to_bladerf(enum rf_gain_ctrl_mode gainmode,
|
||||
bool *ok)
|
||||
{
|
||||
struct bladerf_rfic_gain_mode_map const *mode_map;
|
||||
size_t mode_map_len;
|
||||
|
||||
mode_map = bladerf2_rx_gain_mode_map;
|
||||
mode_map_len = ARRAY_SIZE(bladerf2_rx_gain_mode_map);
|
||||
|
||||
if (NULL != ok) {
|
||||
*ok = false;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < mode_map_len; ++i) {
|
||||
if (mode_map[i].rfic_mode == gainmode) {
|
||||
if (NULL != ok) {
|
||||
*ok = true;
|
||||
}
|
||||
return mode_map[i].brf_mode;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -5,294 +5,296 @@
|
|||
* Reference:
|
||||
* https://wiki.analog.com/resources/tools-software/linux-drivers/iio-transceiver/ad9361-customization
|
||||
*
|
||||
* N/A = not applicable due to other setting; changes may unmask these
|
||||
* DEFAULT = changed during device initialization
|
||||
* N/A = not applicable due to other setting; changes may unmask these
|
||||
* DEFAULT = changed during device initialization
|
||||
*/
|
||||
|
||||
// clang-format off
|
||||
AD9361_InitParam bladerf2_rfic_init_params = {
|
||||
/* Device selection */
|
||||
ID_AD9361, // AD9361 RF Agile Transceiver // dev_sel
|
||||
/* Device selection */
|
||||
ID_AD9361, // AD9361 RF Agile Transceiver // dev_sel
|
||||
|
||||
/* Identification number */
|
||||
0, // Chip ID 0 // id_no
|
||||
/* Identification number */
|
||||
0, // Chip ID 0 // id_no
|
||||
|
||||
/* Reference Clock */
|
||||
38400000UL, // RefClk = 38.4 MHz // reference_clk_rate
|
||||
/* Reference Clock */
|
||||
38400000UL, // RefClk = 38.4 MHz // reference_clk_rate
|
||||
|
||||
/* Base Configuration */
|
||||
1, // use 2Rx2Tx mode // two_rx_two_tx_mode_enable *** adi,2rx-2tx-mode-enable
|
||||
1, // N/A when two_rx_two_tx_mode_enable = 1 // one_rx_one_tx_mode_use_rx_num *** adi,1rx-1tx-mode-use-rx-num
|
||||
1, // N/A when two_rx_two_tx_mode_enable = 1 // one_rx_one_tx_mode_use_tx_num *** adi,1rx-1tx-mode-use-tx-num
|
||||
1, // use FDD mode // frequency_division_duplex_mode_enable *** adi,frequency-division-duplex-mode-enable
|
||||
1, // use independent FDD mode // frequency_division_duplex_independent_mode_enable *** adi,frequency-division-duplex-independent-mode-enable
|
||||
0, // N/A when frequency_division_duplex_mode_enable = 1 // tdd_use_dual_synth_mode_enable *** adi,tdd-use-dual-synth-mode-enable
|
||||
0, // N/A when frequency_division_duplex_mode_enable = 1 // tdd_skip_vco_cal_enable *** adi,tdd-skip-vco-cal-enable
|
||||
0, // TX fastlock delay = 0 ns // tx_fastlock_delay_ns *** adi,tx-fastlock-delay-ns
|
||||
0, // RX fastlock delay = 0 ns // rx_fastlock_delay_ns *** adi,rx-fastlock-delay-ns
|
||||
0, // RX fastlock pin control disabled // rx_fastlock_pincontrol_enable *** adi,rx-fastlock-pincontrol-enable
|
||||
0, // TX fastlock pin control disabled // tx_fastlock_pincontrol_enable *** adi,tx-fastlock-pincontrol-enable
|
||||
0, // use internal RX LO // external_rx_lo_enable *** adi,external-rx-lo-enable
|
||||
0, // use internal TX LO // external_tx_lo_enable *** adi,external-tx-lo-enable
|
||||
5, // apply new tracking word: on gain change, after exiting RX state // dc_offset_tracking_update_event_mask *** adi,dc-offset-tracking-update-event-mask
|
||||
6, // atten value for DC tracking, RX LO > 4 GHz // dc_offset_attenuation_high_range *** adi,dc-offset-attenuation-high-range
|
||||
5, // atten value for DC tracking, RX LO < 4 GHz // dc_offset_attenuation_low_range *** adi,dc-offset-attenuation-low-range
|
||||
0x28, // loop gain for DC tracking, RX LO > 4 GHz // dc_offset_count_high_range *** adi,dc-offset-count-high-range
|
||||
0x32, // loop gain for DC tracking, RX LO < 4 GHz // dc_offset_count_low_range *** adi,dc-offset-count-low-range
|
||||
0, // use full gain table // split_gain_table_mode_enable *** adi,split-gain-table-mode-enable
|
||||
MAX_SYNTH_FREF, // f_ref window 80 MHz // trx_synthesizer_target_fref_overwrite_hz *** adi,trx-synthesizer-target-fref-overwrite-hz
|
||||
0, // don't use improved RX QEC tracking // qec_tracking_slow_mode_enable *** adi,qec-tracking-slow-mode-enable
|
||||
/* Base Configuration */
|
||||
1, // use 2Rx2Tx mode // two_rx_two_tx_mode_enable *** adi,2rx-2tx-mode-enable
|
||||
1, // N/A when two_rx_two_tx_mode_enable = 1 // one_rx_one_tx_mode_use_rx_num *** adi,1rx-1tx-mode-use-rx-num
|
||||
1, // N/A when two_rx_two_tx_mode_enable = 1 // one_rx_one_tx_mode_use_tx_num *** adi,1rx-1tx-mode-use-tx-num
|
||||
1, // use FDD mode // frequency_division_duplex_mode_enable *** adi,frequency-division-duplex-mode-enable
|
||||
1, // use independent FDD mode // frequency_division_duplex_independent_mode_enable *** adi,frequency-division-duplex-independent-mode-enable
|
||||
0, // N/A when frequency_division_duplex_mode_enable = 1 // tdd_use_dual_synth_mode_enable *** adi,tdd-use-dual-synth-mode-enable
|
||||
0, // N/A when frequency_division_duplex_mode_enable = 1 // tdd_skip_vco_cal_enable *** adi,tdd-skip-vco-cal-enable
|
||||
0, // TX fastlock delay = 0 ns // tx_fastlock_delay_ns *** adi,tx-fastlock-delay-ns
|
||||
0, // RX fastlock delay = 0 ns // rx_fastlock_delay_ns *** adi,rx-fastlock-delay-ns
|
||||
0, // RX fastlock pin control disabled // rx_fastlock_pincontrol_enable *** adi,rx-fastlock-pincontrol-enable
|
||||
0, // TX fastlock pin control disabled // tx_fastlock_pincontrol_enable *** adi,tx-fastlock-pincontrol-enable
|
||||
0, // use internal RX LO // external_rx_lo_enable *** adi,external-rx-lo-enable
|
||||
0, // use internal TX LO // external_tx_lo_enable *** adi,external-tx-lo-enable
|
||||
5, // apply new tracking word: on gain change, after exiting RX state // dc_offset_tracking_update_event_mask *** adi,dc-offset-tracking-update-event-mask
|
||||
6, // atten value for DC tracking, RX LO > 4 GHz // dc_offset_attenuation_high_range *** adi,dc-offset-attenuation-high-range
|
||||
5, // atten value for DC tracking, RX LO < 4 GHz // dc_offset_attenuation_low_range *** adi,dc-offset-attenuation-low-range
|
||||
0x28, // loop gain for DC tracking, RX LO > 4 GHz // dc_offset_count_high_range *** adi,dc-offset-count-high-range
|
||||
0x32, // loop gain for DC tracking, RX LO < 4 GHz // dc_offset_count_low_range *** adi,dc-offset-count-low-range
|
||||
0, // use full gain table // split_gain_table_mode_enable *** adi,split-gain-table-mode-enable
|
||||
MAX_SYNTH_FREF, // f_ref window 80 MHz // trx_synthesizer_target_fref_overwrite_hz *** adi,trx-synthesizer-target-fref-overwrite-hz
|
||||
0, // don't use improved RX QEC tracking // qec_tracking_slow_mode_enable *** adi,qec-tracking-slow-mode-enable
|
||||
|
||||
/* ENSM Control */
|
||||
0, // use level mode on ENABLE and TXNRX pins // ensm_enable_pin_pulse_mode_enable *** adi,ensm-enable-pin-pulse-mode-enable
|
||||
0, // use SPI writes for ENSM state, not ENABLE/TXNRX pins // ensm_enable_txnrx_control_enable *** adi,ensm-enable-txnrx-control-enable
|
||||
/* ENSM Control */
|
||||
0, // use level mode on ENABLE and TXNRX pins // ensm_enable_pin_pulse_mode_enable *** adi,ensm-enable-pin-pulse-mode-enable
|
||||
0, // use SPI writes for ENSM state, not ENABLE/TXNRX pins // ensm_enable_txnrx_control_enable *** adi,ensm-enable-txnrx-control-enable
|
||||
|
||||
/* LO Control */
|
||||
2400000000UL, // DEFAULT // rx_synthesizer_frequency_hz *** adi,rx-synthesizer-frequency-hz
|
||||
2400000000UL, // DEFAULT // tx_synthesizer_frequency_hz *** adi,tx-synthesizer-frequency-hz
|
||||
/* LO Control */
|
||||
2400000000UL, // DEFAULT // rx_synthesizer_frequency_hz *** adi,rx-synthesizer-frequency-hz
|
||||
2400000000UL, // DEFAULT // tx_synthesizer_frequency_hz *** adi,tx-synthesizer-frequency-hz
|
||||
|
||||
/* Rate & BW Control */
|
||||
{ 983040000, 245760000, 122880000, 61440000, 30720000, 30720000 }, // DEFAULT // uint32_t rx_path_clock_frequencies[6] *** adi,rx-path-clock-frequencies
|
||||
{ 983040000, 122880000, 122880000, 61440000, 30720000, 30720000 }, // DEFAULT // uint32_t tx_path_clock_frequencies[6] *** adi,tx-path-clock-frequencies
|
||||
18000000, // DEFAULT // rf_rx_bandwidth_hz *** adi,rf-rx-bandwidth-hz
|
||||
18000000, // DEFAULT // rf_tx_bandwidth_hz *** adi,rf-tx-bandwidth-hz
|
||||
/* Rate & BW Control */
|
||||
{ 983040000, 245760000, 122880000, 61440000, 30720000, 30720000 }, // DEFAULT // uint32_t rx_path_clock_frequencies[6] *** adi,rx-path-clock-frequencies
|
||||
{ 983040000, 122880000, 122880000, 61440000, 30720000, 30720000 }, // DEFAULT // uint32_t tx_path_clock_frequencies[6] *** adi,tx-path-clock-frequencies
|
||||
18000000, // DEFAULT // rf_rx_bandwidth_hz *** adi,rf-rx-bandwidth-hz
|
||||
18000000, // DEFAULT // rf_tx_bandwidth_hz *** adi,rf-tx-bandwidth-hz
|
||||
|
||||
/* RF Port Control */
|
||||
0, // DEFAULT // rx_rf_port_input_select *** adi,rx-rf-port-input-select
|
||||
0, // DEFAULT // tx_rf_port_input_select *** adi,tx-rf-port-input-select
|
||||
/* RF Port Control */
|
||||
0, // DEFAULT // rx_rf_port_input_select *** adi,rx-rf-port-input-select
|
||||
0, // DEFAULT // tx_rf_port_input_select *** adi,tx-rf-port-input-select
|
||||
|
||||
/* TX Attenuation Control */
|
||||
10000, // DEFAULT // tx_attenuation_mdB *** adi,tx-attenuation-mdB
|
||||
0, // N/A when frequency_division_duplex_mode_enable = 1 // update_tx_gain_in_alert_enable *** adi,update-tx-gain-in-alert-enable
|
||||
/* TX Attenuation Control */
|
||||
10000, // DEFAULT // tx_attenuation_mdB *** adi,tx-attenuation-mdB
|
||||
0, // N/A when frequency_division_duplex_mode_enable = 1 // update_tx_gain_in_alert_enable *** adi,update-tx-gain-in-alert-enable
|
||||
|
||||
/* Reference Clock Control */
|
||||
1, // Expect external clock into XTALN // xo_disable_use_ext_refclk_enable *** adi,xo-disable-use-ext-refclk-enable
|
||||
{3, 5920}, // ~0 ppm DCXO trim (N/A if ext clk) // dcxo_coarse_and_fine_tune[2] *** adi,dcxo-coarse-and-fine-tune
|
||||
CLKOUT_DISABLE, // disable clkout pin (see enum ad9361_clkout) // clk_output_mode_select *** adi,clk-output-mode-select
|
||||
/* Reference Clock Control */
|
||||
1, // Expect external clock into XTALN // xo_disable_use_ext_refclk_enable *** adi,xo-disable-use-ext-refclk-enable
|
||||
{3, 5920}, // ~0 ppm DCXO trim (N/A if ext clk) // dcxo_coarse_and_fine_tune[2] *** adi,dcxo-coarse-and-fine-tune
|
||||
CLKOUT_DISABLE, // disable clkout pin (see enum ad9361_clkout) // clk_output_mode_select *** adi,clk-output-mode-select
|
||||
|
||||
/* Gain Control */
|
||||
RF_GAIN_SLOWATTACK_AGC, // RX1 BLADERF_GAIN_DEFAULT = slow attack AGC // gc_rx1_mode *** adi,gc-rx1-mode
|
||||
RF_GAIN_SLOWATTACK_AGC, // RX2 BLADERF_GAIN_DEFAULT = slow attack AGC // gc_rx2_mode *** adi,gc-rx2-mode
|
||||
58, // magic AGC setting, see AD9361 docs // gc_adc_large_overload_thresh *** adi,gc-adc-large-overload-thresh
|
||||
4, // magic AGC setting, see AD9361 docs // gc_adc_ovr_sample_size *** adi,gc-adc-ovr-sample-size
|
||||
47, // magic AGC setting, see AD9361 docs // gc_adc_small_overload_thresh *** adi,gc-adc-small-overload-thresh
|
||||
8192, // magic AGC setting, see AD9361 docs // gc_dec_pow_measurement_duration *** adi,gc-dec-pow-measurement-duration
|
||||
0, // magic AGC setting, see AD9361 docs // gc_dig_gain_enable *** adi,gc-dig-gain-enable
|
||||
800, // magic AGC setting, see AD9361 docs // gc_lmt_overload_high_thresh *** adi,gc-lmt-overload-high-thresh
|
||||
704, // magic AGC setting, see AD9361 docs // gc_lmt_overload_low_thresh *** adi,gc-lmt-overload-low-thresh
|
||||
24, // magic AGC setting, see AD9361 docs // gc_low_power_thresh *** adi,gc-low-power-thresh
|
||||
15, // magic AGC setting, see AD9361 docs // gc_max_dig_gain *** adi,gc-max-dig-gain
|
||||
/* Gain Control */
|
||||
RF_GAIN_SLOWATTACK_AGC, // RX1 BLADERF_GAIN_DEFAULT = slow attack AGC // gc_rx1_mode *** adi,gc-rx1-mode
|
||||
RF_GAIN_SLOWATTACK_AGC, // RX2 BLADERF_GAIN_DEFAULT = slow attack AGC // gc_rx2_mode *** adi,gc-rx2-mode
|
||||
58, // magic AGC setting, see AD9361 docs // gc_adc_large_overload_thresh *** adi,gc-adc-large-overload-thresh
|
||||
4, // magic AGC setting, see AD9361 docs // gc_adc_ovr_sample_size *** adi,gc-adc-ovr-sample-size
|
||||
47, // magic AGC setting, see AD9361 docs // gc_adc_small_overload_thresh *** adi,gc-adc-small-overload-thresh
|
||||
8192, // magic AGC setting, see AD9361 docs // gc_dec_pow_measurement_duration *** adi,gc-dec-pow-measurement-duration
|
||||
0, // magic AGC setting, see AD9361 docs // gc_dig_gain_enable *** adi,gc-dig-gain-enable
|
||||
800, // magic AGC setting, see AD9361 docs // gc_lmt_overload_high_thresh *** adi,gc-lmt-overload-high-thresh
|
||||
704, // magic AGC setting, see AD9361 docs // gc_lmt_overload_low_thresh *** adi,gc-lmt-overload-low-thresh
|
||||
24, // magic AGC setting, see AD9361 docs // gc_low_power_thresh *** adi,gc-low-power-thresh
|
||||
15, // magic AGC setting, see AD9361 docs // gc_max_dig_gain *** adi,gc-max-dig-gain
|
||||
|
||||
/* Gain MGC Control */
|
||||
2, // N/A when mgc_rx(1,2)_ctrl_inp_enable = 0 // mgc_dec_gain_step *** adi,mgc-dec-gain-step
|
||||
2, // N/A when mgc_rx(1,2)_ctrl_inp_enable = 0 // mgc_inc_gain_step *** adi,mgc-inc-gain-step
|
||||
0, // don't use CTRL_IN for RX1 MGC stepping // mgc_rx1_ctrl_inp_enable *** adi,mgc-rx1-ctrl-inp-enable
|
||||
0, // don't use CTRL_IN for RX2 MGC stepping // mgc_rx2_ctrl_inp_enable *** adi,mgc-rx2-ctrl-inp-enable
|
||||
0, // N/A when mgc_rx(1,2)_ctrl_inp_enable = 0 // mgc_split_table_ctrl_inp_gain_mode *** adi,mgc-split-table-ctrl-inp-gain-mode
|
||||
/* Gain MGC Control */
|
||||
2, // N/A when mgc_rx(1,2)_ctrl_inp_enable = 0 // mgc_dec_gain_step *** adi,mgc-dec-gain-step
|
||||
2, // N/A when mgc_rx(1,2)_ctrl_inp_enable = 0 // mgc_inc_gain_step *** adi,mgc-inc-gain-step
|
||||
0, // don't use CTRL_IN for RX1 MGC stepping // mgc_rx1_ctrl_inp_enable *** adi,mgc-rx1-ctrl-inp-enable
|
||||
0, // don't use CTRL_IN for RX2 MGC stepping // mgc_rx2_ctrl_inp_enable *** adi,mgc-rx2-ctrl-inp-enable
|
||||
0, // N/A when mgc_rx(1,2)_ctrl_inp_enable = 0 // mgc_split_table_ctrl_inp_gain_mode *** adi,mgc-split-table-ctrl-inp-gain-mode
|
||||
|
||||
/* Gain AGC Control */
|
||||
10, // magic AGC setting, see AD9361 docs // agc_adc_large_overload_exceed_counter *** adi,agc-adc-large-overload-exceed-counter
|
||||
2, // magic AGC setting, see AD9361 docs // agc_adc_large_overload_inc_steps *** adi,agc-adc-large-overload-inc-steps
|
||||
0, // magic AGC setting, see AD9361 docs // agc_adc_lmt_small_overload_prevent_gain_inc_enable *** adi,agc-adc-lmt-small-overload-prevent-gain-inc-enable
|
||||
10, // magic AGC setting, see AD9361 docs // agc_adc_small_overload_exceed_counter *** adi,agc-adc-small-overload-exceed-counter
|
||||
4, // magic AGC setting, see AD9361 docs // agc_dig_gain_step_size *** adi,agc-dig-gain-step-size
|
||||
3, // magic AGC setting, see AD9361 docs // agc_dig_saturation_exceed_counter *** adi,agc-dig-saturation-exceed-counter
|
||||
1000, // magic AGC setting, see AD9361 docs // agc_gain_update_interval_us *** adi,agc-gain-update-interval-us
|
||||
0, // magic AGC setting, see AD9361 docs // agc_immed_gain_change_if_large_adc_overload_enable *** adi,agc-immed-gain-change-if-large-adc-overload-enable
|
||||
0, // magic AGC setting, see AD9361 docs // agc_immed_gain_change_if_large_lmt_overload_enable *** adi,agc-immed-gain-change-if-large-lmt-overload-enable
|
||||
10, // magic AGC setting, see AD9361 docs // agc_inner_thresh_high *** adi,agc-inner-thresh-high
|
||||
1, // magic AGC setting, see AD9361 docs // agc_inner_thresh_high_dec_steps *** adi,agc-inner-thresh-high-dec-steps
|
||||
12, // magic AGC setting, see AD9361 docs // agc_inner_thresh_low *** adi,agc-inner-thresh-low
|
||||
1, // magic AGC setting, see AD9361 docs // agc_inner_thresh_low_inc_steps *** adi,agc-inner-thresh-low-inc-steps
|
||||
10, // magic AGC setting, see AD9361 docs // agc_lmt_overload_large_exceed_counter *** adi,agc-lmt-overload-large-exceed-counter
|
||||
2, // magic AGC setting, see AD9361 docs // agc_lmt_overload_large_inc_steps *** adi,agc-lmt-overload-large-inc-steps
|
||||
10, // magic AGC setting, see AD9361 docs // agc_lmt_overload_small_exceed_counter *** adi,agc-lmt-overload-small-exceed-counter
|
||||
5, // magic AGC setting, see AD9361 docs // agc_outer_thresh_high *** adi,agc-outer-thresh-high
|
||||
2, // magic AGC setting, see AD9361 docs // agc_outer_thresh_high_dec_steps *** adi,agc-outer-thresh-high-dec-steps
|
||||
18, // magic AGC setting, see AD9361 docs // agc_outer_thresh_low *** adi,agc-outer-thresh-low
|
||||
2, // magic AGC setting, see AD9361 docs // agc_outer_thresh_low_inc_steps *** adi,agc-outer-thresh-low-inc-steps
|
||||
1, // magic AGC setting, see AD9361 docs // agc_attack_delay_extra_margin_us; *** adi,agc-attack-delay-extra-margin-us
|
||||
0, // magic AGC setting, see AD9361 docs // agc_sync_for_gain_counter_enable *** adi,agc-sync-for-gain-counter-enable
|
||||
/* Gain AGC Control */
|
||||
10, // magic AGC setting, see AD9361 docs // agc_adc_large_overload_exceed_counter *** adi,agc-adc-large-overload-exceed-counter
|
||||
2, // magic AGC setting, see AD9361 docs // agc_adc_large_overload_inc_steps *** adi,agc-adc-large-overload-inc-steps
|
||||
0, // magic AGC setting, see AD9361 docs // agc_adc_lmt_small_overload_prevent_gain_inc_enable *** adi,agc-adc-lmt-small-overload-prevent-gain-inc-enable
|
||||
10, // magic AGC setting, see AD9361 docs // agc_adc_small_overload_exceed_counter *** adi,agc-adc-small-overload-exceed-counter
|
||||
4, // magic AGC setting, see AD9361 docs // agc_dig_gain_step_size *** adi,agc-dig-gain-step-size
|
||||
3, // magic AGC setting, see AD9361 docs // agc_dig_saturation_exceed_counter *** adi,agc-dig-saturation-exceed-counter
|
||||
1000, // magic AGC setting, see AD9361 docs // agc_gain_update_interval_us *** adi,agc-gain-update-interval-us
|
||||
0, // magic AGC setting, see AD9361 docs // agc_immed_gain_change_if_large_adc_overload_enable *** adi,agc-immed-gain-change-if-large-adc-overload-enable
|
||||
0, // magic AGC setting, see AD9361 docs // agc_immed_gain_change_if_large_lmt_overload_enable *** adi,agc-immed-gain-change-if-large-lmt-overload-enable
|
||||
10, // magic AGC setting, see AD9361 docs // agc_inner_thresh_high *** adi,agc-inner-thresh-high
|
||||
1, // magic AGC setting, see AD9361 docs // agc_inner_thresh_high_dec_steps *** adi,agc-inner-thresh-high-dec-steps
|
||||
12, // magic AGC setting, see AD9361 docs // agc_inner_thresh_low *** adi,agc-inner-thresh-low
|
||||
1, // magic AGC setting, see AD9361 docs // agc_inner_thresh_low_inc_steps *** adi,agc-inner-thresh-low-inc-steps
|
||||
10, // magic AGC setting, see AD9361 docs // agc_lmt_overload_large_exceed_counter *** adi,agc-lmt-overload-large-exceed-counter
|
||||
2, // magic AGC setting, see AD9361 docs // agc_lmt_overload_large_inc_steps *** adi,agc-lmt-overload-large-inc-steps
|
||||
10, // magic AGC setting, see AD9361 docs // agc_lmt_overload_small_exceed_counter *** adi,agc-lmt-overload-small-exceed-counter
|
||||
5, // magic AGC setting, see AD9361 docs // agc_outer_thresh_high *** adi,agc-outer-thresh-high
|
||||
2, // magic AGC setting, see AD9361 docs // agc_outer_thresh_high_dec_steps *** adi,agc-outer-thresh-high-dec-steps
|
||||
18, // magic AGC setting, see AD9361 docs // agc_outer_thresh_low *** adi,agc-outer-thresh-low
|
||||
2, // magic AGC setting, see AD9361 docs // agc_outer_thresh_low_inc_steps *** adi,agc-outer-thresh-low-inc-steps
|
||||
1, // magic AGC setting, see AD9361 docs // agc_attack_delay_extra_margin_us; *** adi,agc-attack-delay-extra-margin-us
|
||||
0, // magic AGC setting, see AD9361 docs // agc_sync_for_gain_counter_enable *** adi,agc-sync-for-gain-counter-enable
|
||||
|
||||
/* Fast AGC */
|
||||
64, // magic AGC setting, see AD9361 docs // fagc_dec_pow_measuremnt_duration *** adi,fagc-dec-pow-measurement-duration
|
||||
260, // magic AGC setting, see AD9361 docs // fagc_state_wait_time_ns *** adi,fagc-state-wait-time-ns
|
||||
/* Fast AGC */
|
||||
64, // magic AGC setting, see AD9361 docs // fagc_dec_pow_measuremnt_duration *** adi,fagc-dec-pow-measurement-duration
|
||||
260, // magic AGC setting, see AD9361 docs // fagc_state_wait_time_ns *** adi,fagc-state-wait-time-ns
|
||||
|
||||
/* Fast AGC - Low Power */
|
||||
0, // magic AGC setting, see AD9361 docs // fagc_allow_agc_gain_increase *** adi,fagc-allow-agc-gain-increase-enable
|
||||
5, // magic AGC setting, see AD9361 docs // fagc_lp_thresh_increment_time *** adi,fagc-lp-thresh-increment-time
|
||||
1, // magic AGC setting, see AD9361 docs // fagc_lp_thresh_increment_steps *** adi,fagc-lp-thresh-increment-steps
|
||||
/* Fast AGC - Low Power */
|
||||
0, // magic AGC setting, see AD9361 docs // fagc_allow_agc_gain_increase *** adi,fagc-allow-agc-gain-increase-enable
|
||||
5, // magic AGC setting, see AD9361 docs // fagc_lp_thresh_increment_time *** adi,fagc-lp-thresh-increment-time
|
||||
1, // magic AGC setting, see AD9361 docs // fagc_lp_thresh_increment_steps *** adi,fagc-lp-thresh-increment-steps
|
||||
|
||||
/* Fast AGC - Lock Level */
|
||||
10, // magic AGC setting, see AD9361 docs // fagc_lock_level *** adi,fagc-lock-level
|
||||
1, // magic AGC setting, see AD9361 docs // fagc_lock_level_lmt_gain_increase_en *** adi,fagc-lock-level-lmt-gain-increase-enable
|
||||
5, // magic AGC setting, see AD9361 docs // fagc_lock_level_gain_increase_upper_limit *** adi,fagc-lock-level-gain-increase-upper-limit
|
||||
/* Fast AGC - Lock Level */
|
||||
10, // magic AGC setting, see AD9361 docs // fagc_lock_level *** adi,fagc-lock-level
|
||||
1, // magic AGC setting, see AD9361 docs // fagc_lock_level_lmt_gain_increase_en *** adi,fagc-lock-level-lmt-gain-increase-enable
|
||||
5, // magic AGC setting, see AD9361 docs // fagc_lock_level_gain_increase_upper_limit *** adi,fagc-lock-level-gain-increase-upper-limit
|
||||
|
||||
/* Fast AGC - Peak Detectors and Final Settling */
|
||||
1, // magic AGC setting, see AD9361 docs // fagc_lpf_final_settling_steps *** adi,fagc-lpf-final-settling-steps
|
||||
1, // magic AGC setting, see AD9361 docs // fagc_lmt_final_settling_steps *** adi,fagc-lmt-final-settling-steps
|
||||
3, // magic AGC setting, see AD9361 docs // fagc_final_overrange_count *** adi,fagc-final-overrange-count
|
||||
/* Fast AGC - Peak Detectors and Final Settling */
|
||||
1, // magic AGC setting, see AD9361 docs // fagc_lpf_final_settling_steps *** adi,fagc-lpf-final-settling-steps
|
||||
1, // magic AGC setting, see AD9361 docs // fagc_lmt_final_settling_steps *** adi,fagc-lmt-final-settling-steps
|
||||
3, // magic AGC setting, see AD9361 docs // fagc_final_overrange_count *** adi,fagc-final-overrange-count
|
||||
|
||||
/* Fast AGC - Final Power Test */
|
||||
0, // magic AGC setting, see AD9361 docs // fagc_gain_increase_after_gain_lock_en *** adi,fagc-gain-increase-after-gain-lock-enable
|
||||
/* Fast AGC - Final Power Test */
|
||||
0, // magic AGC setting, see AD9361 docs // fagc_gain_increase_after_gain_lock_en *** adi,fagc-gain-increase-after-gain-lock-enable
|
||||
|
||||
/* Fast AGC - Unlocking the Gain */
|
||||
0, // magic AGC setting, see AD9361 docs // fagc_gain_index_type_after_exit_rx_mode *** adi,fagc-gain-index-type-after-exit-rx-mode
|
||||
1, // magic AGC setting, see AD9361 docs // fagc_use_last_lock_level_for_set_gain_en *** adi,fagc-use-last-lock-level-for-set-gain-enable
|
||||
1, // magic AGC setting, see AD9361 docs // fagc_rst_gla_stronger_sig_thresh_exceeded_en *** adi,fagc-rst-gla-stronger-sig-thresh-exceeded-enable
|
||||
5, // magic AGC setting, see AD9361 docs // fagc_optimized_gain_offset *** adi,fagc-optimized-gain-offset
|
||||
10, // magic AGC setting, see AD9361 docs // fagc_rst_gla_stronger_sig_thresh_above_ll *** adi,fagc-rst-gla-stronger-sig-thresh-above-ll
|
||||
1, // magic AGC setting, see AD9361 docs // fagc_rst_gla_engergy_lost_sig_thresh_exceeded_en *** adi,fagc-rst-gla-engergy-lost-sig-thresh-exceeded-enable
|
||||
1, // magic AGC setting, see AD9361 docs // fagc_rst_gla_engergy_lost_goto_optim_gain_en *** adi,fagc-rst-gla-engergy-lost-goto-optim-gain-enable
|
||||
10, // magic AGC setting, see AD9361 docs // fagc_rst_gla_engergy_lost_sig_thresh_below_ll *** adi,fagc-rst-gla-engergy-lost-sig-thresh-below-ll
|
||||
8, // magic AGC setting, see AD9361 docs // fagc_energy_lost_stronger_sig_gain_lock_exit_cnt *** adi,fagc-energy-lost-stronger-sig-gain-lock-exit-cnt
|
||||
1, // magic AGC setting, see AD9361 docs // fagc_rst_gla_large_adc_overload_en *** adi,fagc-rst-gla-large-adc-overload-enable
|
||||
1, // magic AGC setting, see AD9361 docs // fagc_rst_gla_large_lmt_overload_en *** adi,fagc-rst-gla-large-lmt-overload-enable
|
||||
0, // magic AGC setting, see AD9361 docs // fagc_rst_gla_en_agc_pulled_high_en *** adi,fagc-rst-gla-en-agc-pulled-high-enable
|
||||
0, // magic AGC setting, see AD9361 docs // fagc_rst_gla_if_en_agc_pulled_high_mode *** adi,fagc-rst-gla-if-en-agc-pulled-high-mode
|
||||
64, // magic AGC setting, see AD9361 docs // fagc_power_measurement_duration_in_state5 *** adi,fagc-power-measurement-duration-in-state5
|
||||
/* Fast AGC - Unlocking the Gain */
|
||||
0, // magic AGC setting, see AD9361 docs // fagc_gain_index_type_after_exit_rx_mode *** adi,fagc-gain-index-type-after-exit-rx-mode
|
||||
1, // magic AGC setting, see AD9361 docs // fagc_use_last_lock_level_for_set_gain_en *** adi,fagc-use-last-lock-level-for-set-gain-enable
|
||||
1, // magic AGC setting, see AD9361 docs // fagc_rst_gla_stronger_sig_thresh_exceeded_en *** adi,fagc-rst-gla-stronger-sig-thresh-exceeded-enable
|
||||
5, // magic AGC setting, see AD9361 docs // fagc_optimized_gain_offset *** adi,fagc-optimized-gain-offset
|
||||
10, // magic AGC setting, see AD9361 docs // fagc_rst_gla_stronger_sig_thresh_above_ll *** adi,fagc-rst-gla-stronger-sig-thresh-above-ll
|
||||
1, // magic AGC setting, see AD9361 docs // fagc_rst_gla_engergy_lost_sig_thresh_exceeded_en *** adi,fagc-rst-gla-engergy-lost-sig-thresh-exceeded-enable
|
||||
1, // magic AGC setting, see AD9361 docs // fagc_rst_gla_engergy_lost_goto_optim_gain_en *** adi,fagc-rst-gla-engergy-lost-goto-optim-gain-enable
|
||||
10, // magic AGC setting, see AD9361 docs // fagc_rst_gla_engergy_lost_sig_thresh_below_ll *** adi,fagc-rst-gla-engergy-lost-sig-thresh-below-ll
|
||||
8, // magic AGC setting, see AD9361 docs // fagc_energy_lost_stronger_sig_gain_lock_exit_cnt *** adi,fagc-energy-lost-stronger-sig-gain-lock-exit-cnt
|
||||
1, // magic AGC setting, see AD9361 docs // fagc_rst_gla_large_adc_overload_en *** adi,fagc-rst-gla-large-adc-overload-enable
|
||||
1, // magic AGC setting, see AD9361 docs // fagc_rst_gla_large_lmt_overload_en *** adi,fagc-rst-gla-large-lmt-overload-enable
|
||||
0, // magic AGC setting, see AD9361 docs // fagc_rst_gla_en_agc_pulled_high_en *** adi,fagc-rst-gla-en-agc-pulled-high-enable
|
||||
0, // magic AGC setting, see AD9361 docs // fagc_rst_gla_if_en_agc_pulled_high_mode *** adi,fagc-rst-gla-if-en-agc-pulled-high-mode
|
||||
64, // magic AGC setting, see AD9361 docs // fagc_power_measurement_duration_in_state5 *** adi,fagc-power-measurement-duration-in-state5
|
||||
|
||||
/* RSSI Control */
|
||||
1, // settling delay on RSSI algo restart = 1 μs // rssi_delay *** adi,rssi-delay
|
||||
1000, // total RSSI measurement duration = 1000 μs // rssi_duration *** adi,rssi-duration
|
||||
GAIN_CHANGE_OCCURS, // reset RSSI accumulator on gain change event // rssi_restart_mode *** adi,rssi-restart-mode
|
||||
0, // RSSI control values are in microseconds // rssi_unit_is_rx_samples_enable *** adi,rssi-unit-is-rx-samples-enable
|
||||
1, // wait 1 μs between RSSI measurements // rssi_wait *** adi,rssi-wait
|
||||
/* RSSI Control */
|
||||
1, // settling delay on RSSI algo restart = 1 μs // rssi_delay *** adi,rssi-delay
|
||||
1000, // total RSSI measurement duration = 1000 μs // rssi_duration *** adi,rssi-duration
|
||||
GAIN_CHANGE_OCCURS, // reset RSSI accumulator on gain change event // rssi_restart_mode *** adi,rssi-restart-mode
|
||||
0, // RSSI control values are in microseconds // rssi_unit_is_rx_samples_enable *** adi,rssi-unit-is-rx-samples-enable
|
||||
1, // wait 1 μs between RSSI measurements // rssi_wait *** adi,rssi-wait
|
||||
|
||||
/* Aux ADC Control */
|
||||
/* bladeRF Micro: N/A, pin tied to GND */
|
||||
256, // AuxADC decimate by 256 // aux_adc_decimation *** adi,aux-adc-decimation
|
||||
40000000UL, // AuxADC sample rate 40 MHz // aux_adc_rate *** adi,aux-adc-rate
|
||||
/* Aux ADC Control */
|
||||
/* bladeRF Micro: N/A, pin tied to GND */
|
||||
256, // AuxADC decimate by 256 // aux_adc_decimation *** adi,aux-adc-decimation
|
||||
40000000UL, // AuxADC sample rate 40 MHz // aux_adc_rate *** adi,aux-adc-rate
|
||||
|
||||
/* AuxDAC Control */
|
||||
/* bladeRF Micro: AuxDAC1 is TP7 and AUXDAC_TRIM, AuxDAC2 is TP8 */
|
||||
1, // AuxDAC does not slave the ENSM // aux_dac_manual_mode_enable *** adi,aux-dac-manual-mode-enable
|
||||
0, // AuxDAC1 default value = 0 mV // aux_dac1_default_value_mV *** adi,aux-dac1-default-value-mV
|
||||
0, // N/A when aux_dac_manual_mode_enable = 1 // aux_dac1_active_in_rx_enable *** adi,aux-dac1-active-in-rx-enable
|
||||
0, // N/A when aux_dac_manual_mode_enable = 1 // aux_dac1_active_in_tx_enable *** adi,aux-dac1-active-in-tx-enable
|
||||
0, // N/A when aux_dac_manual_mode_enable = 1 // aux_dac1_active_in_alert_enable *** adi,aux-dac1-active-in-alert-enable
|
||||
0, // N/A when aux_dac_manual_mode_enable = 1 // aux_dac1_rx_delay_us *** adi,aux-dac1-rx-delay-us
|
||||
0, // N/A when aux_dac_manual_mode_enable = 1 // aux_dac1_tx_delay_us *** adi,aux-dac1-tx-delay-us
|
||||
0, // AuxDAC2 default value = 0 mV // aux_dac2_default_value_mV *** adi,aux-dac2-default-value-mV
|
||||
0, // N/A when aux_dac_manual_mode_enable = 1 // aux_dac2_active_in_rx_enable *** adi,aux-dac2-active-in-rx-enable
|
||||
0, // N/A when aux_dac_manual_mode_enable = 1 // aux_dac2_active_in_tx_enable *** adi,aux-dac2-active-in-tx-enable
|
||||
0, // N/A when aux_dac_manual_mode_enable = 1 // aux_dac2_active_in_alert_enable *** adi,aux-dac2-active-in-alert-enable
|
||||
0, // N/A when aux_dac_manual_mode_enable = 1 // aux_dac2_rx_delay_us *** adi,aux-dac2-rx-delay-us
|
||||
0, // N/A when aux_dac_manual_mode_enable = 1 // aux_dac2_tx_delay_us *** adi,aux-dac2-tx-delay-us
|
||||
/* AuxDAC Control */
|
||||
/* bladeRF Micro: AuxDAC1 is TP7 and AUXDAC_TRIM, AuxDAC2 is TP8 */
|
||||
1, // AuxDAC does not slave the ENSM // aux_dac_manual_mode_enable *** adi,aux-dac-manual-mode-enable
|
||||
0, // AuxDAC1 default value = 0 mV // aux_dac1_default_value_mV *** adi,aux-dac1-default-value-mV
|
||||
0, // N/A when aux_dac_manual_mode_enable = 1 // aux_dac1_active_in_rx_enable *** adi,aux-dac1-active-in-rx-enable
|
||||
0, // N/A when aux_dac_manual_mode_enable = 1 // aux_dac1_active_in_tx_enable *** adi,aux-dac1-active-in-tx-enable
|
||||
0, // N/A when aux_dac_manual_mode_enable = 1 // aux_dac1_active_in_alert_enable *** adi,aux-dac1-active-in-alert-enable
|
||||
0, // N/A when aux_dac_manual_mode_enable = 1 // aux_dac1_rx_delay_us *** adi,aux-dac1-rx-delay-us
|
||||
0, // N/A when aux_dac_manual_mode_enable = 1 // aux_dac1_tx_delay_us *** adi,aux-dac1-tx-delay-us
|
||||
0, // AuxDAC2 default value = 0 mV // aux_dac2_default_value_mV *** adi,aux-dac2-default-value-mV
|
||||
0, // N/A when aux_dac_manual_mode_enable = 1 // aux_dac2_active_in_rx_enable *** adi,aux-dac2-active-in-rx-enable
|
||||
0, // N/A when aux_dac_manual_mode_enable = 1 // aux_dac2_active_in_tx_enable *** adi,aux-dac2-active-in-tx-enable
|
||||
0, // N/A when aux_dac_manual_mode_enable = 1 // aux_dac2_active_in_alert_enable *** adi,aux-dac2-active-in-alert-enable
|
||||
0, // N/A when aux_dac_manual_mode_enable = 1 // aux_dac2_rx_delay_us *** adi,aux-dac2-rx-delay-us
|
||||
0, // N/A when aux_dac_manual_mode_enable = 1 // aux_dac2_tx_delay_us *** adi,aux-dac2-tx-delay-us
|
||||
|
||||
/* Temperature Sensor Control */
|
||||
256, // Temperature sensor decimate by 256 // temp_sense_decimation *** adi,temp-sense-decimation
|
||||
1000, // Measure temperature every 1000 ms // temp_sense_measurement_interval_ms *** adi,temp-sense-measurement-interval-ms
|
||||
206, // Offset = +206 degrees C // temp_sense_offset_signed *** adi,temp-sense-offset-signed
|
||||
1, // Periodic temperature measurements enabled // temp_sense_periodic_measurement_enable *** adi,temp-sense-periodic-measurement-enable
|
||||
/* Temperature Sensor Control */
|
||||
256, // Temperature sensor decimate by 256 // temp_sense_decimation *** adi,temp-sense-decimation
|
||||
1000, // Measure temperature every 1000 ms // temp_sense_measurement_interval_ms *** adi,temp-sense-measurement-interval-ms
|
||||
206, // Offset = +206 degrees C // temp_sense_offset_signed *** adi,temp-sense-offset-signed
|
||||
1, // Periodic temperature measurements enabled // temp_sense_periodic_measurement_enable *** adi,temp-sense-periodic-measurement-enable
|
||||
|
||||
/* Control Out Setup */
|
||||
/* See https://wiki.analog.com/resources/tools-software/linux-drivers/iio-transceiver/ad9361-customization#control_output_setup */
|
||||
0xFF, // Enable all CTRL_OUT bits // ctrl_outs_enable_mask *** adi,ctrl-outs-enable-mask
|
||||
0, // CTRL_OUT index is 0 // ctrl_outs_index *** adi,ctrl-outs-index
|
||||
/* Control Out Setup */
|
||||
/* See https://wiki.analog.com/resources/tools-software/linux-drivers/iio-transceiver/ad9361-customization#control_output_setup */
|
||||
0xFF, // Enable all CTRL_OUT bits // ctrl_outs_enable_mask *** adi,ctrl-outs-enable-mask
|
||||
0, // CTRL_OUT index is 0 // ctrl_outs_index *** adi,ctrl-outs-index
|
||||
|
||||
/* External LNA Control */
|
||||
/* bladeRF Micro: GPO_0 is TP3, GPO_1 is TP4 */
|
||||
0, // N/A when elna_rx(1,2)_gpo(0,1)_control_enable = 0 // elna_settling_delay_ns *** adi,elna-settling-delay-ns
|
||||
0, // MUST be 0 when elna_rx(1,2)_gpo(0,1)_control_enable = 0 // elna_gain_mdB *** adi,elna-gain-mdB
|
||||
0, // MUST be 0 when elna_rx(1,2)_gpo(0,1)_control_enable = 0 // elna_bypass_loss_mdB *** adi,elna-bypass-loss-mdB
|
||||
0, // Ext LNA Ctrl bit in Rx1 gain table does NOT set GPO0 state // elna_rx1_gpo0_control_enable *** adi,elna-rx1-gpo0-control-enable
|
||||
0, // Ext LNA Ctrl bit in Rx2 gain table does NOT set GPO1 state // elna_rx2_gpo1_control_enable *** adi,elna-rx2-gpo1-control-enable
|
||||
0, // N/A when elna_rx(1,2)_gpo(0,1)_control_enable = 0 // elna_gaintable_all_index_enable *** adi,elna-gaintable-all-index-enable
|
||||
/* External LNA Control */
|
||||
/* bladeRF Micro: GPO_0 is TP3, GPO_1 is TP4 */
|
||||
0, // N/A when elna_rx(1,2)_gpo(0,1)_control_enable = 0 // elna_settling_delay_ns *** adi,elna-settling-delay-ns
|
||||
0, // MUST be 0 when elna_rx(1,2)_gpo(0,1)_control_enable = 0 // elna_gain_mdB *** adi,elna-gain-mdB
|
||||
0, // MUST be 0 when elna_rx(1,2)_gpo(0,1)_control_enable = 0 // elna_bypass_loss_mdB *** adi,elna-bypass-loss-mdB
|
||||
0, // Ext LNA Ctrl bit in Rx1 gain table does NOT set GPO0 state // elna_rx1_gpo0_control_enable *** adi,elna-rx1-gpo0-control-enable
|
||||
0, // Ext LNA Ctrl bit in Rx2 gain table does NOT set GPO1 state // elna_rx2_gpo1_control_enable *** adi,elna-rx2-gpo1-control-enable
|
||||
0, // N/A when elna_rx(1,2)_gpo(0,1)_control_enable = 0 // elna_gaintable_all_index_enable *** adi,elna-gaintable-all-index-enable
|
||||
|
||||
/* Digital Interface Control */
|
||||
/* Digital Interface Control */
|
||||
#ifdef ENABLE_AD9361_DIGITAL_INTERFACE_TIMING_VERIFICATION
|
||||
/* Calibrate the digital interface delay (hardware validation) */
|
||||
0, // Don't skip digital interface tuning // digital_interface_tune_skip_mode *** adi,digital-interface-tune-skip-mode
|
||||
/* Calibrate the digital interface delay (hardware validation) */
|
||||
0, // Don't skip digital interface tuning // digital_interface_tune_skip_mode *** adi,digital-interface-tune-skip-mode
|
||||
#else
|
||||
/* Use hardcoded digital interface delay values (production) */
|
||||
2, // Skip RX and TX tuning; use hardcoded values below // digital_interface_tune_skip_mode *** adi,digital-interface-tune-skip-mode
|
||||
/* Use hardcoded digital interface delay values (production) */
|
||||
2, // Skip RX and TX tuning; use hardcoded values below // digital_interface_tune_skip_mode *** adi,digital-interface-tune-skip-mode
|
||||
#endif // ENABLE_AD9361_DIGITAL_INTERFACE_TIMING_VERIFICATION
|
||||
0, // ?? UNDOCUMENTED ?? // digital_interface_tune_fir_disable *** adi,digital-interface-tune-fir-disable
|
||||
1, // Swap I and Q (spectral inversion) // pp_tx_swap_enable *** adi,pp-tx-swap-enable
|
||||
1, // Swap I and Q (spectral inversion) // pp_rx_swap_enable *** adi,pp-rx-swap-enable
|
||||
0, // Don't swap TX1 and TX2 // tx_channel_swap_enable *** adi,tx-channel-swap-enable
|
||||
0, // Don't swap RX1 and RX2 // rx_channel_swap_enable *** adi,rx-channel-swap-enable
|
||||
1, // Toggle RX_FRAME with 50% duty cycle // rx_frame_pulse_mode_enable *** adi,rx-frame-pulse-mode-enable
|
||||
0, // Data port timing reflects # of enabled signal paths // two_t_two_r_timing_enable *** adi,2t2r-timing-enable
|
||||
0, // Don't invert data bus // invert_data_bus_enable *** adi,invert-data-bus-enable
|
||||
0, // Don't invert data clock // invert_data_clk_enable *** adi,invert-data-clk-enable
|
||||
0, // MUST be 0 when lvds_mode_enable = 1 // fdd_alt_word_order_enable *** adi,fdd-alt-word-order-enable
|
||||
0, // Don't invert RX_FRAME // invert_rx_frame_enable *** adi,invert-rx-frame-enable
|
||||
0, // Don't make RX sample rate 2x the TX sample rate // fdd_rx_rate_2tx_enable *** adi,fdd-rx-rate-2tx-enable
|
||||
0, // MUST be 0 when lvds_mode_enable = 1 // swap_ports_enable *** adi,swap-ports-enable
|
||||
0, // MUST be 0 when lvds_mode_enable = 1 // single_data_rate_enable *** adi,single-data-rate-enable
|
||||
1, // Use LVDS mode on data port // lvds_mode_enable *** adi,lvds-mode-enable
|
||||
0, // MUST be 0 when lvds_mode_enable = 1 // half_duplex_mode_enable *** adi,half-duplex-mode-enable
|
||||
0, // MUST be 0 when lvds_mode_enable = 1 // single_port_mode_enable *** adi,single-port-mode-enable
|
||||
0, // MUST be 0 when lvds_mode_enable = 1 // full_port_enable *** adi,full-port-enable
|
||||
0, // MUST be 0 when lvds_mode_enable = 1 // full_duplex_swap_bits_enable *** adi,full-duplex-swap-bits-enable
|
||||
0, // RX_DATA delay rel to RX_FRAME = 0 DATA_CLK/2 cycles // delay_rx_data *** adi,delay-rx-data
|
||||
// Approx 0.3 ns/LSB on next 4 values
|
||||
5, // DATA_CLK delay = 1.5 ns // rx_data_clock_delay *** adi,rx-data-clock-delay
|
||||
0, // RX_DATA/RX_FRAME delay = 0 ns // rx_data_delay *** adi,rx-data-delay
|
||||
0, // FB_CLK delay = 0 ns // tx_fb_clock_delay *** adi,tx-fb-clock-delay
|
||||
5, // TX_DATA/TX_FRAME delay = 1.5 ns // tx_data_delay *** adi,tx-data-delay
|
||||
300, // LVDS driver bias 300 mV // lvds_bias_mV *** adi,lvds-bias-mV
|
||||
1, // Enable LVDS on-chip termination // lvds_rx_onchip_termination_enable *** adi,lvds-rx-onchip-termination-enable
|
||||
0, // RX1 and RX2 are not phase-aligned // rx1rx2_phase_inversion_en *** adi,rx1-rx2-phase-inversion-enable
|
||||
0xFF, // Default signal inversion mappings // lvds_invert1_control *** adi,lvds-invert1-control
|
||||
0x0F, // Default signal inversion mappings // lvds_invert2_control *** adi,lvds-invert2-control
|
||||
1, // CLK_OUT drive increased by ~20% // clk_out_drive
|
||||
1, // DATA_CLK drive increased by ~20% // dataclk_drive
|
||||
1, // Data port drive increased by ~20% // data_port_drive
|
||||
0, // CLK_OUT minimum slew (fastest rise/fall) // clk_out_slew
|
||||
0, // DATA_CLK minimum slew (fastest rise/fall) // dataclk_slew
|
||||
0, // Data port minimum slew (fastest rise/fall) // data_port_slew
|
||||
0, // ?? UNDOCUMENTED ?? // digital_interface_tune_fir_disable *** adi,digital-interface-tune-fir-disable
|
||||
1, // Swap I and Q (spectral inversion) // pp_tx_swap_enable *** adi,pp-tx-swap-enable
|
||||
1, // Swap I and Q (spectral inversion) // pp_rx_swap_enable *** adi,pp-rx-swap-enable
|
||||
0, // Don't swap TX1 and TX2 // tx_channel_swap_enable *** adi,tx-channel-swap-enable
|
||||
0, // Don't swap RX1 and RX2 // rx_channel_swap_enable *** adi,rx-channel-swap-enable
|
||||
1, // Toggle RX_FRAME with 50% duty cycle // rx_frame_pulse_mode_enable *** adi,rx-frame-pulse-mode-enable
|
||||
0, // Data port timing reflects # of enabled signal paths // two_t_two_r_timing_enable *** adi,2t2r-timing-enable
|
||||
0, // Don't invert data bus // invert_data_bus_enable *** adi,invert-data-bus-enable
|
||||
0, // Don't invert data clock // invert_data_clk_enable *** adi,invert-data-clk-enable
|
||||
0, // MUST be 0 when lvds_mode_enable = 1 // fdd_alt_word_order_enable *** adi,fdd-alt-word-order-enable
|
||||
0, // Don't invert RX_FRAME // invert_rx_frame_enable *** adi,invert-rx-frame-enable
|
||||
0, // Don't make RX sample rate 2x the TX sample rate // fdd_rx_rate_2tx_enable *** adi,fdd-rx-rate-2tx-enable
|
||||
0, // MUST be 0 when lvds_mode_enable = 1 // swap_ports_enable *** adi,swap-ports-enable
|
||||
0, // MUST be 0 when lvds_mode_enable = 1 // single_data_rate_enable *** adi,single-data-rate-enable
|
||||
1, // Use LVDS mode on data port // lvds_mode_enable *** adi,lvds-mode-enable
|
||||
0, // MUST be 0 when lvds_mode_enable = 1 // half_duplex_mode_enable *** adi,half-duplex-mode-enable
|
||||
0, // MUST be 0 when lvds_mode_enable = 1 // single_port_mode_enable *** adi,single-port-mode-enable
|
||||
0, // MUST be 0 when lvds_mode_enable = 1 // full_port_enable *** adi,full-port-enable
|
||||
0, // MUST be 0 when lvds_mode_enable = 1 // full_duplex_swap_bits_enable *** adi,full-duplex-swap-bits-enable
|
||||
0, // RX_DATA delay rel to RX_FRAME = 0 DATA_CLK/2 cycles // delay_rx_data *** adi,delay-rx-data
|
||||
// Approx 0.3 ns/LSB on next 4 values
|
||||
5, // DATA_CLK delay = 1.5 ns // rx_data_clock_delay *** adi,rx-data-clock-delay
|
||||
0, // RX_DATA/RX_FRAME delay = 0 ns // rx_data_delay *** adi,rx-data-delay
|
||||
0, // FB_CLK delay = 0 ns // tx_fb_clock_delay *** adi,tx-fb-clock-delay
|
||||
5, // TX_DATA/TX_FRAME delay = 1.5 ns // tx_data_delay *** adi,tx-data-delay
|
||||
300, // LVDS driver bias 300 mV // lvds_bias_mV *** adi,lvds-bias-mV
|
||||
1, // Enable LVDS on-chip termination // lvds_rx_onchip_termination_enable *** adi,lvds-rx-onchip-termination-enable
|
||||
0, // RX1 and RX2 are not phase-aligned // rx1rx2_phase_inversion_en *** adi,rx1-rx2-phase-inversion-enable
|
||||
0xFF, // Default signal inversion mappings // lvds_invert1_control *** adi,lvds-invert1-control
|
||||
0x0F, // Default signal inversion mappings // lvds_invert2_control *** adi,lvds-invert2-control
|
||||
1, // CLK_OUT drive increased by ~20% // clk_out_drive
|
||||
1, // DATA_CLK drive increased by ~20% // dataclk_drive
|
||||
1, // Data port drive increased by ~20% // data_port_drive
|
||||
0, // CLK_OUT minimum slew (fastest rise/fall) // clk_out_slew
|
||||
0, // DATA_CLK minimum slew (fastest rise/fall) // dataclk_slew
|
||||
0, // Data port minimum slew (fastest rise/fall) // data_port_slew
|
||||
|
||||
/* GPO Control */
|
||||
0, // GPO0 is LOW in Sleep/Wait/Alert states // gpo0_inactive_state_high_enable *** adi,gpo0-inactive-state-high-enable
|
||||
0, // GPO1 is LOW in Sleep/Wait/Alert states // gpo1_inactive_state_high_enable *** adi,gpo1-inactive-state-high-enable
|
||||
0, // GPO2 is LOW in Sleep/Wait/Alert states // gpo2_inactive_state_high_enable *** adi,gpo2-inactive-state-high-enable
|
||||
0, // GPO3 is LOW in Sleep/Wait/Alert states // gpo3_inactive_state_high_enable *** adi,gpo3-inactive-state-high-enable
|
||||
0, // GPO0 does not change state when entering RX state // gpo0_slave_rx_enable *** adi,gpo0-slave-rx-enable
|
||||
0, // GPO0 does not change state when entering TX state // gpo0_slave_tx_enable *** adi,gpo0-slave-tx-enable
|
||||
0, // GPO1 does not change state when entering RX state // gpo1_slave_rx_enable *** adi,gpo1-slave-rx-enable
|
||||
0, // GPO1 does not change state when entering TX state // gpo1_slave_tx_enable *** adi,gpo1-slave-tx-enable
|
||||
0, // GPO2 does not change state when entering RX state // gpo2_slave_rx_enable *** adi,gpo2-slave-rx-enable
|
||||
0, // GPO2 does not change state when entering TX state // gpo2_slave_tx_enable *** adi,gpo2-slave-tx-enable
|
||||
0, // GPO3 does not change state when entering RX state // gpo3_slave_rx_enable *** adi,gpo3-slave-rx-enable
|
||||
0, // GPO3 does not change state when entering TX state // gpo3_slave_tx_enable *** adi,gpo3-slave-tx-enable
|
||||
0, // N/A when gpo0_slave_rx_enable = 0 // gpo0_rx_delay_us *** adi,gpo0-rx-delay-us
|
||||
0, // N/A when gpo0_slave_tx_enable = 0 // gpo0_tx_delay_us *** adi,gpo0-tx-delay-us
|
||||
0, // N/A when gpo1_slave_rx_enable = 0 // gpo1_rx_delay_us *** adi,gpo1-rx-delay-us
|
||||
0, // N/A when gpo1_slave_tx_enable = 0 // gpo1_tx_delay_us *** adi,gpo1-tx-delay-us
|
||||
0, // N/A when gpo2_slave_rx_enable = 0 // gpo2_rx_delay_us *** adi,gpo2-rx-delay-us
|
||||
0, // N/A when gpo2_slave_tx_enable = 0 // gpo2_tx_delay_us *** adi,gpo2-tx-delay-us
|
||||
0, // N/A when gpo3_slave_rx_enable = 0 // gpo3_rx_delay_us *** adi,gpo3-rx-delay-us
|
||||
0, // N/A when gpo3_slave_tx_enable = 0 // gpo3_tx_delay_us *** adi,gpo3-tx-delay-us
|
||||
/* GPO Control */
|
||||
0, // GPO0 is LOW in Sleep/Wait/Alert states // gpo0_inactive_state_high_enable *** adi,gpo0-inactive-state-high-enable
|
||||
0, // GPO1 is LOW in Sleep/Wait/Alert states // gpo1_inactive_state_high_enable *** adi,gpo1-inactive-state-high-enable
|
||||
0, // GPO2 is LOW in Sleep/Wait/Alert states // gpo2_inactive_state_high_enable *** adi,gpo2-inactive-state-high-enable
|
||||
0, // GPO3 is LOW in Sleep/Wait/Alert states // gpo3_inactive_state_high_enable *** adi,gpo3-inactive-state-high-enable
|
||||
0, // GPO0 does not change state when entering RX state // gpo0_slave_rx_enable *** adi,gpo0-slave-rx-enable
|
||||
0, // GPO0 does not change state when entering TX state // gpo0_slave_tx_enable *** adi,gpo0-slave-tx-enable
|
||||
0, // GPO1 does not change state when entering RX state // gpo1_slave_rx_enable *** adi,gpo1-slave-rx-enable
|
||||
0, // GPO1 does not change state when entering TX state // gpo1_slave_tx_enable *** adi,gpo1-slave-tx-enable
|
||||
0, // GPO2 does not change state when entering RX state // gpo2_slave_rx_enable *** adi,gpo2-slave-rx-enable
|
||||
0, // GPO2 does not change state when entering TX state // gpo2_slave_tx_enable *** adi,gpo2-slave-tx-enable
|
||||
0, // GPO3 does not change state when entering RX state // gpo3_slave_rx_enable *** adi,gpo3-slave-rx-enable
|
||||
0, // GPO3 does not change state when entering TX state // gpo3_slave_tx_enable *** adi,gpo3-slave-tx-enable
|
||||
0, // N/A when gpo0_slave_rx_enable = 0 // gpo0_rx_delay_us *** adi,gpo0-rx-delay-us
|
||||
0, // N/A when gpo0_slave_tx_enable = 0 // gpo0_tx_delay_us *** adi,gpo0-tx-delay-us
|
||||
0, // N/A when gpo1_slave_rx_enable = 0 // gpo1_rx_delay_us *** adi,gpo1-rx-delay-us
|
||||
0, // N/A when gpo1_slave_tx_enable = 0 // gpo1_tx_delay_us *** adi,gpo1-tx-delay-us
|
||||
0, // N/A when gpo2_slave_rx_enable = 0 // gpo2_rx_delay_us *** adi,gpo2-rx-delay-us
|
||||
0, // N/A when gpo2_slave_tx_enable = 0 // gpo2_tx_delay_us *** adi,gpo2-tx-delay-us
|
||||
0, // N/A when gpo3_slave_rx_enable = 0 // gpo3_rx_delay_us *** adi,gpo3-rx-delay-us
|
||||
0, // N/A when gpo3_slave_tx_enable = 0 // gpo3_tx_delay_us *** adi,gpo3-tx-delay-us
|
||||
|
||||
/* Tx Monitor Control */
|
||||
/* bladeRF Micro: N/A, TX_MON1 and TX_MON2 tied to GND */
|
||||
37000, // N/A // low_high_gain_threshold_mdB *** adi,txmon-low-high-thresh
|
||||
0, // N/A // low_gain_dB *** adi,txmon-low-gain
|
||||
24, // N/A // high_gain_dB *** adi,txmon-high-gain
|
||||
0, // N/A // tx_mon_track_en *** adi,txmon-dc-tracking-enable
|
||||
0, // N/A // one_shot_mode_en *** adi,txmon-one-shot-mode-enable
|
||||
511, // N/A // tx_mon_delay *** adi,txmon-delay
|
||||
8192, // N/A // tx_mon_duration *** adi,txmon-duration
|
||||
2, // N/A // tx1_mon_front_end_gain *** adi,txmon-1-front-end-gain
|
||||
2, // N/A // tx2_mon_front_end_gain *** adi,txmon-2-front-end-gain
|
||||
48, // N/A // tx1_mon_lo_cm *** adi,txmon-1-lo-cm
|
||||
48, // N/A // tx2_mon_lo_cm *** adi,txmon-2-lo-cm
|
||||
/* Tx Monitor Control */
|
||||
/* bladeRF Micro: N/A, TX_MON1 and TX_MON2 tied to GND */
|
||||
37000, // N/A // low_high_gain_threshold_mdB *** adi,txmon-low-high-thresh
|
||||
0, // N/A // low_gain_dB *** adi,txmon-low-gain
|
||||
24, // N/A // high_gain_dB *** adi,txmon-high-gain
|
||||
0, // N/A // tx_mon_track_en *** adi,txmon-dc-tracking-enable
|
||||
0, // N/A // one_shot_mode_en *** adi,txmon-one-shot-mode-enable
|
||||
511, // N/A // tx_mon_delay *** adi,txmon-delay
|
||||
8192, // N/A // tx_mon_duration *** adi,txmon-duration
|
||||
2, // N/A // tx1_mon_front_end_gain *** adi,txmon-1-front-end-gain
|
||||
2, // N/A // tx2_mon_front_end_gain *** adi,txmon-2-front-end-gain
|
||||
48, // N/A // tx1_mon_lo_cm *** adi,txmon-1-lo-cm
|
||||
48, // N/A // tx2_mon_lo_cm *** adi,txmon-2-lo-cm
|
||||
|
||||
/* GPIO definitions */
|
||||
RFFE_CONTROL_RESET_N, // Reset using RFFE bit 0 // gpio_resetb *** reset-gpios
|
||||
/* GPIO definitions */
|
||||
RFFE_CONTROL_RESET_N, // Reset using RFFE bit 0 // gpio_resetb *** reset-gpios
|
||||
|
||||
/* MCS Sync */
|
||||
-1, // Future use (MCS Sync) // gpio_sync *** sync-gpios
|
||||
-1, // Future use (MCS Sync) // gpio_cal_sw1 *** cal-sw1-gpios
|
||||
-1, // Future use (MCS Sync) // gpio_cal_sw2 *** cal-sw2-gpios
|
||||
/* MCS Sync */
|
||||
-1, // Future use (MCS Sync) // gpio_sync *** sync-gpios
|
||||
-1, // Future use (MCS Sync) // gpio_cal_sw1 *** cal-sw1-gpios
|
||||
-1, // Future use (MCS Sync) // gpio_cal_sw2 *** cal-sw2-gpios
|
||||
|
||||
/* External LO clocks */
|
||||
NULL, // Future use (RX_EXT_LO, TX_EXT_LO control) // (*ad9361_rfpll_ext_recalc_rate)()
|
||||
NULL, // Future use (RX_EXT_LO, TX_EXT_LO control) // (*ad9361_rfpll_ext_round_rate)()
|
||||
NULL // Future use (RX_EXT_LO, TX_EXT_LO control) // (*ad9361_rfpll_ext_set_rate)()
|
||||
/* External LO clocks */
|
||||
NULL, // Future use (RX_EXT_LO, TX_EXT_LO control) // (*ad9361_rfpll_ext_recalc_rate)()
|
||||
NULL, // Future use (RX_EXT_LO, TX_EXT_LO control) // (*ad9361_rfpll_ext_round_rate)()
|
||||
NULL // Future use (RX_EXT_LO, TX_EXT_LO control) // (*ad9361_rfpll_ext_set_rate)()
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
/**
|
||||
* AD9361 FIR Filters
|
||||
|
|
@ -327,14 +329,14 @@ AD9361_InitParam bladerf2_rfic_init_params = {
|
|||
* [ ADC ] -> [ HB3/DEC3 ] -> [ HB2 ] -> [ HB1 ] -> [ Programmable RX FIR ]
|
||||
*
|
||||
* The TIA LPF is a transimpedance amplifier which applies a single-pole
|
||||
* low-pass filter, and the BB LPF is a third-order Butterworth low-pass
|
||||
* filter. Both have programmable corner frequencies.
|
||||
* low-pass filter, and the BB LPF is a third-order Butterworth low-pass filter.
|
||||
* Both have programmable corner frequencies.
|
||||
*
|
||||
* HB3/DEC3 is a fixed-coefficient decimating filter, and can decimate by a
|
||||
* factor of 2 or 3, or be bypassed. HB2 is a fixed-coefficient half-band
|
||||
* decimating filter, and can decimate by a factor of 2 or be bypassed. HB1
|
||||
* is a fixed-coefficient half-band decimating filter, and can also decimate by
|
||||
* a factor of 2 or be bypassed.
|
||||
* decimating filter, and can decimate by a factor of 2 or be bypassed. HB1 is a
|
||||
* fixed-coefficient half-band decimating filter, and can also decimate by a
|
||||
* factor of 2 or be bypassed.
|
||||
*
|
||||
* The Programmable RX FIR filter is a programmable polyphase filter, which can
|
||||
* decimate by a factor of 1, 2, or 4, or be bypassed. Similar to the TX FIR,
|
||||
|
|
@ -344,8 +346,8 @@ AD9361_InitParam bladerf2_rfic_init_params = {
|
|||
* so the below RX filters are configured for a -6 dB gain to effect a net gain
|
||||
* of 0 dB.
|
||||
*
|
||||
* In practice, the decimation/interpolation settings must match for both the
|
||||
* RX and TX FIR filters. If they differ, TX quadrature calibration (and likely
|
||||
* In practice, the decimation/interpolation settings must match for both the RX
|
||||
* and TX FIR filters. If they differ, TX quadrature calibration (and likely
|
||||
* other calibrations) will fail.
|
||||
*
|
||||
*
|
||||
|
|
@ -355,16 +357,16 @@ AD9361_InitParam bladerf2_rfic_init_params = {
|
|||
* bladerf2_rfic_rx_fir_config_dec2 = decimate by 2 RX FIR
|
||||
* bladerf2_rfic_tx_fir_config_int2 = interpolate by 2 TX FIR
|
||||
*
|
||||
* The first two (the 1x filters) are the default, and should provide
|
||||
* reasonable performance under most circumstances. The other two filters are
|
||||
* primarily intended for situations requiring a flatter TX spectrum,
|
||||
* particularly when the ratio of sample rate to signal bandwidth is low.
|
||||
* The first two (the 1x filters) are the default, and should provide reasonable
|
||||
* performance under most circumstances. The other two filters are primarily
|
||||
* intended for situations requiring a flatter TX spectrum, particularly when
|
||||
* the ratio of sample rate to signal bandwidth is low.
|
||||
*/
|
||||
|
||||
AD9361_RXFIRConfig bladerf2_rfic_rx_fir_config = {
|
||||
3, // rx (RX1 = 1, RX2 = 2, both = 3)
|
||||
-6, // rx_gain (-12, -6, 0, or 6 dB)
|
||||
1, // rx_dec (decimate by 1, 2, or 4)
|
||||
3, // rx (RX1 = 1, RX2 = 2, both = 3)
|
||||
-6, // rx_gain (-12, -6, 0, or 6 dB)
|
||||
1, // rx_dec (decimate by 1, 2, or 4)
|
||||
|
||||
/**
|
||||
* RX FIR Filter
|
||||
|
|
@ -372,8 +374,8 @@ AD9361_RXFIRConfig bladerf2_rfic_rx_fir_config = {
|
|||
* Branch: filter_generation
|
||||
* Commit: f749cef974f687f696226455dc7684277886cf3b
|
||||
*
|
||||
* This filter is intended to improve the flatness of the RX spectrum. It
|
||||
* is a 64-tap, decimate-by-1 filter.
|
||||
* This filter is intended to improve the flatness of the RX spectrum. It is
|
||||
* a 64-tap, decimate-by-1 filter.
|
||||
*
|
||||
* Design parameters:
|
||||
*
|
||||
|
|
@ -400,6 +402,7 @@ AD9361_RXFIRConfig bladerf2_rfic_rx_fir_config = {
|
|||
* fdp.FIRdBmin = 0;
|
||||
* fdp.int_FIR = 1;
|
||||
*/
|
||||
// clang-format off
|
||||
{
|
||||
0, 0, 0, 1, -1, 3, -6, 11,
|
||||
-19, 33, -53, 84, -129, 193, -282, 404,
|
||||
|
|
@ -417,10 +420,11 @@ AD9361_RXFIRConfig bladerf2_rfic_rx_fir_config = {
|
|||
0, 0, 0, 0, 0, 0, 0, 0, // unused
|
||||
0, 0, 0, 0, 0, 0, 0, 0, // unused
|
||||
0, 0, 0, 0, 0, 0, 0, 0, // unused
|
||||
}, // rx_coef[128]
|
||||
64, // rx_coef_size
|
||||
{0, 0, 0, 0, 0, 0}, // rx_path_clks[6]
|
||||
0 // rx_bandwidth
|
||||
}, // rx_coef[128]
|
||||
// clang-format on
|
||||
64, // rx_coef_size
|
||||
{ 0, 0, 0, 0, 0, 0 }, // rx_path_clks[6]
|
||||
0 // rx_bandwidth
|
||||
};
|
||||
|
||||
AD9361_TXFIRConfig bladerf2_rfic_tx_fir_config = {
|
||||
|
|
@ -433,6 +437,7 @@ AD9361_TXFIRConfig bladerf2_rfic_tx_fir_config = {
|
|||
*
|
||||
* This filter literally does nothing, but it is here as a placeholder.
|
||||
*/
|
||||
// clang-format off
|
||||
{
|
||||
32767, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
|
|
@ -450,16 +455,17 @@ AD9361_TXFIRConfig bladerf2_rfic_tx_fir_config = {
|
|||
0, 0, 0, 0, 0, 0, 0, 0, // unused
|
||||
0, 0, 0, 0, 0, 0, 0, 0, // unused
|
||||
0, 0, 0, 0, 0, 0, 0, 0, // unused
|
||||
}, // tx_coef[128]
|
||||
64, // tx_coef_size
|
||||
{0, 0, 0, 0, 0, 0}, // tx_path_clks[6]
|
||||
0 // tx_bandwidth
|
||||
}, // tx_coef[128]
|
||||
// clang-format on
|
||||
64, // tx_coef_size
|
||||
{ 0, 0, 0, 0, 0, 0 }, // tx_path_clks[6]
|
||||
0 // tx_bandwidth
|
||||
};
|
||||
|
||||
AD9361_RXFIRConfig bladerf2_rfic_rx_fir_config_dec2 = {
|
||||
3, // rx (RX1 = 1, RX2 = 2, both = 3)
|
||||
-6, // rx_gain (-12, -6, 0, or 6 dB)
|
||||
2, // rx_dec (decimate by 1, 2, or 4)
|
||||
3, // rx (RX1 = 1, RX2 = 2, both = 3)
|
||||
-6, // rx_gain (-12, -6, 0, or 6 dB)
|
||||
2, // rx_dec (decimate by 1, 2, or 4)
|
||||
|
||||
/**
|
||||
* RX FIR Filter
|
||||
|
|
@ -497,6 +503,7 @@ AD9361_RXFIRConfig bladerf2_rfic_rx_fir_config_dec2 = {
|
|||
* fdp.FIRdBmin = 0;
|
||||
* fdp.int_FIR = 1;
|
||||
*/
|
||||
// clang-format off
|
||||
{
|
||||
22, 125, 207, 190, 15, -98, -45, 91,
|
||||
60, -76, -90, 69, 115, -47, -147, 22,
|
||||
|
|
@ -514,10 +521,11 @@ AD9361_RXFIRConfig bladerf2_rfic_rx_fir_config_dec2 = {
|
|||
245, -116, -237, 53, 216, -2, -187, -37,
|
||||
154, 64, -119, -82, 87, 89, -56, -96,
|
||||
30, 99, 3, -120, -107, 0, 56, 45,
|
||||
}, // rx_coef[128]
|
||||
128, // rx_coef_size
|
||||
{0, 0, 0, 0, 0, 0}, // rx_path_clks[6]
|
||||
0 // rx_bandwidth
|
||||
}, // rx_coef[128]
|
||||
// clang-format on
|
||||
128, // rx_coef_size
|
||||
{ 0, 0, 0, 0, 0, 0 }, // rx_path_clks[6]
|
||||
0 // rx_bandwidth
|
||||
};
|
||||
|
||||
AD9361_TXFIRConfig bladerf2_rfic_tx_fir_config_int2 = {
|
||||
|
|
@ -561,6 +569,7 @@ AD9361_TXFIRConfig bladerf2_rfic_tx_fir_config_int2 = {
|
|||
* fdp.FIRdBmin = 0;
|
||||
* fdp.int_FIR = 1;
|
||||
*/
|
||||
// clang-format off
|
||||
{
|
||||
20, 104, 183, 161, 0, -129, -82, 61,
|
||||
69, -65, -108, 31, 117, -15, -145, -23,
|
||||
|
|
@ -578,17 +587,19 @@ AD9361_TXFIRConfig bladerf2_rfic_tx_fir_config_int2 = {
|
|||
267, -3, -234, -46, 192, 79, -153, -103,
|
||||
107, 109, -76, -117, 32, 103, -19, -115,
|
||||
-35, 83, 34, -120, -204, -134, -42, 12,
|
||||
}, // tx_coef[128]
|
||||
128, // tx_coef_size
|
||||
{0, 0, 0, 0, 0, 0}, // tx_path_clks[6]
|
||||
0 // tx_bandwidth
|
||||
}, // tx_coef[128]
|
||||
// clang-format on
|
||||
128, // tx_coef_size
|
||||
{ 0, 0, 0, 0, 0, 0 }, // tx_path_clks[6]
|
||||
0 // tx_bandwidth
|
||||
};
|
||||
|
||||
AD9361_RXFIRConfig bladerf2_rfic_rx_fir_config_dec4 = {
|
||||
3, // rx (RX1 = 1, RX2 = 2, both = 3)
|
||||
-6, // rx_gain (-12, -6, 0, or 6 dB)
|
||||
4, // rx_dec (decimate by 1, 2, or 4)
|
||||
/**
|
||||
3, // rx (RX1 = 1, RX2 = 2, both = 3)
|
||||
-6, // rx_gain (-12, -6, 0, or 6 dB)
|
||||
4, // rx_dec (decimate by 1, 2, or 4)
|
||||
|
||||
/**
|
||||
* RX FIR Filter
|
||||
* Built using https://github.com/analogdevicesinc/libad9361-iio
|
||||
* Branch: filter_generation
|
||||
|
|
@ -624,6 +635,7 @@ AD9361_RXFIRConfig bladerf2_rfic_rx_fir_config_dec4 = {
|
|||
* fdp.FIRdBmin = 0;
|
||||
* fdp.int_FIR = 1;
|
||||
*/
|
||||
// clang-format off
|
||||
{
|
||||
-30, -24, -46, -54, -28, -6, 50, 82,
|
||||
108, 84, 28, -60, -136, -172, -132, -24,
|
||||
|
|
@ -641,16 +653,19 @@ AD9361_RXFIRConfig bladerf2_rfic_rx_fir_config_dec4 = {
|
|||
-244, -34, 154, 256, 240, 136, -4, -116,
|
||||
-168, -144, -74, 14, 74, 102, 76, 38,
|
||||
-28, -54, -96, -68, -82, -26, -34, -2,
|
||||
}, // rx_coef[128]
|
||||
128, // rx_coef_size
|
||||
{0, 0, 0, 0, 0, 0}, // rx_path_clks[6]
|
||||
0 // rx_bandwidth
|
||||
}, // rx_coef[128]
|
||||
// clang-format on
|
||||
128, // rx_coef_size
|
||||
{ 0, 0, 0, 0, 0, 0 }, // rx_path_clks[6]
|
||||
0 // rx_bandwidth
|
||||
};
|
||||
AD9361_TXFIRConfig bladerf2_rfic_tx_fir_config_int4 = {
|
||||
|
||||
AD9361_TXFIRConfig bladerf2_rfic_tx_fir_config_int4 = {
|
||||
3, // tx (TX1 = 1, TX2 = 2, both = 3)
|
||||
0, // tx_gain (-6 or 0 dB)
|
||||
4, // tx_int (interpolate by 1, 2, or 4)
|
||||
/**
|
||||
|
||||
/**
|
||||
* TX FIR Filter
|
||||
* Built using https://github.com/analogdevicesinc/libad9361-iio
|
||||
* Branch: filter_generation
|
||||
|
|
@ -686,6 +701,7 @@ AD9361_RXFIRConfig bladerf2_rfic_rx_fir_config_dec4 = {
|
|||
* fdp.FIRdBmin = 0;
|
||||
* fdp.int_FIR = 1;
|
||||
*/
|
||||
// clang-format off
|
||||
{
|
||||
-18, 2, -14, 16, 34, 76, 104, 124,
|
||||
108, 62, -12, -86, -136, -128, -58, 58,
|
||||
|
|
@ -703,10 +719,9 @@ AD9361_RXFIRConfig bladerf2_rfic_rx_fir_config_dec4 = {
|
|||
-212, -24, 144, 230, 218, 124, 2, -100,
|
||||
-146, -126, -62, 18, 82, 110, 98, 60,
|
||||
12, -28, -52, -56, -50, -32, -18, -8,
|
||||
}, // tx_coef[128]
|
||||
128, // tx_coef_size
|
||||
{0, 0, 0, 0, 0, 0}, // tx_path_clks[6]
|
||||
0 // tx_bandwidth
|
||||
}, // tx_coef[128]
|
||||
// clang-format on
|
||||
128, // tx_coef_size
|
||||
{ 0, 0, 0, 0, 0, 0 }, // tx_path_clks[6]
|
||||
0 // tx_bandwidth
|
||||
};
|
||||
|
||||
const float ina219_r_shunt = 0.001F;
|
||||
|
|
|
|||
185
fpga_common/src/bladerf2_common.c
Normal file
185
fpga_common/src/bladerf2_common.c
Normal file
|
|
@ -0,0 +1,185 @@
|
|||
/* This file is part of the bladeRF project:
|
||||
* http://www.github.com/nuand/bladeRF
|
||||
*
|
||||
* Copyright (c) 2018 Nuand LLC
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "bladerf2_common.h"
|
||||
|
||||
/**
|
||||
* Value of the current sense resistor (R132)
|
||||
*/
|
||||
float const ina219_r_shunt = 0.001F;
|
||||
|
||||
int errno_ad9361_to_bladerf(int err)
|
||||
{
|
||||
if (err >= 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
switch (err) {
|
||||
case EIO:
|
||||
return BLADERF_ERR_IO;
|
||||
case EAGAIN:
|
||||
return BLADERF_ERR_WOULD_BLOCK;
|
||||
case ENOMEM:
|
||||
return BLADERF_ERR_MEM;
|
||||
case EFAULT:
|
||||
return BLADERF_ERR_UNEXPECTED;
|
||||
case ENODEV:
|
||||
return BLADERF_ERR_NODEV;
|
||||
case EINVAL:
|
||||
return BLADERF_ERR_INVAL;
|
||||
case ETIMEDOUT:
|
||||
return BLADERF_ERR_TIMEOUT;
|
||||
}
|
||||
|
||||
return BLADERF_ERR_UNEXPECTED;
|
||||
}
|
||||
|
||||
struct band_port_map const *_get_band_port_map_by_freq(bladerf_channel ch,
|
||||
bladerf_frequency freq)
|
||||
{
|
||||
struct band_port_map const *port_map;
|
||||
size_t port_map_len;
|
||||
int64_t freqi = (int64_t)freq;
|
||||
size_t i;
|
||||
|
||||
/* Select the band->port map for RX vs TX */
|
||||
if (BLADERF_CHANNEL_IS_TX(ch)) {
|
||||
port_map = bladerf2_tx_band_port_map;
|
||||
port_map_len = ARRAY_SIZE(bladerf2_tx_band_port_map);
|
||||
} else {
|
||||
port_map = bladerf2_rx_band_port_map;
|
||||
port_map_len = ARRAY_SIZE(bladerf2_rx_band_port_map);
|
||||
}
|
||||
|
||||
if (NULL == port_map) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Search through the band->port map for the desired band */
|
||||
for (i = 0; i < port_map_len; i++) {
|
||||
if (is_within_range(&port_map[i].frequency, freqi)) {
|
||||
return &port_map[i];
|
||||
}
|
||||
}
|
||||
|
||||
/* Wasn't found, return a null ptr */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int _modify_spdt_bits_by_freq(uint32_t *reg,
|
||||
bladerf_channel ch,
|
||||
bool enabled,
|
||||
bladerf_frequency freq)
|
||||
{
|
||||
struct band_port_map const *port_map;
|
||||
uint32_t shift;
|
||||
|
||||
if (NULL == reg) {
|
||||
return BLADERF_ERR_INVAL;
|
||||
}
|
||||
|
||||
/* Look up the port configuration for this frequency */
|
||||
port_map = _get_band_port_map_by_freq(ch, enabled ? freq : 0);
|
||||
|
||||
if (NULL == port_map) {
|
||||
return BLADERF_ERR_INVAL;
|
||||
}
|
||||
|
||||
/* Modify the reg bits accordingly */
|
||||
switch (ch) {
|
||||
case BLADERF_CHANNEL_RX(0):
|
||||
shift = RFFE_CONTROL_RX_SPDT_1;
|
||||
break;
|
||||
case BLADERF_CHANNEL_RX(1):
|
||||
shift = RFFE_CONTROL_RX_SPDT_2;
|
||||
break;
|
||||
case BLADERF_CHANNEL_TX(0):
|
||||
shift = RFFE_CONTROL_TX_SPDT_1;
|
||||
break;
|
||||
case BLADERF_CHANNEL_TX(1):
|
||||
shift = RFFE_CONTROL_TX_SPDT_2;
|
||||
break;
|
||||
default:
|
||||
return BLADERF_ERR_INVAL;
|
||||
}
|
||||
|
||||
*reg &= ~(RFFE_CONTROL_SPDT_MASK << shift);
|
||||
*reg |= port_map->spdt << shift;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _get_rffe_control_bit_for_dir(bladerf_direction dir)
|
||||
{
|
||||
switch (dir) {
|
||||
case BLADERF_RX:
|
||||
return RFFE_CONTROL_ENABLE;
|
||||
case BLADERF_TX:
|
||||
return RFFE_CONTROL_TXNRX;
|
||||
default:
|
||||
return UINT32_MAX;
|
||||
}
|
||||
}
|
||||
|
||||
int _get_rffe_control_bit_for_ch(bladerf_channel ch)
|
||||
{
|
||||
switch (ch) {
|
||||
case BLADERF_CHANNEL_RX(0):
|
||||
return RFFE_CONTROL_MIMO_RX_EN_0;
|
||||
case BLADERF_CHANNEL_RX(1):
|
||||
return RFFE_CONTROL_MIMO_RX_EN_1;
|
||||
case BLADERF_CHANNEL_TX(0):
|
||||
return RFFE_CONTROL_MIMO_TX_EN_0;
|
||||
case BLADERF_CHANNEL_TX(1):
|
||||
return RFFE_CONTROL_MIMO_TX_EN_1;
|
||||
default:
|
||||
return UINT32_MAX;
|
||||
}
|
||||
}
|
||||
|
||||
bool _rffe_ch_enabled(uint32_t reg, bladerf_channel ch)
|
||||
{
|
||||
return (reg >> _get_rffe_control_bit_for_ch(ch)) & 0x1;
|
||||
}
|
||||
|
||||
bool _rffe_dir_enabled(uint32_t reg, bladerf_direction dir)
|
||||
{
|
||||
return (reg >> _get_rffe_control_bit_for_dir(dir)) & 0x1;
|
||||
}
|
||||
|
||||
bool _rffe_dir_otherwise_enabled(uint32_t reg, bladerf_channel ch)
|
||||
{
|
||||
switch (ch) {
|
||||
case BLADERF_CHANNEL_RX(0):
|
||||
return _rffe_ch_enabled(reg, BLADERF_CHANNEL_RX(1));
|
||||
case BLADERF_CHANNEL_RX(1):
|
||||
return _rffe_ch_enabled(reg, BLADERF_CHANNEL_RX(0));
|
||||
case BLADERF_CHANNEL_TX(0):
|
||||
return _rffe_ch_enabled(reg, BLADERF_CHANNEL_TX(1));
|
||||
case BLADERF_CHANNEL_TX(1):
|
||||
return _rffe_ch_enabled(reg, BLADERF_CHANNEL_TX(0));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
54
host/common/include/range.h
Normal file
54
host/common/include/range.h
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
/* This file is part of the bladeRF project:
|
||||
* http://www.github.com/nuand/bladeRF
|
||||
*
|
||||
* Copyright (c) 2018 Nuand LLC
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef RANGE_H_
|
||||
#define RANGE_H_
|
||||
|
||||
#if !defined(BLADERF_NIOS_BUILD) && !defined(BLADERF_NIOS_PC_SIMULATION)
|
||||
#include <libbladeRF.h>
|
||||
#else
|
||||
#include "libbladeRF_nios_compat.h"
|
||||
#endif
|
||||
|
||||
#include "bladerf2_common.h"
|
||||
|
||||
#ifdef BLADERF_NIOS_BUILD
|
||||
// don't do scaling on the Nios, since multiplication and division suck
|
||||
#define __scale(r, v) (v)
|
||||
#define __unscale(r, v) (v)
|
||||
#else
|
||||
#define __scale(r, v) ((float)(v) / (r)->scale)
|
||||
#define __unscale(r, v) ((float)(v) * (r)->scale)
|
||||
#endif // BLADERF_NIOS_BUILD
|
||||
|
||||
#define __scale_int(r, v) (__round_int(__scale(r, v)))
|
||||
#define __scale_int64(r, v) (__round_int64(__scale(r, v)))
|
||||
|
||||
#define __unscale_int(r, v) (__round_int(__unscale(r, v)))
|
||||
#define __unscale_int64(r, v) (__round_int64(__unscale(r, v)))
|
||||
|
||||
bool is_within_range(struct bladerf_range const *range, int64_t value);
|
||||
int64_t clamp_to_range(struct bladerf_range const *range, int64_t value);
|
||||
|
||||
#endif // RANGE_H_
|
||||
65
host/common/src/range.c
Normal file
65
host/common/src/range.c
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
/*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#include "range.h"
|
||||
|
||||
#if !defined(BLADERF_NIOS_BUILD) && !defined(BLADERF_NIOS_PC_SIMULATION)
|
||||
#include "log.h"
|
||||
#endif
|
||||
|
||||
bool is_within_range(struct bladerf_range const *range, int64_t value)
|
||||
{
|
||||
if (NULL == range) {
|
||||
log_error("%s: range is null\n", __FUNCTION__);
|
||||
return false;
|
||||
}
|
||||
|
||||
return (__scale(range, value) >= range->min &&
|
||||
__scale(range, value) <= range->max);
|
||||
}
|
||||
|
||||
int64_t clamp_to_range(struct bladerf_range const *range, int64_t value)
|
||||
{
|
||||
if (NULL == range) {
|
||||
log_error("%s: range is null\n", __FUNCTION__);
|
||||
return value;
|
||||
}
|
||||
|
||||
if (__scale(range, value) < range->min) {
|
||||
log_debug("%s: Requested value %" PRIi64
|
||||
" is below range [%g,%g], clamping to %" PRIi64 "\n",
|
||||
__FUNCTION__, value, __unscale(range, range->min),
|
||||
__unscale(range, range->max),
|
||||
__unscale_int64(range, range->min));
|
||||
value = __unscale_int64(range, range->min);
|
||||
}
|
||||
|
||||
if (__scale(range, value) > range->max) {
|
||||
log_debug("%s: Requested value %" PRIi64
|
||||
" is above range [%g,%g], clamping to %" PRIi64 "\n",
|
||||
__FUNCTION__, value, __unscale(range, range->min),
|
||||
__unscale(range, range->max),
|
||||
__unscale_int64(range, range->max));
|
||||
value = __unscale_int64(range, range->max);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
|
@ -306,8 +306,11 @@ include_directories(${LIBBLADERF_INCLUDES})
|
|||
# Configure source files
|
||||
################################################################################
|
||||
set(LIBBLADERF_SOURCE_BLADERF2
|
||||
${BLADERF_FPGA_COMMON_SOURCE_DIR}/ad936x_helpers.c
|
||||
${BLADERF_FPGA_COMMON_SOURCE_DIR}/bladerf2_common.c
|
||||
src/board/bladerf2/bladerf2.c
|
||||
src/board/bladerf2/capabilities.c
|
||||
src/board/bladerf2/common.c
|
||||
src/board/bladerf2/compatibility.c
|
||||
)
|
||||
|
||||
|
|
@ -349,6 +352,7 @@ set(LIBBLADERF_SOURCE
|
|||
${BLADERF_FPGA_COMMON_SOURCE_DIR}/lms.c
|
||||
${BLADERF_FPGA_COMMON_SOURCE_DIR}/band_select.c
|
||||
${BLADERF_HOST_COMMON_SOURCE_DIR}/parse.c
|
||||
${BLADERF_HOST_COMMON_SOURCE_DIR}/range.c
|
||||
)
|
||||
|
||||
if(BUILD_AD936X)
|
||||
|
|
|
|||
|
|
@ -69,8 +69,8 @@ int CALL_CONV bladerf_set_bias_tee(struct bladerf *dev,
|
|||
/**
|
||||
* @defgroup FN_BLADERF2_LOW_LEVEL Low-level accessors
|
||||
*
|
||||
* In a most cases, higher-level routines should be used. These routines are
|
||||
* only intended to support development and testing.
|
||||
* In most cases, higher-level routines should be used. These routines are only
|
||||
* intended to support development and testing.
|
||||
*
|
||||
* Use these routines with great care, and be sure to reference the relevant
|
||||
* schematics, data sheets, and source code (i.e., firmware and hdl).
|
||||
|
|
@ -134,7 +134,7 @@ int CALL_CONV bladerf_get_rfic_temperature(struct bladerf *dev, float *val);
|
|||
* value (e.g. in dBm) is desired, a calibration should be performed
|
||||
* against a reference signal.
|
||||
*
|
||||
* @note See `src/board/bladerf2/params.c` for the RSSI control parameters.
|
||||
* @note See `fpga_common/src/ad936x_params.c` for the RSSI control parameters.
|
||||
*
|
||||
* Reference: AD9361 Reference Manual UG-570
|
||||
*
|
||||
|
|
@ -171,11 +171,11 @@ int CALL_CONV bladerf_get_rfic_ctrl_out(struct bladerf *dev, uint8_t *ctrl_out);
|
|||
* RFIC RX FIR filter choices
|
||||
*/
|
||||
typedef enum {
|
||||
BLADERF_RFIC_RXFIR_BYPASS, /**< No filter */
|
||||
BLADERF_RFIC_RXFIR_CUSTOM, /**< Custom FIR filter (currently unused) */
|
||||
BLADERF_RFIC_RXFIR_DEC1, /**< Decimate by 1 (default) */
|
||||
BLADERF_RFIC_RXFIR_DEC2, /**< Decimate by 2 */
|
||||
BLADERF_RFIC_RXFIR_DEC4, /**< Decimate by 4 */
|
||||
BLADERF_RFIC_RXFIR_BYPASS = 0, /**< No filter */
|
||||
BLADERF_RFIC_RXFIR_CUSTOM, /**< Custom FIR filter (currently unused) */
|
||||
BLADERF_RFIC_RXFIR_DEC1, /**< Decimate by 1 (default) */
|
||||
BLADERF_RFIC_RXFIR_DEC2, /**< Decimate by 2 */
|
||||
BLADERF_RFIC_RXFIR_DEC4, /**< Decimate by 4 */
|
||||
} bladerf_rfic_rxfir;
|
||||
|
||||
/** Default RFIC RX FIR filter */
|
||||
|
|
@ -185,11 +185,11 @@ typedef enum {
|
|||
* RFIC TX FIR filter choices
|
||||
*/
|
||||
typedef enum {
|
||||
BLADERF_RFIC_TXFIR_BYPASS, /**< No filter (default) */
|
||||
BLADERF_RFIC_TXFIR_CUSTOM, /**< Custom FIR filter (currently unused) */
|
||||
BLADERF_RFIC_TXFIR_INT1, /**< Interpolate by 1 */
|
||||
BLADERF_RFIC_TXFIR_INT2, /**< Interpolate by 2 */
|
||||
BLADERF_RFIC_TXFIR_INT4, /**< Interpolate by 4 */
|
||||
BLADERF_RFIC_TXFIR_BYPASS = 0, /**< No filter (default) */
|
||||
BLADERF_RFIC_TXFIR_CUSTOM, /**< Custom FIR filter (currently unused) */
|
||||
BLADERF_RFIC_TXFIR_INT1, /**< Interpolate by 1 */
|
||||
BLADERF_RFIC_TXFIR_INT2, /**< Interpolate by 2 */
|
||||
BLADERF_RFIC_TXFIR_INT4, /**< Interpolate by 4 */
|
||||
} bladerf_rfic_txfir;
|
||||
|
||||
/** Default RFIC TX FIR filter */
|
||||
|
|
@ -201,6 +201,8 @@ typedef enum {
|
|||
* @param dev Device handle
|
||||
* @param rxfir RX FIR selection
|
||||
*
|
||||
* @note See `fpga_common/src/ad936x_params.c` for FIR parameters.
|
||||
*
|
||||
* @return 0 on success, value from \ref RETCODES list on failure
|
||||
*/
|
||||
API_EXPORT
|
||||
|
|
@ -213,6 +215,8 @@ int CALL_CONV bladerf_get_rfic_rx_fir(struct bladerf *dev,
|
|||
* @param dev Device handle
|
||||
* @param rxfir RX FIR selection
|
||||
*
|
||||
* @note See `fpga_common/src/ad936x_params.c` for FIR parameters.
|
||||
*
|
||||
* @return 0 on success, value from \ref RETCODES list on failure
|
||||
*/
|
||||
API_EXPORT
|
||||
|
|
@ -225,6 +229,8 @@ int CALL_CONV bladerf_set_rfic_rx_fir(struct bladerf *dev,
|
|||
* @param dev Device handle
|
||||
* @param txfir TX FIR selection
|
||||
*
|
||||
* @note See `fpga_common/src/ad936x_params.c` for FIR parameters.
|
||||
*
|
||||
* @return 0 on success, value from \ref RETCODES list on failure
|
||||
*/
|
||||
API_EXPORT
|
||||
|
|
@ -237,6 +243,8 @@ int CALL_CONV bladerf_get_rfic_tx_fir(struct bladerf *dev,
|
|||
* @param dev Device handle
|
||||
* @param txfir TX FIR selection
|
||||
*
|
||||
* @note See `fpga_common/src/ad936x_params.c` for FIR parameters.
|
||||
*
|
||||
* @return 0 on success, value from \ref RETCODES list on failure
|
||||
*/
|
||||
API_EXPORT
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
387
host/libraries/libbladeRF/src/board/bladerf2/common.c
Normal file
387
host/libraries/libbladeRF/src/board/bladerf2/common.c
Normal file
|
|
@ -0,0 +1,387 @@
|
|||
/*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "board/board.h"
|
||||
#include "capabilities.h"
|
||||
#include "common.h"
|
||||
|
||||
|
||||
/******************************************************************************/
|
||||
/* Constants */
|
||||
/******************************************************************************/
|
||||
|
||||
/* Board state to string map */
|
||||
char const *bladerf2_state_to_string[] = {
|
||||
[STATE_UNINITIALIZED] = "Uninitialized",
|
||||
[STATE_FIRMWARE_LOADED] = "Firmware Loaded",
|
||||
[STATE_FPGA_LOADED] = "FPGA Loaded",
|
||||
[STATE_INITIALIZED] = "Initialized",
|
||||
};
|
||||
|
||||
|
||||
/******************************************************************************/
|
||||
/* Sample format control */
|
||||
/******************************************************************************/
|
||||
|
||||
static inline int requires_timestamps(bladerf_format format, bool *required)
|
||||
{
|
||||
switch (format) {
|
||||
case BLADERF_FORMAT_SC16_Q11_META:
|
||||
*required = true;
|
||||
break;
|
||||
|
||||
case BLADERF_FORMAT_SC16_Q11:
|
||||
*required = false;
|
||||
break;
|
||||
|
||||
default:
|
||||
return BLADERF_ERR_INVAL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int perform_format_config(struct bladerf *dev,
|
||||
bladerf_direction dir,
|
||||
bladerf_format format)
|
||||
{
|
||||
CHECK_BOARD_STATE(STATE_INITIALIZED);
|
||||
|
||||
struct bladerf2_board_data *board_data = dev->board_data;
|
||||
bool use_timestamps, other_using_timestamps;
|
||||
bladerf_channel other;
|
||||
uint32_t gpio_val;
|
||||
int status;
|
||||
|
||||
status = requires_timestamps(format, &use_timestamps);
|
||||
if (status != 0) {
|
||||
log_debug("%s: Invalid format: %d\n", __FUNCTION__, format);
|
||||
return status;
|
||||
}
|
||||
|
||||
switch (dir) {
|
||||
case BLADERF_RX:
|
||||
other = BLADERF_TX;
|
||||
break;
|
||||
|
||||
case BLADERF_TX:
|
||||
other = BLADERF_RX;
|
||||
break;
|
||||
|
||||
default:
|
||||
log_debug("Invalid direction: %d\n", dir);
|
||||
return BLADERF_ERR_INVAL;
|
||||
}
|
||||
|
||||
status = requires_timestamps(board_data->module_format[other],
|
||||
&other_using_timestamps);
|
||||
if ((status == 0) && (other_using_timestamps != use_timestamps)) {
|
||||
log_debug("Format conflict detected: RX=%d, TX=%d\n");
|
||||
return BLADERF_ERR_INVAL;
|
||||
}
|
||||
|
||||
CHECK_STATUS(dev->backend->config_gpio_read(dev, &gpio_val));
|
||||
|
||||
if (use_timestamps) {
|
||||
gpio_val |= BLADERF_GPIO_TIMESTAMP;
|
||||
} else {
|
||||
gpio_val &= ~BLADERF_GPIO_TIMESTAMP;
|
||||
}
|
||||
|
||||
CHECK_STATUS(dev->backend->config_gpio_write(dev, gpio_val));
|
||||
|
||||
board_data->module_format[dir] = format;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int perform_format_deconfig(struct bladerf *dev, bladerf_direction dir)
|
||||
{
|
||||
struct bladerf2_board_data *board_data = dev->board_data;
|
||||
|
||||
switch (dir) {
|
||||
case BLADERF_RX:
|
||||
case BLADERF_TX:
|
||||
/* We'll reconfigure the HW when we call perform_format_config,
|
||||
* so we just need to update our stored information */
|
||||
board_data->module_format[dir] = -1;
|
||||
break;
|
||||
|
||||
default:
|
||||
log_debug("%s: Invalid direction: %d\n", __FUNCTION__, dir);
|
||||
return BLADERF_ERR_INVAL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************/
|
||||
/* Size checks */
|
||||
/******************************************************************************/
|
||||
|
||||
bool is_valid_fpga_size(bladerf_fpga_size fpga, size_t len)
|
||||
{
|
||||
/* We do not build FPGAs with compression enabled. Therfore, they
|
||||
* will always have a fixed file size.
|
||||
*/
|
||||
size_t const FPGA_SIZE_XA4 = (2632660);
|
||||
size_t const FPGA_SIZE_XA9 = (12858972);
|
||||
char const env_override[] = "BLADERF_SKIP_FPGA_SIZE_CHECK";
|
||||
|
||||
bool valid;
|
||||
size_t expected;
|
||||
|
||||
switch (fpga) {
|
||||
case BLADERF_FPGA_A4:
|
||||
expected = FPGA_SIZE_XA4;
|
||||
break;
|
||||
|
||||
case BLADERF_FPGA_A9:
|
||||
expected = FPGA_SIZE_XA9;
|
||||
break;
|
||||
|
||||
default:
|
||||
expected = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Provide a means to override this check. This is intended to allow
|
||||
* folks who know what they're doing to work around this quickly without
|
||||
* needing to make a code change. (e.g., someone building a custom FPGA
|
||||
* image that enables compressoin) */
|
||||
if (getenv(env_override)) {
|
||||
log_info("Overriding FPGA size check per %s\n", env_override);
|
||||
valid = true;
|
||||
} else if (expected > 0) {
|
||||
valid = (len == expected);
|
||||
} else {
|
||||
log_debug("Unknown FPGA type (%d). Using relaxed size criteria.\n",
|
||||
fpga);
|
||||
|
||||
if (len < (1 * 1024 * 1024)) {
|
||||
valid = false;
|
||||
} else if (len > BLADERF_FLASH_BYTE_LEN_FPGA) {
|
||||
valid = false;
|
||||
} else {
|
||||
valid = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!valid) {
|
||||
log_warning("Detected potentially incorrect FPGA file (length was %d, "
|
||||
"expected %d).\n",
|
||||
len, expected);
|
||||
|
||||
log_debug("If you are certain this file is valid, you may define\n"
|
||||
"BLADERF_SKIP_FPGA_SIZE_CHECK in your environment to skip "
|
||||
"this check.\n\n");
|
||||
}
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
||||
bool is_valid_fw_size(size_t len)
|
||||
{
|
||||
/* Simple FW applications generally are significantly larger than this
|
||||
*/
|
||||
if (len < (50 * 1024)) {
|
||||
return false;
|
||||
} else if (len > BLADERF_FLASH_BYTE_LEN_FIRMWARE) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bladerf_tuning_mode default_tuning_mode(struct bladerf *dev)
|
||||
{
|
||||
struct bladerf2_board_data *board_data = dev->board_data;
|
||||
bladerf_tuning_mode mode;
|
||||
char const *env_var;
|
||||
|
||||
if (have_cap(board_data->capabilities, BLADERF_CAP_FPGA_TUNING)) {
|
||||
mode = BLADERF_TUNING_MODE_FPGA;
|
||||
} else {
|
||||
mode = BLADERF_TUNING_MODE_HOST;
|
||||
}
|
||||
|
||||
env_var = getenv("BLADERF_DEFAULT_TUNING_MODE");
|
||||
|
||||
if (env_var != NULL) {
|
||||
if (!strcasecmp("host", env_var)) {
|
||||
mode = BLADERF_TUNING_MODE_HOST;
|
||||
} else if (!strcasecmp("fpga", env_var)) {
|
||||
/* Capability check */
|
||||
if (!have_cap(board_data->capabilities, BLADERF_CAP_FPGA_TUNING)) {
|
||||
log_error("The loaded FPGA version (%u.%u.%u) does not support "
|
||||
"the tuning mode being used to override the default. "
|
||||
"Ignoring BLADERF_DEFAULT_TUNING_MODE.\n",
|
||||
board_data->fpga_version.major,
|
||||
board_data->fpga_version.minor,
|
||||
board_data->fpga_version.patch);
|
||||
} else {
|
||||
mode = BLADERF_TUNING_MODE_FPGA;
|
||||
}
|
||||
} else {
|
||||
log_debug("Invalid tuning mode override: %s\n", env_var);
|
||||
}
|
||||
}
|
||||
|
||||
switch (mode) {
|
||||
case BLADERF_TUNING_MODE_HOST:
|
||||
log_debug("Default tuning mode: Host\n");
|
||||
break;
|
||||
case BLADERF_TUNING_MODE_FPGA:
|
||||
log_debug("Default tuning mode: FPGA\n");
|
||||
break;
|
||||
default:
|
||||
assert(!"Bug encountered.");
|
||||
mode = BLADERF_TUNING_MODE_HOST;
|
||||
}
|
||||
|
||||
return mode;
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************/
|
||||
/* Misc */
|
||||
/******************************************************************************/
|
||||
|
||||
bool check_total_sample_rate(struct bladerf *dev)
|
||||
{
|
||||
int status;
|
||||
uint32_t reg;
|
||||
size_t i;
|
||||
|
||||
bladerf_sample_rate rate_accum = 0;
|
||||
size_t active_channels = 0;
|
||||
|
||||
const bladerf_sample_rate MAX_SAMPLE_THROUGHPUT = 80000000;
|
||||
|
||||
/* Read RFFE control register */
|
||||
status = dev->backend->rffe_control_read(dev, ®);
|
||||
if (status < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Accumulate sample rates for all channels */
|
||||
if (_rffe_dir_enabled(reg, BLADERF_RX)) {
|
||||
bladerf_sample_rate rx_rate;
|
||||
|
||||
status =
|
||||
dev->board->get_sample_rate(dev, BLADERF_CHANNEL_RX(0), &rx_rate);
|
||||
if (status < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (i = 0; i < dev->board->get_channel_count(dev, BLADERF_RX); ++i) {
|
||||
if (_rffe_ch_enabled(reg, BLADERF_CHANNEL_RX(i))) {
|
||||
rate_accum += rx_rate;
|
||||
++active_channels;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (_rffe_dir_enabled(reg, BLADERF_TX)) {
|
||||
bladerf_sample_rate tx_rate;
|
||||
|
||||
status =
|
||||
dev->board->get_sample_rate(dev, BLADERF_CHANNEL_TX(0), &tx_rate);
|
||||
if (status < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (i = 0; i < dev->board->get_channel_count(dev, BLADERF_TX); ++i) {
|
||||
if (_rffe_ch_enabled(reg, BLADERF_CHANNEL_TX(i))) {
|
||||
rate_accum += tx_rate;
|
||||
++active_channels;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
log_verbose("%s: active_channels=%d, rate_accum=%d, maximum=%d\n",
|
||||
__FUNCTION__, active_channels, rate_accum,
|
||||
MAX_SAMPLE_THROUGHPUT);
|
||||
|
||||
if (rate_accum > MAX_SAMPLE_THROUGHPUT) {
|
||||
log_warning("The total sample throughput for the %d active channel%s, "
|
||||
"%g Msps, is greater than the recommended maximum sample "
|
||||
"throughput, %g Msps. You may experience dropped samples "
|
||||
"unless the sample rate is reduced, or some channels are "
|
||||
"deactivated.\n",
|
||||
active_channels, (active_channels == 1 ? "" : "s"),
|
||||
rate_accum / 1e6, MAX_SAMPLE_THROUGHPUT / 1e6);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool does_rffe_dir_have_enabled_ch(uint32_t reg, bladerf_direction dir)
|
||||
{
|
||||
switch (dir) {
|
||||
case BLADERF_RX:
|
||||
return _rffe_ch_enabled(reg, BLADERF_CHANNEL_RX(0)) ||
|
||||
_rffe_ch_enabled(reg, BLADERF_CHANNEL_RX(1));
|
||||
case BLADERF_TX:
|
||||
return _rffe_ch_enabled(reg, BLADERF_CHANNEL_TX(0)) ||
|
||||
_rffe_ch_enabled(reg, BLADERF_CHANNEL_TX(1));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
int get_gain_offset(struct bladerf *dev, bladerf_channel ch, float *offset)
|
||||
{
|
||||
CHECK_BOARD_STATE(STATE_INITIALIZED);
|
||||
NULL_CHECK(offset);
|
||||
|
||||
struct bladerf_gain_range const *ranges = NULL;
|
||||
bladerf_frequency frequency = 0;
|
||||
size_t i, ranges_len;
|
||||
|
||||
if (BLADERF_CHANNEL_IS_TX(ch)) {
|
||||
ranges = bladerf2_tx_gain_ranges;
|
||||
ranges_len = ARRAY_SIZE(bladerf2_tx_gain_ranges);
|
||||
} else {
|
||||
ranges = bladerf2_rx_gain_ranges;
|
||||
ranges_len = ARRAY_SIZE(bladerf2_rx_gain_ranges);
|
||||
}
|
||||
|
||||
CHECK_STATUS(dev->board->get_frequency(dev, ch, &frequency));
|
||||
|
||||
for (i = 0; i < ranges_len; ++i) {
|
||||
struct bladerf_gain_range const *r = &(ranges[i]);
|
||||
struct bladerf_range const *rfreq = &(r->frequency);
|
||||
|
||||
// if the frequency range matches, and the range name is null,
|
||||
// then we found our match
|
||||
if (is_within_range(rfreq, frequency) && (NULL == r->name)) {
|
||||
*offset = r->offset;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return BLADERF_ERR_INVAL;
|
||||
}
|
||||
359
host/libraries/libbladeRF/src/board/bladerf2/common.h
Normal file
359
host/libraries/libbladeRF/src/board/bladerf2/common.h
Normal file
|
|
@ -0,0 +1,359 @@
|
|||
/*
|
||||
* 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 BLADERF2_COMMON_H_
|
||||
#define BLADERF2_COMMON_H_
|
||||
|
||||
#if !defined(BLADERF_NIOS_BUILD) && !defined(BLADERF_NIOS_PC_SIMULATION)
|
||||
#include "log.h"
|
||||
#endif
|
||||
|
||||
#include "bladerf2_common.h"
|
||||
#include "helpers/version.h"
|
||||
#include "streaming/sync.h"
|
||||
|
||||
|
||||
/******************************************************************************/
|
||||
/* Types */
|
||||
/******************************************************************************/
|
||||
|
||||
enum bladerf2_vctcxo_trim_source {
|
||||
TRIM_SOURCE_NONE,
|
||||
TRIM_SOURCE_TRIM_DAC,
|
||||
TRIM_SOURCE_PLL,
|
||||
TRIM_SOURCE_AUXDAC
|
||||
};
|
||||
|
||||
struct bladerf2_board_data {
|
||||
/* Board state */
|
||||
enum {
|
||||
STATE_UNINITIALIZED,
|
||||
STATE_FIRMWARE_LOADED,
|
||||
STATE_FPGA_LOADED,
|
||||
STATE_INITIALIZED,
|
||||
} state;
|
||||
|
||||
/* AD9361 PHY Handle */
|
||||
struct ad9361_rf_phy *phy;
|
||||
|
||||
/* Bitmask of capabilities determined by version numbers */
|
||||
uint64_t capabilities;
|
||||
|
||||
/* Format currently being used with a module, or -1 if module is not used */
|
||||
bladerf_format module_format[NUM_MODULES];
|
||||
|
||||
/* Which mode of operation we use for tuning */
|
||||
bladerf_tuning_mode tuning_mode;
|
||||
|
||||
/* Board properties */
|
||||
bladerf_fpga_size fpga_size;
|
||||
/* Data message size */
|
||||
size_t msg_size;
|
||||
|
||||
/* Version information */
|
||||
struct bladerf_version fpga_version;
|
||||
struct bladerf_version fw_version;
|
||||
char fpga_version_str[BLADERF_VERSION_STR_MAX + 1];
|
||||
char fw_version_str[BLADERF_VERSION_STR_MAX + 1];
|
||||
|
||||
/* Synchronous interface handles */
|
||||
struct bladerf_sync sync[2];
|
||||
|
||||
/* TX Mute Status */
|
||||
bool tx_mute[2];
|
||||
|
||||
/* VCTCXO trim state */
|
||||
enum bladerf2_vctcxo_trim_source trim_source;
|
||||
uint16_t trimdac_last_value; /**< saved running value */
|
||||
uint16_t trimdac_stored_value; /**< cached value read from SPI flash */
|
||||
|
||||
/* RFIC FIR Filter status */
|
||||
bool low_samplerate_mode;
|
||||
bladerf_rfic_rxfir rxfir, rxfir_orig;
|
||||
bladerf_rfic_txfir txfir, txfir_orig;
|
||||
|
||||
/* Quick Tune Profile Status */
|
||||
uint16_t quick_tune_tx_profile;
|
||||
uint16_t quick_tune_rx_profile;
|
||||
};
|
||||
|
||||
struct bladerf_rfic_status_register {
|
||||
bool rfic_initialized;
|
||||
size_t write_queue_length;
|
||||
};
|
||||
|
||||
|
||||
/******************************************************************************/
|
||||
/* Externs */
|
||||
/******************************************************************************/
|
||||
|
||||
extern AD9361_InitParam bladerf2_rfic_init_params;
|
||||
extern AD9361_RXFIRConfig bladerf2_rfic_rx_fir_config;
|
||||
extern AD9361_TXFIRConfig bladerf2_rfic_tx_fir_config;
|
||||
extern AD9361_RXFIRConfig bladerf2_rfic_rx_fir_config_dec2;
|
||||
extern AD9361_TXFIRConfig bladerf2_rfic_tx_fir_config_int2;
|
||||
extern AD9361_RXFIRConfig bladerf2_rfic_rx_fir_config_dec4;
|
||||
extern AD9361_TXFIRConfig bladerf2_rfic_tx_fir_config_int4;
|
||||
extern const float ina219_r_shunt;
|
||||
|
||||
|
||||
/******************************************************************************/
|
||||
/* Constants */
|
||||
/******************************************************************************/
|
||||
|
||||
char const *bladerf2_state_to_string[4];
|
||||
|
||||
|
||||
/******************************************************************************/
|
||||
/* Macros */
|
||||
/******************************************************************************/
|
||||
|
||||
/* Macro for logging and returning an error status. This should be used for
|
||||
* errors defined in the \ref RETCODES list. */
|
||||
#define RETURN_ERROR_STATUS(_what, _status) \
|
||||
do { \
|
||||
log_error("%s: %s failed: %s\n", __FUNCTION__, _what, \
|
||||
bladerf_strerror(_status)); \
|
||||
return _status; \
|
||||
} while (0)
|
||||
|
||||
/* Macro for converting, logging, and returning libad9361 error codes. */
|
||||
#define RETURN_ERROR_AD9361(_what, _status) \
|
||||
do { \
|
||||
RETURN_ERROR_STATUS(_what, errno_ad9361_to_bladerf(_status)); \
|
||||
} while (0)
|
||||
|
||||
/* Macro for logging and returning ::BLADERF_ERR_INVAL */
|
||||
#define RETURN_INVAL_ARG(_what, _arg, _why) \
|
||||
do { \
|
||||
log_error("%s: %s '%s' invalid: %s\n", __FUNCTION__, _what, _arg, \
|
||||
_why); \
|
||||
return BLADERF_ERR_INVAL; \
|
||||
} while (0)
|
||||
|
||||
#define RETURN_INVAL(_what, _why) \
|
||||
do { \
|
||||
log_error("%s: %s invalid: %s\n", __FUNCTION__, _what, _why); \
|
||||
return BLADERF_ERR_INVAL; \
|
||||
} while (0)
|
||||
|
||||
/**
|
||||
* @brief Null test
|
||||
*
|
||||
* @param _var The variable to check
|
||||
*
|
||||
* @return RETURN_INVAL if _var is null, continues otherwise
|
||||
*/
|
||||
#define NULL_CHECK(_var) \
|
||||
do { \
|
||||
if (NULL == _var) { \
|
||||
RETURN_INVAL(#_var, "is null"); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/**
|
||||
* @brief Null test, with mutex unlock on failure
|
||||
*
|
||||
* @param _var The variable to check
|
||||
*
|
||||
* @return RETURN_INVAL if _var is null, continues otherwise
|
||||
*/
|
||||
#define NULL_CHECK_LOCKED(_var) \
|
||||
do { \
|
||||
NULL_CHECK(dev); \
|
||||
\
|
||||
if (NULL == _var) { \
|
||||
MUTEX_UNLOCK(__lock); \
|
||||
RETURN_INVAL(#_var, "is null"); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/**
|
||||
* @brief Board state check
|
||||
*
|
||||
* @param _state Minimum sufficient board state
|
||||
*
|
||||
* @return BLADERF_ERR_NOT_INIT if board's state is less than _state, continues
|
||||
* otherwise
|
||||
*/
|
||||
#define CHECK_BOARD_STATE(_state) \
|
||||
do { \
|
||||
NULL_CHECK(dev); \
|
||||
NULL_CHECK(dev->board); \
|
||||
\
|
||||
struct bladerf2_board_data *_bd = dev->board_data; \
|
||||
\
|
||||
if (_bd->state < _state) { \
|
||||
log_error("%s: Board state insufficient for operation " \
|
||||
"(current \"%s\", requires \"%s\").\n", \
|
||||
__FUNCTION__, bladerf2_state_to_string[_bd->state], \
|
||||
bladerf2_state_to_string[_state]); \
|
||||
\
|
||||
return BLADERF_ERR_NOT_INIT; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/**
|
||||
* @brief Test if board is a bladeRF 2
|
||||
*
|
||||
* @param _dev Device handle
|
||||
*
|
||||
* @return BLADERF_ERR_UNSUPPORTED if board is not a bladeRF 2, continues
|
||||
* otherwise
|
||||
*/
|
||||
#define CHECK_BOARD_IS_BLADERF2(_dev) \
|
||||
do { \
|
||||
NULL_CHECK(_dev); \
|
||||
NULL_CHECK(_dev->board); \
|
||||
\
|
||||
if (_dev->board != &bladerf2_board_fns) { \
|
||||
log_error("%s: Board type \"%s\" not supported\n", __FUNCTION__, \
|
||||
_dev->board->name); \
|
||||
return BLADERF_ERR_UNSUPPORTED; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/**
|
||||
* @brief Call a function and return early if it fails
|
||||
*
|
||||
* @param _fn The function
|
||||
*
|
||||
* @return function return value if less than zero; continues otherwise
|
||||
*/
|
||||
#define CHECK_STATUS(_fn) \
|
||||
do { \
|
||||
int _s = _fn; \
|
||||
if (_s < 0) { \
|
||||
RETURN_ERROR_STATUS(#_fn, _s); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/**
|
||||
* @brief Call a function and, if it fails, unlock the mutex and return
|
||||
*
|
||||
* @param _fn The function
|
||||
*
|
||||
* @return function return value if less than zero; continues otherwise
|
||||
*/
|
||||
#define CHECK_STATUS_LOCKED(_fn) \
|
||||
do { \
|
||||
int _s = _fn; \
|
||||
if (_s < 0) { \
|
||||
MUTEX_UNLOCK(__lock); \
|
||||
RETURN_ERROR_STATUS(#_fn, _s); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/**
|
||||
* @brief Call a function and return early if it fails, with error translation
|
||||
* from AD936x to bladeRF return codes
|
||||
*
|
||||
* @param _fn The function
|
||||
*
|
||||
* @return function return value if less than zero; continues otherwise
|
||||
*/
|
||||
#define CHECK_AD936X(_fn) \
|
||||
do { \
|
||||
int _s = _fn; \
|
||||
if (_s < 0) { \
|
||||
RETURN_ERROR_AD9361(#_fn, _s); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/**
|
||||
* @brief Call a function and, if it fails, unlock the mutex and return, with
|
||||
* error translation from AD936x to bladeRF return codes
|
||||
*
|
||||
* @param _fn The function
|
||||
*
|
||||
* @return function return value if less than zero; continues otherwise
|
||||
*/
|
||||
#define CHECK_AD936X_LOCKED(_fn) \
|
||||
do { \
|
||||
int _s = _fn; \
|
||||
if (_s < 0) { \
|
||||
MUTEX_UNLOCK(__lock); \
|
||||
RETURN_ERROR_AD9361(#_fn, _s); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/**
|
||||
* @brief Execute a command block with a mutex lock
|
||||
*
|
||||
* @note Variables declared within the including scope must be declared
|
||||
* one-per-line.
|
||||
*
|
||||
* @param _lock Lock to hold
|
||||
* @param _thing Block to execute
|
||||
*/
|
||||
#define WITH_MUTEX(_lock, _thing) \
|
||||
do { \
|
||||
MUTEX *__lock = _lock; \
|
||||
\
|
||||
MUTEX_LOCK(__lock); \
|
||||
_thing; \
|
||||
MUTEX_UNLOCK(__lock); \
|
||||
} while (0)
|
||||
|
||||
|
||||
/******************************************************************************/
|
||||
/* Functions */
|
||||
/******************************************************************************/
|
||||
|
||||
/**
|
||||
* Perform the neccessary device configuration for the specified format
|
||||
* (e.g., enabling/disabling timestamp support), first checking that the
|
||||
* requested format would not conflict with the other stream direction.
|
||||
*
|
||||
* @param dev Device handle
|
||||
* @param[in] dir Direction that is currently being configured
|
||||
* @param[in] format Format the channel is being configured for
|
||||
*
|
||||
* @return 0 on success, BLADERF_ERR_* on failure
|
||||
*/
|
||||
int perform_format_config(struct bladerf *dev,
|
||||
bladerf_direction dir,
|
||||
bladerf_format format);
|
||||
|
||||
/**
|
||||
* Deconfigure and update any state pertaining what a format that a stream
|
||||
* direction is no longer using.
|
||||
*
|
||||
* @param dev Device handle
|
||||
* @param[in] dir Direction that is currently being deconfigured
|
||||
*
|
||||
* @return 0 on success, BLADERF_ERR_* on failure
|
||||
*/
|
||||
int perform_format_deconfig(struct bladerf *dev, bladerf_direction dir);
|
||||
|
||||
bool is_valid_fpga_size(bladerf_fpga_size fpga, size_t len);
|
||||
|
||||
bool is_valid_fw_size(size_t len);
|
||||
|
||||
bladerf_tuning_mode default_tuning_mode(struct bladerf *dev);
|
||||
|
||||
bool check_total_sample_rate(struct bladerf *dev);
|
||||
|
||||
bool does_rffe_dir_have_enabled_ch(uint32_t reg, bladerf_direction dir);
|
||||
|
||||
int get_gain_offset(struct bladerf *dev, bladerf_channel ch, float *offset);
|
||||
|
||||
#endif // BLADERF2_COMMON_H_
|
||||
Loading…
Add table
Add a link
Reference in a new issue