libbladeRF: Device properties

| libbladeRF 2.2.1-git Nuand bladeRF library

Data Structures | Enumerations | Functions
Device properties

## Description

These functions provide the ability to query various pieces of information from an attached device.

These functions are thread-safe.

## Data Structures
struct | bladerf_range
struct | bladerf_serial
struct | bladerf_version

## Enumerations
enum | bladerf_fpga_size { BLADERF_FPGA_UNKNOWN = 0, BLADERF_FPGA_40KLE = 40, BLADERF_FPGA_115KLE = 115, BLADERF_FPGA_A4 = 49, BLADERF_FPGA_A9 = 301 }
enum | bladerf_dev_speed { BLADERF_DEVICE_SPEED_UNKNOWN, BLADERF_DEVICE_SPEED_HIGH, BLADERF_DEVICE_SPEED_SUPER }
enum | bladerf_fpga_source { BLADERF_FPGA_SOURCE_UNKNOWN = 0, BLADERF_FPGA_SOURCE_FLASH = 1, BLADERF_FPGA_SOURCE_HOST = 2 }

## Functions
API_EXPORT int CALL_CONV | bladerf_get_serial (struct bladerf *dev, char *serial)
API_EXPORT int CALL_CONV | bladerf_get_serial_struct (struct bladerf *dev, struct bladerf_serial *serial)
API_EXPORT int CALL_CONV | bladerf_get_fpga_size (struct bladerf *dev, bladerf_fpga_size *size)
API_EXPORT int CALL_CONV | bladerf_get_fpga_bytes (struct bladerf *dev, size_t *size)
API_EXPORT int CALL_CONV | bladerf_get_flash_size (struct bladerf *dev, uint32_t *size, bool *is_guess)
API_EXPORT int CALL_CONV | bladerf_fw_version (struct bladerf *dev, struct bladerf_version *version)
API_EXPORT int CALL_CONV | bladerf_is_fpga_configured (struct bladerf *dev)
API_EXPORT int CALL_CONV | bladerf_fpga_version (struct bladerf *dev, struct bladerf_version *version)
API_EXPORT int CALL_CONV | bladerf_get_fpga_source (struct bladerf *dev, bladerf_fpga_source *source)
API_EXPORT bladerf_dev_speed CALL_CONV | bladerf_device_speed (struct bladerf *dev)
const API_EXPORT char *CALL_CONV | bladerf_get_board_name (struct bladerf *dev)

## Enumeration Type Documentation

## ◆ bladerf_dev_speed

enum bladerf_dev_speed

This enum describes the USB Speed at which the bladeRF is connected. Speeds not listed here are not supported.

Definition at line 412 of file libbladeRF.h.

## ◆ bladerf_fpga_size

enum bladerf_fpga_size

FPGA device variant (size)

Enumerator
BLADERF_FPGA_UNKNOWN | Unable to determine FPGA variant
BLADERF_FPGA_40KLE | 40 kLE FPGA
BLADERF_FPGA_115KLE | 115 kLE FPGA
BLADERF_FPGA_A4 | 49 kLE FPGA (A4)
BLADERF_FPGA_A9 | 301 kLE FPGA (A9)

Definition at line 400 of file libbladeRF.h.

## ◆ bladerf_fpga_source

enum bladerf_fpga_source

FPGA configuration source

Note: the numbering of this enum must match NuandFpgaConfigSource in firmware_common/bladeRF.h

Enumerator
BLADERF_FPGA_SOURCE_UNKNOWN | Uninitialized/invalid
BLADERF_FPGA_SOURCE_FLASH | Last FPGA load was from flash
BLADERF_FPGA_SOURCE_HOST | Last FPGA load was from host

Definition at line 424 of file libbladeRF.h.

## Function Documentation

## ◆ bladerf_device_speed()

API_EXPORT bladerf_dev_speed CALL_CONV bladerf_device_speed | ( | struct bladerf * | dev | ) |

Obtain the bus speed at which the device is operating

Parameters

  dev | Device handle

Returns
  Device speed enumeration

## ◆ bladerf_fpga_version()

API_EXPORT int CALL_CONV bladerf_fpga_version | ( | struct bladerf * | dev,
|  | struct bladerf_version * | version
| ) |  |

Query FPGA version

Parameters

  | dev | Device handle
  [out] | version | Updated to contain firmware version

Returns
  0 on success, value from Error codes list on failure

## ◆ bladerf_fw_version()

API_EXPORT int CALL_CONV bladerf_fw_version | ( | struct bladerf * | dev,
|  | struct bladerf_version * | version
| ) |  |

