bladeRF-cli: add support for ADF4002 access

Adds "print adf_enable", "set adf_enable {0,1}", peek adf, and poke adf
commands
This commit is contained in:
Rey Tucker 2017-08-22 16:46:31 -04:00 • committed by Robert Ghilduta
commit f0bc08dc46
5 changed files with 292 additions and 114 deletions

View file

@ -422,11 +422,13 @@ device specifier format.
peek
----
Usage: `peek <adi|dac|lms|si> <address> [num_addresses]`
Usage: `peek <adf|adi|dac|lms|si> <address> [num_addresses]`
The peek command can read any of the devices hanging off the FPGA which
includes the AD9361 or LMS6002D transceiver, VCTCXO trim DAC or the Si5338
clock generator chip.
The peek command can read any of the devices hanging off the FPGA. This
includes the:
* bladeRF 1: LMS6002D transceiver, VCTCXO trim DAC, Si5338 clock generator
* bladeRF 2: AD9361 transceiver, VCTCXO trim DAC, ADF4002 frequency synthesizer
If `num_addresses` is supplied, the address is incremented by 1 and
another peek is performed for that many addresses.
@ -435,6 +437,7 @@ Valid Address Ranges:
Device Address Range
----------- -----------------
`adf` 0 to 3
`adi` 0 to 0x3F7 (1015)
`dac` 0 to 255
`lms` 0 to 127
@ -448,16 +451,19 @@ Example:
poke
----
Usage: `poke <adi|dac|lms|si> <address> <data>`
Usage: `poke <adf|adi|dac|lms|si> <address> <data>`
The poke command can write any of the devices hanging off the FPGA which
includes the AD9361 or LMS6002D transceiver, VCTCXO trim DAC or the Si5338
clock generator chip.
The poke command can write any of the devices hanging off the FPGA. This
includes the:
* bladeRF 1: LMS6002D transceiver, VCTCXO trim DAC, Si5338 clock generator
* bladeRF 2: AD9361 transceiver, VCTCXO trim DAC, ADF4002 frequency synthesizer
Valid Address Ranges:
Device Address Range
----------- -----------------
`adf` 0 to 3
`adi` 0 to 0x3F7 (1015)
`dac` 0 to 255
`lms` 0 to 127
@ -522,6 +528,14 @@ BladeRF1-only parameters:
`xb_gpio_dir` Expansion board GPIO direction (1=output, 0=input)
----------------------------------------------------------------------
BladeRF2-only parameters:
----------------------------------------------------------------------
Parameter Description
------------- --------------------------------------------------------
`adf_enable` Enables (1) or disables (0) the ADF4002 chip
----------------------------------------------------------------------
probe
-----
@ -881,6 +895,14 @@ BladeRF1-only parameters:
`xb_gpio_dir` Expansion board GPIO direction (1=output, 0=input)
----------------------------------------------------------------------
BladeRF2-only parameters:
----------------------------------------------------------------------
Parameter Description
------------- --------------------------------------------------------
`adf_enable` Enables (1) or disables (0) the ADF4002 chip
----------------------------------------------------------------------
version
-------

View file

