Draft in progress (not tested at all) set_freq().

This commit is contained in:
TitanMKD
2013-02-26 00:17:18 +01:00
parent f150732215
commit e2c05fbfe2
6 changed files with 195 additions and 4 deletions

View File

@@ -44,7 +44,8 @@ typedef enum {
HACKRF_VENDOR_REQUEST_SPIFLASH_READ = 12,
HACKRF_VENDOR_REQUEST_CPLD_WRITE = 13,
HACKRF_VENDOR_REQUEST_BOARD_ID_READ = 14,
HACKRF_VENDOR_REQUEST_VERSION_STRING_READ = 15
HACKRF_VENDOR_REQUEST_VERSION_STRING_READ = 15,
HACKRF_VENDOR_REQUEST_SET_FREQ = 16
} hackrf_vendor_request;
typedef enum {
@@ -569,6 +570,26 @@ int hackrf_version_string_read(hackrf_device* device, char* version,
}
}
int hackrf_set_freq(hackrf_device* device, const uint32_t freq_mhz) {
/* TODO add freq_hz in addition from 0 to 999999Hz */
int result = libusb_control_transfer(
device->usb_device,
LIBUSB_ENDPOINT_OUT | LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE,
HACKRF_VENDOR_REQUEST_SET_FREQ,
freq_mhz & 0xffff,
freq_mhz >> 16,
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;