1 /*
2 * Copyright (c) 2018-2021 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7 #include <stdint.h>
8 #include <stdbool.h>
9
10 #include "hal/ccm.h"
11 #include "hal/radio.h"
12
13 #include <soc.h>
14 #include "hal/debug.h"
15
16 static uint8_t chan_sel_remap(uint8_t *chan_map, uint8_t chan_index);
17 #if defined(CONFIG_BT_CTLR_CHAN_SEL_2)
18 static uint16_t chan_prn_s(uint16_t counter, uint16_t chan_id);
19 static uint16_t chan_prn_e(uint16_t counter, uint16_t chan_id);
20
21 #if defined(CONFIG_BT_CTLR_ISO)
22 static uint8_t chan_sel_remap_index(uint8_t *chan_map, uint8_t chan_index);
23 static uint16_t chan_prn_subevent_se(uint16_t chan_id,
24 uint16_t *prn_subevent_lu);
25 static uint8_t chan_d(uint8_t n);
26 #endif /* CONFIG_BT_CTLR_ISO */
27 #endif /* CONFIG_BT_CTLR_CHAN_SEL_2 */
28
29 #if defined(CONFIG_BT_CONN)
30 /* Refer to Bluetooth Specification v5.2 Vol 6, Part B, Section 4.5.8.2
31 * Channel Selection algorithm #1
32 */
lll_chan_sel_1(uint8_t * chan_use,uint8_t hop,uint16_t latency,uint8_t * chan_map,uint8_t chan_count)33 uint8_t lll_chan_sel_1(uint8_t *chan_use, uint8_t hop, uint16_t latency, uint8_t *chan_map,
34 uint8_t chan_count)
35 {
36 uint8_t chan_next;
37
38 chan_next = ((*chan_use) + (hop * (1 + latency))) % 37;
39 *chan_use = chan_next;
40
41 if ((chan_map[chan_next >> 3] & (1 << (chan_next % 8))) == 0U) {
42 uint8_t chan_index;
43
44 chan_index = chan_next % chan_count;
45 chan_next = chan_sel_remap(chan_map, chan_index);
46
47 } else {
48 /* channel can be used, return it */
49 }
50
51 return chan_next;
52 }
53 #endif /* CONFIG_BT_CONN */
54
55 #if defined(CONFIG_BT_CTLR_CHAN_SEL_2)
56 /* Refer to Bluetooth Specification v5.2 Vol 6, Part B, Section 4.5.8.3.2
57 * Inputs and basic components
58 */
lll_chan_id(uint8_t * access_addr)59 uint16_t lll_chan_id(uint8_t *access_addr)
60 {
61 uint16_t aa_ls = ((uint16_t)access_addr[1] << 8) | access_addr[0];
62 uint16_t aa_ms = ((uint16_t)access_addr[3] << 8) | access_addr[2];
63
64 return aa_ms ^ aa_ls;
65 }
66
67 /* Refer to Bluetooth Specification v5.2 Vol 6, Part B, Section 4.5.8.3
68 * Channel Selection algorithm #2, and Section 4.5.8.3.1 Overview
69 * Below interface is used for ACL connections.
70 */
lll_chan_sel_2(uint16_t counter,uint16_t chan_id,uint8_t * chan_map,uint8_t chan_count)71 uint8_t lll_chan_sel_2(uint16_t counter, uint16_t chan_id, uint8_t *chan_map,
72 uint8_t chan_count)
73 {
74 uint8_t chan_next;
75 uint16_t prn_e;
76
77 prn_e = chan_prn_e(counter, chan_id);
78 chan_next = prn_e % 37;
79
80 if ((chan_map[chan_next >> 3] & (1 << (chan_next % 8))) == 0U) {
81 uint8_t chan_index;
82
83 chan_index = ((uint32_t)chan_count * prn_e) >> 16;
84 chan_next = chan_sel_remap(chan_map, chan_index);
85
86 } else {
87 /* channel can be used, return it */
88 }
89
90 return chan_next;
91 }
92
93 #if defined(CONFIG_BT_CTLR_ISO)
94 /* Refer to Bluetooth Specification v5.2 Vol 6, Part B, Section 4.5.8.3
95 * Channel Selection algorithm #2, and Section 4.5.8.3.1 Overview
96 *
97 * Below interface is used for ISO first subevent.
98 */
lll_chan_iso_event(uint16_t counter,uint16_t chan_id,uint8_t * chan_map,uint8_t chan_count,uint16_t * prn_s,uint16_t * remap_idx)99 uint8_t lll_chan_iso_event(uint16_t counter, uint16_t chan_id,
100 uint8_t *chan_map, uint8_t chan_count,
101 uint16_t *prn_s, uint16_t *remap_idx)
102 {
103 uint8_t chan_idx;
104 uint16_t prn_e;
105
106 *prn_s = chan_prn_s(counter, chan_id);
107 prn_e = *prn_s ^ chan_id;
108 chan_idx = prn_e % 37;
109
110 if ((chan_map[chan_idx >> 3] & (1 << (chan_idx % 8))) == 0U) {
111 *remap_idx = ((uint32_t)chan_count * prn_e) >> 16;
112 chan_idx = chan_sel_remap(chan_map, *remap_idx);
113
114 } else {
115 *remap_idx = chan_sel_remap_index(chan_map, chan_idx);
116 }
117
118 return chan_idx;
119 }
120
121 /* Refer to Bluetooth Specification v5.2 Vol 6, Part B, Section 4.5.8.3
122 * Channel Selection algorithm #2, and Section 4.5.8.3.1 Overview
123 *
124 * Below interface is used for ISO next subevent.
125 */
lll_chan_iso_subevent(uint16_t chan_id,uint8_t * chan_map,uint8_t chan_count,uint16_t * prn_subevent_lu,uint16_t * remap_idx)126 uint8_t lll_chan_iso_subevent(uint16_t chan_id, uint8_t *chan_map,
127 uint8_t chan_count, uint16_t *prn_subevent_lu,
128 uint16_t *remap_idx)
129 {
130 uint16_t prn_subevent_se;
131 uint8_t d;
132 uint8_t x;
133
134 prn_subevent_se = chan_prn_subevent_se(chan_id, prn_subevent_lu);
135
136 d = chan_d(chan_count);
137
138 /* Sub-expression to get natural number (N - 2d + 1) to be used in the
139 * calculation of d.
140 */
141 if ((chan_count + 1) > (d << 1)) {
142 x = (chan_count + 1) - (d << 1);
143 } else {
144 x = 0;
145 }
146
147 *remap_idx = ((((uint32_t)prn_subevent_se * x) >> 16) +
148 d + *remap_idx) % chan_count;
149
150 return chan_sel_remap(chan_map, *remap_idx);
151 }
152 #endif /* CONFIG_BT_CTLR_ISO */
153 #endif /* CONFIG_BT_CTLR_CHAN_SEL_2 */
154
155 /* Refer to Bluetooth Specification v5.2 Vol 6, Part B, Section 4.5.8.3
156 * Channel Selection algorithm #2, and Section 4.5.8.3.4 Event mapping to used
157 * channel index
158 */
chan_sel_remap(uint8_t * chan_map,uint8_t chan_index)159 static uint8_t chan_sel_remap(uint8_t *chan_map, uint8_t chan_index)
160 {
161 uint8_t chan_next;
162 uint8_t byte_count;
163
164 chan_next = 0U;
165 byte_count = 5U;
166 while (byte_count--) {
167 uint8_t bite;
168 uint8_t bit_count;
169
170 bite = *chan_map;
171 bit_count = 8U;
172 while (bit_count--) {
173 if (bite & 0x01) {
174 if (chan_index == 0U) {
175 break;
176 }
177 chan_index--;
178 }
179 chan_next++;
180 bite >>= 1;
181 }
182
183 if (bit_count < 8) {
184 break;
185 }
186
187 chan_map++;
188 }
189
190 return chan_next;
191 }
192
193 #if defined(CONFIG_BT_CTLR_CHAN_SEL_2)
194 /* Attribution:
195 * http://graphics.stanford.edu/%7Eseander/bithacks.html#ReverseByteWith32Bits
196 */
197 /* Refer to Bluetooth Specification v5.2 Vol 6, Part B, Section 4.5.8.3.2
198 * Inputs and basic components, for below operations
199 */
chan_rev_8(uint8_t b)200 static uint8_t chan_rev_8(uint8_t b)
201 {
202 b = (((uint32_t)b * 0x0802LU & 0x22110LU) |
203 ((uint32_t)b * 0x8020LU & 0x88440LU)) * 0x10101LU >> 16;
204
205 return b;
206 }
207
chan_perm(uint16_t i)208 static uint16_t chan_perm(uint16_t i)
209 {
210 return (chan_rev_8((i >> 8) & 0xFF) << 8) | chan_rev_8(i & 0xFF);
211 }
212
chan_mam(uint16_t a,uint16_t b)213 static uint16_t chan_mam(uint16_t a, uint16_t b)
214 {
215 return ((uint32_t)a * 17U + b) & 0xFFFF;
216 }
217
chan_prn_s(uint16_t counter,uint16_t chan_id)218 static uint16_t chan_prn_s(uint16_t counter, uint16_t chan_id)
219 {
220 uint8_t iterate;
221 uint16_t prn_s;
222
223 prn_s = counter ^ chan_id;
224
225 for (iterate = 0U; iterate < 3; iterate++) {
226 prn_s = chan_perm(prn_s);
227 prn_s = chan_mam(prn_s, chan_id);
228 }
229
230 return prn_s;
231 }
232
chan_prn_e(uint16_t counter,uint16_t chan_id)233 static uint16_t chan_prn_e(uint16_t counter, uint16_t chan_id)
234 {
235 uint16_t prn_e;
236
237 prn_e = chan_prn_s(counter, chan_id);
238 prn_e ^= chan_id;
239
240 return prn_e;
241 }
242
243 #if defined(CONFIG_BT_CTLR_ISO)
244 /* Refer to Bluetooth Specification v5.2 Vol 6, Part B, Section 4.5.8.3
245 * Channel Selection algorithm #2, and Section 4.5.8.3.4 Event mapping to used
246 * channel index
247 *
248 * Below function is used in the context of next subevent, return remapping
249 * index.
250 */
chan_sel_remap_index(uint8_t * chan_map,uint8_t chan_index)251 static uint8_t chan_sel_remap_index(uint8_t *chan_map, uint8_t chan_index)
252 {
253 uint8_t octet_count;
254 uint8_t remap_index;
255
256 remap_index = 0U;
257 octet_count = 5U;
258 while (octet_count--) {
259 uint8_t octet;
260 uint8_t bit_count;
261
262 octet = *chan_map;
263 bit_count = 8U;
264 while (bit_count--) {
265 if (!chan_index) {
266 return remap_index;
267 }
268 chan_index--;
269
270 if (octet & BIT(0)) {
271 remap_index++;
272 }
273 octet >>= 1;
274 }
275
276 chan_map++;
277 }
278
279 return 0;
280 }
281
282 /* Refer to Bluetooth Specification v5.2 Vol 6, Part B, Section 4.5.8.3
283 * Channel Selection algorithm #2, and Section 4.5.8.3.5 Subevent pseudo-random
284 * number generation
285 */
chan_prn_subevent_se(uint16_t chan_id,uint16_t * prn_subevent_lu)286 static uint16_t chan_prn_subevent_se(uint16_t chan_id,
287 uint16_t *prn_subevent_lu)
288 {
289 uint16_t prn_subevent_se;
290 uint16_t lu;
291
292 lu = *prn_subevent_lu;
293 lu = chan_perm(lu);
294 lu = chan_mam(lu, chan_id);
295
296 *prn_subevent_lu = lu;
297
298 prn_subevent_se = lu ^ chan_id;
299
300 return prn_subevent_se;
301 }
302
303 /* Refer to Bluetooth Specification v5.2 Vol 6, Part B, Section 4.5.8.3
304 * Channel Selection algorithm #2, and Section 4.5.8.3.6 Subevent mapping to
305 * used channel index
306 */
chan_d(uint8_t n)307 static uint8_t chan_d(uint8_t n)
308 {
309 uint8_t x, y;
310
311 /* Sub-expression to get natural number (N - 5) to be used in the
312 * calculation of d.
313 */
314 if (n > 5) {
315 x = n - 5;
316 } else {
317 x = 0;
318 }
319
320 /* Sub-expression to get natural number ((N - 10) / 2) to be used in the
321 * calculation of d.
322 */
323 if (n > 10) {
324 y = (n - 10) >> 1;
325 } else {
326 y = 0;
327 }
328
329 /* Calculate d using the above sub expressions */
330 return MAX(1, MAX(MIN(3, x), MIN(11, y)));
331 }
332 #endif /* CONFIG_BT_CTLR_ISO */
333
334 #if defined(CONFIG_BT_CTLR_TEST)
335 /* Refer to Bluetooth Specification v5.2 Vol 6, Part C, Section 3 LE Channel
336 * Selection algorithm #2 sample data
337 */
lll_chan_sel_2_ut(void)338 void lll_chan_sel_2_ut(void)
339 {
340 uint8_t chan_map_1[] = {0xFF, 0xFF, 0xFF, 0xFF, 0x1F};
341 uint8_t const chan_map_1_37_used = 37U;
342 uint8_t chan_map_2[] = {0x00, 0x06, 0xE0, 0x00, 0x1E};
343 uint8_t const chan_map_2_9_used = 9U;
344 uint8_t chan_map_3[] = {0x06, 0x00, 0x00, 0x00, 0x00};
345 uint8_t const chan_map_3_2_used = 2U;
346 uint16_t const chan_id = 0x305F;
347 uint8_t m;
348
349 /* Tests when ISO not supported */
350 /* Section 3.1 Sample Data 1 (37 used channels) */
351 m = lll_chan_sel_2(0U, chan_id, chan_map_1, chan_map_1_37_used);
352 LL_ASSERT(m == 25U);
353
354 m = lll_chan_sel_2(1U, chan_id, chan_map_1, chan_map_1_37_used);
355 LL_ASSERT(m == 20U);
356
357 m = lll_chan_sel_2(2U, chan_id, chan_map_1, chan_map_1_37_used);
358 LL_ASSERT(m == 6U);
359
360 m = lll_chan_sel_2(3U, chan_id, chan_map_1, chan_map_1_37_used);
361 LL_ASSERT(m == 21U);
362
363 /* Section 3.2 Sample Data 2 (9 used channels) */
364 m = lll_chan_sel_2(6U, chan_id, chan_map_2, chan_map_2_9_used);
365 LL_ASSERT(m == 23U);
366
367 m = lll_chan_sel_2(7U, chan_id, chan_map_2, chan_map_2_9_used);
368 LL_ASSERT(m == 9U);
369
370 m = lll_chan_sel_2(8U, chan_id, chan_map_2, chan_map_2_9_used);
371 LL_ASSERT(m == 34U);
372
373 /* FIXME: Use Sample Data from Spec, if one is added.
374 * Below is a random sample to cover implementation in this file.
375 */
376 /* Section x.x Sample Data 3 (2 used channels) */
377 m = lll_chan_sel_2(11U, chan_id, chan_map_3, chan_map_3_2_used);
378 LL_ASSERT(m == 1U);
379
380 m = lll_chan_sel_2(12U, chan_id, chan_map_3, chan_map_3_2_used);
381 LL_ASSERT(m == 2U);
382
383 m = lll_chan_sel_2(13U, chan_id, chan_map_3, chan_map_3_2_used);
384 LL_ASSERT(m == 1U);
385
386 #if defined(CONFIG_BT_CTLR_ISO)
387 uint16_t prn_subevent_lu;
388 uint16_t prn_subevent_se;
389 uint16_t remap_idx;
390 uint16_t prn_s;
391
392 /* BIS subevent 2, event counter 0, test prnSubEvent_se */
393 prn_s = 56857U ^ chan_id;
394 prn_subevent_lu = prn_s;
395 prn_subevent_se = chan_prn_subevent_se(chan_id, &prn_subevent_lu);
396 LL_ASSERT(prn_subevent_se == 11710U);
397
398 /* BIS subevent 3, event counter 0 */
399 prn_subevent_se = chan_prn_subevent_se(chan_id, &prn_subevent_lu);
400 LL_ASSERT(prn_subevent_se == 16649U);
401
402 /* BIS subevent 4, event counter 0 */
403 prn_subevent_se = chan_prn_subevent_se(chan_id, &prn_subevent_lu);
404 LL_ASSERT(prn_subevent_se == 38198U);
405
406 /* Section 3.1 Sample Data 1 (37 used channels) */
407 /* BIS subevent 1, event counter 0 */
408 m = lll_chan_iso_event(0U, chan_id, chan_map_1, chan_map_1_37_used, &prn_s, &remap_idx);
409 LL_ASSERT((prn_s ^ chan_id) == 56857U);
410 LL_ASSERT(m == 25U);
411 LL_ASSERT(remap_idx == 25U);
412
413 /* BIS subvent 2 */
414 m = lll_chan_iso_subevent(chan_id, chan_map_1, chan_map_1_37_used, &prn_s, &remap_idx);
415 LL_ASSERT(remap_idx == 1U);
416 LL_ASSERT(m == 1U);
417
418 /* BIS subvent 3 */
419 m = lll_chan_iso_subevent(chan_id, chan_map_1, chan_map_1_37_used, &prn_s, &remap_idx);
420 LL_ASSERT(remap_idx == 16U);
421 LL_ASSERT(m == 16U);
422
423 /* BIS subvent 4 */
424 m = lll_chan_iso_subevent(chan_id, chan_map_1, chan_map_1_37_used, &prn_s, &remap_idx);
425 LL_ASSERT(remap_idx == 36U);
426 LL_ASSERT(m == 36U);
427
428 /* BIS subevent 1, event counter 1 */
429 m = lll_chan_iso_event(1U, chan_id, chan_map_1, chan_map_1_37_used, &prn_s, &remap_idx);
430 LL_ASSERT((prn_s ^ chan_id) == 1685U);
431 LL_ASSERT(m == 20U);
432 LL_ASSERT(remap_idx == 20U);
433
434 /* BIS subvent 2 */
435 m = lll_chan_iso_subevent(chan_id, chan_map_1, chan_map_1_37_used, &prn_s, &remap_idx);
436 LL_ASSERT(remap_idx == 36U);
437 LL_ASSERT(m == 36U);
438
439 /* BIS subvent 3 */
440 m = lll_chan_iso_subevent(chan_id, chan_map_1, chan_map_1_37_used, &prn_s, &remap_idx);
441 LL_ASSERT(remap_idx == 12U);
442 LL_ASSERT(m == 12U);
443
444 /* BIS subvent 4 */
445 m = lll_chan_iso_subevent(chan_id, chan_map_1, chan_map_1_37_used, &prn_s, &remap_idx);
446 LL_ASSERT(remap_idx == 34U);
447 LL_ASSERT(m == 34U);
448
449 /* BIS subevent 1, event counter 2 */
450 m = lll_chan_iso_event(2U, chan_id, chan_map_1, chan_map_1_37_used, &prn_s, &remap_idx);
451 LL_ASSERT((prn_s ^ chan_id) == 38301U);
452 LL_ASSERT(m == 6U);
453 LL_ASSERT(remap_idx == 6U);
454
455 /* BIS subvent 2 */
456 m = lll_chan_iso_subevent(chan_id, chan_map_1, chan_map_1_37_used, &prn_s, &remap_idx);
457 LL_ASSERT(remap_idx == 18U);
458 LL_ASSERT(m == 18U);
459
460 /* BIS subvent 3 */
461 m = lll_chan_iso_subevent(chan_id, chan_map_1, chan_map_1_37_used, &prn_s, &remap_idx);
462 LL_ASSERT(remap_idx == 32U);
463 LL_ASSERT(m == 32U);
464
465 /* BIS subvent 4 */
466 m = lll_chan_iso_subevent(chan_id, chan_map_1, chan_map_1_37_used, &prn_s, &remap_idx);
467 LL_ASSERT(remap_idx == 21U);
468 LL_ASSERT(m == 21U);
469
470 /* BIS subevent 1, event counter 3 */
471 m = lll_chan_iso_event(3U, chan_id, chan_map_1, chan_map_1_37_used, &prn_s, &remap_idx);
472 LL_ASSERT((prn_s ^ chan_id) == 27475U);
473 LL_ASSERT(m == 21U);
474 LL_ASSERT(remap_idx == 21U);
475
476 /* BIS subvent 2 */
477 m = lll_chan_iso_subevent(chan_id, chan_map_1, chan_map_1_37_used, &prn_s, &remap_idx);
478 LL_ASSERT(remap_idx == 4U);
479 LL_ASSERT(m == 4U);
480
481 /* BIS subvent 3 */
482 m = lll_chan_iso_subevent(chan_id, chan_map_1, chan_map_1_37_used, &prn_s, &remap_idx);
483 LL_ASSERT(remap_idx == 22U);
484 LL_ASSERT(m == 22U);
485
486 /* BIS subvent 4 */
487 m = lll_chan_iso_subevent(chan_id, chan_map_1, chan_map_1_37_used, &prn_s, &remap_idx);
488 LL_ASSERT(remap_idx == 8U);
489 LL_ASSERT(m == 8U);
490
491 /* Section 3.2 Sample Data 2 (9 used channels) */
492 /* BIS subevent 1, event counter 6 */
493 m = lll_chan_iso_event(6U, chan_id, chan_map_2, chan_map_2_9_used, &prn_s, &remap_idx);
494 LL_ASSERT((prn_s ^ chan_id) == 10975U);
495 LL_ASSERT(remap_idx == 4U);
496 LL_ASSERT(m == 23U);
497
498 /* BIS subvent 2 */
499 m = lll_chan_iso_subevent(chan_id, chan_map_2, chan_map_2_9_used, &prn_s, &remap_idx);
500 LL_ASSERT(remap_idx == 7U);
501 LL_ASSERT(m == 35U);
502
503 /* BIS subvent 3 */
504 m = lll_chan_iso_subevent(chan_id, chan_map_2, chan_map_2_9_used, &prn_s, &remap_idx);
505 LL_ASSERT(remap_idx == 2U);
506 LL_ASSERT(m == 21U);
507
508 /* BIS subvent 4 */
509 m = lll_chan_iso_subevent(chan_id, chan_map_2, chan_map_2_9_used, &prn_s, &remap_idx);
510 LL_ASSERT(remap_idx == 8U);
511 LL_ASSERT(m == 36U);
512
513 /* BIS subevent 1, event counter 7 */
514 m = lll_chan_iso_event(7U, chan_id, chan_map_2, chan_map_2_9_used, &prn_s, &remap_idx);
515 LL_ASSERT((prn_s ^ chan_id) == 5490U);
516 LL_ASSERT(remap_idx == 0U);
517 LL_ASSERT(m == 9U);
518
519 /* BIS subvent 2 */
520 m = lll_chan_iso_subevent(chan_id, chan_map_2, chan_map_2_9_used, &prn_s, &remap_idx);
521 LL_ASSERT(remap_idx == 3U);
522 LL_ASSERT(m == 22U);
523
524 /* BIS subvent 3 */
525 m = lll_chan_iso_subevent(chan_id, chan_map_2, chan_map_2_9_used, &prn_s, &remap_idx);
526 LL_ASSERT(remap_idx == 8U);
527 LL_ASSERT(m == 36U);
528
529 /* BIS subvent 4 */
530 m = lll_chan_iso_subevent(chan_id, chan_map_2, chan_map_2_9_used, &prn_s, &remap_idx);
531 LL_ASSERT(remap_idx == 5U);
532 LL_ASSERT(m == 33U);
533
534 /* BIS subevent 1, event counter 8 */
535 m = lll_chan_iso_event(8U, chan_id, chan_map_2, chan_map_2_9_used, &prn_s, &remap_idx);
536 LL_ASSERT((prn_s ^ chan_id) == 46970U);
537 LL_ASSERT(remap_idx == 6U);
538 LL_ASSERT(m == 34U);
539
540 /* BIS subvent 2 */
541 m = lll_chan_iso_subevent(chan_id, chan_map_2, chan_map_2_9_used, &prn_s, &remap_idx);
542 LL_ASSERT(remap_idx == 0U);
543 LL_ASSERT(m == 9U);
544
545 /* BIS subvent 3 */
546 m = lll_chan_iso_subevent(chan_id, chan_map_2, chan_map_2_9_used, &prn_s, &remap_idx);
547 LL_ASSERT(remap_idx == 5U);
548 LL_ASSERT(m == 33U);
549
550 /* BIS subvent 4 */
551 m = lll_chan_iso_subevent(chan_id, chan_map_2, chan_map_2_9_used, &prn_s, &remap_idx);
552 LL_ASSERT(remap_idx == 1U);
553 LL_ASSERT(m == 10U);
554
555 /* FIXME: Use Sample Data from Spec, if one is added.
556 * Below is a random sample to cover implementation in this file.
557 */
558 /* Section x.x Sample Data 3 (2 used channels) */
559 /* BIS subevent 1, event counter 11 */
560 m = lll_chan_iso_event(11U, chan_id, chan_map_3, chan_map_3_2_used, &prn_s, &remap_idx);
561 LL_ASSERT((prn_s ^ chan_id) == 8628U);
562 LL_ASSERT(remap_idx == 0U);
563 LL_ASSERT(m == 1U);
564
565 /* BIS subvent 2 */
566 m = lll_chan_iso_subevent(chan_id, chan_map_3, chan_map_3_2_used, &prn_s, &remap_idx);
567 LL_ASSERT(remap_idx == 1U);
568 LL_ASSERT(m == 2U);
569
570 /* BIS subvent 3 */
571 m = lll_chan_iso_subevent(chan_id, chan_map_3, chan_map_3_2_used, &prn_s, &remap_idx);
572 LL_ASSERT(remap_idx == 0U);
573 LL_ASSERT(m == 1U);
574
575 /* BIS subvent 4 */
576 m = lll_chan_iso_subevent(chan_id, chan_map_3, chan_map_3_2_used, &prn_s, &remap_idx);
577 LL_ASSERT(remap_idx == 1U);
578 LL_ASSERT(m == 2U);
579
580 /* BIS subevent 1, event counter 12 */
581 m = lll_chan_iso_event(12U, chan_id, chan_map_3, chan_map_3_2_used, &prn_s, &remap_idx);
582 LL_ASSERT((prn_s ^ chan_id) == 34748U);
583 LL_ASSERT(remap_idx == 1U);
584 LL_ASSERT(m == 2U);
585
586 /* BIS subvent 2 */
587 m = lll_chan_iso_subevent(chan_id, chan_map_3, chan_map_3_2_used, &prn_s, &remap_idx);
588 LL_ASSERT(remap_idx == 0U);
589 LL_ASSERT(m == 1U);
590
591 /* BIS subvent 3 */
592 m = lll_chan_iso_subevent(chan_id, chan_map_3, chan_map_3_2_used, &prn_s, &remap_idx);
593 LL_ASSERT(remap_idx == 1U);
594 LL_ASSERT(m == 2U);
595
596 /* BIS subvent 4 */
597 m = lll_chan_iso_subevent(chan_id, chan_map_3, chan_map_3_2_used, &prn_s, &remap_idx);
598 LL_ASSERT(remap_idx == 0U);
599 LL_ASSERT(m == 1U);
600
601 /* BIS subevent 1, event counter 13 */
602 m = lll_chan_iso_event(13U, chan_id, chan_map_3, chan_map_3_2_used, &prn_s, &remap_idx);
603 LL_ASSERT((prn_s ^ chan_id) == 22072U);
604 LL_ASSERT(remap_idx == 0U);
605 LL_ASSERT(m == 1U);
606
607 /* BIS subvent 2 */
608 m = lll_chan_iso_subevent(chan_id, chan_map_3, chan_map_3_2_used, &prn_s, &remap_idx);
609 LL_ASSERT(remap_idx == 1U);
610 LL_ASSERT(m == 2U);
611
612 /* BIS subvent 3 */
613 m = lll_chan_iso_subevent(chan_id, chan_map_3, chan_map_3_2_used, &prn_s, &remap_idx);
614 LL_ASSERT(remap_idx == 0U);
615 LL_ASSERT(m == 1U);
616
617 /* BIS subvent 4 */
618 m = lll_chan_iso_subevent(chan_id, chan_map_3, chan_map_3_2_used, &prn_s, &remap_idx);
619 LL_ASSERT(remap_idx == 1U);
620 LL_ASSERT(m == 2U);
621
622 #endif /* CONFIG_BT_CTLR_ISO */
623 }
624 #endif /* CONFIG_BT_CTLR_TEST */
625 #endif /* CONFIG_BT_CTLR_CHAN_SEL_2 */
626