@ -17,21 +17,26 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include <libbladeRF.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <libbladeRF.h>
#include "common.h"
#include "cmd.h"
#include "peekpoke.h"
#include "common.h"
#include "conversions.h"
#include "peekpoke.h"
static inline bool matches_ad9361(const char *str)
{
return strcasecmp("adi", str) == 0 || strcasecmp("ad9361", str) == 0;
}
static inline bool matches_adf4002(const char *str)
{
return strcasecmp("adf", str) == 0 || strcasecmp("adf4002", str) == 0;
}
static inline bool matches_lms6002d(const char *str)
{
return strcasecmp("lms", str) == 0 || strcasecmp("lms6002d", str) == 0;
@ -45,23 +50,26 @@ static inline bool matches_si5338(const char *str)
int cmd_peek(struct cli_state *state, int argc, char **argv)
{
/* Valid commands:
peek dac <address> [num addresses]
peek lms <address> [num addresses]
peek si <address> [num addresses]
peek {adi,ad9361} <address> [num addresses]
peek {adf,adf4002} <address> [num addresses]
peek dac <address> [num addresses]
peek lms <address> [num addresses]
peek si <address> [num addresses]
*/
int rv = CLI_RET_OK;
bool ok;
int (*f)(struct bladerf *, uint8_t, uint8_t *) = NULL;
int (*f)(struct bladerf *, uint8_t, uint8_t *) = NULL;
int (*f2)(struct bladerf *, uint16_t, uint8_t *) = NULL;
int (*f3)(struct bladerf *, uint8_t, uint32_t *) = NULL;
unsigned int count, address, max_address;
if( argc == 3 || argc == 4 ) {
if (argc == 3 || argc == 4) {
count = 1;
/* Parse the number of addresses */
if( argc == 4 ) {
count = str2uint( argv[3], 0, MAX_NUM_ADDRESSES, &ok );
if( !ok ) {
if (argc == 4) {
count = str2uint(argv[3], 0, MAX_NUM_ADDRESSES, &ok);
if (!ok) {
cli_err(state, argv[0],
"Invalid number of addresses provided (%s)\n", argv[3]);
return CLI_RET_INVPARAM;
@ -71,25 +79,38 @@ int cmd_peek(struct cli_state *state, int argc, char **argv)
/* Are we reading from the AD9361 */
if (matches_ad9361(argv[1])) {
/* Parse address */
address = str2uint( argv[2], 0, ADI_MAX_ADDRESS, &ok );
if( !ok ) {
address = str2uint(argv[2], 0, ADI_MAX_ADDRESS, &ok);
if (!ok) {
invalid_address(state, argv[0], argv[2]);
rv = CLI_RET_INVPARAM;
} else {
f2 = bladerf_ad9361_read;
f2 = bladerf_ad9361_read;
max_address = ADI_MAX_ADDRESS;
}
}
/* Are we reading from the ADF4002? */
else if (matches_adf4002(argv[1])) {
/* Parse address */
address = str2uint(argv[2], 0, ADF4002_MAX_ADDRESS, &ok);
if (!ok) {
invalid_address(state, argv[0], argv[2]);
rv = CLI_RET_INVPARAM;
} else {
f3 = bladerf_adf4002_read;
max_address = ADF4002_MAX_ADDRESS;
}
}
/* Are we reading from the LMS6002D */
else if (matches_lms6002d(argv[1])) {
/* Parse address */
address = str2uint( argv[2], 0, LMS_MAX_ADDRESS, &ok );
if( !ok ) {
address = str2uint(argv[2], 0, LMS_MAX_ADDRESS, &ok);
if (!ok) {
invalid_address(state, argv[0], argv[2]);
rv = CLI_RET_INVPARAM;
} else {
f = bladerf_lms_read;
f = bladerf_lms_read;
max_address = LMS_MAX_ADDRESS;
}
}
@ -97,12 +118,12 @@ int cmd_peek(struct cli_state *state, int argc, char **argv)
/* Are we reading from the Si5338? */
else if (matches_si5338(argv[1])) {
/* Parse address */
address = str2uint( argv[2], 0, SI_MAX_ADDRESS, &ok );
if( !ok ) {
address = str2uint(argv[2], 0, SI_MAX_ADDRESS, &ok);
if (!ok) {
invalid_address(state, argv[0], argv[2]);
rv = CLI_RET_INVPARAM;
} else {
f = bladerf_si5338_read;
f = bladerf_si5338_read;
max_address = SI_MAX_ADDRESS;
}
}
@ -114,24 +135,31 @@ int cmd_peek(struct cli_state *state, int argc, char **argv)
}
/* Loop over the addresses and output the values */
if( rv == CLI_RET_OK && (f || f2) ) {
if (rv == CLI_RET_OK && (f || f2 || f3)) {
int status = BLADERF_ERR_UNEXPECTED;
uint8_t val;
uint32_t val32;
putchar('\n');
for(; count > 0 && address < max_address; count-- ) {
for (; count > 0 && address <= max_address; count--) {
if (f) {
status = f( state->dev, (uint8_t)address, &val );
status = f(state->dev, (uint8_t)address, &val);
} else if (f2) {
status = f2( state->dev, (uint16_t)address, &val );
status = f2(state->dev, (uint16_t)address, &val);
} else if (f3) {
status = f3(state->dev, (uint8_t)address, &val32);
}
if (status < 0) {
state->last_lib_error = status;
rv = CLI_RET_LIBBLADERF;
rv = CLI_RET_LIBBLADERF;
} else {
printf( " 0x%2.2x: 0x%2.2x\n", address, val );
if (f || f2) {
printf(" 0x%2.2x: 0x%2.2x\n", address, val);
} else if (f3) {
printf(" 0x%2.2x: 0x%8.8x\n", address, val32);
}
if (matches_lms6002d(argv[1])) {
lms_reg_info(address, val);
@ -144,9 +172,8 @@ int cmd_peek(struct cli_state *state, int argc, char **argv)
}
} else {
cli_err(state, argv[0], "Invalid number of arguments (%d)\n", argc);
cli_err(state, argv[0], "Invalid number of arguments (%d)\n", argc);
rv = CLI_RET_INVPARAM;
}
return rv;
}

View file

@ -26,14 +26,16 @@
#include "common.h"
#define ADI_MAX_ADDRESS 0x3F7
#define DAC_MAX_ADDRESS 127
#define LMS_MAX_ADDRESS 127
#define SI_MAX_ADDRESS 255
#define MAX_NUM_ADDRESSES 256
#define MAX_VALUE 255
// clang-format off
#define ADI_MAX_ADDRESS 0x3F7
#define DAC_MAX_ADDRESS 127
#define LMS_MAX_ADDRESS 127
#define SI_MAX_ADDRESS 255
#define ADF4002_MAX_ADDRESS 3
#define MAX_NUM_ADDRESSES 256
#define MAX_VALUE 255
// clang-format on
/* Convenience shared function */
void invalid_address(struct cli_state *s, char *fn, char *addr);
@ -42,4 +44,3 @@ void invalid_address(struct cli_state *s, char *fn, char *addr);
void lms_reg_info(unsigned int address, unsigned int value);
#endif /* PEEKPOKE_H__ */

View file

@ -17,48 +17,54 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include <libbladeRF.h>
#include <stdio.h>
#include <string.h>
#include <libbladeRF.h>
#include "cmd.h"
#include "peekpoke.h"
#include "conversions.h"
#include "peekpoke.h"
static inline bool matches_ad9361(const char *str)
{
return strcasecmp("adi", str) == 0 || strcasecmp("ad9361", str) == 0;
}
static inline bool matches_adf4002(const char *str)
{
return strcasecmp("adf", str) == 0 || strcasecmp("adf4002", str) == 0;
}
int cmd_poke(struct cli_state *state, int argc, char **argv)
{
/* Valid commands:
poke dac <address> <value>
poke lms <address> <value>
poke si <address> <value>
poke {adi,ad9361} <address> <value>
poke {adf,adf4002} <address> <value>
poke dac <address> <value>
poke lms <address> <value>
poke si <address> <value>
*/
int rv = CLI_RET_OK;
int status;
bool ok;
int (*f)(struct bladerf *, uint8_t, uint8_t) = NULL;
int (*f)(struct bladerf *, uint8_t, uint8_t) = NULL;
int (*f2)(struct bladerf *, uint16_t, uint8_t) = NULL;
int (*f3)(struct bladerf *, uint8_t, uint32_t) = NULL;
unsigned int address, value;
if( argc == 4 ) {
if (argc == 4) {
/* Parse the value */
value = str2uint( argv[3], 0, MAX_VALUE, &ok );
if( !ok ) {
cli_err(state, argv[0],
"Invalid value provided (%s)", argv[3]);
value = str2uint(argv[3], 0, MAX_VALUE, &ok);
if (!ok) {
cli_err(state, argv[0], "Invalid value provided (%s)", argv[3]);
return CLI_RET_INVPARAM;
}
/* Are we reading from the DAC? */
if( strcasecmp( argv[1], "dac" ) == 0 ) {
/* Are we writing to the DAC? */
if (strcasecmp(argv[1], "dac") == 0) {
/* Parse address */
address = str2uint( argv[2], 0, DAC_MAX_ADDRESS, &ok );
if( !ok ) {
address = str2uint(argv[2], 0, DAC_MAX_ADDRESS, &ok);
if (!ok) {
invalid_address(state, argv[0], argv[2]);
rv = CLI_RET_INVPARAM;
} else {
@ -68,22 +74,35 @@ int cmd_poke(struct cli_state *state, int argc, char **argv)
}
}
/* Are we reading from the AD9361 */
else if(matches_ad9361(argv[1])) {
/* Are we writing to the AD9361? */
else if (matches_ad9361(argv[1])) {
/* Parse address */
address = str2uint( argv[2], 0, ADI_MAX_ADDRESS, &ok );
if( !ok ) {
address = str2uint(argv[2], 0, ADI_MAX_ADDRESS, &ok);
if (!ok) {
invalid_address(state, argv[0], argv[2]);
rv = CLI_RET_INVPARAM;
} else {
f2 = bladerf_ad9361_write;;
f2 = bladerf_ad9361_write;
}
}
/* Are we reading from the LMS6002D */
else if( strcasecmp( argv[1], "lms" ) == 0 ) {
/* Are we writing to the ADF4002? */
else if (matches_adf4002(argv[1])) {
/* Parse address */
address = str2uint( argv[2], 0, LMS_MAX_ADDRESS, &ok );
if( !ok ) {
address = str2uint(argv[2], 0, ADF4002_MAX_ADDRESS, &ok);
if (!ok) {
invalid_address(state, argv[0], argv[2]);
rv = CLI_RET_INVPARAM;
} else {
f3 = bladerf_adf4002_write;
}
}
/* Are we writing to the LMS6002D? */
else if (strcasecmp(argv[1], "lms") == 0) {
/* Parse address */
address = str2uint(argv[2], 0, LMS_MAX_ADDRESS, &ok);
if (!ok) {
invalid_address(state, argv[0], argv[2]);
rv = CLI_RET_INVPARAM;
} else {
@ -91,11 +110,11 @@ int cmd_poke(struct cli_state *state, int argc, char **argv)
}
}
/* Are we reading from the Si5338? */
else if( strcasecmp( argv[1], "si" ) == 0 ) {
/* Are we writing to the Si5338? */
else if (strcasecmp(argv[1], "si") == 0) {
/* Parse address */
address = str2uint( argv[2], 0, SI_MAX_ADDRESS, &ok );
if( !ok ) {
address = str2uint(argv[2], 0, SI_MAX_ADDRESS, &ok);
if (!ok) {
invalid_address(state, argv[0], argv[2]);
rv = CLI_RET_INVPARAM;
} else {
@ -103,29 +122,35 @@ int cmd_poke(struct cli_state *state, int argc, char **argv)
}
}
/* I guess we aren't reading from anything :( */
/* I guess we aren't writing to anything :( */
else {
cli_err(state, argv[0], "%s is not a pokeable device\n", argv[1] );
cli_err(state, argv[0], "%s is not a pokeable device\n", argv[1]);
rv = CLI_RET_INVPARAM;
}
/* Write the value to the address */
if( rv == CLI_RET_OK && (f || f2) ) {
if( f ) {
status = f( state->dev, (uint8_t)address, (uint8_t)value );
} else if( f2 ) {
status = f2( state->dev, (uint16_t)address, (uint8_t)value );
if (rv == CLI_RET_OK && (f || f2 || f3)) {
if (f) {
status = f(state->dev, (uint8_t)address, (uint8_t)value);
} else if (f2) {
status = f2(state->dev, (uint16_t)address, (uint8_t)value);
} else if (f3) {
status = f3(state->dev, (uint8_t)address, (uint32_t)value);
}
if (status < 0) {
state->last_lib_error = status;
rv = CLI_RET_LIBBLADERF;
rv = CLI_RET_LIBBLADERF;
} else {
printf( "\n 0x%2.2x: 0x%2.2x\n", address, value );
putchar('\n');
if (f || f2) {
printf(" 0x%2.2x: 0x%2.2x\n", address, value);
} else if (f3) {
printf(" 0x%2.2x: 0x%8.8x\n", address, value);
}
if (f == bladerf_lms_write) {
uint8_t readback;
int status = bladerf_lms_read(state->dev,
(uint8_t)address,
int status = bladerf_lms_read(state->dev, (uint8_t)address,
&readback);
if (status == 0) {
lms_reg_info(address, readback);
@ -141,4 +166,3 @@ int cmd_poke(struct cli_state *state, int argc, char **argv)
}
return rv;
}

View file

@ -50,7 +50,11 @@ enum printall_option {
PRINTALL_OPTION_APPEND_NEWLINE, /**< Print an extra newline after entry */
};
#define BOARD_ANY NULL
enum board_option {
BOARD_ANY, /**< Supported on all hardware */
BOARD_BLADERF1, /**< Supported on bladeRF 1 */
BOARD_BLADERF2, /**< Supported on bladeRF 2 */
};
/* An entry in the printset table */
struct printset_entry {
@ -68,11 +72,12 @@ struct printset_entry {
* 'print command' with no options (i.e., print everything) */
enum printall_option pa_option;
/** Board associated with this parameter, or NULL for generic */
const char *board;
/** Board associated with this parameter, or BOARD_ANY for generic */
enum board_option const board;
};
/* Declarations */
PRINTSET_DECL(adf_enable);
PRINTSET_DECL(bandwidth);
PRINTSET_DECL(frequency);
PRINTSET_DECL(agc);
@ -96,29 +101,31 @@ PRINTSET_DECL(xb_gpio_dir);
// clang-format off
/* print/set parameter table */
struct printset_entry printset_table[] = {
PRINTSET_ENTRY(bandwidth, PRINTALL_OPTION_APPEND_NEWLINE, BOARD_ANY),
PRINTSET_ENTRY(frequency, PRINTALL_OPTION_APPEND_NEWLINE, BOARD_ANY),
PRINTSET_ENTRY(agc, PRINTALL_OPTION_APPEND_NEWLINE, BOARD_ANY),
PRINTSET_ENTRY(gpio, PRINTALL_OPTION_APPEND_NEWLINE, "bladerf1"),
PRINTSET_ENTRY(loopback, PRINTALL_OPTION_APPEND_NEWLINE, BOARD_ANY),
PRINTSET_ENTRY(rx_mux, PRINTALL_OPTION_APPEND_NEWLINE, BOARD_ANY),
PRINTSET_ENTRY(lnagain, PRINTALL_OPTION_NONE, "bladerf1"),
PRINTSET_ENTRY(rxvga1, PRINTALL_OPTION_NONE, "bladerf1"),
PRINTSET_ENTRY(rxvga2, PRINTALL_OPTION_NONE, "bladerf1"),
PRINTSET_ENTRY(txvga1, PRINTALL_OPTION_NONE, "bladerf1"),
PRINTSET_ENTRY(txvga2, PRINTALL_OPTION_APPEND_NEWLINE, "bladerf1"),
PRINTSET_ENTRY(sampling, PRINTALL_OPTION_APPEND_NEWLINE, "bladerf1"),
PRINTSET_ENTRY(samplerate, PRINTALL_OPTION_APPEND_NEWLINE, BOARD_ANY),
PRINTSET_ENTRY(smb_mode, PRINTALL_OPTION_APPEND_NEWLINE, "bladerf1"),
PRINTSET_ENTRY(trimdac, PRINTALL_OPTION_APPEND_NEWLINE, BOARD_ANY),
PRINTSET_ENTRY(vctcxo_tamer, PRINTALL_OPTION_APPEND_NEWLINE, "bladerf1"),
PRINTSET_ENTRY(xb_spi, PRINTALL_OPTION_SKIP, "bladerf1"),
PRINTSET_ENTRY(xb_gpio, PRINTALL_OPTION_NONE, "bladerf1"),
PRINTSET_ENTRY(xb_gpio_dir, PRINTALL_OPTION_NONE, "bladerf1"),
PRINTSET_ENTRY(bandwidth, PRINTALL_OPTION_APPEND_NEWLINE, BOARD_ANY),
PRINTSET_ENTRY(frequency, PRINTALL_OPTION_APPEND_NEWLINE, BOARD_ANY),
PRINTSET_ENTRY(agc, PRINTALL_OPTION_APPEND_NEWLINE, BOARD_ANY),
PRINTSET_ENTRY(gpio, PRINTALL_OPTION_APPEND_NEWLINE, BOARD_BLADERF1),
PRINTSET_ENTRY(loopback, PRINTALL_OPTION_APPEND_NEWLINE, BOARD_ANY),
PRINTSET_ENTRY(rx_mux, PRINTALL_OPTION_APPEND_NEWLINE, BOARD_ANY),
PRINTSET_ENTRY(lnagain, PRINTALL_OPTION_NONE, BOARD_BLADERF1),
PRINTSET_ENTRY(rxvga1, PRINTALL_OPTION_NONE, BOARD_BLADERF1),
PRINTSET_ENTRY(rxvga2, PRINTALL_OPTION_NONE, BOARD_BLADERF1),
PRINTSET_ENTRY(txvga1, PRINTALL_OPTION_NONE, BOARD_BLADERF1),
PRINTSET_ENTRY(txvga2, PRINTALL_OPTION_APPEND_NEWLINE, BOARD_BLADERF1),
PRINTSET_ENTRY(sampling, PRINTALL_OPTION_APPEND_NEWLINE, BOARD_BLADERF1),
PRINTSET_ENTRY(samplerate, PRINTALL_OPTION_APPEND_NEWLINE, BOARD_ANY),
PRINTSET_ENTRY(smb_mode, PRINTALL_OPTION_APPEND_NEWLINE, BOARD_BLADERF1),
PRINTSET_ENTRY(adf_enable, PRINTALL_OPTION_APPEND_NEWLINE, BOARD_BLADERF2),
PRINTSET_ENTRY(trimdac, PRINTALL_OPTION_APPEND_NEWLINE, BOARD_ANY),
PRINTSET_ENTRY(vctcxo_tamer, PRINTALL_OPTION_APPEND_NEWLINE, BOARD_BLADERF1),
PRINTSET_ENTRY(xb_spi, PRINTALL_OPTION_SKIP, BOARD_BLADERF1),
PRINTSET_ENTRY(xb_gpio, PRINTALL_OPTION_NONE, BOARD_BLADERF1),
PRINTSET_ENTRY(xb_gpio_dir, PRINTALL_OPTION_NONE, BOARD_BLADERF1),
/* End of table marked by entry with NULL/empty fields */
{ FIELD_INIT(.print, NULL), FIELD_INIT(.set, NULL), FIELD_INIT(.name, ""),
FIELD_INIT(.pa_option, PRINTALL_OPTION_NONE), FIELD_INIT(.board, NULL) }
FIELD_INIT(.pa_option, PRINTALL_OPTION_NONE),
FIELD_INIT(.board, BOARD_ANY) }
};
// clang-format on
@ -132,6 +139,51 @@ static bool _is_tx(bladerf_channel ch)
return (ch == BLADERF_CHANNEL_TX(0) || ch == BLADERF_CHANNEL_TX(1));
}
static bool _is_board(struct bladerf *dev, enum board_option board)
{
char const *board_name = bladerf_get_board_name(dev);
if (BOARD_ANY == board) {
return true;
}
if (BOARD_BLADERF1 == board && strcmp(board_name, "bladerf1") == 0) {
return true;
}
if (BOARD_BLADERF2 == board && strcmp(board_name, "bladerf2") == 0) {
return true;
}
return false;
}
static int _gpio_modify(struct bladerf *dev, uint32_t mask, uint32_t val)
{
int status;
uint32_t gpio;
// read from gpio
status = bladerf_config_gpio_read(dev, &gpio);
if (status < 0) {
return status;
}
// clear bits
gpio &= ~(mask);
// set bits
gpio |= (val & mask);
// write back to gpio
status = bladerf_config_gpio_write(dev, gpio);
if (status < 0) {
return status;
}
return status;
}
bladerf_channel get_channel(char *ch, bool *ok)
{
bladerf_channel rv;
@ -184,6 +236,60 @@ static inline void invalid_gain(struct cli_state *s,
cli_err_nnl(s, cmd, "Invalid gain setting for %s (%s)\n", param, gain);
}
int print_adf_enable(struct cli_state *state, int argc, char **argv)
{
int rv = CLI_RET_OK;
int *err = &state->last_lib_error;
int status;
uint32_t val;
status = bladerf_config_gpio_read(state->dev, &val);
if (status < 0) {
*err = status;
rv = CLI_RET_LIBBLADERF;
}
if (rv == CLI_RET_OK) {
int adf_chip_enable = (val >> 11) & 0x01; // 11
printf(" ADF Chip Enable: %s\n",
adf_chip_enable ? "enabled" : "disabled");
}
return rv;
}
int set_adf_enable(struct cli_state *state, int argc, char **argv)
{
/* set adf_enable {0,1} */
int rv = CLI_RET_OK;
int *err = &state->last_lib_error;
int status;
uint32_t val;
if (argc == 3) {
bool ok;
val = str2uint(argv[2], 0, 1, &ok);
if (!ok) {
cli_err_nnl(state, argv[0], "Invalid adf_enable value (%s)\n",
argv[2]);
rv = CLI_RET_INVPARAM;
} else {
status = _gpio_modify(state->dev, 0x800, (val << 11));
if (status < 0) {
*err = status;
rv = CLI_RET_LIBBLADERF;
} else {
rv = print_adf_enable(state, argc, argv);
}
}
} else {
rv = CLI_RET_NARGS;
}
return rv;
}
int print_bandwidth(struct cli_state *state, int argc, char **argv)
{
/* Usage: print bandwidth [rx|tx]*/
@ -648,11 +754,11 @@ int print_gpio(struct cli_state *state, int argc, char **argv)
if (rv == CLI_RET_OK) {
printf(" GPIO: 0x%8.8x\n", val);
if (strcmp(bladerf_get_board_name(state->dev), "bladerf1") == 0) {
if (_is_board(state->dev, BOARD_BLADERF1)) {
_print_gpio_bladerf1(val);
}
if (strcmp(bladerf_get_board_name(state->dev), "bladerf2") == 0) {
if (_is_board(state->dev, BOARD_BLADERF2)) {
_print_gpio_bladerf2(val);
}
}
@ -2203,9 +2309,7 @@ int cmd_print(struct cli_state *state, int argc, char **argv)
for (entry = &printset_table[0]; entry->print != NULL; entry++) {
if (entry->pa_option == PRINTALL_OPTION_SKIP) {
continue;
} else if (entry->board &&
strcmp(entry->board,
bladerf_get_board_name(state->dev)) != 0) {
} else if (!_is_board(state->dev, entry->board)) {
continue;
}