Skip to content

Commit 1885516

Browse files
committed
libhackrf: fallback to original code path for new_host -> old_firmware
1 parent ee9846d commit 1885516

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;
@@ -3780,7 +3782,11 @@ int ADDCALL hackrf_str_to_fp64(uint8_t Qn, char* str, char* endptr, uint64_t* co
37803782

37813783
int ADDCALL hackrf_radio_set_frequency(hackrf_device* device, const fp_40_24_t freq_hz)
37823784
{
3783-
USB_API_REQUIRED(device, 0x0113);
3785+
USB_API_REQUIRED_OR(device, 0x0113)
3786+
{
3787+
return hackrf_set_freq(device, FP_FREQ_HZ(freq_hz));
3788+
}
3789+
37843790
uint64_t set_freq_fp_param;
37853791
uint8_t length;
37863792
int result;
@@ -3814,6 +3820,15 @@ int ADDCALL hackrf_radio_set_frequency_explicit(
38143820
const fp_40_24_t lo_freq_hz,
38153821
const enum rf_path_filter path)
38163822
{
3823+
USB_API_REQUIRED_OR(device, 0x0113)
3824+
{
3825+
return hackrf_set_freq_explicit(
3826+
device,
3827+
FP_FREQ_HZ(if_freq_hz),
3828+
FP_FREQ_HZ(lo_freq_hz),
3829+
path);
3830+
}
3831+
38173832
struct {
38183833
fp_40_24_t if_freq_hz;
38193834
fp_40_24_t lo_freq_hz;
@@ -3864,7 +3879,11 @@ int ADDCALL hackrf_radio_set_frequency_explicit(
38643879

38653880
int ADDCALL hackrf_radio_set_sample_rate(hackrf_device* device, const fp_28_36_t freq_hz)
38663881
{
3867-
USB_API_REQUIRED(device, 0x0113);
3882+
USB_API_REQUIRED_OR(device, 0x0113)
3883+
{
3884+
return hackrf_set_sample_rate(device, (double) freq_hz / (1ULL << 36));
3885+
}
3886+
38683887
uint64_t set_sr_fp_param;
38693888
uint8_t length;
38703889
int result;

0 commit comments

Comments
 (0)