Skip to content

Commit

Permalink
applications: nrf5340_audio: Added comment for CI strings
Browse files Browse the repository at this point in the history
- Makes it clearer which strings are used by CI
- Should not change these without notifying CI

Signed-off-by: Alexander Svensen <alexander.svensen@nordicsemi.no>
  • Loading branch information
alexsven authored and rlubos committed Aug 18, 2023
1 parent a741296 commit cf5e2b3
Show file tree
Hide file tree
Showing 16 changed files with 69 additions and 44 deletions.
82 changes: 41 additions & 41 deletions applications/nrf5340_audio/src/audio/audio_datapath.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,23 @@ LOG_MODULE_REGISTER(audio_datapath, CONFIG_AUDIO_DATAPATH_LOG_LEVEL);

/* Total sample FIFO period in microseconds */
#define FIFO_SMPL_PERIOD_US (CONFIG_AUDIO_MAX_PRES_DLY_US * 2)
#define FIFO_NUM_BLKS NUM_BLKS(FIFO_SMPL_PERIOD_US)
#define MAX_FIFO_SIZE (FIFO_NUM_BLKS * BLK_SIZE_SAMPLES(CONFIG_AUDIO_SAMPLE_RATE_HZ) * 2)
#define FIFO_NUM_BLKS NUM_BLKS(FIFO_SMPL_PERIOD_US)
#define MAX_FIFO_SIZE (FIFO_NUM_BLKS * BLK_SIZE_SAMPLES(CONFIG_AUDIO_SAMPLE_RATE_HZ) * 2)

/* Number of audio blocks given a duration */
#define NUM_BLKS(d) ((d) / BLK_PERIOD_US)
#define NUM_BLKS(d) ((d) / BLK_PERIOD_US)
/* Single audio block size in number of samples (stereo) */
#define BLK_SIZE_SAMPLES(r) (((r)*BLK_PERIOD_US) / 1000000)
/* Increment sample FIFO index by one block */
#define NEXT_IDX(i) (((i) < (FIFO_NUM_BLKS - 1)) ? ((i) + 1) : 0)
#define NEXT_IDX(i) (((i) < (FIFO_NUM_BLKS - 1)) ? ((i) + 1) : 0)
/* Decrement sample FIFO index by one block */
#define PREV_IDX(i) (((i) > 0) ? ((i)-1) : (FIFO_NUM_BLKS - 1))
#define PREV_IDX(i) (((i) > 0) ? ((i)-1) : (FIFO_NUM_BLKS - 1))

#define NUM_BLKS_IN_FRAME NUM_BLKS(CONFIG_AUDIO_FRAME_DURATION_US)
#define BLK_MONO_NUM_SAMPS BLK_SIZE_SAMPLES(CONFIG_AUDIO_SAMPLE_RATE_HZ)
#define BLK_STEREO_NUM_SAMPS (BLK_MONO_NUM_SAMPS * 2)
#define NUM_BLKS_IN_FRAME NUM_BLKS(CONFIG_AUDIO_FRAME_DURATION_US)
#define BLK_MONO_NUM_SAMPS BLK_SIZE_SAMPLES(CONFIG_AUDIO_SAMPLE_RATE_HZ)
#define BLK_STEREO_NUM_SAMPS (BLK_MONO_NUM_SAMPS * 2)
/* Number of octets in a single audio block */
#define BLK_MONO_SIZE_OCTETS (BLK_MONO_NUM_SAMPS * CONFIG_AUDIO_BIT_DEPTH_OCTETS)
#define BLK_MONO_SIZE_OCTETS (BLK_MONO_NUM_SAMPS * CONFIG_AUDIO_BIT_DEPTH_OCTETS)
#define BLK_STEREO_SIZE_OCTETS (BLK_MONO_SIZE_OCTETS * 2)
/* How many function calls before moving on with drift compensation */
#define DRIFT_COMP_WAITING_CNT (DRIFT_MEAS_PERIOD_US / BLK_PERIOD_US)
Expand All @@ -67,27 +67,27 @@ LOG_MODULE_REGISTER(audio_datapath, CONFIG_AUDIO_DATAPATH_LOG_LEVEL);

