h1r9: stop writing MAX2837 registers to MAX2839

This commit is contained in:
Michael Ossmann
2022-09-19 09:58:48 -04:00
committed by Mike Walters
parent f4817b60a3
commit edd0a80812
3 changed files with 95 additions and 38 deletions

View File

@ -30,11 +30,11 @@
#include "hackrf_ui.h"
#include "gpio_lpc.h"
#include "platform_detect.h"
#include <mixer.h>
#include <max2837.h>
#include <max5864.h>
#include <sgpio.h>
#include "mixer.h"
#include "max2837.h"
#include "max2839.h"
#include "max5864.h"
#include "sgpio.h"
#if (defined JAWBREAKER || defined HACKRF_ONE || defined RAD1O)
/*
@ -370,11 +370,12 @@ void rf_path_init(rf_path_t* const rf_path)
max5864_setup(&max5864);
max5864_shutdown(&max5864);
ssp1_set_mode_max2837();
if (detected_platform() == BOARD_ID_HACKRF1_R9) {
ssp1_set_mode_max2839();
max2839_setup(&max2839);
max2839_start(&max2839);
} else {
ssp1_set_mode_max2837();
max2837_setup(&max2837);
max2837_start(&max2837);
}
@ -405,8 +406,13 @@ void rf_path_set_direction(rf_path_t* const rf_path, const rf_path_direction_t d
}
ssp1_set_mode_max5864();
max5864_tx(&max5864);
if (detected_platform() == BOARD_ID_HACKRF1_R9) {
ssp1_set_mode_max2839();
max2839_tx(&max2839);
} else {
ssp1_set_mode_max2837();
max2837_tx(&max2837);
}
sgpio_configure(&sgpio_config, SGPIO_DIRECTION_TX);
break;
@ -424,8 +430,13 @@ void rf_path_set_direction(rf_path_t* const rf_path, const rf_path_direction_t d
}
ssp1_set_mode_max5864();
max5864_rx(&max5864);
if (detected_platform() == BOARD_ID_HACKRF1_R9) {
ssp1_set_mode_max2839();
max2839_rx(&max2839);
} else {
ssp1_set_mode_max2837();
max2837_rx(&max2837);
}
sgpio_configure(&sgpio_config, SGPIO_DIRECTION_RX);
break;
@ -440,8 +451,13 @@ void rf_path_set_direction(rf_path_t* const rf_path, const rf_path_direction_t d
mixer_disable(&mixer);
ssp1_set_mode_max5864();
max5864_standby(&max5864);
if (detected_platform() == BOARD_ID_HACKRF1_R9) {
ssp1_set_mode_max2839();
max2839_set_mode(&max2839, MAX2839_MODE_STANDBY);
} else {
ssp1_set_mode_max2837();
max2837_set_mode(&max2837, MAX2837_MODE_STANDBY);
}
sgpio_configure(&sgpio_config, SGPIO_DIRECTION_RX);
break;
}

View File

@ -22,14 +22,14 @@
*/
#include "tuning.h"
#include "hackrf_ui.h"
#include <hackrf_core.h>
#include <mixer.h>
#include <max2837.h>
#include <sgpio.h>
#include <operacake.h>
#include "hackrf_core.h"
#include "mixer.h"
#include "max2837.h"
#include "max2839.h"
#include "sgpio.h"
#include "operacake.h"
#include "platform_detect.h"
#define FREQ_ONE_MHZ (1000ULL * 1000)
@ -70,8 +70,15 @@ bool set_freq(const uint64_t freq)
success = true;
const max2837_mode_t prior_max2837_mode = max2837_mode(&max2837);
max2839_mode_t prior_max2839_mode = MAX2839_MODE_STANDBY;
max2837_mode_t prior_max2837_mode = MAX2837_MODE_STANDBY;
if (detected_platform() == BOARD_ID_HACKRF1_R9) {
prior_max2839_mode = max2839_mode(&max2839);
max2839_set_mode(&max2839, MAX2839_MODE_STANDBY);
} else {
prior_max2837_mode = max2837_mode(&max2837);
max2837_set_mode(&max2837, MAX2837_MODE_STANDBY);
}
if (freq_mhz < MAX_LP_FREQ_MHZ) {
rf_path_set_filter(&rf_path, RF_PATH_FILTER_LOW_PASS);
#ifdef RAD1O
@ -83,13 +90,21 @@ bool set_freq(const uint64_t freq)
mixer_freq_mhz = (max2837_freq_nominal_hz / FREQ_ONE_MHZ) + freq_mhz;
/* Set Freq and read real freq */
real_mixer_freq_hz = mixer_set_frequency(&mixer, mixer_freq_mhz);
if (detected_platform() == BOARD_ID_HACKRF1_R9) {
max2839_set_frequency(&max2839, real_mixer_freq_hz - freq);
} else {
max2837_set_frequency(&max2837, real_mixer_freq_hz - freq);
}
sgpio_cpld_stream_rx_set_q_invert(&sgpio_config, 1);
} else if ((freq_mhz >= MIN_BYPASS_FREQ_MHZ) && (freq_mhz < MAX_BYPASS_FREQ_MHZ)) {
rf_path_set_filter(&rf_path, RF_PATH_FILTER_BYPASS);
MAX2837_freq_hz = (freq_mhz * FREQ_ONE_MHZ) + freq_hz;
/* mixer_freq_mhz <= not used in Bypass mode */
if (detected_platform() == BOARD_ID_HACKRF1_R9) {
max2839_set_frequency(&max2839, MAX2837_freq_hz);
} else {
max2837_set_frequency(&max2837, MAX2837_freq_hz);
}
sgpio_cpld_stream_rx_set_q_invert(&sgpio_config, 0);
} else if ((freq_mhz >= MIN_HP_FREQ_MHZ) && (freq_mhz <= MAX_HP_FREQ_MHZ)) {
if (freq_mhz < MID1_HP_FREQ_MHZ) {
@ -110,13 +125,21 @@ bool set_freq(const uint64_t freq)
mixer_freq_mhz = freq_mhz - (max2837_freq_nominal_hz / FREQ_ONE_MHZ);
/* Set Freq and read real freq */
real_mixer_freq_hz = mixer_set_frequency(&mixer, mixer_freq_mhz);
if (detected_platform() == BOARD_ID_HACKRF1_R9) {
max2839_set_frequency(&max2839, freq - real_mixer_freq_hz);
} else {
max2837_set_frequency(&max2837, freq - real_mixer_freq_hz);
}
sgpio_cpld_stream_rx_set_q_invert(&sgpio_config, 0);
} else {
/* Error freq_mhz too high */
success = false;
}
if (detected_platform() == BOARD_ID_HACKRF1_R9) {
max2839_set_mode(&max2839, prior_max2839_mode);
} else {
max2837_set_mode(&max2837, prior_max2837_mode);
}
if (success) {
freq_cache = freq;
hackrf_ui()->set_frequency(freq);
@ -147,7 +170,11 @@ bool set_freq_explicit(
}
rf_path_set_filter(&rf_path, path);
if (detected_platform() == BOARD_ID_HACKRF1_R9) {
max2839_set_frequency(&max2839, if_freq_hz);
} else {
max2837_set_frequency(&max2837, if_freq_hz);
}
if (lo_freq_hz > if_freq_hz) {
sgpio_cpld_stream_rx_set_q_invert(&sgpio_config, 1);
} else {

View File

@ -32,12 +32,14 @@
#include "usb_api_cpld.h" // Remove when CPLD update is handled elsewhere
#include <max2837.h>
#include <rf_path.h>
#include <tuning.h>
#include <streaming.h>
#include <usb.h>
#include <usb_queue.h>
#include "max2837.h"
#include "max2839.h"
#include "rf_path.h"
#include "tuning.h"
#include "streaming.h"
#include "usb.h"
#include "usb_queue.h"
#include "platform_detect.h"
#include <stddef.h>
#include <string.h>
@ -163,8 +165,12 @@ usb_request_status_t usb_vendor_request_set_lna_gain(
const usb_transfer_stage_t stage)
{
if (stage == USB_TRANSFER_STAGE_SETUP) {
const uint8_t value =
max2837_set_lna_gain(&max2837, endpoint->setup.index);
uint8_t value;
if (detected_platform() == BOARD_ID_HACKRF1_R9) {
value = max2839_set_lna_gain(&max2839, endpoint->setup.index);
} else {
value = max2837_set_lna_gain(&max2837, endpoint->setup.index);
}
endpoint->buffer[0] = value;
if (value) {
hackrf_ui()->set_bb_lna_gain(endpoint->setup.index);
@ -186,8 +192,12 @@ usb_request_status_t usb_vendor_request_set_vga_gain(
const usb_transfer_stage_t stage)
{
if (stage == USB_TRANSFER_STAGE_SETUP) {
const uint8_t value =
max2837_set_vga_gain(&max2837, endpoint->setup.index);
uint8_t value;
if (detected_platform() == BOARD_ID_HACKRF1_R9) {
value = max2839_set_vga_gain(&max2839, endpoint->setup.index);
} else {
value = max2837_set_vga_gain(&max2837, endpoint->setup.index);
}
endpoint->buffer[0] = value;
if (value) {
hackrf_ui()->set_bb_vga_gain(endpoint->setup.index);
@ -209,8 +219,12 @@ usb_request_status_t usb_vendor_request_set_txvga_gain(
const usb_transfer_stage_t stage)
{
if (stage == USB_TRANSFER_STAGE_SETUP) {
const uint8_t value =
max2837_set_txvga_gain(&max2837, endpoint->setup.index);
uint8_t value;
if (detected_platform() == BOARD_ID_HACKRF1_R9) {
value = max2839_set_txvga_gain(&max2839, endpoint->setup.index);
} else {
value = max2837_set_txvga_gain(&max2837, endpoint->setup.index);
}
endpoint->buffer[0] = value;
if (value) {
hackrf_ui()->set_bb_tx_vga_gain(endpoint->setup.index);