Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,14 @@ Peripheral samples

* :ref:`radio_test` sample:

* Added the new ``start_tx_sweep_with_sleep`` shell command.
It allows for running a TX sweep with silent periods between each frequency.
* Added:

* ``start_tx_sweep_with_sleep`` shell command.
It allows for running a TX sweep with silent periods between each frequency.
* ``set_channel_sequence`` shell command.
It allows for setting a custom channel sequence for the ``start_tx_sweep_with_sleep`` command.
* ``print_channel_sequence`` shell command.
It prints the currently configured channel sequence.

PMIC samples
------------
Expand Down
6 changes: 6 additions & 0 deletions samples/peripheral/radio_test/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,15 @@ User interface
* - parameters_print
-
- Print current delay, channel, and other parameters.
* - print_channel_sequence
-
- Print the custom sequence set with the set_channel_sequence command
Comment thread
thomas-m-johansen marked this conversation as resolved.
* - print_rx
-
- Print the received RX payload.
* - set_channel_sequence
- <sequence of up to 80 channels>
- Set a custom channel sequence for the start_tx_with_sleep command
* - start_channel
- <channel>
- Start channel for the sweep or the channel for the constant carrier (in MHz, as difference from 2400 MHz).
Expand Down
67 changes: 62 additions & 5 deletions samples/peripheral/radio_test/src/radio_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -672,11 +672,9 @@ static int cmd_tx_sweep_with_sleep_start(const struct shell *shell, size_t argc,
memset(&test_config, 0, sizeof(test_config));
test_config.type = TX_SWEEP_WITH_SLEEP;
test_config.mode = config.mode;
test_config.params.tx_sweep_duty_cycle.channel_index_start = 0;
test_config.params.tx_sweep_duty_cycle.channel_index_end = 71;
test_config.params.tx_sweep_duty_cycle.t_tx_us = config.t_tx_us;
test_config.params.tx_sweep_duty_cycle.t_sleep_us = config.t_sleep_us;
test_config.params.tx_sweep_duty_cycle.txpower = config.txpower;
test_config.params.tx_sweep_with_sleep.t_tx_us = config.t_tx_us;
test_config.params.tx_sweep_with_sleep.t_sleep_us = config.t_sleep_us;
test_config.params.tx_sweep_with_sleep.txpower = config.txpower;

radio_test_start(&test_config);

Expand All @@ -686,6 +684,58 @@ static int cmd_tx_sweep_with_sleep_start(const struct shell *shell, size_t argc,
return 0;
}

static int cmd_set_channel_sequence(const struct shell *shell, size_t argc,
char **argv)
{
if (argc == 1) {
shell_help(shell);
return SHELL_CMD_HELP_PRINTED;
}

uint8_t sequence_length = argc - 1;

if (sequence_length > 80) {
shell_error(shell, "Too many channels in array, %i is larger than 80",
sequence_length);
}

for (uint8_t i = 0; i < sequence_length; i++) {
int channel = atoi(argv[i + 1]);

if (channel > 80 || channel < 0) {
shell_error(shell, "Channel number %i with value %i is out of range. "
"Allowed range for channels is 0 to 80", i,
channel);
return -EINVAL;
}
}

struct radio_test_channel_sequence *channel_sequence = radio_test_channel_sequence_get();

channel_sequence->sequence_length = sequence_length;
for (uint8_t i = 0; i < sequence_length; i++) {
uint8_t channel = atoi(argv[i + 1]);

channel_sequence->sequence_array[i] = channel;
}
return 0;
}

static int cmd_print_channel_sequence(const struct shell *shell, size_t argc, char **argv)
{
struct radio_test_channel_sequence *channel_sequence = radio_test_channel_sequence_get();

shell_print(shell, "Channel Sequence length: %i", channel_sequence->sequence_length);
shell_fprintf_normal(shell, "Channel Sequence: [%i", channel_sequence->sequence_array[0]);

for (uint8_t i = 1; i < channel_sequence->sequence_length; i++) {
shell_fprintf_normal(shell, ", %i", channel_sequence->sequence_array[i]);
}

shell_print(shell, "]");
return 0;
}

static int cmd_rx_start(const struct shell *shell, size_t argc, char **argv)
{
if (test_in_progress) {
Expand Down Expand Up @@ -1530,6 +1580,13 @@ SHELL_CMD_REGISTER(start_tx_sweep_with_sleep, NULL,
"Start TX sweep with sleep cycle, "
"<tx_time> (us) <sleep_time> (us)",
cmd_tx_sweep_with_sleep_start);
SHELL_CMD_REGISTER(set_channel_sequence, NULL,
"Set a custom channel sequence for TX "
"<sequence_of_up_to_80_channels>",
cmd_set_channel_sequence);
SHELL_CMD_REGISTER(print_channel_sequence, NULL,
"Print the custom channel sequence for TX.",
cmd_print_channel_sequence);
SHELL_CMD_REGISTER(start_rx, NULL, "Start RX", cmd_rx_start);
Comment thread
thomas-m-johansen marked this conversation as resolved.
SHELL_CMD_REGISTER(print_rx, NULL, "Print RX payload", cmd_print_payload);
#if defined(TOGGLE_DCDC_HELP)
Expand Down
30 changes: 19 additions & 11 deletions samples/peripheral/radio_test/src/radio_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,13 @@ static uint32_t rx_packet_cnt;
static uint8_t current_channel;

/* Radio TX Sweep with sleep channel array */
const static uint8_t channel_array[72] = {4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
static struct radio_test_channel_sequence channel_sequence = {
.sequence_length = 72,
.sequence_array = {4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
17, 18, 19, 20, 21, 22, 23, 24, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41,
42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78};
64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78}
};

/* Timer used for channel sweeps and tx with duty cycle. */
static nrfx_timer_t timer =
Expand Down Expand Up @@ -1142,9 +1145,9 @@ void radio_test_start(const struct radio_test_config *config)
config->params.modulated_tx_duty_cycle.duty_cycle);
break;
case TX_SWEEP_WITH_SLEEP:
radio_tx_sweep_with_sleep(config->params.tx_sweep_duty_cycle.txpower,
config->params.tx_sweep_duty_cycle.t_tx_us,
config->params.tx_sweep_duty_cycle.t_sleep_us);
radio_tx_sweep_with_sleep(config->params.tx_sweep_with_sleep.txpower,
config->params.tx_sweep_with_sleep.t_tx_us,
config->params.tx_sweep_with_sleep.t_sleep_us);
break;
}

Expand Down Expand Up @@ -1273,14 +1276,14 @@ static void timer_handler(nrf_timer_event_t event_type, void *context)
sweep_processing = true;

/* disable radio after tone */
radio_unmodulated_tx_carrier_radio_setup(NRF_RADIO_MODE_BLE_1MBIT,
config->params.tx_sweep_duty_cycle.txpower,
channel_array[current_channel],
false);
radio_unmodulated_tx_carrier_radio_setup(
NRF_RADIO_MODE_BLE_1MBIT,
config->params.tx_sweep_with_sleep.txpower,
channel_sequence.sequence_array[current_channel], false);

/* set up next channel */
channel_start = config->params.tx_sweep_duty_cycle.channel_index_start;
channel_end = config->params.tx_sweep_duty_cycle.channel_index_end;
channel_start = 0;
channel_end = channel_sequence.sequence_length - 1;
} else {
printk("Unexpected test type: %d\n", config->type);
return;
Expand Down Expand Up @@ -1404,3 +1407,8 @@ int radio_test_init(struct radio_test_config *config)

return 0;
}

