lib/fw: rename the sample rate function

This commit is contained in:
Hoernchen
2013-06-08 22:53:51 +02:00
committed by Sylvain Munaut
parent 791476b422
commit fe7558fcf3
4 changed files with 14 additions and 52 deletions

View File

@ -426,22 +426,6 @@ usb_request_status_t usb_vendor_request_read_si5351c(
} }
} }
usb_request_status_t usb_vendor_request_set_sample_rate(
usb_endpoint_t* const endpoint,
const usb_transfer_stage_t stage
) {
if( stage == USB_TRANSFER_STAGE_SETUP ) {
const uint32_t sample_rate = (endpoint->setup.index << 16) | endpoint->setup.value;
if( sample_rate_set(sample_rate) ) {
usb_endpoint_schedule_ack(endpoint->in);
return USB_REQUEST_STATUS_OK;
}
return USB_REQUEST_STATUS_STALL;
} else {
return USB_REQUEST_STATUS_OK;
}
}
usb_request_status_t usb_vendor_request_set_baseband_filter_bandwidth( usb_request_status_t usb_vendor_request_set_baseband_filter_bandwidth(
usb_endpoint_t* const endpoint, usb_endpoint_t* const endpoint,
const usb_transfer_stage_t stage const usb_transfer_stage_t stage
@ -835,7 +819,7 @@ static const usb_request_handler_fn vendor_request_handler[] = {
usb_vendor_request_read_max2837, usb_vendor_request_read_max2837,
usb_vendor_request_write_si5351c, usb_vendor_request_write_si5351c,
usb_vendor_request_read_si5351c, usb_vendor_request_read_si5351c,
usb_vendor_request_set_sample_rate, usb_vendor_request_set_sample_rate_frac,
usb_vendor_request_set_baseband_filter_bandwidth, usb_vendor_request_set_baseband_filter_bandwidth,
usb_vendor_request_write_rffc5071, usb_vendor_request_write_rffc5071,
usb_vendor_request_read_rffc5071, usb_vendor_request_read_rffc5071,
@ -851,7 +835,6 @@ static const usb_request_handler_fn vendor_request_handler[] = {
usb_vendor_request_set_lna_gain, usb_vendor_request_set_lna_gain,
usb_vendor_request_set_vga_gain, usb_vendor_request_set_vga_gain,
usb_vendor_request_set_txvga_gain, usb_vendor_request_set_txvga_gain,
usb_vendor_request_set_sample_rate_frac
}; };
static const uint32_t vendor_request_handler_count = static const uint32_t vendor_request_handler_count =

View File

@ -591,7 +591,7 @@ int main(int argc, char** argv) {
signal(SIGABRT, &sigint_callback_handler); signal(SIGABRT, &sigint_callback_handler);
#endif #endif
printf("call hackrf_sample_rate_set(%u Hz/%.03f MHz)\n", sample_rate_hz,((float)sample_rate_hz/(float)FREQ_ONE_MHZ)); printf("call hackrf_sample_rate_set(%u Hz/%.03f MHz)\n", sample_rate_hz,((float)sample_rate_hz/(float)FREQ_ONE_MHZ));
result = hackrf_sample_rate_set(device, sample_rate_hz); result = hackrf_set_sample_rate_manual(device, sample_rate_hz, 1);
if( result != HACKRF_SUCCESS ) { if( result != HACKRF_SUCCESS ) {
printf("hackrf_sample_rate_set() failed: %s (%d)\n", hackrf_error_name(result), result); printf("hackrf_sample_rate_set() failed: %s (%d)\n", hackrf_error_name(result), result);
usage(); usage();
@ -600,7 +600,7 @@ int main(int argc, char** argv) {
printf("call hackrf_baseband_filter_bandwidth_set(%d Hz/%.03f MHz)\n", printf("call hackrf_baseband_filter_bandwidth_set(%d Hz/%.03f MHz)\n",
baseband_filter_bw_hz, ((float)baseband_filter_bw_hz/(float)FREQ_ONE_MHZ)); baseband_filter_bw_hz, ((float)baseband_filter_bw_hz/(float)FREQ_ONE_MHZ));
result = hackrf_baseband_filter_bandwidth_set(device, baseband_filter_bw_hz); result = hackrf_set_baseband_filter_bandwidth(device, baseband_filter_bw_hz);
if( result != HACKRF_SUCCESS ) { if( result != HACKRF_SUCCESS ) {
printf("hackrf_baseband_filter_bandwidth_set() failed: %s (%d)\n", hackrf_error_name(result), result); printf("hackrf_baseband_filter_bandwidth_set() failed: %s (%d)\n", hackrf_error_name(result), result);
usage(); usage();

View File

@ -64,7 +64,6 @@ 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 {
@ -473,29 +472,7 @@ int ADDCALL hackrf_si5351c_write(hackrf_device* device, uint16_t register_number
} }
} }
int ADDCALL hackrf_sample_rate_set(hackrf_device* device, const uint32_t sampling_rate_hz) int ADDCALL hackrf_set_baseband_filter_bandwidth(hackrf_device* device, const uint32_t bandwidth_hz)
{
int result;
result = libusb_control_transfer(
device->usb_device,
LIBUSB_ENDPOINT_OUT | LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE,
HACKRF_VENDOR_REQUEST_SAMPLE_RATE_SET,
sampling_rate_hz & 0xffff,
sampling_rate_hz >> 16,
NULL,
0,
0
);
if( result != 0 )
{
return HACKRF_ERROR_LIBUSB;
} else {
return HACKRF_SUCCESS;
}
}
int ADDCALL hackrf_baseband_filter_bandwidth_set(hackrf_device* device, const uint32_t bandwidth_hz)
{ {
int result; int result;
result = libusb_control_transfer( result = libusb_control_transfer(
@ -769,7 +746,7 @@ typedef struct {
} set_fracrate_params_t; } set_fracrate_params_t;
int ADDCALL hackrf_set_fracrate_manual(hackrf_device* device, int ADDCALL hackrf_set_sample_rate_manual(hackrf_device* device,
const uint32_t freq_hz, uint32_t divider) const uint32_t freq_hz, uint32_t divider)
{ {
set_fracrate_params_t set_fracrate_params; set_fracrate_params_t set_fracrate_params;
@ -783,7 +760,7 @@ int ADDCALL hackrf_set_fracrate_manual(hackrf_device* device,
result = libusb_control_transfer( result = libusb_control_transfer(
device->usb_device, device->usb_device,
LIBUSB_ENDPOINT_OUT | LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE, LIBUSB_ENDPOINT_OUT | LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE,
HACKRF_VENDOR_REQUEST_SET_FRACRATE, HACKRF_VENDOR_REQUEST_SAMPLE_RATE_SET,
0, 0,
0, 0,
(unsigned char*)&set_fracrate_params, (unsigned char*)&set_fracrate_params,
@ -799,7 +776,7 @@ int ADDCALL hackrf_set_fracrate_manual(hackrf_device* device,
} }
} }
int ADDCALL hackrf_set_fracrate(hackrf_device* device, const double freq) int ADDCALL hackrf_set_sample_rate(hackrf_device* device, const double freq)
{ {
const int MAX_N = 32; const int MAX_N = 32;
uint32_t freq_hz, divider; uint32_t freq_hz, divider;
@ -831,7 +808,7 @@ int ADDCALL hackrf_set_fracrate(hackrf_device* device, const double freq)
freq_hz = (uint32_t)(freq * i + 0.5); freq_hz = (uint32_t)(freq * i + 0.5);
divider = i; divider = i;
return hackrf_set_fracrate_manual(device, freq_hz, divider); return hackrf_set_sample_rate_manual(device, freq_hz, divider);
} }
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)

View File

@ -112,8 +112,7 @@ extern ADDAPI int ADDCALL hackrf_max2837_write(hackrf_device* device, uint8_t re
extern ADDAPI int ADDCALL hackrf_si5351c_read(hackrf_device* device, uint16_t register_number, uint16_t* value); extern ADDAPI int ADDCALL hackrf_si5351c_read(hackrf_device* device, uint16_t register_number, uint16_t* value);
extern ADDAPI int ADDCALL hackrf_si5351c_write(hackrf_device* device, uint16_t register_number, uint16_t value); extern ADDAPI int ADDCALL hackrf_si5351c_write(hackrf_device* device, uint16_t register_number, uint16_t value);
extern ADDAPI int ADDCALL hackrf_sample_rate_set(hackrf_device* device, const uint32_t sampling_rate_hz); extern ADDAPI int ADDCALL hackrf_set_baseband_filter_bandwidth(hackrf_device* device, const uint32_t bandwidth_hz);
extern ADDAPI int ADDCALL hackrf_baseband_filter_bandwidth_set(hackrf_device* device, const uint32_t bandwidth_hz);
extern ADDAPI int ADDCALL hackrf_rffc5071_read(hackrf_device* device, uint8_t register_number, uint16_t* value); extern ADDAPI int ADDCALL hackrf_rffc5071_read(hackrf_device* device, uint8_t register_number, uint16_t* value);
extern ADDAPI int ADDCALL hackrf_rffc5071_write(hackrf_device* device, uint8_t register_number, uint16_t value); extern ADDAPI int ADDCALL hackrf_rffc5071_write(hackrf_device* device, uint8_t register_number, uint16_t value);
@ -129,8 +128,11 @@ 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_manual(hackrf_device* device, const uint32_t freq_hz, const uint32_t divider);
extern ADDAPI int ADDCALL hackrf_set_fracrate(hackrf_device* device, const double freq_hz); /* 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 */
extern ADDAPI int ADDCALL hackrf_set_sample_rate_manual(hackrf_device* device, const uint32_t freq_hz, const uint32_t divider);
extern ADDAPI int ADDCALL hackrf_set_sample_rate(hackrf_device* device, const double freq_hz);
/* 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);