libbladeRF: SMB clock port control

| libbladeRF 2.2.1-git Nuand bladeRF library

Enumerations | Macros | Functions
SMB clock port control
bladeRF1-specific API

## Description

The SMB clock port (J62) may be used to synchronize sampling on multiple devices, or to generate an arbitrary clock output for a different device.

For MIMO configurations, one device is the clock "master" and outputs its 38.4 MHz reference on this port. The clock "slave" devices configure the SMB port as an input and expect to see this 38.4 MHz reference on this port. This implies that the "master" must be configured first.

Alternatively, this port may be used to generate an arbitrary clock signal for use with other devices via the bladerf_set_smb_frequency() and bladerf_set_rational_smb_frequency() functions.

Warning
  Do not use these functions when operating an expansion board. A different clock configuration is required for the XB devices which cannot be used simultaneously with the SMB clock port.

These functions are thread-safe.

## Enumerations
enum | bladerf_smb_mode { BLADERF_SMB_MODE_INVALID = -1, BLADERF_SMB_MODE_DISABLED, BLADERF_SMB_MODE_OUTPUT, BLADERF_SMB_MODE_INPUT, BLADERF_SMB_MODE_UNAVAILBLE }

## Macros
#define | BLADERF_SMB_FREQUENCY_MAX 200000000u
#define | BLADERF_SMB_FREQUENCY_MIN ((38400000u * 66u) / (32 * 567))

## Functions
API_EXPORT int CALL_CONV | bladerf_set_smb_mode (struct bladerf *dev, bladerf_smb_mode mode)
API_EXPORT int CALL_CONV | bladerf_get_smb_mode (struct bladerf *dev, bladerf_smb_mode *mode)
API_EXPORT int CALL_CONV | bladerf_set_rational_smb_frequency (struct bladerf *dev, struct bladerf_rational_rate *rate, struct bladerf_rational_rate *actual)
API_EXPORT int CALL_CONV | bladerf_set_smb_frequency (struct bladerf *dev, uint32_t rate, uint32_t *actual)
API_EXPORT int CALL_CONV | bladerf_get_rational_smb_frequency (struct bladerf *dev, struct bladerf_rational_rate *rate)
API_EXPORT int CALL_CONV | bladerf_get_smb_frequency (struct bladerf *dev, unsigned int *rate)

## Enumeration Type Documentation

## ◆ bladerf_smb_mode

enum bladerf_smb_mode

SMB clock port mode of operation

Enumerator
BLADERF_SMB_MODE_INVALID | Invalid selection
BLADERF_SMB_MODE_DISABLED | Not in use. Device operates from its onboard clock and does not use J62.
BLADERF_SMB_MODE_OUTPUT | Device outputs a 38.4 MHz reference clock on J62. This may be used to drive another device that is configured with BLADERF_SMB_MODE_INPUT.
BLADERF_SMB_MODE_INPUT | Device configures J62 as an input and expects a 38.4 MHz reference to be available when this setting is applied.
BLADERF_SMB_MODE_UNAVAILBLE | SMB port is unavailable for use due to the underlying clock being used elsewhere (e.g., for an expansion board).

Definition at line 508 of file bladeRF1.h.

## Macro Definition Documentation

## ◆ BLADERF_SMB_FREQUENCY_MAX

#define BLADERF_SMB_FREQUENCY_MAX 200000000u

Maximum output frequency on SMB connector, if no expansion board attached.

Definition at line 497 of file bladeRF1.h.

## ◆ BLADERF_SMB_FREQUENCY_MIN

#define BLADERF_SMB_FREQUENCY_MIN ((38400000u * 66u) / (32 * 567))

Minimum output frequency on SMB connector, if no expansion board attached.

Definition at line 502 of file bladeRF1.h.

## Function Documentation

## ◆ bladerf_get_rational_smb_frequency()

API_EXPORT int CALL_CONV bladerf_get_rational_smb_frequency | ( | struct bladerf * | dev,
|  | struct bladerf_rational_rate * | rate
| ) |  |

Read the SMB connector output frequency in rational Hz

Parameters

  | dev | Device handle
  [out] | rate | Pointer to returned rational frequency

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

## ◆ bladerf_get_smb_frequency()

API_EXPORT int CALL_CONV bladerf_get_smb_frequency | ( | struct bladerf * | dev,
|  | unsigned int * | rate
| ) |  |

Read the SMB connector output frequency in Hz

Parameters

  | dev | Device handle
  [out] | rate | Pointer to returned frequency

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

## ◆ bladerf_get_smb_mode()

API_EXPORT int CALL_CONV bladerf_get_smb_mode | ( | struct bladerf * | dev,
|  | bladerf_smb_mode * | mode
| ) |  |

Get the current mode of operation of the SMB clock port

Parameters

  | dev | Device handle
  [out] | mode | Desired mode

Returns
  0 on success, or a value from Error codes list on failure.

## ◆ bladerf_set_rational_smb_frequency()

API_EXPORT int CALL_CONV bladerf_set_rational_smb_frequency | ( | struct bladerf * | dev,
|  | struct bladerf_rational_rate * | rate,
|  | struct bladerf_rational_rate * | actual
| ) |  |

Set the SMB clock port frequency in rational Hz

Parameters

  | dev | Device handle
  [in] | rate | Rational frequency
  [out] | actual | If non-NULL, this is written with the actual

The frequency must be between BLADERF_SMB_FREQUENCY_MIN and BLADERF_SMB_FREQUENCY_MAX.

This function inherently configures the SMB clock port as an output. Do not call bladerf_set_smb_mode() with BLADERF_SMB_MODE_OUTPUT, as this will reset the output frequency to the 38.4 MHz reference.

Warning
  This clock should not be set if an expansion board is connected.

Returns
  0 on success, BLADERF_ERR_INVAL for an invalid frequency, or a value from Error codes list on failure.

## ◆ bladerf_set_smb_frequency()

API_EXPORT int CALL_CONV bladerf_set_smb_frequency | ( | struct bladerf * | dev,
|  | uint32_t | rate,
|  | uint32_t * | actual
| ) |  |

Set the SMB connector output frequency in Hz. Use bladerf_set_rational_smb_frequency() for more arbitrary values.

Parameters

  | dev | Device handle
  [in] | rate | Frequency
  [out] | actual | If non-NULL. this is written with the actual frequency achieved.

This function inherently configures the SMB clock port as an output. Do not call bladerf_set_smb_mode() with BLADERF_SMB_MODE_OUTPUT, as this will reset the output frequency to the 38.4 MHz reference.

The frequency must be between BLADERF_SMB_FREQUENCY_MIN and BLADERF_SMB_FREQUENCY_MAX.

Warning
  This clock should not be set if an expansion board is connected.

Returns
  0 on success, BLADERF_ERR_INVAL for an invalid frequency, or a value from Error codes list on other failures

## ◆ bladerf_set_smb_mode()

API_EXPORT int CALL_CONV bladerf_set_smb_mode | ( | struct bladerf * | dev,
|  | bladerf_smb_mode | mode
| ) |  |

Set the current mode of operation of the SMB clock port

In a MIMO configuration, one "master" device should first be configured to output its reference clock to the slave devices via `bladerf_set_smb_mode(dev, BLADERF_SMB_MODE_OUTPUT)`.

Next, all "slave" devices should be configured to use the reference clock provided on the SMB clock port (instead of using their on-board reference) via `bladerf_set_smb_mode(dev, BLADERF_SMB_MODE_INPUT)`.

Parameters

  | dev | Device handle
  [in] | mode | Desired mode

Returns
  0 on success, or a value from Error codes list on failure.