Query firmware version

Parameters

  | dev | Device handle
  [out] | version | Updated to contain firmware version

Returns
  0 on success, value from Error codes list upon failing to retrieve this information from the device.

## ◆ bladerf_get_board_name()

const API_EXPORT char* CALL_CONV bladerf_get_board_name | ( | struct bladerf * | dev | ) |

Get the board name

Parameters

  dev | Device handle

Returns
  Pointer to C string with the board's model name, either `bladerf1` for a bladeRF x40/x115, or `bladerf2` for a bladeRF Micro.

## ◆ bladerf_get_flash_size()

API_EXPORT int CALL_CONV bladerf_get_flash_size | ( | struct bladerf * | dev,
|  | uint32_t * | size,
|  | bool * | is_guess
| ) |  |

Query a device's Flash size

Parameters

  | dev | Device handle
  [out] | size | Will be updated with the size of the onboard flash, in bytes. If an error occurs, no data will be written to this pointer.
  [out] | is_guess | True if the flash size is a guess (using FPGA size). False if the flash ID was queried and its size was successfully decoded.

Returns
  0 on success, value from Error codes list on failure

## ◆ bladerf_get_fpga_bytes()

API_EXPORT int CALL_CONV bladerf_get_fpga_bytes | ( | struct bladerf * | dev,
|  | size_t * | size
| ) |  |

Query a device's expected FPGA bitstream length, in bytes

Parameters

  | dev | Device handle
  [out] | size | Will be updated with expected bitstream length. If an error occurs, no data will be written to this pointer.

Returns
  0 on success, value from Error codes list on failure

## ◆ bladerf_get_fpga_size()

API_EXPORT int CALL_CONV bladerf_get_fpga_size | ( | struct bladerf * | dev,
|  | bladerf_fpga_size * | size
| ) |  |

Query a device's FPGA size

Parameters

  | dev | Device handle
  [out] | size | Will be updated with the on-board FPGA's size. If an error occurs, no data will be written to this pointer.

Returns
  0 on success, value from Error codes list on failure

## ◆ bladerf_get_fpga_source()

API_EXPORT int CALL_CONV bladerf_get_fpga_source | ( | struct bladerf * | dev,
|  | bladerf_fpga_source * | source
| ) |  |

Query FPGA configuration source

Determine whether the FPGA image was loaded from flash, or if it was loaded from the host, by asking the firmware for the last-known FPGA configuration source.

Parameters

  | dev | Device handle
  [out] | source | Source of the configuration

Returns
  0 on success, BLADERF_ERR_UNSUPPORTED if the BLADERF_CAP_FW_FPGA_SOURCE capability is not present, value from Error codes list on failure

## ◆ bladerf_get_serial()

API_EXPORT int CALL_CONV bladerf_get_serial | ( | struct bladerf * | dev,
|  | char * | serial
| ) |  |

Query a device's serial number (deprecated)

Parameters

  | dev | Device handle
  [out] | serial | This user-supplied buffer, which must be at least BLADERF_SERIAL_LENGTH bytes, will be updated to contain a NUL-terminated serial number string. If an error occurs (as indicated by a non-zero return value), no data will be written to this buffer.

Deprecated:
  New code should use bladerf_get_serial_struct instead.

Returns
  0 on success, value from Error codes list on failure

## ◆ bladerf_get_serial_struct()

API_EXPORT int CALL_CONV bladerf_get_serial_struct | ( | struct bladerf * | dev,
|  | struct bladerf_serial * | serial
| ) |  |

Query a device's serial number

Parameters

  | dev | Device handle
  [out] | serial | Pointer to a bladerf_serial structure, which will be populated with a `serial` string on success.

Example code:

struct bladerf_serial sn;
status = bladerf_get_serial_struct(dev, &sn);
if (status < 0) {
// error handling here
}
printf("Serial number: %s\n", sn.serial);

Returns
  0 on success, value from Error codes list on failure

## ◆ bladerf_is_fpga_configured()

API_EXPORT int CALL_CONV bladerf_is_fpga_configured | ( | struct bladerf * | dev | ) |

Check FPGA configuration status

Parameters

  dev | Device handle

Returns
  1 if FPGA is configured, 0 if it is not, and value from Error codes list on failure

bladerf_get_serial_struct
API_EXPORT int CALL_CONV bladerf_get_serial_struct(struct bladerf *dev, struct bladerf_serial *serial)
bladerf_serial
Definition: libbladeRF.h:379