multiple sample rate

soapy api multiple options for sample rate in the modem. supported by firmware
bug_fixes_integration_tx
David Michaeli 2023-05-16 16:28:08 +03:00
rodzic 8f446598e0
commit 09d5832a30
3 zmienionych plików z 88 dodań i 4 usunięć

43
firmware/lvds_tx.v 100644
Wyświetl plik

@ -0,0 +1,43 @@
module lvds_tx
(
input i_rst_b,
input i_ddr_clk,
output [1:0] o_ddr_data,
input i_fifo_empty,
output o_fifo_read_clk,
output o_fifo_pull,
input [31:0] i_fifo_data,
input i_sync_input,
output [1:0] o_debug_state );
// Internal Registers
reg [4:0] r_phase_count;
// Initial conditions
initial begin
r_phase_count = 5'b11111;
end
assign o_fifo_read_clk = i_ddr_clk;
// Main Process / shift register
always @(posedge i_ddr_clk)
begin
if (i_rst_b == 1'b0) begin
o_fifo_pull <= ~i_fifo_empty;
r_phase_count <= 5'b11111;
end else begin
if (r_phase_count == 5'b00001) begin
o_fifo_pull <= ~i_fifo_empty;
end else begin
o_fifo_pull <= 1'b0;
end
o_ddr_data <= i_fifo_data[r_phase_count:r_phase_count-1];
r_phase_count <= r_phase_count - 2;
end
end
endmodule

Wyświetl plik

@ -37,7 +37,7 @@ Cariboulite::Cariboulite(const SoapySDR::Kwargs &args)
//========================================================
Cariboulite::~Cariboulite()
{
SoapySDR_logf(SOAPY_SDR_INFO, "Desposing radio type '%d'", radio.type);
SoapySDR_logf(SOAPY_SDR_INFO, "Disposing radio type '%d'", radio.type);
cariboulite_radio_dispose(&radio);
if (stream) delete stream;
}
@ -234,31 +234,71 @@ bool Cariboulite::getGainMode( const int direction, const size_t channel ) const
******************************************************************/
void Cariboulite::setSampleRate( const int direction, const size_t channel, const double rate )
{
at86rf215_radio_sample_rate_en fs = at86rf215_radio_rx_sample_rate_4000khz;
at86rf215_radio_f_cut_en rx_cuttof = radio.rx_fcut;
at86rf215_radio_f_cut_en tx_cuttof = radio.tx_fcut;
if (fabs(rate - (400000)) < 1) fs = at86rf215_radio_rx_sample_rate_400khz;
if (fabs(rate - (500000)) < 1) fs = at86rf215_radio_rx_sample_rate_500khz;
if (fabs(rate - (666000)) < 1) fs = at86rf215_radio_rx_sample_rate_666khz;
if (fabs(rate - (800000)) < 1) fs = at86rf215_radio_rx_sample_rate_800khz;
if (fabs(rate - (1000000)) < 1) fs = at86rf215_radio_rx_sample_rate_1000khz;
if (fabs(rate - (1333000)) < 1) fs = at86rf215_radio_rx_sample_rate_1333khz;
if (fabs(rate - (2000000)) < 1) fs = at86rf215_radio_rx_sample_rate_2000khz;
if (fabs(rate - (4000000)) < 1) fs = at86rf215_radio_rx_sample_rate_4000khz;
//printf("setSampleRate dir: %d, channel: %ld, rate: %.2f\n", direction, channel, rate);
if (direction == SOAPY_SDR_RX)
{
cariboulite_radio_set_rx_samp_cutoff(&radio, at86rf215_radio_rx_sample_rate_4000khz, rx_cuttof);
cariboulite_radio_set_rx_samp_cutoff((cariboulite_radio_state_st*)&radio, fs, rx_cuttof);
}
else if (direction == SOAPY_SDR_TX)
{
cariboulite_radio_set_tx_samp_cutoff(&radio, at86rf215_radio_rx_sample_rate_4000khz, tx_cuttof);
cariboulite_radio_set_tx_samp_cutoff((cariboulite_radio_state_st*)&radio, fs, tx_cuttof);
}
}
//========================================================
double Cariboulite::getSampleRate( const int direction, const size_t channel ) const
{
at86rf215_radio_sample_rate_en fs = at86rf215_radio_rx_sample_rate_4000khz;
if (direction == SOAPY_SDR_RX)
{
cariboulite_radio_get_rx_samp_cutoff((cariboulite_radio_state_st*)&radio, &fs, NULL);
}
else if (direction == SOAPY_SDR_TX)
{
cariboulite_radio_get_tx_samp_cutoff((cariboulite_radio_state_st*)&radio, &fs, NULL);
}
switch(fs)
{
case at86rf215_radio_rx_sample_rate_4000khz: return 4000000;
case at86rf215_radio_rx_sample_rate_2000khz: return 2000000;
case at86rf215_radio_rx_sample_rate_1333khz: return 1333000;
case at86rf215_radio_rx_sample_rate_1000khz: return 1000000;
case at86rf215_radio_rx_sample_rate_800khz: return 800000;
case at86rf215_radio_rx_sample_rate_666khz: return 666000;
case at86rf215_radio_rx_sample_rate_500khz: return 500000;
case at86rf215_radio_rx_sample_rate_400khz: return 400000;
}
return 4000000;
}
//========================================================
std::vector<double> Cariboulite::listSampleRates( const int direction, const size_t channel ) const
{
//printf("listSampleRates dir: %d, channel: %ld\n", direction, channel);
std::vector<double> options;
options.push_back( 4000000 );
options.push_back( 2000000 );
options.push_back( 1333000 );
options.push_back( 1000000 );
options.push_back( 800000 );
options.push_back( 666000 );
options.push_back( 500000 );
options.push_back( 400000 );
return(options);
}

Wyświetl plik

@ -43,7 +43,8 @@ SoapyCaribouliteSession::SoapyCaribouliteSession(void)
{
CARIBOULITE_CONFIG_DEFAULT(temp);
memcpy(&sys, &temp, sizeof(sys_st));
sys.force_fpga_reprogramming = false;
int ret = cariboulite_init_driver(&sys, NULL);
if (ret != 0)
{