Add USB requests and host support to set TX/RX shortfall limits.

This adds `-T` and `-R` options to `hackrf_debug`, which set the TX
underrun and RX overrun limits in bytes.
This commit is contained in:
Martin Ling
2021-12-24 09:56:52 +00:00
parent 2f79c03b2c
commit 5abc39c53a
6 changed files with 124 additions and 3 deletions

View File

@@ -93,6 +93,8 @@ typedef enum {
HACKRF_VENDOR_REQUEST_OPERACAKE_GET_MODE = 39,
HACKRF_VENDOR_REQUEST_OPERACAKE_SET_DWELL_TIMES = 40,
HACKRF_VENDOR_REQUEST_GET_M0_STATE = 41,
HACKRF_VENDOR_REQUEST_SET_TX_UNDERRUN_LIMIT = 42,
HACKRF_VENDOR_REQUEST_SET_RX_OVERRUN_LIMIT = 43,
} hackrf_vendor_request;
#define USB_CONFIG_STANDARD 0x1
@@ -1033,6 +1035,56 @@ int ADDCALL hackrf_get_m0_state(hackrf_device* device, hackrf_m0_state* state)
}
}
int ADDCALL hackrf_set_tx_underrun_limit(hackrf_device* device, uint32_t value)
{
USB_API_REQUIRED(device, 0x0106)
int result;
result = libusb_control_transfer(
device->usb_device,
LIBUSB_ENDPOINT_OUT | LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE,
HACKRF_VENDOR_REQUEST_SET_TX_UNDERRUN_LIMIT,
value & 0xffff,
value >> 16,
NULL,
0,
0
);
if( result != 0 )
{
last_libusb_error = result;
return HACKRF_ERROR_LIBUSB;
} else {
return HACKRF_SUCCESS;
}
}
int ADDCALL hackrf_set_rx_overrun_limit(hackrf_device* device, uint32_t value)
{
USB_API_REQUIRED(device, 0x0106)
int result;
result = libusb_control_transfer(
device->usb_device,
LIBUSB_ENDPOINT_OUT | LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE,
HACKRF_VENDOR_REQUEST_SET_RX_OVERRUN_LIMIT,
value & 0xffff,
value >> 16,
NULL,
0,
0
);
if( result != 0 )
{
last_libusb_error = result;
return HACKRF_ERROR_LIBUSB;
} else {
return HACKRF_SUCCESS;
}
}
int ADDCALL hackrf_spiflash_erase(hackrf_device* device)
{
int result;