libhackrf
HackRF SDR platform library
hackrf.h
1/*
2Copyright (c) 2012-2022 Great Scott Gadgets <info@greatscottgadgets.com>
3Copyright (c) 2012, Jared Boone <jared@sharebrained.com>
4Copyright (c) 2013, Benjamin Vernoux <titanmkd@gmail.com>
5
6All rights reserved.
7
8Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
9
10 Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
11 Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the
12 documentation and/or other materials provided with the distribution.
13 Neither the name of Great Scott Gadgets nor the names of its contributors may be used to endorse or promote products derived from this software
14 without specific prior written permission.
15
16THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
17THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
21ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22*/
23
24#ifndef __HACKRF_H__
25#define __HACKRF_H__
26
27#include <stdint.h>
28#include <sys/types.h>
29#include <stdbool.h> // for bool
30#ifdef _WIN32
31 #define ADD_EXPORTS
32
33 /* You should define ADD_EXPORTS *only* when building the DLL. */
34 #ifdef ADD_EXPORTS
35 #define ADDAPI __declspec(dllexport)
36 #else
37 #define ADDAPI __declspec(dllimport)
38 #endif
39
40 /* Define calling convention in one place, for convenience. */
41 #define ADDCALL __cdecl
42
43#else /* _WIN32 not defined. */
44
45 #define ADDAPI
46 #define ADDCALL
47
48#endif
49
512#define SAMPLES_PER_BLOCK 8192
513
518#define BYTES_PER_BLOCK 16384
519
524#define MAX_SWEEP_RANGES 10
525
530#define HACKRF_OPERACAKE_ADDRESS_INVALID 0xFF
531
536#define HACKRF_OPERACAKE_MAX_BOARDS 8
537
542#define HACKRF_OPERACAKE_MAX_DWELL_TIMES 16
543
548#define HACKRF_OPERACAKE_MAX_FREQ_RANGES 8
549
613};
614
619#define HACKRF_BOARD_REV_GSG (0x80)
620
625#define HACKRF_PLATFORM_JAWBREAKER (1 << 0)
630#define HACKRF_PLATFORM_HACKRF1_OG (1 << 1)
635#define HACKRF_PLATFORM_RAD1O (1 << 2)
640#define HACKRF_PLATFORM_HACKRF1_R9 (1 << 3)
641
677};
678
683#define BOARD_ID_HACKRF_ONE (BOARD_ID_HACKRF1_OG)
688#define BOARD_ID_INVALID (BOARD_ID_UNDETECTED)
689
721
742
751};
752
777};
778
799};
800
814};
815
833};
834
852};
853
859
867typedef struct {
871 uint8_t* buffer;
877 void* rx_ctx;
879 void* tx_ctx;
881
886typedef struct {
890 uint32_t part_id[2];
894 uint32_t serial_no[4];
896
901typedef struct {
905 uint32_t dwell;
909 uint8_t port;
911
916typedef struct {
920 uint16_t freq_min;
924 uint16_t freq_max;
928 uint8_t port;
930
935typedef struct {
940
947typedef struct {
952
957typedef struct {
961 uint16_t request_flag;
963 uint32_t active_mode;
965 uint32_t m0_count;
967 uint32_t m4_count;
975 uint32_t threshold;
977 uint32_t next_mode;
979 uint32_t error;
981
1001
1006
1015};
1016
1017typedef struct hackrf_device_list hackrf_device_list_t;
1018
1032
1039typedef void (*hackrf_tx_block_complete_cb_fn)(hackrf_transfer* transfer, int);
1040
1047typedef void (*hackrf_flush_cb_fn)(void* flush_ctx, int);
1048
1049#ifdef __cplusplus
1050extern "C" {
1051#endif
1052
1060extern ADDAPI int ADDCALL hackrf_init();
1061
1069extern ADDAPI int ADDCALL hackrf_exit();
1070
1078extern ADDAPI const char* ADDCALL hackrf_library_version();
1079
1087extern ADDAPI const char* ADDCALL hackrf_library_release();
1088
1094extern ADDAPI hackrf_device_list_t* ADDCALL hackrf_device_list();
1095
1104extern ADDAPI int ADDCALL hackrf_device_list_open(
1105 hackrf_device_list_t* list,
1106 int idx,
1107 hackrf_device** device);
1108
1114extern ADDAPI void ADDCALL hackrf_device_list_free(hackrf_device_list_t* list);
1115
1122extern ADDAPI int ADDCALL hackrf_open(hackrf_device** device);
1123
1131extern ADDAPI int ADDCALL hackrf_open_by_serial(
1132 const char* const desired_serial_number,
1133 hackrf_device** device);
1134
1141extern ADDAPI int ADDCALL hackrf_close(hackrf_device* device);
1142
1155extern ADDAPI int ADDCALL hackrf_start_rx(
1156 hackrf_device* device,
1158 void* rx_ctx);
1159
1167extern ADDAPI int ADDCALL hackrf_stop_rx(hackrf_device* device);
1168
1183extern ADDAPI int ADDCALL hackrf_start_tx(
1184 hackrf_device* device,
1186 void* tx_ctx);
1187
1199 hackrf_device* device,
1201
1213extern ADDAPI int ADDCALL hackrf_enable_tx_flush(
1214 hackrf_device* device,
1215 hackrf_flush_cb_fn callback,
1216 void* flush_ctx);
1217
1225extern ADDAPI int ADDCALL hackrf_stop_tx(hackrf_device* device);
1226
1236extern ADDAPI int ADDCALL hackrf_get_m0_state(
1237 hackrf_device* device,
1238 hackrf_m0_state* value);
1239
1251extern ADDAPI int ADDCALL hackrf_set_tx_underrun_limit(
1252 hackrf_device* device,
1253 uint32_t value);
1254
1266extern ADDAPI int ADDCALL hackrf_set_rx_overrun_limit(
1267 hackrf_device* device,
1268 uint32_t value);
1269
1277extern ADDAPI int ADDCALL hackrf_is_streaming(hackrf_device* device);
1278
1290extern ADDAPI int ADDCALL hackrf_max2837_read(
1291 hackrf_device* device,
1292 uint8_t register_number,
1293 uint16_t* value);
1294
1306extern ADDAPI int ADDCALL hackrf_max2837_write(
1307 hackrf_device* device,
1308 uint8_t register_number,
1309 uint16_t value);
1310
1322extern ADDAPI int ADDCALL hackrf_si5351c_read(
1323 hackrf_device* device,
1324 uint16_t register_number,
1325 uint16_t* value);
1326
1338extern ADDAPI int ADDCALL hackrf_si5351c_write(
1339 hackrf_device* device,
1340 uint16_t register_number,
1341 uint16_t value);
1342
1357 hackrf_device* device,
1358 const uint32_t bandwidth_hz);
1359
1371extern ADDAPI int ADDCALL hackrf_rffc5071_read(
1372 hackrf_device* device,
1373 uint8_t register_number,
1374 uint16_t* value);
1375
1387extern ADDAPI int ADDCALL hackrf_rffc5071_write(
1388 hackrf_device* device,
1389 uint8_t register_number,
1390 uint16_t value);
1391
1401extern ADDAPI int ADDCALL hackrf_spiflash_erase(hackrf_device* device);
1402
1415extern ADDAPI int ADDCALL hackrf_spiflash_write(
1416 hackrf_device* device,
1417 const uint32_t address,
1418 const uint16_t length,
1419 unsigned char* const data);
1420
1433extern ADDAPI int ADDCALL hackrf_spiflash_read(
1434 hackrf_device* device,
1435 const uint32_t address,
1436 const uint16_t length,
1437 unsigned char* data);
1438
1450extern ADDAPI int ADDCALL hackrf_spiflash_status(hackrf_device* device, uint8_t* data);
1451
1462extern ADDAPI int ADDCALL hackrf_spiflash_clear_status(hackrf_device* device);
1463
1464/* device will need to be reset after hackrf_cpld_write */
1465
1476extern ADDAPI int ADDCALL hackrf_cpld_write(
1477 hackrf_device* device,
1478 unsigned char* const data,
1479 const unsigned int total_length);
1480
1492extern ADDAPI int ADDCALL hackrf_board_id_read(hackrf_device* device, uint8_t* value);
1493
1504extern ADDAPI int ADDCALL hackrf_version_string_read(
1505 hackrf_device* device,
1506 char* version,
1507 uint8_t length);
1508
1527extern ADDAPI int ADDCALL hackrf_usb_api_version_read(
1528 hackrf_device* device,
1529 uint16_t* version);
1530
1543extern ADDAPI int ADDCALL hackrf_set_freq(hackrf_device* device, const uint64_t freq_hz);
1544
1557extern ADDAPI int ADDCALL hackrf_set_freq_explicit(
1558 hackrf_device* device,
1559 const uint64_t if_freq_hz,
1560 const uint64_t lo_freq_hz,
1561 const enum rf_path_filter path);
1562
1577extern ADDAPI int ADDCALL hackrf_set_sample_rate_manual(
1578 hackrf_device* device,
1579 const uint32_t freq_hz,
1580 const uint32_t divider);
1581
1593extern ADDAPI int ADDCALL hackrf_set_sample_rate(
1594 hackrf_device* device,
1595 const double freq_hz);
1596
1607extern ADDAPI int ADDCALL hackrf_set_amp_enable(
1608 hackrf_device* device,
1609 const uint8_t value);
1610
1621extern ADDAPI int ADDCALL hackrf_board_partid_serialno_read(
1622 hackrf_device* device,
1623 read_partid_serialno_t* read_partid_serialno);
1624
1635extern ADDAPI int ADDCALL hackrf_set_lna_gain(hackrf_device* device, uint32_t value);
1636
1645extern ADDAPI int ADDCALL hackrf_set_vga_gain(hackrf_device* device, uint32_t value);
1646
1655extern ADDAPI int ADDCALL hackrf_set_txvga_gain(hackrf_device* device, uint32_t value);
1656
1669extern ADDAPI int ADDCALL hackrf_set_antenna_enable(
1670 hackrf_device* device,
1671 const uint8_t value);
1672
1679extern ADDAPI const char* ADDCALL hackrf_error_name(enum hackrf_error errcode);
1680
1688extern ADDAPI const char* ADDCALL hackrf_board_id_name(enum hackrf_board_id board_id);
1689
1697extern ADDAPI uint32_t ADDCALL hackrf_board_id_platform(enum hackrf_board_id board_id);
1698
1699// part of docstring is from hackrf.h
1706extern ADDAPI const char* ADDCALL hackrf_usb_board_id_name(
1707 enum hackrf_usb_board_id usb_board_id);
1708
1715extern ADDAPI const char* ADDCALL hackrf_filter_path_name(const enum rf_path_filter path);
1716
1727 const uint32_t bandwidth_hz);
1728
1738extern ADDAPI uint32_t ADDCALL hackrf_compute_baseband_filter_bw(
1739 const uint32_t bandwidth_hz);
1740
1741/* All features below require USB API version 0x1002 or higher) */
1742
1754extern ADDAPI int ADDCALL hackrf_set_hw_sync_mode(
1755 hackrf_device* device,
1756 const uint8_t value);
1757
1774extern ADDAPI int ADDCALL hackrf_init_sweep(
1775 hackrf_device* device,
1776 const uint16_t* frequency_list,
1777 const int num_ranges,
1778 const uint32_t num_bytes,
1779 const uint32_t step_width,
1780 const uint32_t offset,
1781 const enum sweep_style style);
1782
1794extern ADDAPI int ADDCALL hackrf_get_operacake_boards(
1795 hackrf_device* device,
1796 uint8_t* boards);
1797
1808extern ADDAPI int ADDCALL hackrf_set_operacake_mode(
1809 hackrf_device* device,
1810 uint8_t address,
1811 enum operacake_switching_mode mode);
1812
1823extern ADDAPI int ADDCALL hackrf_get_operacake_mode(
1824 hackrf_device* device,
1825 uint8_t address,
1826 enum operacake_switching_mode* mode);
1827
1841extern ADDAPI int ADDCALL hackrf_set_operacake_ports(
1842 hackrf_device* device,
1843 uint8_t address,
1844 uint8_t port_a,
1845 uint8_t port_b);
1846
1861extern ADDAPI int ADDCALL hackrf_set_operacake_dwell_times(
1862 hackrf_device* device,
1863 hackrf_operacake_dwell_time* dwell_times,
1864 uint8_t count);
1865
1880extern ADDAPI int ADDCALL hackrf_set_operacake_freq_ranges(
1881 hackrf_device* device,
1882 hackrf_operacake_freq_range* freq_ranges,
1883 uint8_t count);
1884
1893extern ADDAPI int ADDCALL hackrf_reset(hackrf_device* device);
1894
1910extern ADDAPI int ADDCALL hackrf_set_operacake_ranges(
1911 hackrf_device* device,
1912 uint8_t* ranges,
1913 uint8_t num_ranges);
1914
1924extern ADDAPI int ADDCALL hackrf_set_clkout_enable(
1925 hackrf_device* device,
1926 const uint8_t value);
1927
1939extern ADDAPI int ADDCALL hackrf_get_clkin_status(hackrf_device* device, uint8_t* status);
1940
1956extern ADDAPI int ADDCALL hackrf_operacake_gpio_test(
1957 hackrf_device* device,
1958 uint8_t address,
1959 uint16_t* test_result);
1960
1961#ifdef HACKRF_ISSUE_609_IS_FIXED
1973extern ADDAPI int ADDCALL hackrf_cpld_checksum(hackrf_device* device, uint32_t* crc);
1974#endif /* HACKRF_ISSUE_609_IS_FIXED */
1975
1987extern ADDAPI int ADDCALL hackrf_set_ui_enable(hackrf_device* device, const uint8_t value);
1988
2001extern ADDAPI int ADDCALL hackrf_start_rx_sweep(
2002 hackrf_device* device,
2004 void* rx_ctx);
2005
2006// docsstring partly from hackrf.c
2013extern ADDAPI size_t ADDCALL hackrf_get_transfer_buffer_size(hackrf_device* device);
2014
2015// docsstring partly from hackrf.c
2022extern ADDAPI uint32_t ADDCALL hackrf_get_transfer_queue_depth(hackrf_device* device);
2023
2033extern ADDAPI int ADDCALL hackrf_board_rev_read(hackrf_device* device, uint8_t* value);
2034
2042extern ADDAPI const char* ADDCALL hackrf_board_rev_name(enum hackrf_board_rev board_rev);
2043
2055extern ADDAPI int ADDCALL hackrf_supported_platform_read(
2056 hackrf_device* device,
2057 uint32_t* value);
2058
2073extern ADDAPI int ADDCALL hackrf_set_leds(hackrf_device* device, const uint8_t state);
2074
2099extern ADDAPI int ADDCALL hackrf_set_user_bias_t_opts(
2100 hackrf_device* device,
2102
2103#ifdef __cplusplus
2104} // __cplusplus defined.
2105#endif
2106
2107#endif /*__HACKRF_H__*/
int hackrf_set_clkout_enable(hackrf_device *device, const uint8_t value)
Enable / disable CLKOUT.
int hackrf_set_lna_gain(hackrf_device *device, uint32_t value)
Set LNA gain.
int hackrf_get_clkin_status(hackrf_device *device, uint8_t *status)
Get CLKIN status.
const char * hackrf_filter_path_name(const enum rf_path_filter path)
Convert rf_path_filter into human-readable string.
rf_path_filter
RF filter path setting enum.
Definition: hackrf.h:786
int hackrf_set_sample_rate_manual(hackrf_device *device, const uint32_t freq_hz, const uint32_t divider)
Set sample rate explicitly.
int hackrf_set_baseband_filter_bandwidth(hackrf_device *device, const uint32_t bandwidth_hz)
Set baseband filter bandwidth.
int hackrf_set_sample_rate(hackrf_device *device, const double freq_hz)
Set sample rate.
int hackrf_set_amp_enable(hackrf_device *device, const uint8_t value)
Enable/disable 14dB RF amplifier.
int hackrf_set_freq(hackrf_device *device, const uint64_t freq_hz)
Set the center frequency.
int hackrf_set_txvga_gain(hackrf_device *device, uint32_t value)
Set RF TX gain of the MAX2837 transceiver IC ("IF" or "VGA" gain setting) in decibels.
uint32_t hackrf_compute_baseband_filter_bw(const uint32_t bandwidth_hz)
Compute nearest valid baseband filter bandwidth to specified value.
int hackrf_set_freq_explicit(hackrf_device *device, const uint64_t if_freq_hz, const uint64_t lo_freq_hz, const enum rf_path_filter path)
Set the center frequency via explicit tuning.
int hackrf_set_vga_gain(hackrf_device *device, uint32_t value)
Set baseband RX gain of the MAX2837 transceier IC ("BB" or "VGA" gain setting) in decibels.
int hackrf_set_antenna_enable(hackrf_device *device, const uint8_t value)
Enable / disable bias-tee (antenna port power)
uint32_t hackrf_compute_baseband_filter_bw_round_down_lt(const uint32_t bandwidth_hz)
Compute nearest valid baseband filter bandwidth lower than a specified value.
@ RF_PATH_FILTER_HIGH_PASS
HPF is selected, .
Definition: hackrf.h:798
@ RF_PATH_FILTER_BYPASS
No filter is selected, the mixer is bypassed, .
Definition: hackrf.h:790
@ RF_PATH_FILTER_LOW_PASS
LPF is selected, .
Definition: hackrf.h:794
int hackrf_spiflash_erase(hackrf_device *device)
Erase firmware image on the SPI flash.
int hackrf_max2837_read(hackrf_device *device, uint8_t register_number, uint16_t *value)
Directly read the registers of the MAX2837 transceiver IC.
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_si5351c_write(hackrf_device *device, uint16_t register_number, uint16_t value)
Directly write the registers of the Si5351 clock generator IC.
int hackrf_max2837_write(hackrf_device *device, uint8_t register_number, uint16_t value)
Directly write the registers of the MAX2837 transceiver IC.
int hackrf_rffc5071_read(hackrf_device *device, uint8_t register_number, uint16_t *value)
Directly read the registers of the RFFC5071/5072 mixer-synthesizer IC.
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_si5351c_read(hackrf_device *device, uint16_t register_number, uint16_t *value)
Directly read the registers of the Si5351C clock generator IC.
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.
int hackrf_rffc5071_write(hackrf_device *device, uint8_t register_number, uint16_t value)
Directly write the registers of the RFFC5071/5072 mixer-synthesizer IC.
int hackrf_get_m0_state(hackrf_device *device, hackrf_m0_state *value)
Get the state of the M0 code on the LPC43xx MCU.
int hackrf_close(hackrf_device *device)
Close a previously opened device.
int hackrf_device_list_open(hackrf_device_list_t *list, int idx, hackrf_device **device)
Open a hackrf_device from a device list.
int hackrf_supported_platform_read(hackrf_device *device, uint32_t *value)
Read supported platform of device.
int hackrf_open_by_serial(const char *const desired_serial_number, hackrf_device **device)
Open HackRF device by serial number.
void hackrf_device_list_free(hackrf_device_list_t *list)
Free a previously allocated hackrf_device_list list.
int hackrf_set_ui_enable(hackrf_device *device, const uint8_t value)
Enable / disable UI display (RAD1O, PortaPack, etc.)
uint32_t hackrf_board_id_platform(enum hackrf_board_id board_id)
Lookup platform ID (HACKRF_PLATFORM_xxx) from board id (hackrf_board_id)
int hackrf_board_partid_serialno_read(hackrf_device *device, read_partid_serialno_t *read_partid_serialno)
Read board part ID and serial number.
int hackrf_set_leds(hackrf_device *device, const uint8_t state)
Turn on or off (override) the LEDs of the HackRF device.
const char * hackrf_board_rev_name(enum hackrf_board_rev board_rev)
Convert board revision name.
const char * hackrf_usb_board_id_name(enum hackrf_usb_board_id usb_board_id)
Convert hackrf_usb_board_id into human-readable string.
hackrf_board_id
HACKRF board id enum.
Definition: hackrf.h:648
hackrf_usb_board_id
USB board ID (product ID) enum.
Definition: hackrf.h:760
int hackrf_board_rev_read(hackrf_device *device, uint8_t *value)
Read board revision of device.
const char * hackrf_board_id_name(enum hackrf_board_id board_id)
Convert hackrf_board_id into human-readable string.
int hackrf_open(hackrf_device **device)
Open first available HackRF device.
struct hackrf_device hackrf_device
Opaque struct for hackrf device info.
Definition: hackrf.h:858
int hackrf_version_string_read(hackrf_device *device, char *version, uint8_t length)
Read HackRF firmware version as a string.
int hackrf_board_id_read(hackrf_device *device, uint8_t *value)
Read hackrf_board_id from a device.
int hackrf_usb_api_version_read(hackrf_device *device, uint16_t *version)
Read HackRF USB API version.
hackrf_board_rev
Board revision enum.
Definition: hackrf.h:696
int hackrf_reset(hackrf_device *device)
Reset HackRF device.
hackrf_device_list_t * hackrf_device_list()
List connected HackRF devices.
int hackrf_set_user_bias_t_opts(hackrf_device *device, hackrf_bias_t_user_settting_req *req)
Configure bias tee behavior of the HackRF device when changing RF states.
@ BOARD_ID_UNDETECTED
Unknown board (detection not yet attempted, should be default value)
Definition: hackrf.h:676
@ BOARD_ID_HACKRF1_R9
HackRF One (rev.
Definition: hackrf.h:668
@ BOARD_ID_JELLYBEAN
Jellybean (pre-production revision, not supported)
Definition: hackrf.h:652
@ BOARD_ID_UNRECOGNIZED
Unknown board (failed detection)
Definition: hackrf.h:672
@ BOARD_ID_HACKRF1_OG
HackRF One (prior to rev 9, same limits: 1-6000MHz, 20MSPS, bias-tee)
Definition: hackrf.h:660
@ BOARD_ID_RAD1O
RAD1O (Chaos Computer Club special edition with LCD & other features.
Definition: hackrf.h:664
@ BOARD_ID_JAWBREAKER
Jawbreaker (beta platform, 10-6000MHz, no bias-tee)
Definition: hackrf.h:656
@ USB_BOARD_ID_INVALID
Invalid / unknown USB product id.
Definition: hackrf.h:776
@ USB_BOARD_ID_RAD1O
RAD1O (custom version) USB product id.
Definition: hackrf.h:772
@ USB_BOARD_ID_JAWBREAKER
Jawbreaker (beta platform) USB product id.
Definition: hackrf.h:764
@ USB_BOARD_ID_HACKRF_ONE
HackRF One USB product id.
Definition: hackrf.h:768
@ BOARD_REV_GSG_HACKRF1_R7
board revision 7, made by GSG
Definition: hackrf.h:729
@ BOARD_REV_HACKRF1_R9
board revision 9, generic
Definition: hackrf.h:716
@ BOARD_REV_UNDETECTED
unknown board revision (detection not yet attempted)
Definition: hackrf.h:750
@ BOARD_REV_GSG_HACKRF1_R8
board revision 8, made by GSG
Definition: hackrf.h:733
@ BOARD_REV_HACKRF1_R10
board revision 10, generic
Definition: hackrf.h:720
@ BOARD_REV_HACKRF1_R8
board revision 8, generic
Definition: hackrf.h:712
@ BOARD_REV_HACKRF1_R6
board revision 6, generic
Definition: hackrf.h:704
@ BOARD_REV_HACKRF1_OLD
Older than rev6.
Definition: hackrf.h:700
@ BOARD_REV_GSG_HACKRF1_R9
board revision 9, made by GSG
Definition: hackrf.h:737
@ BOARD_REV_HACKRF1_R7
board revision 7, generic
Definition: hackrf.h:708
@ BOARD_REV_UNRECOGNIZED
unknown board revision (detection failed)
Definition: hackrf.h:746
@ BOARD_REV_GSG_HACKRF1_R10
board revision 10, made by GSG
Definition: hackrf.h:741
@ BOARD_REV_GSG_HACKRF1_R6
board revision 6, made by GSG
Definition: hackrf.h:725
hackrf_error
error enum, returned by many libhackrf functions
Definition: hackrf.h:556
int hackrf_init()
Initialize libhackrf.
int hackrf_exit()
Exit libhackrf.
const char * hackrf_error_name(enum hackrf_error errcode)
Convert hackrf_error into human-readable string.
size_t hackrf_get_transfer_buffer_size(hackrf_device *device)
Get USB transfer buffer size.
const char * hackrf_library_release()
Get library release.
uint32_t hackrf_get_transfer_queue_depth(hackrf_device *device)
Get the total number of USB transfer buffers.
const char * hackrf_library_version()
Get library version.
@ HACKRF_ERROR_THREAD
Error setting up transfer thread (pthread-related error)
Definition: hackrf.h:588
@ HACKRF_ERROR_NOT_FOUND
USB device not found, returned at opening.
Definition: hackrf.h:572
@ HACKRF_ERROR_NO_MEM
Memory allocation (on host side) failed.
Definition: hackrf.h:580
@ HACKRF_SUCCESS
no error happened
Definition: hackrf.h:560
@ HACKRF_TRUE
TRUE value, returned by some functions that return boolean value.
Definition: hackrf.h:564
@ HACKRF_ERROR_USB_API_VERSION
The installed firmware does not support this function.
Definition: hackrf.h:604
@ HACKRF_ERROR_INVALID_PARAM
The function was called with invalid parameters.
Definition: hackrf.h:568
@ HACKRF_ERROR_STREAMING_THREAD_ERR
Streaming thread could not start due to an error.
Definition: hackrf.h:592
@ HACKRF_ERROR_STREAMING_EXIT_CALLED
Streaming thread exited (normally)
Definition: hackrf.h:600
@ HACKRF_ERROR_LIBUSB
LibUSB error, use hackrf_error_name to get a human-readable error string (using libusb_strerror)
Definition: hackrf.h:584
@ HACKRF_ERROR_BUSY
Resource is busy, possibly the device is already opened.
Definition: hackrf.h:576
@ HACKRF_ERROR_OTHER
Unspecified error.
Definition: hackrf.h:612
@ HACKRF_ERROR_STREAMING_STOPPED
Streaming thread stopped due to an error.
Definition: hackrf.h:596
@ HACKRF_ERROR_NOT_LAST_DEVICE
Can not exit library as one or more HackRFs still in use.
Definition: hackrf.h:608
int hackrf_get_operacake_mode(hackrf_device *device, uint8_t address, enum operacake_switching_mode *mode)
Query Opera Cake mode.
int hackrf_set_operacake_ranges(hackrf_device *device, uint8_t *ranges, uint8_t num_ranges)
Setup Opera Cake frequency ranges in OPERACAKE_MODE_FREQUENCY mode operation.
int hackrf_set_operacake_freq_ranges(hackrf_device *device, hackrf_operacake_freq_range *freq_ranges, uint8_t count)
Setup Opera Cake frequency ranges in OPERACAKE_MODE_FREQUENCY mode operation.
operacake_switching_mode
Opera Cake port switching mode.
Definition: hackrf.h:820
int hackrf_get_operacake_boards(hackrf_device *device, uint8_t *boards)
Query connected Opera Cake boards.
int hackrf_set_operacake_ports(hackrf_device *device, uint8_t address, uint8_t port_a, uint8_t port_b)
Setup Opera Cake ports in OPERACAKE_MODE_MANUAL mode operation.
int hackrf_set_operacake_mode(hackrf_device *device, uint8_t address, enum operacake_switching_mode mode)
Setup Opera Cake operation mode.
int hackrf_set_operacake_dwell_times(hackrf_device *device, hackrf_operacake_dwell_time *dwell_times, uint8_t count)
Setup Opera Cake dwell times in OPERACAKE_MODE_TIME mode operation.
operacake_ports
Opera Cake secondary ports (A1-A4, B1-B4)
Definition: hackrf.h:805
int hackrf_operacake_gpio_test(hackrf_device *device, uint8_t address, uint16_t *test_result)
Perform GPIO test on an Opera Cake addon board.
@ OPERACAKE_MODE_FREQUENCY
Port connections are switched automatically when the frequency is changed.
Definition: hackrf.h:828
@ OPERACAKE_MODE_TIME
Port connections are switched automatically over time.
Definition: hackrf.h:832
@ OPERACAKE_MODE_MANUAL
Port connections are set manually using hackrf_set_operacake_ports.
Definition: hackrf.h:824
@ OPERACAKE_PB4
Definition: hackrf.h:813
@ OPERACAKE_PB2
Definition: hackrf.h:811
@ OPERACAKE_PA1
Definition: hackrf.h:806
@ OPERACAKE_PA2
Definition: hackrf.h:807
@ OPERACAKE_PB1
Definition: hackrf.h:810
@ OPERACAKE_PA4
Definition: hackrf.h:809
@ OPERACAKE_PB3
Definition: hackrf.h:812
@ OPERACAKE_PA3
Definition: hackrf.h:808
void(* hackrf_flush_cb_fn)(void *flush_ctx, int)
Flush (end of transmission) callback.
Definition: hackrf.h:1047
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)
Initialize sweep mode.
int hackrf_stop_tx(hackrf_device *device)
Stop transmission.
int hackrf_start_rx_sweep(hackrf_device *device, hackrf_sample_block_cb_fn callback, void *rx_ctx)
Start RX sweep.
int(* hackrf_sample_block_cb_fn)(hackrf_transfer *transfer)
Sample block callback, used in RX and TX (set via hackrf_start_rx, hackrf_start_rx_sweep and hackrf_s...
Definition: hackrf.h:1031
void(* hackrf_tx_block_complete_cb_fn)(hackrf_transfer *transfer, int)
Block complete callback.
Definition: hackrf.h:1039
int hackrf_stop_rx(hackrf_device *device)
Stop receiving.
int hackrf_start_rx(hackrf_device *device, hackrf_sample_block_cb_fn callback, void *rx_ctx)
Start receiving.
int hackrf_enable_tx_flush(hackrf_device *device, hackrf_flush_cb_fn callback, void *flush_ctx)
Setup flush (end-of-transmission) callback.
int hackrf_set_hw_sync_mode(hackrf_device *device, const uint8_t value)
Set hardware sync mode (hardware triggering)
int hackrf_set_tx_underrun_limit(hackrf_device *device, uint32_t value)
Set transmit underrun limit.
int hackrf_start_tx(hackrf_device *device, hackrf_sample_block_cb_fn callback, void *tx_ctx)
Start transmitting.
int hackrf_set_tx_block_complete_callback(hackrf_device *device, hackrf_tx_block_complete_cb_fn callback)
Setup callback to be called when an USB transfer is completed.
int hackrf_set_rx_overrun_limit(hackrf_device *device, uint32_t value)
Set receive overrun limit.
int hackrf_is_streaming(hackrf_device *device)
Query device streaming status.
sweep_style
sweep mode enum
Definition: hackrf.h:843
@ LINEAR
step_width is added to the current frequency at each step.
Definition: hackrf.h:847
@ INTERLEAVED
each step is divided into two interleaved sub-steps, allowing the host to select the best portions of...
Definition: hackrf.h:851
User settings for user-supplied bias tee defaults.
Definition: hackrf.h:947
hackrf_bool_user_settting rx
Definition: hackrf.h:949
hackrf_bool_user_settting tx
Definition: hackrf.h:948
hackrf_bool_user_settting off
Definition: hackrf.h:950
Helper struct for hackrf_bias_t_user_setting.
Definition: hackrf.h:935
bool change_on_mode_entry
Definition: hackrf.h:937
bool enabled
Definition: hackrf.h:938
bool do_update
Definition: hackrf.h:936
List of connected HackRF devices.
Definition: hackrf.h:988
char ** serial_numbers
Array of human-readable serial numbers.
Definition: hackrf.h:992
int devicecount
Number of connected HackRF devices, the length of arrays serial_numbers, usb_board_ids and usb_device...
Definition: hackrf.h:1005
int * usb_device_index
USB device index for a given HW entry.
Definition: hackrf.h:1000
enum hackrf_usb_board_id * usb_board_ids
ID of each board, based on USB product ID.
Definition: hackrf.h:996
void ** usb_devices
All USB devices (as libusb_device** array)
Definition: hackrf.h:1010
int usb_devicecount
Number of all queried USB devices.
Definition: hackrf.h:1014
State of the SGPIO loop running on the M0 core.
Definition: hackrf.h:957
uint32_t longest_shortfall
Longest shortfall in bytes.
Definition: hackrf.h:971
uint16_t requested_mode
Requested mode.
Definition: hackrf.h:959
uint16_t request_flag
Request flag, 0 means request is completed, any other value means request is pending.
Definition: hackrf.h:961
uint32_t active_mode
Active mode.
Definition: hackrf.h:963
uint32_t m0_count
Number of bytes transferred by the M0.
Definition: hackrf.h:965
uint32_t next_mode
Mode which will be switched to when threshold is reached.
Definition: hackrf.h:977
uint32_t num_shortfalls
Number of shortfalls.
Definition: hackrf.h:969
uint32_t threshold
Threshold m0_count value (in bytes) for next mode change.
Definition: hackrf.h:975
uint32_t error
Error, if any, that caused the M0 to revert to IDLE mode.
Definition: hackrf.h:979
uint32_t shortfall_limit
Shortfall limit in bytes.
Definition: hackrf.h:973
uint32_t m4_count
Number of bytes transferred by the M4.
Definition: hackrf.h:967
Opera Cake port setting in OPERACAKE_MODE_TIME operation.
Definition: hackrf.h:901
uint8_t port
Port to connect A0 to (B0 mirrors this choice) Must be one of operacake_ports.
Definition: hackrf.h:909
uint32_t dwell
Dwell time for port (in number of samples)
Definition: hackrf.h:905
Opera Cake port setting in OPERACAKE_MODE_FREQUENCY operation.
Definition: hackrf.h:916
uint8_t port
Port (A0) to use for that frequency range.
Definition: hackrf.h:928
uint16_t freq_min
Start frequency (in MHz)
Definition: hackrf.h:920
uint16_t freq_max
Stop frequency (in MHz)
Definition: hackrf.h:924
USB transfer information passed to RX or TX callback.
Definition: hackrf.h:867
int buffer_length
length of data buffer in bytes
Definition: hackrf.h:873
void * rx_ctx
User provided RX context.
Definition: hackrf.h:877
hackrf_device * device
HackRF USB device for this transfer.
Definition: hackrf.h:869
uint8_t * buffer
transfer data buffer (interleaved 8 bit I/Q samples)
Definition: hackrf.h:871
int valid_length
number of buffer bytes that were transferred
Definition: hackrf.h:875
void * tx_ctx
User provided TX context.
Definition: hackrf.h:879
MCU (LPC43xx) part ID and serial number.
Definition: hackrf.h:886