lib: fractional sample rates

This commit is contained in:
Hoernchen
2013-06-06 14:09:11 +02:00
parent f60cfd677f
commit cd7da974d5
2 changed files with 38 additions and 0 deletions

View File

@ -57,6 +57,7 @@ typedef enum {
HACKRF_VENDOR_REQUEST_SET_LNA_GAIN = 19, HACKRF_VENDOR_REQUEST_SET_LNA_GAIN = 19,
HACKRF_VENDOR_REQUEST_SET_VGA_GAIN = 20, HACKRF_VENDOR_REQUEST_SET_VGA_GAIN = 20,
HACKRF_VENDOR_REQUEST_SET_TXVGA_GAIN = 21, HACKRF_VENDOR_REQUEST_SET_TXVGA_GAIN = 21,
HACKRF_VENDOR_REQUEST_SET_FRACRATE = 22,
} hackrf_vendor_request; } hackrf_vendor_request;
typedef enum { typedef enum {
@ -754,6 +755,42 @@ int ADDCALL hackrf_set_freq(hackrf_device* device, const uint64_t freq_hz)
} }
} }
typedef struct {
float freq_mhz;
} set_fracrate_params_t;
int ADDCALL hackrf_set_fracrate(hackrf_device* device, const float freq_mhz)
{
uint32_t l_freq_mhz;
uint32_t l_freq_hz;
set_fracrate_params_t set_fracrate_params;
uint8_t length;
int result;
set_fracrate_params.freq_mhz = freq_mhz;
length = sizeof(set_fracrate_params_t);
result = libusb_control_transfer(
device->usb_device,
LIBUSB_ENDPOINT_OUT | LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE,
HACKRF_VENDOR_REQUEST_SET_FRACRATE,
0,
0,
(unsigned char*)&set_fracrate_params,
length,
0
);
if (result < length)
{
return HACKRF_ERROR_LIBUSB;
} else {
return HACKRF_SUCCESS;
}
}
int ADDCALL hackrf_set_amp_enable(hackrf_device* device, const uint8_t value) int ADDCALL hackrf_set_amp_enable(hackrf_device* device, const uint8_t value)
{ {
int result; int result;

View File

@ -129,6 +129,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_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_freq(hackrf_device* device, const uint64_t freq_hz);
extern ADDAPI int ADDCALL hackrf_set_fracrate(hackrf_device* device, const float freq_mhz);
/* external amp, bool on/off */ /* external amp, bool on/off */
extern ADDAPI int ADDCALL hackrf_set_amp_enable(hackrf_device* device, const uint8_t value); extern ADDAPI int ADDCALL hackrf_set_amp_enable(hackrf_device* device, const uint8_t value);