fix(hackrf-ui): Make the calls weak

This commit is contained in:
Tobias Schneider
2015-12-09 22:26:16 +01:00
parent c6e7490397
commit d7c162902c
6 changed files with 18 additions and 30 deletions

View File

@ -0,0 +1,17 @@
#ifndef HACKRF_UI_H
#define HACKRF_UI_H
#include <rf_path.h>
#include <stdint.h>
void hackrf_ui_init(void) __attribute__((weak));
void hackrf_ui_setFrequency(uint64_t _freq) __attribute__((weak));
void hackrf_ui_setSampleRate(uint32_t _sample_rate) __attribute__((weak));
void hackrf_ui_setDirection(const rf_path_direction_t _direction) __attribute__((weak));
void hackrf_ui_setFilterBW(uint32_t bw) __attribute__((weak));
void hackrf_ui_setLNAPower(bool _lna_on) __attribute__((weak));
void hackrf_ui_setBBLNAGain(const uint32_t gain_db) __attribute__((weak));
void hackrf_ui_setBBVGAGain(const uint32_t gain_db) __attribute__((weak));
void hackrf_ui_setBBTXVGAGain(const uint32_t gain_db) __attribute__((weak));
#endif

View File

@ -28,9 +28,7 @@
#include "sgpio.h" #include "sgpio.h"
#include "rf_path.h" #include "rf_path.h"
#if HACKRF_ENABLE_UI
#include "hackrf-ui.h" #include "hackrf-ui.h"
#endif
#include <libopencm3/lpc43xx/i2c.h> #include <libopencm3/lpc43xx/i2c.h>
#include <libopencm3/lpc43xx/cgu.h> #include <libopencm3/lpc43xx/cgu.h>
@ -91,9 +89,7 @@ bool sample_rate_frac_set(uint32_t rate_num, uint32_t rate_denom)
uint32_t a, b, c; uint32_t a, b, c;
uint32_t rem; uint32_t rem;
#if HACKRF_ENABLE_UI
hackrf_ui_setSampleRate(rate_num/2); hackrf_ui_setSampleRate(rate_num/2);
#endif
/* Find best config */ /* Find best config */
a = (VCO_FREQ * rate_denom) / rate_num; a = (VCO_FREQ * rate_denom) / rate_num;
@ -179,9 +175,7 @@ bool sample_rate_set(const uint32_t sample_rate_hz) {
return false; return false;
} }
#if HACKRF_ENABLE_UI
hackrf_ui_setSampleRate(sample_rate_hz); hackrf_ui_setSampleRate(sample_rate_hz);
#endif
/* NOTE: Because MS1, 2, 3 outputs are slaved to PLLA, the p1, p2, p3 /* NOTE: Because MS1, 2, 3 outputs are slaved to PLLA, the p1, p2, p3
* values are irrelevant. */ * values are irrelevant. */
@ -262,12 +256,11 @@ bool sample_rate_set(const uint32_t sample_rate_hz) {
#endif #endif
} }
bool baseband_filter_bandwidth_set(const uint32_t bandwidth_hz) { bool baseband_filter_bandwidth_set(const uint32_t bandwidth_hz) {
uint32_t bandwidth_hz_real = max2837_set_lpf_bandwidth(bandwidth_hz); uint32_t bandwidth_hz_real = max2837_set_lpf_bandwidth(bandwidth_hz);
#if HACKRF_ENABLE_UI
if(bandwidth_hz_real) hackrf_ui_setFilterBW(bandwidth_hz_real); if(bandwidth_hz_real) hackrf_ui_setFilterBW(bandwidth_hz_real);
#endif
return bandwidth_hz_real != 0; return bandwidth_hz_real != 0;
} }

View File

@ -27,9 +27,7 @@
#include <hackrf_core.h> #include <hackrf_core.h>
#if HACKRF_ENABLE_UI
#include "hackrf-ui.h" #include "hackrf-ui.h"
#endif
#include <mixer.h> #include <mixer.h>
#include <max2837.h> #include <max2837.h>
@ -398,9 +396,7 @@ void rf_path_set_direction(const rf_path_direction_t direction) {
switchctrl_set(switchctrl); switchctrl_set(switchctrl);
#if HACKRF_ENABLE_UI
hackrf_ui_setDirection(direction); hackrf_ui_setDirection(direction);
#endif
} }
void rf_path_set_filter(const rf_path_filter_t filter) { void rf_path_set_filter(const rf_path_filter_t filter) {
@ -444,9 +440,7 @@ void rf_path_set_lna(const uint_fast8_t enable) {
switchctrl_set(switchctrl); switchctrl_set(switchctrl);
#if HACKRF_ENABLE_UI
hackrf_ui_setLNAPower(enable); hackrf_ui_setLNAPower(enable);
#endif
} }
/* antenna port power control */ /* antenna port power control */

View File

@ -22,9 +22,7 @@
#include "tuning.h" #include "tuning.h"
#if HACKRF_ENABLE_UI
#include "hackrf-ui.h" #include "hackrf-ui.h"
#endif
#include <mixer.h> #include <mixer.h>
#include <max2837.h> #include <max2837.h>
@ -112,9 +110,7 @@ bool set_freq(const uint64_t freq)
max2837_set_mode(prior_max2837_mode); max2837_set_mode(prior_max2837_mode);
if( success ) { if( success ) {
freq_cache = freq; freq_cache = freq;
#if HACKRF_ENABLE_UI
hackrf_ui_setFrequency(freq); hackrf_ui_setFrequency(freq);
#endif
} }
return success; return success;
} }

