Skip to content

Commit 754425a

Browse files
committed
libhackrf: fallback to original code path for new_host -> old_firmware
1 parent 2f4fa47 commit 754425a

1 file changed

Lines changed: 21 additions & 2 deletions

File tree

host/libhackrf/src/hackrf.c

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,8 @@ static const max2837_ft_t max2837_ft[] = {
204204
if (device->usb_api_version < version) \
205205
return HACKRF_ERROR_USB_API_VERSION;
206206

207+
#define USB_API_REQUIRED_OR(device, version) if (device->usb_api_version < version)
208+
207209
static const uint16_t hackrf_usb_vid = 0x1d50;
208210
static const uint16_t hackrf_jawbreaker_usb_pid = 0x604b;
209211
static const uint16_t hackrf_one_usb_pid = 0x6089;
@@ -3747,7 +3749,11 @@ int ADDCALL hackrf_str_to_fp64(const uint8_t Qn, const char* str, uint64_t* cons
37473749

37483750
int ADDCALL hackrf_radio_set_frequency(hackrf_device* device, const fp_40_24_t freq_hz)
37493751
{
3750-
USB_API_REQUIRED(device, 0x0113);
3752+
USB_API_REQUIRED_OR(device, 0x0113)
3753+
{
3754+
return hackrf_set_freq(device, FP_FREQ_HZ(freq_hz));
3755+
}
3756+
37513757
uint64_t set_freq_fp_param;
37523758
uint8_t length;
37533759
int result;
@@ -3781,6 +3787,15 @@ int ADDCALL hackrf_radio_set_frequency_explicit(
37813787
const fp_40_24_t lo_freq_hz,
37823788
const enum rf_path_filter path)
37833789
{
3790+
USB_API_REQUIRED_OR(device, 0x0113)
3791+
{
3792+
return hackrf_set_freq_explicit(
3793+
device,
3794+
FP_FREQ_HZ(if_freq_hz),
3795+
FP_FREQ_HZ(lo_freq_hz),
3796+
path);
3797+
}
3798+
37843799
struct {
37853800
fp_40_24_t if_freq_hz;
37863801
fp_40_24_t lo_freq_hz;
@@ -3831,7 +3846,11 @@ int ADDCALL hackrf_radio_set_frequency_explicit(
38313846

38323847
int ADDCALL hackrf_radio_set_sample_rate(hackrf_device* device, const fp_28_36_t freq_hz)
38333848
{
3834-
USB_API_REQUIRED(device, 0x0113);
3849+
USB_API_REQUIRED_OR(device, 0x0113)
3850+
{
3851+
return hackrf_set_sample_rate(device, (double) freq_hz / (1ULL << 36));
3852+
}
3853+
38353854
uint64_t set_sr_fp_param;
38363855
uint8_t length;
38373856
int result;

0 commit comments

Comments
 (0)