1 /*
2  * Copyright (c) 2024 Nordic Semiconductor ASA
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #include <zephyr/bluetooth/cs.h>
8 
9 #define INITIATOR_ACCESS_ADDRESS 0x4D7B8A2F
10 #define REFLECTOR_ACCESS_ADDRESS 0x96F93DB1
11 #define NUM_MODE_0_STEPS         3
12 
test_params_get(enum bt_conn_le_cs_role role)13 static struct bt_le_cs_test_param test_params_get(enum bt_conn_le_cs_role role)
14 {
15 	struct bt_le_cs_test_param params;
16 
17 	params.role = role;
18 	params.main_mode = BT_CONN_LE_CS_MAIN_MODE_2;
19 	params.sub_mode = BT_CONN_LE_CS_SUB_MODE_1;
20 	params.main_mode_repetition = 1;
21 	params.mode_0_steps = NUM_MODE_0_STEPS;
22 	params.rtt_type = BT_CONN_LE_CS_RTT_TYPE_AA_ONLY;
23 	params.cs_sync_phy = BT_CONN_LE_CS_SYNC_1M_PHY;
24 	params.cs_sync_antenna_selection = BT_LE_CS_TEST_CS_SYNC_ANTENNA_SELECTION_ONE;
25 	params.subevent_len = 5000;
26 	params.subevent_interval = 0;
27 	params.max_num_subevents = 1;
28 	params.transmit_power_level = BT_HCI_OP_LE_CS_TEST_MAXIMIZE_TX_POWER;
29 	params.t_ip1_time = 145;
30 	params.t_ip2_time = 145;
31 	params.t_fcs_time = 150;
32 	params.t_pm_time = 40;
33 	params.t_sw_time = 0;
34 	params.tone_antenna_config_selection = BT_LE_CS_TONE_ANTENNA_CONFIGURATION_INDEX_ONE;
35 
36 	params.initiator_snr_control = BT_LE_CS_SNR_CONTROL_NOT_USED;
37 	params.reflector_snr_control = BT_LE_CS_SNR_CONTROL_NOT_USED;
38 
39 	params.drbg_nonce = 0x1234;
40 
41 	params.override_config = BIT(2) | BIT(5);
42 	params.override_config_0.channel_map_repetition = 1;
43 
44 	memset(params.override_config_0.not_set.channel_map, 0, 10);
45 
46 	for (uint8_t i = 40; i < 75; i++) {
47 		BT_LE_CS_CHANNEL_BIT_SET_VAL(params.override_config_0.not_set.channel_map, i, 1);
48 	}
49 
50 	params.override_config_0.not_set.channel_selection_type = BT_CONN_LE_CS_CHSEL_TYPE_3B;
51 	params.override_config_0.not_set.ch3c_shape = BT_CONN_LE_CS_CH3C_SHAPE_HAT;
52 	params.override_config_0.not_set.ch3c_jump = 2;
53 	params.override_config_2.main_mode_steps = 8;
54 	params.override_config_5.cs_sync_aa_initiator = INITIATOR_ACCESS_ADDRESS;
55 	params.override_config_5.cs_sync_aa_reflector = REFLECTOR_ACCESS_ADDRESS;
56 
57 	return params;
58 }
59