/* Audio clock - nRF5340 Analog Phase-Locked Loop (APLL) */
#define APLL_FREQ_CENTER 39854
#define APLL_FREQ_MIN 36834
#define APLL_FREQ_MAX 42874
#define APLL_FREQ_MIN 36834
#define APLL_FREQ_MAX 42874
/* Use nanoseconds to reduce rounding errors */
#define APLL_FREQ_ADJ(t) (-((t)*1000) / 331)

#define DRIFT_MEAS_PERIOD_US 100000
#define DRIFT_ERR_THRESH_LOCK 16
#define DRIFT_MEAS_PERIOD_US 100000
#define DRIFT_ERR_THRESH_LOCK 16
#define DRIFT_ERR_THRESH_UNLOCK 32

/* 3000 us to allow BLE transmission and (host -> HCI -> controller) */
#define JUST_IN_TIME_US (CONFIG_AUDIO_FRAME_DURATION_US - 3000)
#define JUST_IN_TIME_US (CONFIG_AUDIO_FRAME_DURATION_US - 3000)
#define JUST_IN_TIME_THRESHOLD_US 1500

/* How often to print underrun warning */
#define UNDERRUN_LOG_INTERVAL_BLKS 5000

enum drift_comp_state {
DRIFT_STATE_INIT, /* Waiting for data to be received */
DRIFT_STATE_CALIB, /* Calibrate and zero out local delay */
DRIFT_STATE_INIT, /* Waiting for data to be received */
DRIFT_STATE_CALIB, /* Calibrate and zero out local delay */
DRIFT_STATE_OFFSET, /* Adjust I2S offset relative to SDU Reference */
DRIFT_STATE_LOCKED /* Drift compensation locked - Minor corrections */
DRIFT_STATE_LOCKED /* Drift compensation locked - Minor corrections */
};

