From 3c7bc948f189e0c15311a3bdabea6463a4133708 Mon Sep 17 00:00:00 2001 From: Hoernchen Date: Sat, 15 Jun 2013 01:24:26 +0200 Subject: [PATCH] lib: if freq --- host/libhackrf/src/hackrf.c | 29 +++++++++++++++++++++++++++++ host/libhackrf/src/hackrf.h | 1 + 2 files changed, 30 insertions(+) diff --git a/host/libhackrf/src/hackrf.c b/host/libhackrf/src/hackrf.c index 4dcc9302..7e36dc55 100644 --- a/host/libhackrf/src/hackrf.c +++ b/host/libhackrf/src/hackrf.c @@ -64,6 +64,7 @@ typedef enum { HACKRF_VENDOR_REQUEST_SET_LNA_GAIN = 19, HACKRF_VENDOR_REQUEST_SET_VGA_GAIN = 20, HACKRF_VENDOR_REQUEST_SET_TXVGA_GAIN = 21, + HACKRF_VENDOR_REQUEST_SET_IF_FREQ = 22, } hackrf_vendor_request; typedef enum { @@ -958,6 +959,34 @@ int ADDCALL hackrf_set_txvga_gain(hackrf_device* device, uint32_t value) } } +int ADDCALL hackrf_set_if_freq(hackrf_device* device, const uint32_t freq_mhz) +{ + int result; + + if(freq_mhz < 2300 || freq_mhz > 2700) + { + return HACKRF_ERROR_INVALID_PARAM; + } + + result = libusb_control_transfer( + device->usb_device, + LIBUSB_ENDPOINT_OUT | LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE, + HACKRF_VENDOR_REQUEST_SET_IF_FREQ, + 0, + freq_mhz, + NULL, + 0, + 0 + ); + + if( result != 0 ) + { + return HACKRF_ERROR_LIBUSB; + } else { + return HACKRF_SUCCESS; + } +} + static void* transfer_threadproc(void* arg) { hackrf_device* device = (hackrf_device*)arg; diff --git a/host/libhackrf/src/hackrf.h b/host/libhackrf/src/hackrf.h index b79c7499..18671061 100644 --- a/host/libhackrf/src/hackrf.h +++ b/host/libhackrf/src/hackrf.h @@ -128,6 +128,7 @@ extern ADDAPI int ADDCALL hackrf_board_id_read(hackrf_device* device, uint8_t* v extern ADDAPI int ADDCALL hackrf_version_string_read(hackrf_device* device, char* version, uint8_t length); extern ADDAPI int ADDCALL hackrf_set_freq(hackrf_device* device, const uint64_t freq_hz); +extern ADDAPI int ADDCALL hackrf_set_if_freq(hackrf_device* device, const uint32_t freq_mhz); /* currently 8-20Mhz - either as a fraction, i.e. freq 20000000hz divider 2 -> 10Mhz or as plain old 10000000hz (double) preferred rates are 8, 10, 12.5, 16, 20Mhz due to less jitter */