View File

@ -49,9 +49,7 @@
#include "si5351c.h" #include "si5351c.h"
#include "w25q80bv.h" #include "w25q80bv.h"
#if HACKRF_ENABLE_UI
#include "hackrf-ui.h" #include "hackrf-ui.h"
#endif
static volatile transceiver_mode_t _transceiver_mode = TRANSCEIVER_MODE_OFF; static volatile transceiver_mode_t _transceiver_mode = TRANSCEIVER_MODE_OFF;
@ -259,9 +257,7 @@ int main(void) {
nvic_set_priority(NVIC_USB0_IRQ, 255); nvic_set_priority(NVIC_USB0_IRQ, 255);
#if HACKRF_ENABLE_UI
hackrf_ui_init(); hackrf_ui_init();
#endif
usb_run(&usb_device); usb_run(&usb_device);

View File

@ -24,9 +24,7 @@
#include <libopencm3/lpc43xx/gpio.h> #include <libopencm3/lpc43xx/gpio.h>
#if HACKRF_ENABLE_UI
#include "hackrf-ui.h" #include "hackrf-ui.h"
#endif
#include <max2837.h> #include <max2837.h>
#include <rf_path.h> #include <rf_path.h>
@ -151,9 +149,7 @@ usb_request_status_t usb_vendor_request_set_lna_gain(
if( stage == USB_TRANSFER_STAGE_SETUP ) { if( stage == USB_TRANSFER_STAGE_SETUP ) {
const uint8_t value = max2837_set_lna_gain(endpoint->setup.index); const uint8_t value = max2837_set_lna_gain(endpoint->setup.index);
endpoint->buffer[0] = value; endpoint->buffer[0] = value;
#if HACKRF_ENABLE_UI
if(value) hackrf_ui_setBBLNAGain(endpoint->setup.index); if(value) hackrf_ui_setBBLNAGain(endpoint->setup.index);
#endif
usb_transfer_schedule_block(endpoint->in, &endpoint->buffer, 1, usb_transfer_schedule_block(endpoint->in, &endpoint->buffer, 1,
NULL, NULL); NULL, NULL);
usb_transfer_schedule_ack(endpoint->out); usb_transfer_schedule_ack(endpoint->out);
@ -168,9 +164,7 @@ usb_request_status_t usb_vendor_request_set_vga_gain(
if( stage == USB_TRANSFER_STAGE_SETUP ) { if( stage == USB_TRANSFER_STAGE_SETUP ) {
const uint8_t value = max2837_set_vga_gain(endpoint->setup.index); const uint8_t value = max2837_set_vga_gain(endpoint->setup.index);
endpoint->buffer[0] = value; endpoint->buffer[0] = value;
#if HACKRF_ENABLE_UI
if(value) hackrf_ui_setBBVGAGain(endpoint->setup.index); if(value) hackrf_ui_setBBVGAGain(endpoint->setup.index);
#endif
usb_transfer_schedule_block(endpoint->in, &endpoint->buffer, 1, usb_transfer_schedule_block(endpoint->in, &endpoint->buffer, 1,
NULL, NULL); NULL, NULL);
usb_transfer_schedule_ack(endpoint->out); usb_transfer_schedule_ack(endpoint->out);
@ -185,9 +179,7 @@ usb_request_status_t usb_vendor_request_set_txvga_gain(
if( stage == USB_TRANSFER_STAGE_SETUP ) { if( stage == USB_TRANSFER_STAGE_SETUP ) {
const uint8_t value = max2837_set_txvga_gain(endpoint->setup.index); const uint8_t value = max2837_set_txvga_gain(endpoint->setup.index);
endpoint->buffer[0] = value; endpoint->buffer[0] = value;
#if HACKRF_ENABLE_UI
if(value) hackrf_ui_setBBTXVGAGain(endpoint->setup.index); if(value) hackrf_ui_setBBTXVGAGain(endpoint->setup.index);
#endif
usb_transfer_schedule_block(endpoint->in, &endpoint->buffer, 1, usb_transfer_schedule_block(endpoint->in, &endpoint->buffer, 1,
NULL, NULL); NULL, NULL);
usb_transfer_schedule_ack(endpoint->out); usb_transfer_schedule_ack(endpoint->out);