RF antenna bias voltage control API.

This commit is contained in:
Jared Boone 2016-01-22 23:24:20 -08:00
parent 02b3e891f7
commit 10d4172d5c
6 changed files with 40 additions and 1 deletions

View File

@ -152,7 +152,13 @@ void set_baseband_decimation_by(const size_t n) {
baseband_cpld.set_decimation_by(n);
}
void set_antenna_bias(const bool on) {
/* Pull MOSFET gate low to turn on antenna bias. */
first_if.set_gpo1(on ? 0 : 1);
}
void disable() {
set_antenna_bias(false);
baseband_codec.set_mode(max5864::Mode::Shutdown);
second_if.set_mode(max2837::Mode::Standby);
first_if.disable();

View File

@ -42,6 +42,7 @@ void set_vga_gain(const int_fast8_t db);
void set_sampling_frequency(const uint32_t frequency);
void set_baseband_filter_bandwidth(const uint32_t bandwidth_minimum);
void set_baseband_decimation_by(const size_t n);
void set_antenna_bias(const bool on);
void disable();

View File

@ -52,6 +52,15 @@ void ReceiverModel::set_reference_ppm_correction(int32_t v) {
clock_manager.set_reference_ppb(v * 1000);
}
bool ReceiverModel::antenna_bias() const {
return antenna_bias_;
}
void ReceiverModel::set_antenna_bias(bool enabled) {
antenna_bias_ = enabled;
update_antenna_bias();
}
bool ReceiverModel::rf_amp() const {
return rf_amp_;
}
@ -113,6 +122,7 @@ uint32_t ReceiverModel::baseband_oversampling() const {
void ReceiverModel::enable() {
radio::set_direction(rf::Direction::Receive);
update_tuning_frequency();
update_antenna_bias();
update_rf_amp();
update_lna();
update_vga();
@ -148,6 +158,10 @@ void ReceiverModel::update_tuning_frequency() {
radio::set_tuning_frequency(persistent_memory::tuned_frequency() + tuning_offset());
}
void ReceiverModel::update_antenna_bias() {
radio::set_antenna_bias(antenna_bias_);
}
void ReceiverModel::update_rf_amp() {
radio::set_rf_amp(rf_amp_);
}

View File

@ -58,6 +58,9 @@ public:
int32_t reference_ppm_correction() const;
void set_reference_ppm_correction(int32_t v);
bool antenna_bias() const;
void set_antenna_bias(bool enabled);
bool rf_amp() const;
void set_rf_amp(bool enabled);
@ -87,6 +90,7 @@ public:
private:
rf::Frequency frequency_step_ { 25000 };
bool rf_amp_ { false };
bool antenna_bias_ { false };
int32_t lna_gain_db_ { 32 };
uint32_t baseband_bandwidth_ { max2837::filter::bandwidth_minimum };
int32_t vga_gain_db_ { 32 };
@ -101,6 +105,7 @@ private:
int32_t tuning_offset();
void update_tuning_frequency();
void update_antenna_bias();
void update_rf_amp();
void update_lna();
void update_baseband_bandwidth();

View File

@ -262,6 +262,18 @@ void RFFC507x::set_frequency(const rf::Frequency lo_frequency) {
flush();
}
void RFFC507x::set_gpo1(const bool new_value) {
if( new_value ) {
_map.r.gpo.p2gpo |= 1;
_map.r.gpo.p1gpo |= 1;
} else {
_map.r.gpo.p2gpo &= ~1;
_map.r.gpo.p1gpo &= ~1;
}
flush_one(Register::GPO);
}
spi::reg_t RFFC507x::readback(const Readback readback) {
/* TODO: This clobbers the rest of the DEV_CTRL register
* Time to implement bitfields for registers.

View File

@ -808,6 +808,7 @@ public:
void set_mixer_current(const uint8_t value);
void set_frequency(const rf::Frequency lo_frequency);
void set_gpo1(const bool new_value);
reg_t read(const address_t reg_num);