Single function to configure/enable radio.

This commit is contained in:
Jared Boone 2016-02-10 16:58:25 -08:00
parent 692a262f41
commit 49a89b9dee
5 changed files with 54 additions and 24 deletions

View File

@ -341,14 +341,16 @@ AISAppView::AISAppView(NavigationView&) {
}
);
set_target_frequency(initial_target_frequency);
radio::set_rf_amp(false);
radio::set_lna_gain(32);
radio::set_vga_gain(32);
radio::set_baseband_rate(sampling_rate);
radio::set_baseband_decimation_by(1);
radio::set_baseband_filter_bandwidth(baseband_bandwidth);
radio::set_direction(rf::Direction::Receive);
target_frequency_ = initial_target_frequency;
radio::enable({
tuning_frequency(),
sampling_rate,
baseband_bandwidth,
rf::Direction::Receive,
false, 32, 32,
1,
});
BasebandConfigurationMessage message { {
.mode = 3,

View File

@ -131,14 +131,14 @@ ERTAppView::ERTAppView(NavigationView&) {
}
);
radio::set_tuning_frequency(initial_target_frequency);
radio::set_rf_amp(false);
radio::set_lna_gain(32);
radio::set_vga_gain(32);
radio::set_baseband_rate(sampling_rate);
radio::set_baseband_decimation_by(1);
radio::set_baseband_filter_bandwidth(baseband_bandwidth);
radio::set_direction(rf::Direction::Receive);
radio::enable({
initial_target_frequency,
sampling_rate,
baseband_bandwidth,
rf::Direction::Receive,
false, 32, 32,
1,
});
BasebandConfigurationMessage message { {
.mode = 6,

View File

@ -169,4 +169,19 @@ void disable() {
set_rf_amp(false);
}
void enable(Configuration configuration) {
configure(configuration);
}
void configure(Configuration configuration) {
set_tuning_frequency(configuration.tuning_frequency);
set_rf_amp(configuration.rf_amp);
set_lna_gain(configuration.lna_gain);
set_vga_gain(configuration.vga_gain);
set_baseband_rate(configuration.baseband_rate);
set_baseband_decimation_by(configuration.baseband_decimation);
set_baseband_filter_bandwidth(configuration.baseband_filter_bandwidth);
set_direction(configuration.direction);
}
} /* namespace radio */

View File

@ -32,6 +32,17 @@
namespace radio {
struct Configuration {
rf::Frequency tuning_frequency;
uint32_t baseband_rate;
uint32_t baseband_filter_bandwidth;
rf::Direction direction;
bool rf_amp;
int8_t lna_gain;
int8_t vga_gain;
uint8_t baseband_decimation;
};
void init();
void set_direction(const rf::Direction new_direction);
@ -44,6 +55,8 @@ void set_baseband_rate(const uint32_t rate);
void set_baseband_decimation_by(const size_t n);
void set_antenna_bias(const bool on);
void enable(Configuration configuration);
void configure(Configuration configuration);
void disable();
extern rffc507x::RFFC507x first_if;

View File

@ -238,14 +238,14 @@ TPMSAppView::TPMSAppView(NavigationView&) {
}
);
radio::set_tuning_frequency(tuning_frequency());
radio::set_rf_amp(false);
radio::set_lna_gain(32);
radio::set_vga_gain(32);
radio::set_baseband_rate(sampling_rate);
radio::set_baseband_decimation_by(1);
radio::set_baseband_filter_bandwidth(baseband_bandwidth);
radio::set_direction(rf::Direction::Receive);
radio::enable({
tuning_frequency(),
sampling_rate,
baseband_bandwidth,
rf::Direction::Receive,
false, 32, 32,
1,
});
BasebandConfigurationMessage message { {
.mode = 5,