mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2026-08-18 05:34:01 +00:00
8f5b25b10d
* fix clock init and add mayhem tx capacity * aligned external clock and RX config * fix(clock): cap TX interpolation to x16 to prevent doubled waveform speed The TX gateware only implements interpolation factors x1..x16 (tx_intrp 0..4), but the rate search could select n==5 (x32) for very low TX sample rates. That left the AFE/CLK0/CLK1 running at the x32 rate while the FPGA only interpolated by x16, clocking the TX datapath at twice the gateware output rate. Cap afe_rate and _resampling_n to the x16 limit in TX so the clocks stay aligned with the interpolation setting. * fix(praline): source PLL1 from 40MHz GP_CLKIN instead of 12MHz XTAL For the intermediate 90-110MHz PLL1 stepping stage, source PLL1 from GP_CLKIN (Si5351 CLK2/MCU_CLK at 40MHz) giving N=2, M=10, Fclk=100MHz, rather than the on-chip 12MHz XTAL bootstrap path. This matches the non-PRALINE path. Remove the dead commented-out XTAL enable/PLL code. * docs(fpga_bridge): correct register 0x03 description for PRALINE gateware Register 0x03 is RX_DIGITAL_GAIN in RX and TX_NCO_CTRL in TX, not RX_PSTEP. * Fix fpga_tx_set_nco_enable to use FPGA_REG3_TX_NCO_CTRL (0x03)
98 lines
2.8 KiB
C++
98 lines
2.8 KiB
C++
/*
|
|
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
|
|
* Copyright (C) 2016 Furrtek
|
|
* Copyright (C) 2023 Kyle Reed
|
|
*
|
|
* This file is part of PortaPack.
|
|
*
|
|
* 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 __TRANSMITTER_MODEL_H__
|
|
#define __TRANSMITTER_MODEL_H__
|
|
|
|
#include <cstdint>
|
|
#include <cstddef>
|
|
|
|
#include "app_settings.hpp"
|
|
#include "hackrf_hal.hpp"
|
|
#include "max2837.hpp"
|
|
#include "message.hpp"
|
|
#include "receiver_model.hpp"
|
|
#include "rf_path.hpp"
|
|
#include "signal.hpp"
|
|
|
|
class TransmitterModel {
|
|
public:
|
|
struct settings_t {
|
|
uint32_t baseband_bandwidth = max283x::filter::bandwidth_minimum;
|
|
uint32_t sampling_rate = 3'072'000;
|
|
uint32_t channel_bandwidth = 1;
|
|
/* Platform default chosen to avoid PRALINE MAX2831 overdrive while
|
|
* preserving legacy HackRF One behavior. */
|
|
uint8_t tx_gain_db = hackrf::one::default_tx_gain_db;
|
|
bool rf_amp = false;
|
|
};
|
|
|
|
/* The frequency to transmit on. */
|
|
rf::Frequency target_frequency() const;
|
|
void set_target_frequency(rf::Frequency f);
|
|
|
|
uint32_t baseband_bandwidth() const;
|
|
void set_baseband_bandwidth(uint32_t v);
|
|
|
|
// TODO: Doesn't actually affect radio.
|
|
uint32_t channel_bandwidth() const;
|
|
void set_channel_bandwidth(uint32_t v);
|
|
|
|
uint32_t sampling_rate() const;
|
|
void set_sampling_rate(uint32_t v);
|
|
|
|
uint8_t tx_gain() const;
|
|
void set_tx_gain(uint8_t v_db);
|
|
|
|
bool rf_amp() const;
|
|
void set_rf_amp(bool enabled);
|
|
|
|
void set_antenna_bias();
|
|
|
|
void enable();
|
|
void disable();
|
|
|
|
void initialize();
|
|
|
|
void configure_from_app_settings(const app_settings::AppSettings& settings);
|
|
|
|
/* Get access to the underlying settings to allow
|
|
* values to be set directly without calling update. */
|
|
settings_t& settings() { return settings_; }
|
|
|
|
private:
|
|
settings_t settings_{};
|
|
bool enabled_ = false;
|
|
SignalToken signal_token_tick_second{};
|
|
|
|
void update_tuning_frequency();
|
|
void update_baseband_bandwidth();
|
|
void update_sampling_rate();
|
|
void update_tx_gain();
|
|
void update_rf_amp();
|
|
void update_antenna_bias();
|
|
void on_tick_second();
|
|
};
|
|
|
|
#endif /*__TRANSMITTER_MODEL_H__*/
|