mirror of
https://github.com/greatscottgadgets/hackrf.git
synced 2026-02-19 16:22:52 +01:00
Implement bias tee with radio registers
This commit is contained in:
@@ -733,7 +733,7 @@ bool radio_update(radio_t* const radio)
|
||||
(1 << RADIO_GAIN_RX_IF) | (1 << RADIO_GAIN_RX_BB) | (1 << RADIO_OPMODE))) {
|
||||
gain = radio_update_gain(radio, &tmp_bank[0]);
|
||||
}
|
||||
if (dirty & (1 << RADIO_BIAS_TEE)) {
|
||||
if (dirty & ((1 << RADIO_BIAS_TEE) | (1 << RADIO_OPMODE))) {
|
||||
bias = radio_update_bias_tee(radio, &tmp_bank[0]);
|
||||
}
|
||||
if (dirty & (1 << RADIO_TRIGGER)) {
|
||||
|
||||
@@ -35,7 +35,6 @@
|
||||
#include "max283x.h"
|
||||
#include "max5864.h"
|
||||
#include "sgpio.h"
|
||||
#include "user_config.h"
|
||||
|
||||
#if (defined JAWBREAKER || defined HACKRF_ONE || defined RAD1O || defined PRALINE)
|
||||
/*
|
||||
@@ -467,9 +466,6 @@ void rf_path_set_direction(rf_path_t* const rf_path, const rf_path_direction_t d
|
||||
/* Turn off TX and RX amplifiers, then enable based on direction and bypass state. */
|
||||
rf_path->switchctrl |= SWITCHCTRL_NO_TX_AMP_PWR | SWITCHCTRL_NO_RX_AMP_PWR;
|
||||
|
||||
// Perform any user-requested actions for mode switch
|
||||
user_config_on_rf_path_direction_change(rf_path, direction);
|
||||
|
||||
switch (direction) {
|
||||
case RF_PATH_DIRECTION_TX:
|
||||
rf_path->switchctrl |= SWITCHCTRL_TX;
|
||||
|
||||
@@ -1,112 +0,0 @@
|
||||
/*
|
||||
* Copyright 2023 Jonathan Suite (GitHub: @ai6aj)
|
||||
*
|
||||
* This file is part of HackRF.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "user_config.h"
|
||||
|
||||
static user_config_user_opt_t user_direction_rx_bias_t_opts = RF_DIRECTION_USER_OPT_NOP;
|
||||
static user_config_user_opt_t user_direction_tx_bias_t_opts = RF_DIRECTION_USER_OPT_NOP;
|
||||
static user_config_user_opt_t user_direction_off_bias_t_opts =
|
||||
RF_DIRECTION_USER_OPT_CLEAR;
|
||||
|
||||
// Perform user-specified actions to Bias T power when transitioning modes
|
||||
static void _rf_path_handle_user_bias_t_action(rf_path_t* const rf_path, int action)
|
||||
{
|
||||
switch (action) {
|
||||
case RF_DIRECTION_USER_OPT_SET:
|
||||
rf_path_set_antenna(rf_path, 1);
|
||||
break;
|
||||
|
||||
case RF_DIRECTION_USER_OPT_CLEAR:
|
||||
rf_path_set_antenna(rf_path, 0);
|
||||
break;
|
||||
|
||||
case RF_DIRECTION_USER_OPT_NOP:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void user_config_on_rf_path_direction_change(
|
||||
rf_path_t* const rf_path,
|
||||
const rf_path_direction_t direction)
|
||||
{
|
||||
switch (direction) {
|
||||
case RF_PATH_DIRECTION_RX:
|
||||
_rf_path_handle_user_bias_t_action(rf_path, user_direction_rx_bias_t_opts);
|
||||
break;
|
||||
|
||||
case RF_PATH_DIRECTION_TX:
|
||||
_rf_path_handle_user_bias_t_action(rf_path, user_direction_tx_bias_t_opts);
|
||||
break;
|
||||
|
||||
case RF_PATH_DIRECTION_OFF:
|
||||
default:
|
||||
_rf_path_handle_user_bias_t_action(
|
||||
rf_path,
|
||||
user_direction_off_bias_t_opts);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void user_config_set_bias_t_opt(
|
||||
const rf_path_direction_t direction,
|
||||
const user_config_user_opt_t option)
|
||||
{
|
||||
switch (direction) {
|
||||
case RF_PATH_DIRECTION_RX:
|
||||
user_direction_rx_bias_t_opts = option;
|
||||
break;
|
||||
|
||||
case RF_PATH_DIRECTION_TX:
|
||||
user_direction_tx_bias_t_opts = option;
|
||||
break;
|
||||
|
||||
case RF_PATH_DIRECTION_OFF:
|
||||
user_direction_off_bias_t_opts = option;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Bias T options are set as follows:
|
||||
Bits 0,1: One of NOP (0), CLEAR (0b10), or SET (0b11)
|
||||
Bit 2: 1=Set OFF behavior according to bits 0,1 0=Don't change
|
||||
Bits 3,4: One of NOP (0), CLEAR (0b10), or SET (0b11)
|
||||
Bit 5: 1=Set RX behavior according to bits 0,1 0=Don't change
|
||||
Bits 6,7: One of NOP (0), CLEAR (0b10), or SET (0b11)
|
||||
Bit 8: 1=Set TX behavior according to bits 0,1 0=Don't change
|
||||
Bits 9-15: Ignored; set to 0
|
||||
*/
|
||||
void user_config_set_bias_t_opts(uint16_t value)
|
||||
{
|
||||
if (value & 0x4) {
|
||||
user_config_set_bias_t_opt(RF_PATH_DIRECTION_OFF, value & 0x3);
|
||||
}
|
||||
if (value & 0x20) {
|
||||
user_config_set_bias_t_opt(RF_PATH_DIRECTION_RX, (value & 0x18) >> 3);
|
||||
}
|
||||
if (value & 0x100) {
|
||||
user_config_set_bias_t_opt(RF_PATH_DIRECTION_TX, (value & 0xC0) >> 6);
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
* Copyright 2023 Jonathan Suite (GitHub: @ai6aj)
|
||||
*
|
||||
* This file is part of HackRF.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __USER_CONFIG_H__
|
||||
#define __USER_CONFIG_H__
|
||||
|
||||
#include "rf_path.h"
|
||||
|
||||
typedef enum {
|
||||
RF_DIRECTION_USER_OPT_NOP, // No OPeration / Ignore the thing
|
||||
RF_DIRECTION_USER_OPT_RESERVED, // Currently a NOP
|
||||
RF_DIRECTION_USER_OPT_CLEAR, // Clear/Disable the thing
|
||||
RF_DIRECTION_USER_OPT_SET, // Set/Enable the thing
|
||||
} user_config_user_opt_t;
|
||||
|
||||
void user_config_set_bias_t_opt(
|
||||
const rf_path_direction_t direction,
|
||||
const user_config_user_opt_t action);
|
||||
void user_config_set_bias_t_opts(uint16_t value);
|
||||
|
||||
void user_config_on_rf_path_direction_change(
|
||||
rf_path_t* const rf_path,
|
||||
const rf_path_direction_t direction);
|
||||
|
||||
#endif
|
||||
@@ -187,7 +187,6 @@ macro(DeclareTargets)
|
||||
${PATH_HACKRF_FIRMWARE_COMMON}/firmware_info.c
|
||||
${PATH_HACKRF_FIRMWARE_COMMON}/clkin.c
|
||||
${PATH_HACKRF_FIRMWARE_COMMON}/gpdma.c
|
||||
${PATH_HACKRF_FIRMWARE_COMMON}/user_config.c
|
||||
${PATH_HACKRF_FIRMWARE_COMMON}/radio.c
|
||||
${PATH_HACKRF_FIRMWARE_COMMON}/selftest.c
|
||||
${PATH_HACKRF_FIRMWARE_COMMON}/m0_state.c
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright 2012-2026 Great Scott Gadgets <info@greatscottgadgets.com>
|
||||
* Copyright 2023 Jonathan Suite (GitHub: @ai6aj)
|
||||
* Copyright 2012 Jared Boone
|
||||
* Copyright 2013 Benjamin Vernoux
|
||||
*
|
||||
@@ -22,7 +23,6 @@
|
||||
*/
|
||||
|
||||
#include "usb_api_register.h"
|
||||
#include <user_config.h>
|
||||
#include <hackrf_core.h>
|
||||
#include <usb_queue.h>
|
||||
#include <max2831.h>
|
||||
@@ -241,12 +241,46 @@ usb_request_status_t usb_vendor_request_set_leds(
|
||||
return USB_REQUEST_STATUS_OK;
|
||||
}
|
||||
|
||||
typedef enum {
|
||||
BIAS_TEE_OPT_NOP = 0, // No OPeration / Ignore the thing
|
||||
BIAS_TEE_OPT_RESERVED = 1, // Currently a NOP
|
||||
BIAS_TEE_OPT_CLEAR = 2, // Clear/Disable the thing
|
||||
BIAS_TEE_OPT_SET = 3, // Set/Enable the thing
|
||||
} bias_tee_opt_t;
|
||||
|
||||
static void set_bias_tee_opt(const uint8_t bank, const bias_tee_opt_t option)
|
||||
{
|
||||
uint64_t value;
|
||||
|
||||
switch (option) {
|
||||
case BIAS_TEE_OPT_CLEAR:
|
||||
value = (uint64_t) false;
|
||||
break;
|
||||
case BIAS_TEE_OPT_SET:
|
||||
value = (uint64_t) true;
|
||||
break;
|
||||
default:
|
||||
value = RADIO_UNSET;
|
||||
}
|
||||
|
||||
radio_reg_write(&radio, bank, RADIO_BIAS_TEE, value);
|
||||
}
|
||||
|
||||
usb_request_status_t usb_vendor_request_user_config_set_bias_t_opts(
|
||||
usb_endpoint_t* const endpoint,
|
||||
const usb_transfer_stage_t stage)
|
||||
{
|
||||
if (stage == USB_TRANSFER_STAGE_SETUP) {
|
||||
user_config_set_bias_t_opts(endpoint->setup.value);
|
||||
uint16_t value = endpoint->setup.value;
|
||||
if (value & 0x4) {
|
||||
set_bias_tee_opt(RADIO_BANK_IDLE, value & 0x3);
|
||||
}
|
||||
if (value & 0x20) {
|
||||
set_bias_tee_opt(RADIO_BANK_RX, (value & 0x18) >> 3);
|
||||
}
|
||||
if (value & 0x100) {
|
||||
set_bias_tee_opt(RADIO_BANK_TX, (value & 0xC0) >> 6);
|
||||
}
|
||||
usb_transfer_schedule_ack(endpoint->in);
|
||||
}
|
||||
return USB_REQUEST_STATUS_OK;
|
||||
|
||||
Reference in New Issue
Block a user