static const char *const drift_comp_state_names[] = {
Expand All @@ -98,9 +98,9 @@ static const char *const drift_comp_state_names[] = {
};

enum pres_comp_state {
PRES_STATE_INIT, /* Initialize presentation compensation */
PRES_STATE_MEAS, /* Measure presentation delay */
PRES_STATE_WAIT, /* Wait for some time */
PRES_STATE_INIT, /* Initialize presentation compensation */
PRES_STATE_MEAS, /* Measure presentation delay */
PRES_STATE_WAIT, /* Wait for some time */
PRES_STATE_LOCKED /* Presentation compensation locked */
};

Expand Down Expand Up @@ -137,15 +137,15 @@ static struct {
uint32_t current_pres_dly_us;

struct {
enum drift_comp_state state : 8;
enum drift_comp_state state: 8;
uint16_t ctr; /* Count func calls. Used for waiting */
uint32_t meas_start_time_us;
uint32_t center_freq;
bool enabled;
} drift_comp;

struct {
enum pres_comp_state state : 8;
enum pres_comp_state state: 8;
uint16_t ctr; /* Count func calls. Used for collecting data points and waiting */
int32_t sum_err_dly_us;
uint32_t pres_delay_us;
Expand Down Expand Up @@ -290,6 +290,7 @@ static void pres_comp_state_set(enum pres_comp_state new_state)
ctrl_blk.pres_comp.ctr = 0;

ctrl_blk.pres_comp.state = new_state;
/* NOTE: The string below is used by the Nordic CI system */
LOG_INF("Pres comp state: %s", pres_comp_state_names[new_state]);
if (new_state == PRES_STATE_LOCKED) {
ret = led_on(LED_APP_2_GREEN);
Expand Down Expand Up @@ -1071,24 +1072,23 @@ static int cmd_audio_pres_comp_disable(const struct shell *shell, size_t argc, c
return 0;
}

SHELL_STATIC_SUBCMD_SET_CREATE(
test_cmd,
SHELL_COND_CMD(CONFIG_SHELL, nrf_tone_start, NULL, "Start local tone from nRF5340",
cmd_i2s_tone_play),
SHELL_COND_CMD(CONFIG_SHELL, nrf_tone_stop, NULL, "Stop local tone from nRF5340",
cmd_i2s_tone_stop),
SHELL_COND_CMD(CONFIG_SHELL, pll_drift_comp_enable, NULL,
"Enable audio PLL auto drift compensation (default)",
cmd_hfclkaudio_drift_comp_enable),
SHELL_COND_CMD(CONFIG_SHELL, pll_drift_comp_disable, NULL,
"Disable audio PLL auto drift compensation",
cmd_hfclkaudio_drift_comp_disable),
SHELL_COND_CMD(CONFIG_SHELL, pll_pres_comp_enable, NULL,
"Enable audio presentation compensation (default)",
cmd_audio_pres_comp_enable),
SHELL_COND_CMD(CONFIG_SHELL, pll_pres_comp_disable, NULL,
"Disable audio presentation compensation",
cmd_audio_pres_comp_disable),
SHELL_SUBCMD_SET_END);
SHELL_STATIC_SUBCMD_SET_CREATE(test_cmd,
SHELL_COND_CMD(CONFIG_SHELL, nrf_tone_start, NULL,
"Start local tone from nRF5340", cmd_i2s_tone_play),
SHELL_COND_CMD(CONFIG_SHELL, nrf_tone_stop, NULL,
"Stop local tone from nRF5340", cmd_i2s_tone_stop),
SHELL_COND_CMD(CONFIG_SHELL, pll_drift_comp_enable, NULL,
"Enable audio PLL auto drift compensation (default)",
cmd_hfclkaudio_drift_comp_enable),
SHELL_COND_CMD(CONFIG_SHELL, pll_drift_comp_disable, NULL,
"Disable audio PLL auto drift compensation",
cmd_hfclkaudio_drift_comp_disable),
SHELL_COND_CMD(CONFIG_SHELL, pll_pres_comp_enable, NULL,
"Enable audio presentation compensation (default)",
cmd_audio_pres_comp_enable),
SHELL_COND_CMD(CONFIG_SHELL, pll_pres_comp_disable, NULL,
"Disable audio presentation compensation",
cmd_audio_pres_comp_disable),
SHELL_SUBCMD_SET_END);

SHELL_CMD_REGISTER(test, &test_cmd, "Test mode commands", NULL);
2 changes: 2 additions & 0 deletions applications/nrf5340_audio/src/audio/streamctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ static void le_audio_rx_data_handler(uint8_t const *const p_data, size_t data_si
}

if ((rx_stats[channel_index].recv_cnt % 100) == 0 && rx_stats[channel_index].recv_cnt) {
/* NOTE: The string below is used by the Nordic CI system */
LOG_DBG("ISO RX SDUs: Ch: %d Total: %d Bad: %d Size mismatch %d", channel_index,
rx_stats[channel_index].recv_cnt, rx_stats[channel_index].bad_frame_cnt,
rx_stats[channel_index].data_size_mismatch_cnt);
Expand Down Expand Up @@ -479,6 +480,7 @@ static void le_audio_msg_sub_thread(void)
break;
}

/* NOTE: The string below is used by the Nordic CI system */
LOG_INF("Restarted scanning for broadcaster");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ static void mcc_discover_mcs_cb(struct bt_conn *conn, int err)
}

mcc_peer[idx].mcp_mcs_disc_status = FINISHED;
/* NOTE: The string below is used by the Nordic CI system */
LOG_INF("Discovery of MCS finished");

ret = bt_content_ctrl_media_state_update(conn);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ static void advertising_process(struct k_work *work)
ret = zbus_chan_pub(&bt_mgmt_chan, &msg, K_NO_WAIT);
ERR_CHK(ret);

/* NOTE: The string below is used by the Nordic CI system */
LOG_INF("Advertising successfully started");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ static void connected_cb(struct bt_conn *conn, uint8_t err)

/* ACL connection established */
(void)bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr));
/* NOTE: The string below is used by the Nordic CI system */
LOG_INF("Connected: %s", addr);

if (IS_ENABLED(CONFIG_BT_CENTRAL) && (num_conn < MAX_CONN_NUM)) {
Expand Down Expand Up @@ -157,6 +158,7 @@ static void disconnected_cb(struct bt_conn *conn, uint8_t reason)

(void)bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr));

/* NOTE: The string below is used by the Nordic CI system */
LOG_INF("Disconnected: %s (reason 0x%02x)", addr, reason);