struct radio_test_channel_sequence *radio_test_channel_sequence_get(void)
{
return &channel_sequence;
}
24 changes: 17 additions & 7 deletions samples/peripheral/radio_test/src/radio_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,18 +181,12 @@ struct radio_test_config {
/** Radio output power. */
int8_t txpower;

/** Radio start channel index. */
uint8_t channel_index_start;

/** Radio end channel index. */
uint8_t channel_index_end;

/** Radio transmission time in us. */
uint16_t t_tx_us;

/** Radio sleep time in us. */
uint16_t t_sleep_us;
} tx_sweep_duty_cycle;
} tx_sweep_with_sleep;
} params;

#if CONFIG_FEM
Expand All @@ -216,6 +210,15 @@ struct radio_rx_stats {
uint32_t packet_cnt;
};

/**@brief Configurable channel sequence for TX with sleep. */
struct radio_test_channel_sequence {
/** Length of configurable channel sequence. */
uint8_t sequence_length;

/** Configurable channel sequence contents. */
uint8_t sequence_array[80];
};

/**
* @brief Function for initializing the Radio Test module.
*
Expand Down Expand Up @@ -254,4 +257,11 @@ void radio_rx_stats_get(struct radio_rx_stats *rx_stats);
*/
void toggle_dcdc_state(uint8_t dcdc_state);

/**
* @brief Function for getting the radio_test_channel_sequence for the TX sweep with sleep.
*
* @return Pointer to the static channel_sequence in the radio_test
*/
struct radio_test_channel_sequence *radio_test_channel_sequence_get(void);

#endif /* RADIO_TEST_H_ */
Loading