libhackrf
libhackrf
1 Module Index 1
1.1 Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
3 Module Documentation 5
3.1 Library related functions and enums . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
3.1.1 Detailed Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3.1.2 Library initialization & exit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3.1.3 Error handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3.1.4 Enum conversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3.1.5 Library internals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.1.6 USB API versions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.1.6.1 0x0102 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.1.6.2 0x0103 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.1.6.3 0x0104 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.1.6.4 0x0105 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3.1.6.5 0x0106 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3.1.6.6 0x0107 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3.1.7 Enumeration Type Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3.1.7.1 hackrf_error . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3.1.8 Function Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.1.8.1 hackrf_error_name() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.1.8.2 hackrf_exit() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.1.8.3 hackrf_get_transfer_buffer_size() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
3.1.8.4 hackrf_get_transfer_queue_depth() . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.1.8.5 hackrf_init() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.1.8.6 hackrf_library_release() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.1.8.7 hackrf_library_version() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3.2 Device listing, opening, closing and querying . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3.2.1 Detailed Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.2.2 Opening devices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.2.2.1 Open first device . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.2.2.2 Open by serial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.2.2.3 Open by listing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
3.2.3 Closing devices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
3.2.4 Querying device information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
3.2.4.1 Board ID . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
3.2.4.2 Version string . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Generated by Doxygen
ii
Generated by Doxygen
iii
Generated by Doxygen
iv
3.4.3.1 hackrf_flush_cb_fn . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
3.4.3.2 hackrf_sample_block_cb_fn . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
3.4.3.3 hackrf_tx_block_complete_cb_fn . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
3.4.4 Enumeration Type Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
3.4.4.1 sweep_style . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
3.4.5 Function Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
3.4.5.1 hackrf_enable_tx_flush() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
3.4.5.2 hackrf_init_sweep() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
3.4.5.3 hackrf_is_streaming() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
3.4.5.4 hackrf_set_hw_sync_mode() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
3.4.5.5 hackrf_set_rx_overrun_limit() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
3.4.5.6 hackrf_set_tx_block_complete_callback() . . . . . . . . . . . . . . . . . . . . . . . . . 45
3.4.5.7 hackrf_set_tx_underrun_limit() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
3.4.5.8 hackrf_start_rx() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
3.4.5.9 hackrf_start_rx_sweep() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
3.4.5.10 hackrf_start_tx() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
3.4.5.11 hackrf_stop_rx() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
3.4.5.12 hackrf_stop_tx() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
3.5 Firmware flashing & debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
3.5.1 Detailed Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
3.5.2 Firmware flashing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
3.5.3 Debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
3.5.3.1 MAX2837 2.3 to 2.7 GHz transceiver . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
3.5.3.2 MAX5864 ADC/DAC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
3.5.3.3 Si5351C Clock generator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
3.5.3.4 RFFC5072 Synthesizer/mixer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
3.5.3.5 LPC4320 ARM MCU . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
3.5.3.6 W25Q80B SPI flash . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
3.5.3.7 XC2C64A CPLD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
3.5.4 Function Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
3.5.4.1 hackrf_cpld_write() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
3.5.4.2 hackrf_get_m0_state() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
3.5.4.3 hackrf_max2837_read() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
3.5.4.4 hackrf_max2837_write() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
3.5.4.5 hackrf_rffc5071_read() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
3.5.4.6 hackrf_rffc5071_write() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
3.5.4.7 hackrf_si5351c_read() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
3.5.4.8 hackrf_si5351c_write() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
3.5.4.9 hackrf_spiflash_clear_status() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
Generated by Doxygen
v
3.5.4.10 hackrf_spiflash_erase() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
3.5.4.11 hackrf_spiflash_read() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
3.5.4.12 hackrf_spiflash_status() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
3.5.4.13 hackrf_spiflash_write() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
3.6 Opera Cake add-on board functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
3.6.1 Detailed Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
3.6.1.1 Opera Cake setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
3.6.1.2 Multiple boards . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
3.6.2 Macro Definition Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
3.6.2.1 HACKRF_OPERACAKE_ADDRESS_INVALID . . . . . . . . . . . . . . . . . . . . . . 59
3.6.2.2 HACKRF_OPERACAKE_MAX_BOARDS . . . . . . . . . . . . . . . . . . . . . . . . . 59
3.6.2.3 HACKRF_OPERACAKE_MAX_DWELL_TIMES . . . . . . . . . . . . . . . . . . . . . . 59
3.6.2.4 HACKRF_OPERACAKE_MAX_FREQ_RANGES . . . . . . . . . . . . . . . . . . . . . 59
3.6.3 Enumeration Type Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
3.6.3.1 operacake_ports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
3.6.3.2 operacake_switching_mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
3.6.4 Function Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
3.6.4.1 hackrf_get_operacake_boards() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
3.6.4.2 hackrf_get_operacake_mode() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
3.6.4.3 hackrf_operacake_gpio_test() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
3.6.4.4 hackrf_set_operacake_dwell_times() . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
3.6.4.5 hackrf_set_operacake_freq_ranges() . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
3.6.4.6 hackrf_set_operacake_mode() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
3.6.4.7 hackrf_set_operacake_ports() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
3.6.4.8 hackrf_set_operacake_ranges() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
Generated by Doxygen
vi
Generated by Doxygen
vii
Index 77
Generated by Doxygen
Chapter 1
Module Index
1.1 Modules
Generated by Doxygen
2 Module Index
Generated by Doxygen
Chapter 2
hackrf_bias_t_user_settting_req
User settings for user-supplied bias tee defaults . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
hackrf_bool_user_settting
Helper struct for hackrf_bias_t_user_setting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
hackrf_device_list_t
List of connected HackRF devices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
hackrf_m0_state
State of the SGPIO loop running on the M0 core . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
hackrf_operacake_dwell_time
Opera Cake port setting in OPERACAKE_MODE_TIME operation . . . . . . . . . . . . . . . . . . 71
hackrf_operacake_freq_range
Opera Cake port setting in OPERACAKE_MODE_FREQUENCY operation . . . . . . . . . . . . . . 72
hackrf_transfer
USB transfer information passed to RX or TX callback . . . . . . . . . . . . . . . . . . . . . . . . . 73
read_partid_serialno_t
MCU (LPC43xx) part ID and serial number . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
Generated by Doxygen
4 Data Structure Index
Generated by Doxygen
Chapter 3
Module Documentation
Enumerations
• enum hackrf_error {
HACKRF_SUCCESS = 0 ,
HACKRF_TRUE = 1 ,
HACKRF_ERROR_INVALID_PARAM = -2 ,
HACKRF_ERROR_NOT_FOUND = -5 ,
HACKRF_ERROR_BUSY = -6 ,
HACKRF_ERROR_NO_MEM = -11 ,
HACKRF_ERROR_LIBUSB = -1000 ,
HACKRF_ERROR_THREAD = -1001 ,
HACKRF_ERROR_STREAMING_THREAD_ERR = -1002 ,
HACKRF_ERROR_STREAMING_STOPPED = -1003 ,
HACKRF_ERROR_STREAMING_EXIT_CALLED = -1004 ,
HACKRF_ERROR_USB_API_VERSION = -1005 ,
HACKRF_ERROR_NOT_LAST_DEVICE = -2000 ,
HACKRF_ERROR_OTHER = -9999 }
error enum, returned by many libhackrf functions
Functions
• int hackrf_init ()
Initialize libhackrf.
• int hackrf_exit ()
Exit libhackrf.
• const char ∗ hackrf_library_version ()
Get library version.
Generated by Doxygen
6 Module Documentation
The libhackrf library needs to be initialized in order to use most of its functions. This can be achieved via the function
hackrf_init. This initializes internal state and initializes libusb. You should only call this function on startup, but it's
safe to call it later as well, only it does nothing.
When exiting the program, a call to hackrf_exit should be called. This releases all resources, stops background thread
and exits libusb. This function should only be called if all streaming is stopped and all devices are closed via
hackrf_close, else the error HACKRF_ERROR_NOT_LAST_DEVICE is returned.
Many of the functions in libhackrf can signal errors via returning hackrf_error. This enum is backed by an inte-
ger, thus these functions are declared to return an int, but they in fact return an enum variant. The special case
HACKRF_SUCCESS signals no errors, so return values should be matched for that. It is also set to the value 0,
so boolean conversion can also be used. The function hackrf_error_name can be used to convert the enum into a
human-readable string, useful for logging the error.
There is a special variant HACKRF_TRUE, used by some functions that return boolean. This fact is explicitly mentioned
at those functions.
Instead of if (result != HACKRF_SUCCESS) the line if (result) can also be used with the exact same
behaviour.
Most of the enums defined in libhackrf have a corresponding _name function that converts the enum value into a
human-readable string. All strings returned by these functions are statically allocated and do not need to be freed. An
example is the already mentioned hackrf_error_name function for the hackrf_error enum.
Generated by Doxygen
3.1 Library related functions and enums 7
The library uses libusb (version 1.0) to communicate with HackRF hardware. It uses both the synchronous and asyn-
chronous API for communication (asynchronous for streaming data to/from the device, and synchronous for everything
else). The asynchronous API requires to periodically call a variant of libusb_handle_events, so the library cre-
ates a new "transfer thread" for each device doing that using the pthread library. The library uses multiple transfers
for each device (hackrf_get_transfer_queue_depth).
As all functionality of HackRF devices requires cooperation between the firmware and the host, both devices can have
outdated software. If host machine software is outdated, the new functions will be unalaviable in hackrf.h, causing
linking errors. If the device firmware is outdated, the functions will return HACKRF_ERROR_USB_API_VERSION.
Since device firmware and USB API are separate (but closely related), USB API has its own version numbers. Here is
a list of all the functions that require a certain minimum USB API version, up to version 0x0107
3.1.6.1 0x0102
• hackrf_set_hw_sync_mode
• hackrf_init_sweep
• hackrf_set_operacake_ports
• hackrf_reset
3.1.6.2 0x0103
• hackrf_spiflash_status
• hackrf_spiflash_clear_status
• hackrf_set_operacake_ranges
• hackrf_set_operacake_freq_ranges
• hackrf_set_clkout_enable
• hackrf_operacake_gpio_test
• hackrf_cpld_checksum
3.1.6.3 0x0104
• hackrf_set_ui_enable
• hackrf_start_rx_sweep
Generated by Doxygen
8 Module Documentation
3.1.6.4 0x0105
• hackrf_get_operacake_boards
• hackrf_set_operacake_mode
• hackrf_get_operacake_mode
• hackrf_set_operacake_dwell_times
3.1.6.5 0x0106
• hackrf_get_m0_state
• hackrf_set_tx_underrun_limit
• hackrf_set_rx_overrun_limit
• hackrf_get_clkin_status
• hackrf_board_rev_read
• hackrf_supported_platform_read
3.1.6.6 0x0107
• hackrf_set_leds
3.1.7.1 hackrf_error
enum hackrf_error
Many functions that are specified to return INT are actually returning this enum
Enumerator
Generated by Doxygen
3.1 Library related functions and enums 9
Enumerator
3.1.8.1 hackrf_error_name()
Parameters
errcode enum to convert
Returns
3.1.8.2 hackrf_exit()
int hackrf_exit ( )
Should be called before exit. No other libhackrf functions should be called after it. Can be safely called multiple times.
Returns
Generated by Doxygen
10 Module Documentation
3.1.8.3 hackrf_get_transfer_buffer_size()
size_t hackrf_get_transfer_buffer_size (
hackrf_device ∗ device )
Generated by Doxygen
3.1 Library related functions and enums 11
Parameters
in device unused
Returns
size in bytes
3.1.8.4 hackrf_get_transfer_queue_depth()
uint32_t hackrf_get_transfer_queue_depth (
hackrf_device ∗ device )
Parameters
in device unused
Returns
number of buffers
3.1.8.5 hackrf_init()
int hackrf_init ( )
Should be called before any other libhackrf function. Initializes libusb. Can be safely called multiple times.
Returns
3.1.8.6 hackrf_library_release()
Returns
Generated by Doxygen
12 Module Documentation
3.1.8.7 hackrf_library_version()
Returns
Data Structures
• struct read_partid_serialno_t
MCU (LPC43xx) part ID and serial number.
• struct hackrf_bias_t_user_settting_req
User settings for user-supplied bias tee defaults.
• struct hackrf_device_list_t
List of connected HackRF devices.
Macros
Typedefs
Generated by Doxygen
3.2 Device listing, opening, closing and querying 13
Enumerations
• enum hackrf_board_id {
BOARD_ID_JELLYBEAN = 0 ,
BOARD_ID_JAWBREAKER = 1 ,
BOARD_ID_HACKRF1_OG = 2 ,
BOARD_ID_RAD1O = 3 ,
BOARD_ID_HACKRF1_R9 = 4 ,
BOARD_ID_UNRECOGNIZED = 0xFE ,
BOARD_ID_UNDETECTED = 0xFF }
HACKRF board id enum.
• enum hackrf_board_rev {
BOARD_REV_HACKRF1_OLD = 0 ,
BOARD_REV_HACKRF1_R6 = 1 ,
BOARD_REV_HACKRF1_R7 = 2 ,
BOARD_REV_HACKRF1_R8 = 3 ,
BOARD_REV_HACKRF1_R9 = 4 ,
BOARD_REV_HACKRF1_R10 = 5 ,
BOARD_REV_GSG_HACKRF1_R6 = 0x81 ,
BOARD_REV_GSG_HACKRF1_R7 = 0x82 ,
BOARD_REV_GSG_HACKRF1_R8 = 0x83 ,
BOARD_REV_GSG_HACKRF1_R9 = 0x84 ,
BOARD_REV_GSG_HACKRF1_R10 = 0x85 ,
BOARD_REV_UNRECOGNIZED = 0xFE ,
BOARD_REV_UNDETECTED = 0xFF }
Board revision enum.
• enum hackrf_usb_board_id {
USB_BOARD_ID_JAWBREAKER = 0x604B ,
USB_BOARD_ID_HACKRF_ONE = 0x6089 ,
USB_BOARD_ID_RAD1O = 0xCC15 ,
USB_BOARD_ID_INVALID = 0xFFFF }
USB board ID (product ID) enum.
Functions
• hackrf_device_list_t ∗ hackrf_device_list ()
List connected HackRF devices.
• int hackrf_device_list_open (hackrf_device_list_t ∗list, int idx, hackrf_device ∗∗device)
Open a hackrf_device from a device list.
• void hackrf_device_list_free (hackrf_device_list_t ∗list)
Free a previously allocated hackrf_device_list list.
• int hackrf_open (hackrf_device ∗∗device)
Open first available HackRF device.
• int hackrf_open_by_serial (const char ∗const desired_serial_number, hackrf_device ∗∗device)
Open HackRF device by serial number.
• int hackrf_close (hackrf_device ∗device)
Close a previously opened device.
• int hackrf_board_id_read (hackrf_device ∗device, uint8_t ∗value)
Read hackrf_board_id from a device.
• int hackrf_version_string_read (hackrf_device ∗device, char ∗version, uint8_t length)
Generated by Doxygen
14 Module Documentation
The libhackrf library interacts via HackRF hardware through a hackrf_device handle. This handle is opaque, meaning its
fields are internal to the library and should not be accessed by user code. To use a device, it first needs to be opened,
than it can be interacted with, and finally the device needs to be closed via hackrf_close.
hackrf_open opens the first USB device (chosen by libusb). Useful if only one HackRF device is expected to be present.
hackrf_open_by_serial opens a device by a given serial (suffix). If no serial is specified it defaults to hackrf_open
Generated by Doxygen
3.2 Device listing, opening, closing and querying 15
All connected HackRF devices can be listed via hackrf_device_list. The list must be freed by hackrf_device_list_free.
This struct lists all devices and their serial numbers. Any one of them can be opened by hackrf_device_list_open. All
the fields should be treated read-only!
If the device is not needed anymore, then it can be closed via hackrf_close. Closing a device terminates all ongoing
transfers, and resets the device to IDLE mode.
3.2.4.1 Board ID
Board ID identifies the type of HackRF board connected. See the enum hackrf_board_id for possible values. The value
can be read by hackrf_board_id_read and converted into a human-readable string using hackrf_board_id_name. When
reading, the initial value of the enum should be BOARD_ID_UNDETECTED.
Version string identifies the firmware version on the board. It can be read with the function hackrf_version_string_read
USB API version identifies the USB API supported by the device's firmware. It is coded as a xx.xx 16-bit value, and can
be read by hackrf_usb_api_version_read
Generated by Doxygen
16 Module Documentation
The part ID and serial number of the MCU. Read via hackrf_board_partid_serialno_read. See the documentation of the
MCU for details.
Board revision identifies revision of the HackRF board inside a device. Read via hackrf_board_rev_read and converted
into a human-readable string via hackrf_board_rev_name. See hackrf_board_rev for possible values. When reading,
the value should be initialized with BOARD_REV_UNDETECTED
Identifies the platform supported by the firmare of the HackRF device. Read via hackrf_supported_platform_read.
Returns a bitfield. Can identify bad firmware version on device.
3.2.5.1 BOARD_ID_HACKRF_ONE
3.2.5.2 BOARD_ID_INVALID
3.2.5.3 HACKRF_BOARD_REV_GSG
3.2.5.4 HACKRF_PLATFORM_HACKRF1_OG
Generated by Doxygen
3.2 Device listing, opening, closing and querying 17
3.2.5.5 HACKRF_PLATFORM_HACKRF1_R9
3.2.5.6 HACKRF_PLATFORM_JAWBREAKER
3.2.5.7 HACKRF_PLATFORM_RAD1O
3.2.6.1 hackrf_device
Object can be created via hackrf_open, hackrf_device_list_open or hackrf_open_by_serial and be destroyed via
hackrf_close
3.2.7.1 hackrf_board_id
enum hackrf_board_id
Enumerator
3.2.7.2 hackrf_board_rev
enum hackrf_board_rev
Enumerator
3.2.7.3 hackrf_usb_board_id
enum hackrf_usb_board_id
Contains USB-IF product id (field idProduct in libusb_device_descriptor). Can be used to identify general
type of hardware. Only used in hackrf_device_list::usb_board_ids field of hackrf_device_list, and can be converted into
human-readable string via hackrf_usb_board_id_name.
Enumerator
Generated by Doxygen
3.2 Device listing, opening, closing and querying 19
3.2.8.1 hackrf_board_id_name()
Parameters
board←- enum to convert
_id
Returns
3.2.8.2 hackrf_board_id_platform()
uint32_t hackrf_board_id_platform (
enum hackrf_board_id board_id )
Parameters
Returns
3.2.8.3 hackrf_board_id_read()
int hackrf_board_id_read (
hackrf_device ∗ device,
uint8_t ∗ value )
Generated by Doxygen
20 Module Documentation
Parameters
in device device to query
out value hackrf_board_id enum value
Returns
3.2.8.4 hackrf_board_partid_serialno_read()
int hackrf_board_partid_serialno_read (
hackrf_device ∗ device,
read_partid_serialno_t ∗ read_partid_serialno )
Read MCU part id and serial number. See the documentation of the MCU for details!
Parameters
in device device to query
out read_partid_serialno result of query
Returns
3.2.8.5 hackrf_board_rev_name()
Parameters
Returns
Generated by Doxygen
3.2 Device listing, opening, closing and querying 21
3.2.8.6 hackrf_board_rev_read()
int hackrf_board_rev_read (
hackrf_device ∗ device,
uint8_t ∗ value )
Parameters
Returns
3.2.8.7 hackrf_close()
int hackrf_close (
hackrf_device ∗ device )
Parameters
in device device to close
Returns
3.2.8.8 hackrf_device_list()
hackrf_device_list_t ∗ hackrf_device_list ( )
Returns
3.2.8.9 hackrf_device_list_free()
void hackrf_device_list_free (
hackrf_device_list_t ∗ list )
Generated by Doxygen
22 Module Documentation
Parameters
3.2.8.10 hackrf_device_list_open()
int hackrf_device_list_open (
hackrf_device_list_t ∗ list,
int idx,
hackrf_device ∗∗ device )
Parameters
Returns
3.2.8.11 hackrf_open()
int hackrf_open (
hackrf_device ∗∗ device )
Parameters
out device device handle
Returns
Generated by Doxygen
3.2 Device listing, opening, closing and querying 23
3.2.8.12 hackrf_open_by_serial()
int hackrf_open_by_serial (
const char ∗const desired_serial_number,
hackrf_device ∗∗ device )
Parameters
in desired_serial_number serial number of device to open. If NULL then default to first device found.
out device device handle
Returns
3.2.8.13 hackrf_reset()
int hackrf_reset (
hackrf_device ∗ device )
Parameters
device device to reset
Returns
3.2.8.14 hackrf_set_leds()
int hackrf_set_leds (
hackrf_device ∗ device,
const uint8_t state )
This function can turn on or off the LEDs of the device. There are 3 controllable LEDs on the HackRF one: USB, RX and
TX. On the Rad1o, there are 4 LEDs. Each LED can be set individually, but the setting might get overridden by other
functions.
The LEDs can be set via specifying them as bits of a 8 bit number state, bit 0 representing the first (USB on the
HackRF One) and bit 3 or 4 representing the last LED. The upper 4 or 5 bits are unused. For example, binary value
0bxxxxx101 turns on the USB and TX LEDs on the HackRF One.
Requires USB API version 0x0107 or above!
Generated by Doxygen
24 Module Documentation
Parameters
device device to query
state LED states as a bitfield
Returns
3.2.8.15 hackrf_set_ui_enable()
int hackrf_set_ui_enable (
hackrf_device ∗ device,
const uint8_t value )
Parameters
Returns
3.2.8.16 hackrf_set_user_bias_t_opts()
int hackrf_set_user_bias_t_opts (
hackrf_device ∗ device,
hackrf_bias_t_user_settting_req ∗ req )
This function allows the user to configure bias tee behavior so that it can be turned on or off automatically by the HackRF
when entering the RX, TX, or OFF state. By default, the HackRF switches off the bias tee when the RF path switches to
OFF mode.
0000000TmmRmmOmm
Where setting T/R/O bits indicates that the TX/RX/Off behavior should be set to mode 'mm', 0=don't modify
00 - do nothing 01 - reserved, do not use 10 - disable bias tee 11 - enable bias tee
Generated by Doxygen
3.2 Device listing, opening, closing and querying 25
Parameters
Returns
3.2.8.17 hackrf_supported_platform_read()
int hackrf_supported_platform_read (
hackrf_device ∗ device,
uint32_t ∗ value )
Parameters
in device device to query
out value supported platform bitfield
Returns
3.2.8.18 hackrf_usb_api_version_read()
int hackrf_usb_api_version_read (
hackrf_device ∗ device,
uint16_t ∗ version )
Read version as MM.mm 16-bit value, where MM is the major and mm is the minor version, encoded as the hex digits
of the 16-bit number.
Generated by Doxygen
26 Module Documentation
Parameters
in device device to query
out version USB API version
Returns
3.2.8.19 hackrf_usb_board_id_name()
Parameters
usb_board←- enum to convert
_id
Returns
3.2.8.20 hackrf_version_string_read()
int hackrf_version_string_read (
hackrf_device ∗ device,
char ∗ version,
uint8_t length )
Parameters
in device device to query
out version version string
in length length of allocated string without null byte (so set it to length(arr)-1)
Returns
Generated by Doxygen
3.3 Configuration of the RF hardware 27
Enumerations
• enum rf_path_filter {
RF_PATH_FILTER_BYPASS = 0 ,
RF_PATH_FILTER_LOW_PASS = 1 ,
RF_PATH_FILTER_HIGH_PASS = 2 }
RF filter path setting enum.
Functions
Generated by Doxygen
28 Module Documentation
There are 5 different amplifiers in the HackRF One. Most of them have variable gain, but some of them can be either
enabled / disabled. Please note that most of the gain settings are not precise, and they depend on the used frequency
as well.
3.3.2.1 RX path
• baseband gain in the MAX2837 ("BB" or "VGA") - 0-62dB in 2dB steps, configurable via the hackrf_set_vga_gain
function
• RX IF gain in the MAX2837 ("IF") - 0-40dB with 8dB steps, configurabe via the hackrf_set_lna_gain function
• RX RF amplifier near the antenna port ("RF") - 0 or ∼11dB, either enabled or disabled via the
hackrf_set_amp_enable (same function is used for enabling/disabling the TX RF amp in TX mode)
3.3.2.2 TX path
• TX IF gain in the MAX2837 ("IF" or "VGA") - 0-47dB in 1dB steps, configurable via hackrf_set_txvga_gain
• TX RF amplifier near the antenna port ("RF") - 0 or ∼11dB, either enabled or disabled via the
hackrf_set_amp_enable (same function is used for enabling/disabling the RX RF amp in RX mode)
3.3.3 Tuning
The HackRF One can tune to nearly any frequency between 1-6000MHz (and the theoretical limit is even a bit
higher). This is achieved via up/downconverting the RF section of the MAX2837 transceiver IC with the RFFC5072
mixer/synthesizer's local oscillator. The mixer produces the sum and difference frequencies of the IF and LO frequen-
cies, and a LPF or HPF filter can be used to select one of the resulting frequencies. There is also the possibility to
bypass the filter and use the IF as-is. The IF and LO frequencies can be programmed independently, and the behaviour
is selectable. See the function hackrf_set_freq_explicit for more details on it.
There is also the convenience function hackrf_set_freq that automatically select suitable LO and IF frequencies and RF
path for a desired frequency. It should be used in most cases.
3.3.4 Filtering
The MAX2837 has an internal selectable baseband filter for both RX and TX. Its width can be set via
hackrf_set_baseband_filter_bandwidth, but only some values are valid. Valid values can be acquired via the func-
tions hackrf_compute_baseband_filter_bw_round_down_lt and hackrf_compute_baseband_filter_bw.
NOTE in order to avoid aliasing, the bandwidth should not exceed the sample rate. As a sensible default, the firmware
auto-sets the baseband filter bandwidth to a value ≤ 0.75 · Fs whenever the sample rate is changed, thus setting a
custom value should be done after setting the samplerate.
Generated by Doxygen
3.3 Configuration of the RF hardware 29
The sample rate of the ADC/DAC can be set between 2-20MHz via hackrf_set_sample_rate or hackrf_set_sample_rate_manual.
This also automatially adjusts the baseband filter bandwidth to a suitable value.
3.3.6 Clocking
The HackRF one has external clock input and clock output connectors for 10MHz 3.3V clock signals. It automatically
switches to the external clock if it's detected, and its status is readable with hackrf_get_clkin_status. The external clock
can be enabled by the hackrf_set_clkout_enable function.
3.3.7 Bias-tee
The HackRF one has a built in bias-tee (also called (antenna) port power in some of the documentation) ca-
pable of delivering 50mA@3V3 for powering small powered antennas or amplifiers. It can be enabled via the
hackrf_set_antenna_enable function. Please note that when the device is returning to IDLE mode, the firmware au-
tomatically disables this feature. This means it can't be enabled permanently like with the RTL-SDR, and all software
using the HackRF must enable this separatlely.
3.3.8.1 rf_path_filter
enum rf_path_filter
Used only when performing explicit tuning using hackrf_set_freq_explicit, or can be converted into a human readable
string using hackrf_filter_path_name. This can select the image rejection filter (U3, U8 or none) to use - using switches
U5, U6, U9 and U11. When no filter is selected, the mixer itself is bypassed.
Enumerator
Generated by Doxygen
30 Module Documentation
3.3.9.1 hackrf_compute_baseband_filter_bw()
uint32_t hackrf_compute_baseband_filter_bw (
const uint32_t bandwidth_hz )
Parameters
Returns
3.3.9.2 hackrf_compute_baseband_filter_bw_round_down_lt()
uint32_t hackrf_compute_baseband_filter_bw_round_down_lt (
const uint32_t bandwidth_hz )
Parameters
Returns
3.3.9.3 hackrf_filter_path_name()
Parameters
path enum to convert
Generated by Doxygen
3.3 Configuration of the RF hardware 31
Returns
3.3.9.4 hackrf_get_clkin_status()
int hackrf_get_clkin_status (
hackrf_device ∗ device,
uint8_t ∗ status )
Parameters
Returns
3.3.9.5 hackrf_set_amp_enable()
int hackrf_set_amp_enable (
hackrf_device ∗ device,
const uint8_t value )
Enable / disable the ∼11dB RF RX/TX amplifiers U13/U25 via controlling switches U9 and U14.
Parameters
Returns
Generated by Doxygen
32 Module Documentation
3.3.9.6 hackrf_set_antenna_enable()
int hackrf_set_antenna_enable (
hackrf_device ∗ device,
const uint8_t value )
Enable or disable the 3.3V (max 50mA) bias-tee (antenna port power). Defaults to disabled.
NOTE: the firmware auto-disables this after returning to IDLE mode, so a perma-set is not possible, which means all
software supporting HackRF devices must support enabling bias-tee, as setting it externally is not possible like it is with
RTL-SDR for example.
Parameters
Returns
3.3.9.7 hackrf_set_baseband_filter_bandwidth()
int hackrf_set_baseband_filter_bandwidth (
hackrf_device ∗ device,
const uint32_t bandwidth_hz )
Possible values: 1.75, 2.5, 3.5, 5, 5.5, 6, 7, 8, 9, 10, 12, 14, 15, 20, 24, 28MHz, default ≤ 0.75 · Fs The functions
hackrf_compute_baseband_filter_bw and hackrf_compute_baseband_filter_bw_round_down_lt can be used to get a
valid value nearest to a given value.
Setting the sample rate causes the filter bandwidth to be (re)set to its default ≤ 0.75 · Fs value, so setting sample rate
should be done before setting filter bandwidth.
Parameters
Returns
Generated by Doxygen
3.3 Configuration of the RF hardware 33
3.3.9.8 hackrf_set_clkout_enable()
int hackrf_set_clkout_enable (
hackrf_device ∗ device,
const uint8_t value )
Parameters
Returns
3.3.9.9 hackrf_set_freq()
int hackrf_set_freq (
hackrf_device ∗ device,
const uint64_t freq_hz )
This setting is not exact and depends on the PLL settings. Exact resolution is not determined, but the actual tuned
frequency will be quariable in the future.
Parameters
device device to tune
freq_hz center frequency in Hz. Defaults to 900MHz. Should be in range 1-6000MHz, but 0-7250MHz is possible.
The resolution is ∼50Hz, I could not find the exact number.
Returns
3.3.9.10 hackrf_set_freq_explicit()
int hackrf_set_freq_explicit (
hackrf_device ∗ device,
Generated by Doxygen
34 Module Documentation
Center frequency is set to fcenter = fIF + k · fLO where k ∈ {−1; 0; 1}, depending on the value of path. See the
documentation of rf_path_filter for details
Parameters
device device to tune
if_freq_hz tuning frequency of the MAX2837 transceiver IC in Hz. Must be in the range of 2150-2750MHz
lo_freq_hz tuning frequency of the RFFC5072 mixer/synthesizer IC in Hz. Must be in the range
84.375-5400MHz, defaults to 1000MHz. No effect if path is set to RF_PATH_FILTER_BYPASS
path filter path for mixer. See the documentation for rf_path_filter for details
Returns
3.3.9.11 hackrf_set_lna_gain()
int hackrf_set_lna_gain (
hackrf_device ∗ device,
uint32_t value )
Set the RF RX gain of the MAX2837 transceiver IC ("IF" gain setting) in decibels. Must be in range 0-40dB, with 8dB
steps.
Parameters
Returns
3.3.9.12 hackrf_set_sample_rate()
int hackrf_set_sample_rate (
hackrf_device ∗ device,
const double freq_hz )
Generated by Doxygen
3.3 Configuration of the RF hardware 35
Sample rate should be in the range 2-20MHz, with the default being 10MHz. Lower & higher values are technically
possible, but the performance is not guaranteed. This function also sets the baseband filter bandwidth to a value
≤ 0.75 · Fs , so any calls to hackrf_set_baseband_filter_bandwidth should only be made after this.
Parameters
Returns
3.3.9.13 hackrf_set_sample_rate_manual()
int hackrf_set_sample_rate_manual (
hackrf_device ∗ device,
const uint32_t freq_hz,
const uint32_t divider )
Sample rate should be in the range 2-20MHz, with the default being 10MHz. Lower & higher values are technically
possible, but the performance is not guaranteed.
This function sets the sample rate by specifying a clock frequency in Hz and a divider, so the resulting sample rate will
be freq_hz / divider. This function also sets the baseband filter bandwidth to a value ≤ 0.75 · Fs , so any calls to
hackrf_set_baseband_filter_bandwidth should only be made after this.
Parameters
Returns
3.3.9.14 hackrf_set_txvga_gain()
int hackrf_set_txvga_gain (
hackrf_device ∗ device,
uint32_t value )
Generated by Doxygen
36 Module Documentation
Parameters
Returns
3.3.9.15 hackrf_set_vga_gain()
int hackrf_set_vga_gain (
hackrf_device ∗ device,
uint32_t value )
Parameters
Returns
Data Structures
• struct hackrf_transfer
USB transfer information passed to RX or TX callback.
Macros
• #define SAMPLES_PER_BLOCK 8192
Number of samples per tuning when sweeping.
• #define BYTES_PER_BLOCK 16384
Number of bytes per tuning for sweeping.
• #define MAX_SWEEP_RANGES 10
Maximum number of sweep ranges to be specified for hackrf_init_sweep.
Generated by Doxygen
3.4 Transmit & receive operation 37
Typedefs
Enumerations
• enum sweep_style {
LINEAR = 0 ,
INTERLEAVED = 1 }
sweep mode enum
Functions
Generated by Doxygen
38 Module Documentation
3.4.1.1 Streaming
• transmitting (TX)
• receiving (RX)
Each mode needs to be initialized before use, then the mode needs to be entered with the hackrf_start_∗ function.
Data transfer happens through callbacks.
• transfer callback
• flush callback
• initialize libhackrf
• open device
• when done, the transfer callback should return non-zero value, and signal the main thread to stop
Data is transfered through the USB connection via setting up multiple async libusb transfers (hackrf_get_transfer_queue_depth).
In TX mode, the transfers needs to be filled before submitting, and in RX mode, they need to be read out when they
are done. This is done using the transfer callback - it receives a hackrf_transfer object and needs to transfer the data
to/from it. As it's needed for all operations, this gets called whenever we need to move data, so every time a transfer is
finished (and before the first transfer in TX mode). There's a "transfer complete callback" that only gets called when a
transfer is completed. It does not need to do anything special tho, and is optional.
Streaming can be stopped via returning a non-zero value from the transfer callback, but that does NOT reset the device
to IDLE mode, it only stops data transfers. In TX mode, when this happens, and the transmitter runs out of data to
transmit, it will start transmitting all 0 values (but in older firmware versions, it started repeating the last buffer). To
actually stop the operation, a call to hackrf_stop_∗ is needed. Since the callback operate in an async libusb
context, such a call can't be made from there, only from the main thread, so it must be signaled through some means
(for example, a global variable, or better, a pthread_cond) to stop. In RX mode, this signaling can be done from the
transfer callback, but in TX mode, we must make sure that we only stop the operation when the last transfer is completed
and the device transmitted it, or we might lose it. For this reason, the third flush callback exists, that gets called when
this happens. It is adivsed to only signal the main thread to stop from this callback.
The function hackrf_is_streaming can be used to check if the device is streaming or not.
Generated by Doxygen
3.4 Transmit & receive operation 39
3.4.1.1.1 Transfer callback Set when starting an operation with hackrf_start_tx, hackrf_start_rx or hackrf_start_rx_sweep.
This callback supplies / receives data. This function takes a hackrf_transfer struct as a parameter, and fill/read data
to/from its buffer. This function runs in an async libusb context, meaning it should not iteract with the libhackrf library
in other ways. The callback can return a boolean value, if its return value is non-zero then it won't be called again,
meaning that no future transfers will take place, and (in TX case) the flush callback will be called shortly.
3.4.1.1.2 Block complete callback This callback is optional, and only applicable in TX mode. It gets called when-
ever a data transfer is finished, and can read the data. It needs to do nothing at all. This callback can be set using
hackrf_set_tx_block_complete_callback
3.4.1.1.3 Flush callback This callback is optional, and only applicable in TX mode. It get called when the last
transfer is completed, and it's advisable to only stop streaming via this callback. This callback can be set using
hackrf_enable_tx_flush
3.4.1.1.4 Example TX code utilizing the transfer and flush callbacks. // Transmit a 440Hz triangle wave
through FM (144.5MHz) using the libhackrf API
// Copyright (c) 2022 László Baráth "Uncle Dino" HA7DN <https://github.com/Sasszem>
#include <libhackrf/hackrf.h>
#include <math.h>
#include <stdio.h>
#include <pthread.h>
#include <unistd.h>
#include <complex.h>
#include <stdint.h>
const double f_mod = 440;
const uint64_t sample_rate = 10000000;
double triangle() {
// Generate an f_mod frequency triangle wave in the -1 - 1 region
// each call to this function generates a single sample
static double state;
static uint64_t samples_generated;
Generated by Doxygen
40 Module Documentation
hackrf_init();
hackrf_device *device = NULL;
hackrf_open(&device);
hackrf_set_freq(device, 144500000);
hackrf_set_sample_rate(device, 10000000);
hackrf_set_amp_enable(device, 1);
hackrf_set_txvga_gain(device, 20);
// hackrf_set_tx_underrun_limit(device, 100000); // new-ish library function, not always available
hackrf_enable_tx_flush(device, flush_callback, NULL);
hackrf_start_tx(device, transfer_callback, NULL);
pthread_mutex_lock(&mutex);
pthread_cond_wait(&cond, &mutex); // wait fo transfer to complete
hackrf_stop_tx(device);
hackrf_close(device);
hackrf_exit();
return 0;
}
This code can be compiled using gcc -o triangle triangle.c -lm -lhackrf. It generates and trans-
mits a 440Hz triangle wave using FM modulation on the 2m HAM band (check your local laws and regulations on
transmitting and only transmit on bands you have license to!).
For a more complete example, including error handling and more settings, see hackrf_transfer.c
3.4.1.3 Sweeping
Sweeping mode is kind of special. In this mode, the device can be programmed to a list of frequencies to tune on, record
set amount of samples and then tune to the next frequency and repeat. It can be setup via hackrf_init_sweep and started
with hackrf_start_rx_sweep. In this mode, the callback does not receive raw samples, but blocks of samples prefixed
with a frequency header specifying the tuned frequency.
See hackrf_sweep.c for a full example, and especialy the start of the RX callback for parsing the
frequency header.
hackrf_set_hw_sync_mode can be used to setup HW sync mode ( see the documentation on this
mode). This mode allows multiple HackRF Ones to synchronize operations, or one HackRF One to synchrnonize on an
external trigger source.
Generated by Doxygen
3.4 Transmit & receive operation 41
3.4.2.1 BYTES_PER_BLOCK
3.4.2.2 MAX_SWEEP_RANGES
#define MAX_SWEEP_RANGES 10
3.4.2.3 SAMPLES_PER_BLOCK
3.4.3.1 hackrf_flush_cb_fn
Will be called when the last samples are transmitted and stopping transmission will result in no samples getting lost.
Should signal the main thread that it should stop transmission via hackrf_stop_tx
3.4.3.2 hackrf_sample_block_cb_fn
In each mode, it is called when data needs to be handled, meaning filling samples in TX mode or reading them in RX
modes.
In TX mode, it should refill the transfer buffer with new raw IQ data, and set hackrf_transfer::valid_length.
In RX mode, it should copy/process the contents of the transfer buffer's valid part.
In RX SWEEP mode, it receives multiple "blocks" of data, each with a 10-byte header containing the tuned frequency
followed by the samples. See hackrf_init_sweep for more info.
The callback should return 0 if it wants to be called again, and any other value otherwise. Stopping the RX/TX/SWEEP
is still done with hackrf_stop_rx and hackrf_stop_tx, and those should be called from the main thread, so this callback
should signal the main thread that it should stop. Signaling the main thread to stop TX should be done from the flush
callback in order to guarantee that no samples are discarded, see hackrf_flush_cb_fn
Generated by Doxygen
42 Module Documentation
3.4.3.3 hackrf_tx_block_complete_cb_fn
Set via hackrf_set_tx_block_complete_callback, called when a transfer is finished to the device's buffer, regardless if the
transfer was successful or not. It can signal the main thread to stop on failure, can catch USB transfer errors and can
also gather statistics about the transfered data.
3.4.4.1 sweep_style
enum sweep_style
Linear mode is no longer used by the hackrf_sweep command line tool and in general the interleaved method is al-
ways preferable, but the linear mode remains available for backward compatibility and might be useful in some special
circumstances.
Enumerator
3.4.5.1 hackrf_enable_tx_flush()
int hackrf_enable_tx_flush (
hackrf_device ∗ device,
hackrf_flush_cb_fn callback,
void ∗ flush_ctx )
This callback will be called when all the data was transmitted and all data transfers were completed. First parameter is
supplied context, second parameter is success flag.
Generated by Doxygen
3.4 Transmit & receive operation 43
Parameters
Returns
3.4.5.2 hackrf_init_sweep()
int hackrf_init_sweep (
hackrf_device ∗ device,
const uint16_t ∗ frequency_list,
const int num_ranges,
const uint32_t num_bytes,
const uint32_t step_width,
const uint32_t offset,
const enum sweep_style style )
In this mode, in a single data transfer (single call to the RX transfer callback), multiple blocks of size num_bytes bytes
are received with different center frequencies. At the beginning of each block, a 10-byte frequency header is present in
0x7F - 0x7F - uint64_t frequency (LSBFIRST, in Hz) format, followed by the actual samples.
Parameters
Returns
Generated by Doxygen
44 Module Documentation
3.4.5.3 hackrf_is_streaming()
int hackrf_is_streaming (
hackrf_device ∗ device )
Parameters
device device to query
Returns
3.4.5.4 hackrf_set_hw_sync_mode()
int hackrf_set_hw_sync_mode (
hackrf_device ∗ device,
const uint8_t value )
Parameters
Returns
3.4.5.5 hackrf_set_rx_overrun_limit()
int hackrf_set_rx_overrun_limit (
hackrf_device ∗ device,
uint32_t value )
When this limit is set, after the specified number of samples (bytes, not whole IQ pairs) missing the device will automat-
ically return to IDLE mode, thus stopping operation. Useful for handling cases like program/computer crashes or other
problems. The default value 0 means no limit.
Generated by Doxygen
3.4 Transmit & receive operation 45
Parameters
Returns
3.4.5.6 hackrf_set_tx_block_complete_callback()
int hackrf_set_tx_block_complete_callback (
hackrf_device ∗ device,
hackrf_tx_block_complete_cb_fn callback )
This callback will be called whenever an USB transfer to the device is completed, regardless if it was successful or not
(indicated by the second parameter).
Parameters
Returns
3.4.5.7 hackrf_set_tx_underrun_limit()
int hackrf_set_tx_underrun_limit (
hackrf_device ∗ device,
uint32_t value )
When this limit is set, after the specified number of samples (bytes, not whole IQ pairs) missing the device will automat-
ically return to IDLE mode, thus stopping operation. Useful for handling cases like program/computer crashes or other
problems. The default value 0 means no limit.
Parameters
Returns
3.4.5.8 hackrf_start_rx()
int hackrf_start_rx (
hackrf_device ∗ device,
hackrf_sample_block_cb_fn callback,
void ∗ rx_ctx )
Should be called after setting gains, frequency and sampling rate, as these values won't get reset but instead keep their
last value, thus their state is unknown.
The callback is called with a hackrf_transfer object whenever the buffer is full. The callback is called in an async context
so no libhackrf functions should be called from it. The callback should treat its argument as read-only.
Parameters
Returns
3.4.5.9 hackrf_start_rx_sweep()
int hackrf_start_rx_sweep (
hackrf_device ∗ device,
hackrf_sample_block_cb_fn callback,
void ∗ rx_ctx )
Parameters
device device to start sweeping
callback rx callback processing the received data
rx_ctx User provided RX context. Not used by the library, but available to callback as hackrf_transfer::rx_ctx.
Generated by Doxygen
3.4 Transmit & receive operation 47
Returns
3.4.5.10 hackrf_start_tx()
int hackrf_start_tx (
hackrf_device ∗ device,
hackrf_sample_block_cb_fn callback,
void ∗ tx_ctx )
Should be called after setting gains, frequency and sampling rate, as these values won't get reset but instead keep
their last value, thus their state is unknown. Setting flush function (using hackrf_enable_tx_flush) and/or setting block
complete callback (using hackrf_set_tx_block_complete_callback) (if these features are used) should also be done
before this.
The callback is called with a hackrf_transfer object whenever a transfer buffer is needed to be filled with samples. The
callback is called in an async context so no libhackrf functions should be called from it. The callback should treat its
argument as read-only, except the hackrf_transfer::buffer and hackrf_transfer::valid_length.
Parameters
Returns
3.4.5.11 hackrf_stop_rx()
int hackrf_stop_rx (
hackrf_device ∗ device )
Parameters
device device to stop RX on
Returns
Generated by Doxygen
48 Module Documentation
3.4.5.12 hackrf_stop_tx()
int hackrf_stop_tx (
hackrf_device ∗ device )
Parameters
device device to stop TX on
Returns
Data Structures
• struct hackrf_m0_state
State of the SGPIO loop running on the M0 core.
Functions
Generated by Doxygen
3.5 Firmware flashing & debugging 49
• int hackrf_spiflash_write (hackrf_device ∗device, const uint32_t address, const uint16_t length, unsigned char
∗const data)
Write firmware image on the SPI flash.
• int hackrf_spiflash_read (hackrf_device ∗device, const uint32_t address, const uint16_t length, unsigned char
∗data)
Read firmware image on the SPI flash.
• int hackrf_spiflash_status (hackrf_device ∗device, uint8_t ∗data)
Read the status registers of the W25Q80BV SPI flash chip.
• int hackrf_spiflash_clear_status (hackrf_device ∗device)
Clear the status registers of the W25Q80BV SPI flash chip.
• int hackrf_cpld_write (hackrf_device ∗device, unsigned char ∗const data, const unsigned int total_length)
Write configuration bitstream into the XC2C64A-7VQ100C CPLD.
IMPORTANT You should try to use the existing flashing utilities (hackrf_spiflash) to flash new firmware to the
device! Incorrect usage of the SPIFLASH functions (especially hackrf_spiflash_erase an hackrf_spiflash_write) can
brick the device, and DFU mode will be needed to unbrick it!
Firmware flashing can be achieved via writing to the SPI flash holding the firmware of the ARM microcontroller. This can
be achieved by the hackrf_spiflash_∗ functions.
The Spartan II CPLD inside the HackRF One devices could also be reconfigured in the past, but in newer firmwares,
the ARM MCU automatically reconfigures it on startup with a bitstream baked into the firmware image, thus the function
hackrf_cpld_write has no effect, and CPLD flashing can only be done by building a custom firmware (or the automatic
loading can be disabled this way as well). The function hackrf_cpld_write and the util hackrf_cpldjtag are depre-
cated and only kept for backward compatibility with older firmware versions.
3.5.3 Debugging
The functions in this section can be used to directly read/write internal registers of the chips inside a HackRF One unit.
See the page Hardware Components for more details on them.
Here's a brief introduction on the various chips in the HackRF One unit:
This transceiver chip is the RF modulator/demodulator of the HackRF One. This chip sends/receives analoge I/Q
samples to/from the MAX5864 ADC/DAC chip.
Its registers are accessible through the functions hackrf_max2837_read and hackrf_max2837_write
Generated by Doxygen
50 Module Documentation
This chip converts received analgoe I/Q samples to digital and transmitted I/Q samples to analoge. It connects to the
main ARM MCU through the CPLD. No configuration is needed for it, only the sample rate can be set via the clock
generator IC.
This chip supplies clock signals to all of the other chips. It can synthesize a wide range of frequencies from its clock
inputs (internal or external). It uses a fixed 800-MHz internal clock (synthesized via a PLL).
Its registers are accessible through the functions hackrf_si5351c_read and hackrf_si5351c_write
This mixer mixes the RF signal with an internally synthesized local oscillator signal and thus results in the sum and
difference frequencies. Combined with the LPF or HPF filters and the frequency setting in the MAX2837 IC it can be
used to tune to any frequency in the 0-6000MHz range.
Its registers are accessible through the functions hackrf_rffc5071_read and hackrf_rffc5071_write
This is the main processor of the unit. It's a multi-core ARM processor. It's configured to boot from a W25Q80B SPI
flash, but can also be booted from DFU in order to unbrick a bricked unit. It communicated with the host PC via USB.
This chip holds the firmware for the LPC4320 ARM MCU.
This CPLD sits between the MAX5864 ADC/DAC and the main MCU, and mainly performs data format conversion and
some synchronisation.
Its bitstream is auto-loaded on reset by the ARM MCU (from the firmware image), but in older versions, it was possible
to reconfigure it via hackrf_cpld_write, and the (since temporarly removed) hackrf_cpld_checksum function could
verify the firmware in the configuration flash (again, overwritten on startup, so irrelevant).
See issue 608, issue 1140 and issue 1141 for some more details on this!
Generated by Doxygen
3.5 Firmware flashing & debugging 51
3.5.4.1 hackrf_cpld_write()
int hackrf_cpld_write (
hackrf_device ∗ device,
unsigned char ∗const data,
const unsigned int total_length )
Parameters
Returns
3.5.4.2 hackrf_get_m0_state()
int hackrf_get_m0_state (
hackrf_device ∗ device,
hackrf_m0_state ∗ value )
Parameters
in device device to query
out value MCU code state
Returns
Generated by Doxygen
52 Module Documentation
3.5.4.3 hackrf_max2837_read()
int hackrf_max2837_read (
hackrf_device ∗ device,
uint8_t register_number,
uint16_t ∗ value )
Parameters
in device device to query
in register_number register number to read
out value value of the specified register
Returns
3.5.4.4 hackrf_max2837_write()
int hackrf_max2837_write (
hackrf_device ∗ device,
uint8_t register_number,
uint16_t value )
Parameters
device device to write
register_number register number to write
value value to write in the specified register
Returns
3.5.4.5 hackrf_rffc5071_read()
int hackrf_rffc5071_read (
hackrf_device ∗ device,
Generated by Doxygen
3.5 Firmware flashing & debugging 53
uint8_t register_number,
uint16_t ∗ value )
Parameters
in device device to query
in register_number register number to read
out value value of the specified register
Returns
3.5.4.6 hackrf_rffc5071_write()
int hackrf_rffc5071_write (
hackrf_device ∗ device,
uint8_t register_number,
uint16_t value )
Parameters
in device device to write
in register_number register number to write
out value value to write in the specified register
Returns
3.5.4.7 hackrf_si5351c_read()
int hackrf_si5351c_read (
hackrf_device ∗ device,
uint16_t register_number,
uint16_t ∗ value )
Generated by Doxygen
54 Module Documentation
Parameters
in device device to query
in register_number register number to read
out value value of the specified register
Returns
3.5.4.8 hackrf_si5351c_write()
int hackrf_si5351c_write (
hackrf_device ∗ device,
uint16_t register_number,
uint16_t value )
Parameters
in device device to write
in register_number register number to write
out value value to write in the specified register
Returns
3.5.4.9 hackrf_spiflash_clear_status()
int hackrf_spiflash_clear_status (
hackrf_device ∗ device )
Parameters
device device to clear
Generated by Doxygen
3.5 Firmware flashing & debugging 55
Returns
3.5.4.10 hackrf_spiflash_erase()
int hackrf_spiflash_erase (
hackrf_device ∗ device )
Should be followed by writing a new image, or the HackRF will be soft-bricked (still rescuable in DFU mode)
Parameters
device device to ersase
Returns
3.5.4.11 hackrf_spiflash_read()
int hackrf_spiflash_read (
hackrf_device ∗ device,
const uint32_t address,
const uint16_t length,
unsigned char ∗ data )
Parameters
Returns
Generated by Doxygen
56 Module Documentation
3.5.4.12 hackrf_spiflash_status()
int hackrf_spiflash_status (
hackrf_device ∗ device,
uint8_t ∗ data )
See the datasheet for details of the status registers. The two registers are read in order.
Parameters
in device device to query
out data char[2] array of the status registers
Returns
3.5.4.13 hackrf_spiflash_write()
int hackrf_spiflash_write (
hackrf_device ∗ device,
const uint32_t address,
const uint16_t length,
unsigned char ∗const data )
Should only be used for firmware updating. Can brick the device, but it's still rescuable in DFU mode.
Parameters
device device to write on
address address to write to. Should start at 0
length length of data to write. Must be at most 256.
data data to write
Returns
Generated by Doxygen
3.6 Opera Cake add-on board functions 57
Data Structures
• struct hackrf_operacake_dwell_time
Opera Cake port setting in OPERACAKE_MODE_TIME operation.
• struct hackrf_operacake_freq_range
Opera Cake port setting in OPERACAKE_MODE_FREQUENCY operation.
Macros
Enumerations
• enum operacake_ports {
OPERACAKE_PA1 = 0 ,
OPERACAKE_PA2 = 1 ,
OPERACAKE_PA3 = 2 ,
OPERACAKE_PA4 = 3 ,
OPERACAKE_PB1 = 4 ,
OPERACAKE_PB2 = 5 ,
OPERACAKE_PB3 = 6 ,
OPERACAKE_PB4 = 7 }
Opera Cake secondary ports (A1-A4, B1-B4)
• enum operacake_switching_mode {
OPERACAKE_MODE_MANUAL ,
OPERACAKE_MODE_FREQUENCY ,
OPERACAKE_MODE_TIME }
Opera Cake port switching mode.
Functions
Generated by Doxygen
58 Module Documentation
These boards are versatile RF switching boards capable of switching two primary ports (A0 and B0) to any of 8 (A1-A4
and B1-B4) secondary ports (with the only rule that A0 and B0 can not be connected to the same side/bank of secondary
ports at the same time).
• manual setup
• frequency-based setup
• time-based setup
3.6.1.0.1 Manual setup This mode allows A0 and B0 to be connected to any of the secondary ports. This mode is
configured with hackrf_set_operacake_ports.
3.6.1.0.2 Frequency-based setup In this mode the Opera Cake board automatically switches A0 to a port depending
on the tuning frequency. Up to HACKRF_OPERACAKE_MAX_FREQ_RANGES frequency ranges can be setup using
hackrf_set_operacake_freq_ranges, in a priority order. Port B0 mirrors A0 on the opposite side (but both B and A side
ports can be specified for connections to A0)
3.6.1.0.3 Time-based setup In this mode the Opera Cake board automatically switches A0 to a port for a set
amount of time (specified in samples). Up to HACKRF_OPERACAKE_MAX_DWELL_TIMES times can be setup via
hackrf_set_operacake_dwell_times. Port B0 mirrors A0 on the opposite side.
Opera Cake boards can be listed with hackrf_get_operacake_boards, but if only one board is connected, than using
address 0 defaults to it.
Opera Cake mode can be setup via hackrf_set_operacake_mode, then the corresponding configuration function can be
called.
Generated by Doxygen
3.6 Opera Cake add-on board functions 59
There can be up to HACKRF_OPERACAKE_MAX_BOARDS boards connected to a single HackRF One. They can
be assigned individual addresses via onboard jumpers, see the documentation page for details. Note: the
operating modes of the boards can be set individually via hackrf_set_operacake_mode, but in frequency or time mode,
every board configured to that mode will use the same switching plan!
3.6.2.1 HACKRF_OPERACAKE_ADDRESS_INVALID
3.6.2.2 HACKRF_OPERACAKE_MAX_BOARDS
#define HACKRF_OPERACAKE_MAX_BOARDS 8
3.6.2.3 HACKRF_OPERACAKE_MAX_DWELL_TIMES
#define HACKRF_OPERACAKE_MAX_DWELL_TIMES 16
3.6.2.4 HACKRF_OPERACAKE_MAX_FREQ_RANGES
#define HACKRF_OPERACAKE_MAX_FREQ_RANGES 8
3.6.3.1 operacake_ports
enum operacake_ports
Generated by Doxygen
60 Module Documentation
Enumerator
OPERACAKE_PA1
OPERACAKE_PA2
OPERACAKE_PA3
OPERACAKE_PA4
OPERACAKE_PB1
OPERACAKE_PB2
OPERACAKE_PB3
OPERACAKE_PB4
3.6.3.2 operacake_switching_mode
enum operacake_switching_mode
Enumerator
3.6.4.1 hackrf_get_operacake_boards()
int hackrf_get_operacake_boards (
hackrf_device ∗ device,
uint8_t ∗ boards )
Generated by Doxygen
3.6 Opera Cake add-on board functions 61
Parameters
in device device to query
out boards list of boards
Returns
3.6.4.2 hackrf_get_operacake_mode()
int hackrf_get_operacake_mode (
hackrf_device ∗ device,
uint8_t address,
enum operacake_switching_mode ∗ mode )
Parameters
Returns
3.6.4.3 hackrf_operacake_gpio_test()
int hackrf_operacake_gpio_test (
hackrf_device ∗ device,
uint8_t address,
uint16_t ∗ test_result )
Value 0xFFFF means "GPIO mode disabled", and hackrf_operacake advises to remove additional add-on boards and
retry. Value 0 means all tests passed. In any other values, a 1 bit signals an error. Bits are grouped in groups of 3.
Encoding: 0 - u1ctrl - u3ctrl0 - u3ctrl1 - u2ctrl0 - u2ctrl1
Generated by Doxygen
62 Module Documentation
Parameters
Returns
3.6.4.4 hackrf_set_operacake_dwell_times()
int hackrf_set_operacake_dwell_times (
hackrf_device ∗ device,
hackrf_operacake_dwell_time ∗ dwell_times,
uint8_t count )
Note: this configuration applies to all Opera Cake boards in OPERACAKE_MODE_TIME mode
Parameters
Returns
3.6.4.5 hackrf_set_operacake_freq_ranges()
int hackrf_set_operacake_freq_ranges (
hackrf_device ∗ device,
hackrf_operacake_freq_range ∗ freq_ranges,
uint8_t count )
Generated by Doxygen
3.6 Opera Cake add-on board functions 63
Parameters
Returns
3.6.4.6 hackrf_set_operacake_mode()
int hackrf_set_operacake_mode (
hackrf_device ∗ device,
uint8_t address,
enum operacake_switching_mode mode )
Parameters
Returns
3.6.4.7 hackrf_set_operacake_ports()
int hackrf_set_operacake_ports (
hackrf_device ∗ device,
uint8_t address,
uint8_t port_a,
uint8_t port_b )
Should be called after hackrf_set_operacake_mode. A0 and B0 must be connected to opposite sides (A->A and B->B
or A->B and B->A but not A->A and B->A or A->B and B->B)
Generated by Doxygen
64 Module Documentation
Parameters
Returns
3.6.4.8 hackrf_set_operacake_ranges()
int hackrf_set_operacake_ranges (
hackrf_device ∗ device,
uint8_t ∗ ranges,
uint8_t num_ranges )
Note: this configuration applies to all Opera Cake boards in OPERACAKE_MODE_FREQUENCY mode
Parameters
Returns
Generated by Doxygen
Chapter 4
#include <hackrf.h>
hackrf_bool_user_settting
off
rx
tx
hackrf_bias_t_user
_settting_req
Data Fields
• hackrf_bool_user_settting tx
• hackrf_bool_user_settting rx
• hackrf_bool_user_settting off
Generated by Doxygen
66 Data Structure Documentation
4.1.1.1 off
hackrf_bool_user_settting hackrf_bias_t_user_settting_req::off
4.1.1.2 rx
hackrf_bool_user_settting hackrf_bias_t_user_settting_req::rx
4.1.1.3 tx
hackrf_bool_user_settting hackrf_bias_t_user_settting_req::tx
The documentation for this struct was generated from the following file:
• /tmp/host/libhackrf/src/hackrf.h
#include <hackrf.h>
Data Fields
• bool do_update
• bool change_on_mode_entry
• bool enabled
If 'do_update' is true, then the values of 'change_on_mode_entry' and 'enabled' will be used as the new default. If
'do_update' is false, the current default will not change.
Generated by Doxygen
4.3 hackrf_device_list_t Struct Reference 67
4.2.2.1 change_on_mode_entry
bool hackrf_bool_user_settting::change_on_mode_entry
4.2.2.2 do_update
bool hackrf_bool_user_settting::do_update
4.2.2.3 enabled
bool hackrf_bool_user_settting::enabled
The documentation for this struct was generated from the following file:
• /tmp/host/libhackrf/src/hackrf.h
#include <hackrf.h>
Data Fields
• char ∗∗ serial_numbers
Array of human-readable serial numbers.
• enum hackrf_usb_board_id ∗ usb_board_ids
ID of each board, based on USB product ID.
• int ∗ usb_device_index
USB device index for a given HW entry.
• int devicecount
Number of connected HackRF devices, the length of arrays serial_numbers, usb_board_ids and usb_device_index.
• void ∗∗ usb_devices
All USB devices (as libusb_device∗∗ array)
• int usb_devicecount
Number of all queried USB devices.
Generated by Doxygen
68 Data Structure Documentation
Acquired via hackrf_device_list and should be freeed via hackrf_device_list_free. Individual devices can be opened via
hackrf_device_list_open
4.3.2.1 devicecount
int hackrf_device_list_t::devicecount
4.3.2.2 serial_numbers
char∗∗ hackrf_device_list_t::serial_numbers
4.3.2.3 usb_board_ids
4.3.2.4 usb_device_index
int∗ hackrf_device_list_t::usb_device_index
4.3.2.5 usb_devicecount
int hackrf_device_list_t::usb_devicecount
Generated by Doxygen
4.4 hackrf_m0_state Struct Reference 69
4.3.2.6 usb_devices
void∗∗ hackrf_device_list_t::usb_devices
The documentation for this struct was generated from the following file:
• /tmp/host/libhackrf/src/hackrf.h
#include <hackrf.h>
Data Fields
• uint16_t requested_mode
Requested mode.
• uint16_t request_flag
Request flag, 0 means request is completed, any other value means request is pending.
• uint32_t active_mode
Active mode.
• uint32_t m0_count
Number of bytes transferred by the M0.
• uint32_t m4_count
Number of bytes transferred by the M4.
• uint32_t num_shortfalls
Number of shortfalls.
• uint32_t longest_shortfall
Longest shortfall in bytes.
• uint32_t shortfall_limit
Shortfall limit in bytes.
• uint32_t threshold
Threshold m0_count value (in bytes) for next mode change.
• uint32_t next_mode
Mode which will be switched to when threshold is reached.
• uint32_t error
Error, if any, that caused the M0 to revert to IDLE mode.
Generated by Doxygen
70 Data Structure Documentation
4.4.1.1 active_mode
uint32_t hackrf_m0_state::active_mode
4.4.1.2 error
uint32_t hackrf_m0_state::error
4.4.1.3 longest_shortfall
uint32_t hackrf_m0_state::longest_shortfall
4.4.1.4 m0_count
uint32_t hackrf_m0_state::m0_count
4.4.1.5 m4_count
uint32_t hackrf_m0_state::m4_count
4.4.1.6 next_mode
uint32_t hackrf_m0_state::next_mode
4.4.1.7 num_shortfalls
uint32_t hackrf_m0_state::num_shortfalls
Generated by Doxygen
4.5 hackrf_operacake_dwell_time Struct Reference 71
4.4.1.8 request_flag
uint16_t hackrf_m0_state::request_flag
4.4.1.9 requested_mode
uint16_t hackrf_m0_state::requested_mode
4.4.1.10 shortfall_limit
uint32_t hackrf_m0_state::shortfall_limit
4.4.1.11 threshold
uint32_t hackrf_m0_state::threshold
The documentation for this struct was generated from the following file:
• /tmp/host/libhackrf/src/hackrf.h
#include <hackrf.h>
Data Fields
• uint32_t dwell
Dwell time for port (in number of samples)
• uint8_t port
Port to connect A0 to (B0 mirrors this choice) Must be one of operacake_ports.
Generated by Doxygen
72 Data Structure Documentation
4.5.1.1 dwell
uint32_t hackrf_operacake_dwell_time::dwell
4.5.1.2 port
uint8_t hackrf_operacake_dwell_time::port
The documentation for this struct was generated from the following file:
• /tmp/host/libhackrf/src/hackrf.h
#include <hackrf.h>
Data Fields
• uint16_t freq_min
Start frequency (in MHz)
• uint16_t freq_max
Stop frequency (in MHz)
• uint8_t port
Port (A0) to use for that frequency range.
4.6.1.1 freq_max
uint16_t hackrf_operacake_freq_range::freq_max
Generated by Doxygen
4.7 hackrf_transfer Struct Reference 73
4.6.1.2 freq_min
uint16_t hackrf_operacake_freq_range::freq_min
4.6.1.3 port
uint8_t hackrf_operacake_freq_range::port
The documentation for this struct was generated from the following file:
• /tmp/host/libhackrf/src/hackrf.h
#include <hackrf.h>
Data Fields
• hackrf_device ∗ device
HackRF USB device for this transfer.
• uint8_t ∗ buffer
transfer data buffer (interleaved 8 bit I/Q samples)
• int buffer_length
length of data buffer in bytes
• int valid_length
number of buffer bytes that were transferred
• void ∗ rx_ctx
User provided RX context.
• void ∗ tx_ctx
User provided TX context.
A callback should treat all these fields as read-only except that a TX callback should write to the data buffer and may
write to valid_length to indicate that a smaller number of bytes is to be transmitted.
Generated by Doxygen
74 Data Structure Documentation
4.7.2.1 buffer
uint8_t∗ hackrf_transfer::buffer
4.7.2.2 buffer_length
int hackrf_transfer::buffer_length
4.7.2.3 device
hackrf_device∗ hackrf_transfer::device
4.7.2.4 rx_ctx
void∗ hackrf_transfer::rx_ctx
Not used by the library, but available to transfer callbacks for use. Set along with the transfer callback using
hackrf_start_rx or hackrf_start_rx_sweep
4.7.2.5 tx_ctx
void∗ hackrf_transfer::tx_ctx
Not used by the library, but available to transfer callbacks for use. Set along with the transfer callback using
hackrf_start_tx
4.7.2.6 valid_length
int hackrf_transfer::valid_length
The documentation for this struct was generated from the following file:
• /tmp/host/libhackrf/src/hackrf.h
Generated by Doxygen
4.8 read_partid_serialno_t Struct Reference 75
#include <hackrf.h>
Data Fields
See the documentation of the MCU for details! Read via hackrf_board_partid_serialno_read
4.8.2.1 part_id
uint32_t read_partid_serialno_t::part_id[2]
4.8.2.2 serial_no
uint32_t read_partid_serialno_t::serial_no[4]
The documentation for this struct was generated from the following file:
• /tmp/host/libhackrf/src/hackrf.h
Generated by Doxygen
76 Data Structure Documentation
Generated by Doxygen
Index
Generated by Doxygen
78 INDEX
BOARD_REV_GSG_HACKRF1_R7, 18 hackrf_m0_state, 70
BOARD_REV_GSG_HACKRF1_R8, 18
BOARD_REV_GSG_HACKRF1_R9, 18 Firmware flashing & debugging, 48
BOARD_REV_HACKRF1_OLD, 18 hackrf_cpld_write, 51
BOARD_REV_HACKRF1_R10, 18 hackrf_get_m0_state, 51
BOARD_REV_HACKRF1_R6, 18 hackrf_max2837_read, 51
BOARD_REV_HACKRF1_R7, 18 hackrf_max2837_write, 52
BOARD_REV_HACKRF1_R8, 18 hackrf_rffc5071_read, 52
BOARD_REV_HACKRF1_R9, 18 hackrf_rffc5071_write, 53
BOARD_REV_UNDETECTED, 18 hackrf_si5351c_read, 53
BOARD_REV_UNRECOGNIZED, 18 hackrf_si5351c_write, 54
hackrf_board_id, 17 hackrf_spiflash_clear_status, 54
hackrf_board_id_name, 19 hackrf_spiflash_erase, 55
hackrf_board_id_platform, 19 hackrf_spiflash_read, 55
hackrf_board_id_read, 19 hackrf_spiflash_status, 55
hackrf_board_partid_serialno_read, 20 hackrf_spiflash_write, 56
hackrf_board_rev, 18 freq_max
HACKRF_BOARD_REV_GSG, 16 hackrf_operacake_freq_range, 72
hackrf_board_rev_name, 20 freq_min
hackrf_board_rev_read, 20 hackrf_operacake_freq_range, 72
hackrf_close, 21
hackrf_bias_t_user_settting_req, 65
hackrf_device, 17
off, 66
hackrf_device_list, 21
rx, 66
hackrf_device_list_free, 21
tx, 66
hackrf_device_list_open, 22
hackrf_board_id
hackrf_open, 22
Device listing, opening, closing and querying, 17
hackrf_open_by_serial, 22
hackrf_board_id_name
HACKRF_PLATFORM_HACKRF1_OG, 16
Device listing, opening, closing and querying, 19
HACKRF_PLATFORM_HACKRF1_R9, 16
hackrf_board_id_platform
HACKRF_PLATFORM_JAWBREAKER, 17
Device listing, opening, closing and querying, 19
HACKRF_PLATFORM_RAD1O, 17
hackrf_board_id_read
hackrf_reset, 23
Device listing, opening, closing and querying, 19
hackrf_set_leds, 23
hackrf_board_partid_serialno_read
hackrf_set_ui_enable, 24
Device listing, opening, closing and querying, 20
hackrf_set_user_bias_t_opts, 24
hackrf_board_rev
hackrf_supported_platform_read, 25
Device listing, opening, closing and querying, 18
hackrf_usb_api_version_read, 25
HACKRF_BOARD_REV_GSG
hackrf_usb_board_id, 18
Device listing, opening, closing and querying, 16
hackrf_usb_board_id_name, 26
hackrf_board_rev_name
hackrf_version_string_read, 26
Device listing, opening, closing and querying, 20
USB_BOARD_ID_HACKRF_ONE, 18
hackrf_board_rev_read
USB_BOARD_ID_INVALID, 18
Device listing, opening, closing and querying, 20
USB_BOARD_ID_JAWBREAKER, 18
hackrf_bool_user_settting, 66
USB_BOARD_ID_RAD1O, 18
change_on_mode_entry, 67
devicecount
do_update, 67
hackrf_device_list_t, 68
enabled, 67
do_update
hackrf_close
hackrf_bool_user_settting, 67
Device listing, opening, closing and querying, 21
dwell
hackrf_compute_baseband_filter_bw
hackrf_operacake_dwell_time, 71
Configuration of the RF hardware, 29
enabled hackrf_compute_baseband_filter_bw_round_down_lt
hackrf_bool_user_settting, 67 Configuration of the RF hardware, 30
error hackrf_cpld_write
Firmware flashing & debugging, 51
Generated by Doxygen
INDEX 79
Generated by Doxygen
80 INDEX
HACKRF_OPERACAKE_MAX_FREQ_RANGES hackrf_set_tx_underrun_limit
Opera Cake add-on board functions, 59 Transmit & receive operation, 45
HACKRF_PLATFORM_HACKRF1_OG hackrf_set_txvga_gain
Device listing, opening, closing and querying, 16 Configuration of the RF hardware, 35
HACKRF_PLATFORM_HACKRF1_R9 hackrf_set_ui_enable
Device listing, opening, closing and querying, 16 Device listing, opening, closing and querying, 24
HACKRF_PLATFORM_JAWBREAKER hackrf_set_user_bias_t_opts
Device listing, opening, closing and querying, 17 Device listing, opening, closing and querying, 24
HACKRF_PLATFORM_RAD1O hackrf_set_vga_gain
Device listing, opening, closing and querying, 17 Configuration of the RF hardware, 36
hackrf_reset hackrf_si5351c_read
Device listing, opening, closing and querying, 23 Firmware flashing & debugging, 53
hackrf_rffc5071_read hackrf_si5351c_write
Firmware flashing & debugging, 52 Firmware flashing & debugging, 54
hackrf_rffc5071_write hackrf_spiflash_clear_status
Firmware flashing & debugging, 53 Firmware flashing & debugging, 54
hackrf_sample_block_cb_fn hackrf_spiflash_erase
Transmit & receive operation, 41 Firmware flashing & debugging, 55
hackrf_set_amp_enable hackrf_spiflash_read
Configuration of the RF hardware, 31 Firmware flashing & debugging, 55
hackrf_set_antenna_enable hackrf_spiflash_status
Configuration of the RF hardware, 31 Firmware flashing & debugging, 55
hackrf_set_baseband_filter_bandwidth hackrf_spiflash_write
Configuration of the RF hardware, 32 Firmware flashing & debugging, 56
hackrf_set_clkout_enable hackrf_start_rx
Configuration of the RF hardware, 32 Transmit & receive operation, 46
hackrf_set_freq hackrf_start_rx_sweep
Configuration of the RF hardware, 33 Transmit & receive operation, 46
hackrf_set_freq_explicit hackrf_start_tx
Configuration of the RF hardware, 33 Transmit & receive operation, 47
hackrf_set_hw_sync_mode hackrf_stop_rx
Transmit & receive operation, 44 Transmit & receive operation, 47
hackrf_set_leds hackrf_stop_tx
Device listing, opening, closing and querying, 23 Transmit & receive operation, 48
hackrf_set_lna_gain HACKRF_SUCCESS
Configuration of the RF hardware, 34 Library related functions and enums, 8
hackrf_set_operacake_dwell_times hackrf_supported_platform_read
Opera Cake add-on board functions, 62 Device listing, opening, closing and querying, 25
hackrf_set_operacake_freq_ranges hackrf_transfer, 73
Opera Cake add-on board functions, 62 buffer, 74
hackrf_set_operacake_mode buffer_length, 74
Opera Cake add-on board functions, 63 device, 74
hackrf_set_operacake_ports rx_ctx, 74
Opera Cake add-on board functions, 63 tx_ctx, 74
hackrf_set_operacake_ranges valid_length, 74
Opera Cake add-on board functions, 64 HACKRF_TRUE
hackrf_set_rx_overrun_limit Library related functions and enums, 8
Transmit & receive operation, 44 hackrf_tx_block_complete_cb_fn
hackrf_set_sample_rate Transmit & receive operation, 41
Configuration of the RF hardware, 34 hackrf_usb_api_version_read
hackrf_set_sample_rate_manual Device listing, opening, closing and querying, 25
Configuration of the RF hardware, 35 hackrf_usb_board_id
hackrf_set_tx_block_complete_callback Device listing, opening, closing and querying, 18
Transmit & receive operation, 45 hackrf_usb_board_id_name
Generated by Doxygen
INDEX 81
Generated by Doxygen
82 INDEX
serial_no, 75 tx_ctx
request_flag hackrf_transfer, 74
hackrf_m0_state, 70
requested_mode USB_BOARD_ID_HACKRF_ONE
hackrf_m0_state, 71 Device listing, opening, closing and querying, 18
rf_path_filter USB_BOARD_ID_INVALID
Configuration of the RF hardware, 29 Device listing, opening, closing and querying, 18
RF_PATH_FILTER_BYPASS USB_BOARD_ID_JAWBREAKER
Configuration of the RF hardware, 29 Device listing, opening, closing and querying, 18
RF_PATH_FILTER_HIGH_PASS USB_BOARD_ID_RAD1O
Configuration of the RF hardware, 29 Device listing, opening, closing and querying, 18
RF_PATH_FILTER_LOW_PASS usb_board_ids
Configuration of the RF hardware, 29 hackrf_device_list_t, 68
rx usb_device_index
hackrf_bias_t_user_settting_req, 66 hackrf_device_list_t, 68
rx_ctx usb_devicecount
hackrf_transfer, 74 hackrf_device_list_t, 68
usb_devices
SAMPLES_PER_BLOCK hackrf_device_list_t, 68
Transmit & receive operation, 41
serial_no valid_length
read_partid_serialno_t, 75 hackrf_transfer, 74
serial_numbers
hackrf_device_list_t, 68
shortfall_limit
hackrf_m0_state, 71
sweep_style
Transmit & receive operation, 42
threshold
hackrf_m0_state, 71
Transmit & receive operation, 36
BYTES_PER_BLOCK, 40
hackrf_enable_tx_flush, 42
hackrf_flush_cb_fn, 41
hackrf_init_sweep, 43
hackrf_is_streaming, 43
hackrf_sample_block_cb_fn, 41
hackrf_set_hw_sync_mode, 44
hackrf_set_rx_overrun_limit, 44
hackrf_set_tx_block_complete_callback, 45
hackrf_set_tx_underrun_limit, 45
hackrf_start_rx, 46
hackrf_start_rx_sweep, 46
hackrf_start_tx, 47
hackrf_stop_rx, 47
hackrf_stop_tx, 48
hackrf_tx_block_complete_cb_fn, 41
INTERLEAVED, 42
LINEAR, 42
MAX_SWEEP_RANGES, 41
SAMPLES_PER_BLOCK, 41
sweep_style, 42
tx
hackrf_bias_t_user_settting_req, 66
Generated by Doxygen