if (IS_ENABLED(CONFIG_BT_CENTRAL)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ int bt_mgmt_ctlr_cfg_init(bool watchdog_enable)
}

if (IS_ENABLED(CONFIG_BT_LL_ACS_NRF53)) {
/* NOTE: The string below is used by the Nordic CI system */
LOG_INF("Controller: LL_ACS_NRF53. Version: %d", ctlr_version);
ret = bt_ll_acs_nrf53_cfg();
if (ret) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ static void smp_adv(void)
return;
}

/* NOTE: The string below is used by the Nordic CI system */
LOG_INF("Regular SMP_SVR advertising started");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ int bt_mgmt_scan_start(uint16_t scan_intvl, uint16_t scan_win, enum bt_mgmt_scan
return ret;
}

/* NOTE: The string below is used by the Nordic CI system */
LOG_INF("Scanning successfully started");
return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ int bt_mgmt_scan_for_conn_start(struct bt_le_scan_param *scan_param, char const
bt_foreach_bond(BT_ID_DEFAULT, bond_check, NULL);

if (bonded_num >= CONFIG_BT_MAX_PAIRED) {
/* NOTE: The string below is used by the Nordic CI system */
LOG_INF("All bonded slots filled, will not accept new devices");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ static void stream_started_cb(struct bt_bap_stream *stream)

le_audio_event_publish(LE_AUDIO_EVT_STREAMING);

/* NOTE: The string below is used by the Nordic CI system */
LOG_INF("Broadcast source %p started", (void *)stream);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ static void stream_started_cb(struct bt_bap_stream *stream)
{
le_audio_event_publish(LE_AUDIO_EVT_STREAMING);

/* NOTE: The string below is used by the Nordic CI system */
LOG_INF("Stream index %d started", active_stream_index);
print_codec(&audio_codec_info[active_stream_index]);
}
Expand All @@ -144,6 +145,7 @@ static void stream_stopped_cb(struct bt_bap_stream *stream, uint8_t reason)
{
le_audio_event_publish(LE_AUDIO_EVT_NOT_STREAMING);

/* NOTE: The string below is used by the Nordic CI system */
LOG_INF("Stream index %d stopped. Reason: %d", active_stream_index, reason);
}

Expand Down Expand Up @@ -325,6 +327,7 @@ static void syncable_cb(struct bt_bap_broadcast_sink *sink, bool encrypted)
return;
}

/* NOTE: The string below is used by the Nordic CI system */
LOG_INF("Syncing to broadcast stream index %d", active_stream_index);

if (bis_index_bitfields[active_stream_index] == 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@ static void stream_configured_cb(struct bt_bap_stream *stream, const struct bt_c
}

if (stream->ep->dir == BT_AUDIO_DIR_SINK) {
/* NOTE: The string below is used by the Nordic CI system */
LOG_INF("%s sink stream configured", headsets[channel_index].ch_name);
} else if (stream->ep->dir == BT_AUDIO_DIR_SOURCE) {
LOG_INF("%s source stream configured", headsets[channel_index].ch_name);
Expand Down Expand Up @@ -621,6 +622,7 @@ static void stream_started_cb(struct bt_bap_stream *stream)
headsets[channel_index].seq_num = 0;
}

/* NOTE: The string below is used by the Nordic CI system */
LOG_INF("Stream %p started", (void *)stream);

le_audio_event_publish(LE_AUDIO_EVT_STREAMING, stream->conn);
Expand All @@ -641,6 +643,7 @@ static void stream_stopped_cb(struct bt_bap_stream *stream, uint8_t reason)
int ret;
uint8_t channel_index;

/* NOTE: The string below is used by the Nordic CI system */
LOG_INF("Stream %p stopped. Reason %d", (void *)stream, reason);

ret = channel_index_get(stream->conn, &channel_index);
Expand Down Expand Up @@ -888,6 +891,7 @@ static void discover_sink_cb(struct bt_conn *conn, int err, enum bt_audio_dir di
LOG_ERR("Could not configure sink stream");
}
} else {
/* NOTE: The string below is used by the Nordic CI system */
LOG_WRN("No valid codec capability found for %s headset sink",
headsets[channel_index].ch_name);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ static void stream_start_cb(struct bt_bap_stream *stream)

static void stream_released_cb(struct bt_bap_stream *stream)
{
/* NOTE: The string below is used by the Nordic CI system */
LOG_INF("Stream %p released", stream);
}

Expand Down
1 change: 1 addition & 0 deletions applications/nrf5340_audio/src/modules/audio_usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ static void data_write(const struct device *dev)

ret = data_fifo_pointer_last_filled_get(fifo_tx, &data_out, &data_out_size, K_NO_WAIT);
if (ret) {
/* NOTE: The string below is used by the Nordic CI system */
LOG_WRN("USB TX underrun");
net_buf_unref(buf_out);
return;
Expand Down
4 changes: 4 additions & 0 deletions applications/nrf5340_audio/src/utils/fw_info_app.c.in
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@
LOG_MODULE_REGISTER(fw_info, CONFIG_FW_INFO_LOG_LEVEL);

static const char COMPILE_DATE[] = "@NRF5340_AUDIO_CORE_APP_COMP_DATE@";
/* NOTE: The string below is used by the Nordic CI system */
static const char NRF5340_CORE[] = "nRF5340 Audio nRF5340 Audio DK cpuapp";

int fw_info_app_print(void)
{
/* NOTE: The string below is used by the Nordic CI system */
LOG_INF(COLOR_GREEN "\r\n\t %s \
\r\n\t NCS base version: %s \
\r\n\t Cmake run : %s" COLOR_RESET,
Expand All @@ -41,12 +43,14 @@ int fw_info_app_print(void)
if (ret) {
return ret;
}
/* NOTE: The string below is used by the Nordic CI system */
LOG_INF(COLOR_CYAN "HEADSET left device" COLOR_RESET);
} else if (channel == AUDIO_CH_R) {
ret = log_set_tag(CH_R_TAG);
if (ret) {
return ret;
}
/* NOTE: The string below is used by the Nordic CI system */
LOG_INF(COLOR_CYAN "HEADSET right device" COLOR_RESET);
} else {
__ASSERT(false, "Unknown channel");
Expand Down
7 changes: 4 additions & 3 deletions tests/bluetooth/iso/modules/iso_broadcast_sink.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
LOG_MODULE_REGISTER(broadcast_sink, CONFIG_ISO_TEST_LOG_LEVEL);

#define TIMEOUT_SYNC_CREATE K_SECONDS(10)
#define NAME_LEN 30
#define NAME_LEN 30

#define BT_LE_SCAN_CUSTOM \
BT_LE_SCAN_PARAM(BT_LE_SCAN_TYPE_ACTIVE, BT_LE_SCAN_OPT_NONE, BT_GAP_SCAN_FAST_INTERVAL, \
Expand Down Expand Up @@ -168,6 +168,7 @@ static void biginfo_cb(struct bt_le_per_adv_sync *sync, const struct bt_iso_bigi

bt_addr_le_to_str(biginfo->addr, le_addr, sizeof(le_addr));

/* NOTE: The string below is used by the Nordic CI system */
LOG_DBG("BIG INFO[%u]: [DEVICE]: %s, sid 0x%02x, "
"num_bis %u, nse %u, interval 0x%04x (%u ms), "
"bn %u, pto %u, irc %u, max_pdu %u, "
Expand Down Expand Up @@ -218,6 +219,7 @@ static void iso_recv(struct bt_iso_chan *chan, const struct bt_iso_recv_info *in
last_count = count;

if ((count % CONFIG_PRINT_CONN_INTERVAL) == 0) {
/* NOTE: The string below is used by the Nordic CI system */
LOG_INF("RX. Count: %d, Failed: %d, Success: %d", count, counts_fail,
counts_success);

Expand Down Expand Up @@ -475,8 +477,7 @@ static int argument_check(const struct shell *shell, uint8_t const *const input)
return arg_val;
}

static struct option long_options[] = { { "num_bis:", required_argument, NULL, 'n' },
{ 0, 0, 0, 0 } };
static struct option long_options[] = {{"num_bis:", required_argument, NULL, 'n'}, {0, 0, 0, 0}};

static const char short_options[] = "n:";

Expand Down

0 comments on commit cf5e2b3

Please sign in to comment.