Add init_scan call to libhackrf
This commit is contained in:
@ -39,27 +39,26 @@ static uint64_t scan_freq_min;
|
|||||||
static uint64_t scan_freq_max;
|
static uint64_t scan_freq_max;
|
||||||
static uint64_t scan_freq_step;
|
static uint64_t scan_freq_step;
|
||||||
|
|
||||||
static inline uint64_t bytes_to_uint64(uint8_t* buf) {
|
struct init_scan_params {
|
||||||
uint64_t tmp = buf[0] << 24 | buf[1] << 16 | buf[2] << 8 | buf[3];
|
uint64_t min_freq_hz;
|
||||||
tmp <<= 32;
|
uint64_t max_freq_hz;
|
||||||
tmp |= buf[4] << 24 | buf[5] << 16 | buf[6] << 8 | buf[7];
|
uint64_t step_freq_hz;
|
||||||
return tmp;
|
};
|
||||||
}
|
struct init_scan_params scan_params;
|
||||||
|
|
||||||
usb_request_status_t usb_vendor_request_init_scan(
|
usb_request_status_t usb_vendor_request_init_scan(
|
||||||
usb_endpoint_t* const endpoint, const usb_transfer_stage_t stage)
|
usb_endpoint_t* const endpoint, const usb_transfer_stage_t stage)
|
||||||
{
|
{
|
||||||
uint64_t freqs[3];
|
|
||||||
if ((stage == USB_TRANSFER_STAGE_SETUP) &&
|
if ((stage == USB_TRANSFER_STAGE_SETUP) &&
|
||||||
(endpoint->setup.length == 24)) {
|
(endpoint->setup.length == 24)) {
|
||||||
// DGS set scan frequencies here
|
// DGS set scan frequencies here
|
||||||
//freq_min = bytes_to_uint64();
|
//freq_min = bytes_to_uint64();
|
||||||
usb_transfer_schedule_block(endpoint->out, &freqs, 3*sizeof(uint64_t),
|
usb_transfer_schedule_block(endpoint->out, &scan_params, sizeof(struct init_scan_params),
|
||||||
NULL, NULL);
|
NULL, NULL);
|
||||||
|
|
||||||
scan_freq_min = MAX(MIN_FREQ, freqs[0]);
|
scan_freq_min = MAX(MIN_FREQ, scan_params.min_freq_hz);
|
||||||
scan_freq_max = MIN(MAX_FREQ, freqs[1]);
|
scan_freq_max = MIN(MAX_FREQ, scan_params.max_freq_hz);
|
||||||
scan_freq_step = freqs[2];
|
scan_freq_step = scan_params.step_freq_hz;
|
||||||
|
|
||||||
scan_freq = scan_freq_min;
|
scan_freq = scan_freq_min;
|
||||||
set_freq(scan_freq);
|
set_freq(scan_freq);
|
||||||
|
@ -67,6 +67,8 @@ typedef enum {
|
|||||||
HACKRF_VENDOR_REQUEST_SET_TXVGA_GAIN = 21,
|
HACKRF_VENDOR_REQUEST_SET_TXVGA_GAIN = 21,
|
||||||
HACKRF_VENDOR_REQUEST_ANTENNA_ENABLE = 23,
|
HACKRF_VENDOR_REQUEST_ANTENNA_ENABLE = 23,
|
||||||
HACKRF_VENDOR_REQUEST_SET_FREQ_EXPLICIT = 24,
|
HACKRF_VENDOR_REQUEST_SET_FREQ_EXPLICIT = 24,
|
||||||
|
// USB_WCID_VENDOR_REQ = 25
|
||||||
|
HACKRF_VENDOR_REQUEST_INIT_SCAN = 26,
|
||||||
} hackrf_vendor_request;
|
} hackrf_vendor_request;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
@ -1695,6 +1697,44 @@ uint32_t ADDCALL hackrf_compute_baseband_filter_bw(const uint32_t bandwidth_hz)
|
|||||||
return p->bandwidth_hz;
|
return p->bandwidth_hz;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct init_scan_params {
|
||||||
|
uint64_t min_freq_hz;
|
||||||
|
uint64_t max_freq_hz;
|
||||||
|
uint64_t step_freq_hz;
|
||||||
|
};
|
||||||
|
|
||||||
|
int ADDCALL hackrf_init_scan(hackrf_device* device,
|
||||||
|
const uint64_t min_freq_hz, const uint64_t max_freq_hz,
|
||||||
|
const uint64_t step_freq_hz)
|
||||||
|
{
|
||||||
|
struct init_scan_params params;
|
||||||
|
uint8_t length;
|
||||||
|
int result;
|
||||||
|
|
||||||
|
params.min_freq_hz = TO_LE(min_freq_hz);
|
||||||
|
params.max_freq_hz = TO_LE(max_freq_hz);
|
||||||
|
params.step_freq_hz = TO_LE(step_freq_hz);
|
||||||
|
length = sizeof(struct init_scan_params);
|
||||||
|
|
||||||
|
result = libusb_control_transfer(
|
||||||
|
device->usb_device,
|
||||||
|
LIBUSB_ENDPOINT_OUT | LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE,
|
||||||
|
HACKRF_VENDOR_REQUEST_INIT_SCAN,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
(unsigned char*)¶ms,
|
||||||
|
length,
|
||||||
|
0
|
||||||
|
);
|
||||||
|
|
||||||
|
if (result < length)
|
||||||
|
{
|
||||||
|
return HACKRF_ERROR_LIBUSB;
|
||||||
|
} else {
|
||||||
|
return HACKRF_SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} // __cplusplus defined.
|
} // __cplusplus defined.
|
||||||
#endif
|
#endif
|
||||||
|
@ -196,6 +196,10 @@ extern ADDAPI const char* ADDCALL hackrf_filter_path_name(const enum rf_path_fil
|
|||||||
extern ADDAPI uint32_t ADDCALL hackrf_compute_baseband_filter_bw_round_down_lt(const uint32_t bandwidth_hz);
|
extern ADDAPI uint32_t ADDCALL hackrf_compute_baseband_filter_bw_round_down_lt(const uint32_t bandwidth_hz);
|
||||||
/* Compute best default value depending on sample rate (auto filter) */
|
/* Compute best default value depending on sample rate (auto filter) */
|
||||||
extern ADDAPI uint32_t ADDCALL hackrf_compute_baseband_filter_bw(const uint32_t bandwidth_hz);
|
extern ADDAPI uint32_t ADDCALL hackrf_compute_baseband_filter_bw(const uint32_t bandwidth_hz);
|
||||||
|
/* Start scan mode */
|
||||||
|
extern ADDAPI int ADDCALL hackrf_init_scan(hackrf_device* device,
|
||||||
|
const uint64_t min_freq_hz, const uint64_t max_freq_hz,
|
||||||
|
const uint64_t step_freq_hz);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} // __cplusplus defined.
|
} // __cplusplus defined.
|
||||||
|
Reference in New Issue
Block a user