Skip to content

Commit 7b12723

Browse files
cvinayakcarlescufi
authored andcommitted
Bluetooth: Controller: Replace test vector inputs with auto variable
Replace hard coded channel map count and channel identifier with an auto variables. Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
1 parent 0cb3d31 commit 7b12723

File tree

1 file changed

+49
-56
lines changed

1 file changed

+49
-56
lines changed

subsys/bluetooth/controller/ll_sw/lll_chan.c

Lines changed: 49 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -292,205 +292,198 @@ static uint8_t chan_d(uint8_t n)
292292
void lll_chan_sel_2_ut(void)
293293
{
294294
uint8_t chan_map_1[] = {0xFF, 0xFF, 0xFF, 0xFF, 0x1F};
295+
uint8_t const chan_map_1_37_used = 37U;
295296
uint8_t chan_map_2[] = {0x00, 0x06, 0xE0, 0x00, 0x1E};
297+
uint8_t const chan_map_2_9_used = 9U;
298+
uint16_t const chan_id = 0x305F;
296299
uint8_t m;
297300

298-
m = lll_chan_sel_2(0, 0x305F, chan_map_1, 37);
301+
m = lll_chan_sel_2(0, chan_id, chan_map_1, chan_map_1_37_used);
299302
LL_ASSERT(m == 25U);
300303

301-
m = lll_chan_sel_2(1, 0x305F, chan_map_1, 37);
304+
m = lll_chan_sel_2(1, chan_id, chan_map_1, chan_map_1_37_used);
302305
LL_ASSERT(m == 20U);
303306

304-
m = lll_chan_sel_2(2, 0x305F, chan_map_1, 37);
307+
m = lll_chan_sel_2(2, chan_id, chan_map_1, chan_map_1_37_used);
305308
LL_ASSERT(m == 6U);
306309

307-
m = lll_chan_sel_2(3, 0x305F, chan_map_1, 37);
310+
m = lll_chan_sel_2(3, chan_id, chan_map_1, chan_map_1_37_used);
308311
LL_ASSERT(m == 21U);
309312

310-
m = lll_chan_sel_2(6, 0x305F, chan_map_2, 9);
313+
m = lll_chan_sel_2(6, chan_id, chan_map_2, chan_map_2_9_used);
311314
LL_ASSERT(m == 23U);
312315

313-
m = lll_chan_sel_2(7, 0x305F, chan_map_2, 9);
316+
m = lll_chan_sel_2(7, chan_id, chan_map_2, chan_map_2_9_used);
314317
LL_ASSERT(m == 9U);
315318

316-
m = lll_chan_sel_2(8, 0x305F, chan_map_2, 9);
319+
m = lll_chan_sel_2(8, chan_id, chan_map_2, chan_map_2_9_used);
317320
LL_ASSERT(m == 34U);
318321

319322

320-
321323
#if defined(CONFIG_BT_CTLR_ADV_ISO) || defined(CONFIG_BT_CTLR_SYNC_ISO)
322324
uint16_t prn_subevent_lu;
323325
uint16_t prn_subevent_se;
324326
uint16_t remap_idx;
325327
uint16_t prn_s;
326328

327329
/* BIS subevent 2, event counter 0, test prnSubEvent_se */
328-
prn_s = 56857 ^ 0x305F;
330+
prn_s = 56857 ^ chan_id;
329331
prn_subevent_lu = prn_s;
330-
prn_subevent_se = chan_prn_subevent_se(0x305F, &prn_subevent_lu);
332+
prn_subevent_se = chan_prn_subevent_se(chan_id, &prn_subevent_lu);
331333
LL_ASSERT(prn_subevent_se == 11710);
332334

333335
/* BIS subevent 3, event counter 0 */
334-
prn_subevent_se = chan_prn_subevent_se(0x305F, &prn_subevent_lu);
336+
prn_subevent_se = chan_prn_subevent_se(chan_id, &prn_subevent_lu);
335337
LL_ASSERT(prn_subevent_se == 16649);
336338

337339
/* BIS subevent 4, event counter 0 */
338-
prn_subevent_se = chan_prn_subevent_se(0x305F, &prn_subevent_lu);
340+
prn_subevent_se = chan_prn_subevent_se(chan_id, &prn_subevent_lu);
339341
LL_ASSERT(prn_subevent_se == 38198);
340342

341-
342-
343343
/* BIS subevent 1, event counter 0 */
344-
m = lll_chan_iso_event(0, 0x305F, chan_map_1, 37, &prn_s, &remap_idx);
345-
LL_ASSERT((prn_s ^ 0x305F) == 56857);
344+
m = lll_chan_iso_event(0, chan_id, chan_map_1, chan_map_1_37_used, &prn_s, &remap_idx);
345+
LL_ASSERT((prn_s ^ chan_id) == 56857);
346346
LL_ASSERT(m == 25U);
347347
LL_ASSERT(remap_idx == 25U);
348348

349349
/* BIS subvent 2 */
350-
m = lll_chan_iso_subevent(0x305F, chan_map_1, 37, &prn_s, &remap_idx);
350+
m = lll_chan_iso_subevent(chan_id, chan_map_1, chan_map_1_37_used, &prn_s, &remap_idx);
351351
LL_ASSERT(remap_idx == 1U);
352352
LL_ASSERT(m == 1U);
353353

354354
/* BIS subvent 3 */
355-
m = lll_chan_iso_subevent(0x305F, chan_map_1, 37, &prn_s, &remap_idx);
355+
m = lll_chan_iso_subevent(chan_id, chan_map_1, chan_map_1_37_used, &prn_s, &remap_idx);
356356
LL_ASSERT(remap_idx == 16U);
357357
LL_ASSERT(m == 16U);
358358

359359
/* BIS subvent 4 */
360-
m = lll_chan_iso_subevent(0x305F, chan_map_1, 37, &prn_s, &remap_idx);
360+
m = lll_chan_iso_subevent(chan_id, chan_map_1, chan_map_1_37_used, &prn_s, &remap_idx);
361361
LL_ASSERT(remap_idx == 36U);
362362
LL_ASSERT(m == 36U);
363363

364-
365364
/* BIS subevent 1, event counter 1 */
366-
m = lll_chan_iso_event(1, 0x305F, chan_map_1, 37, &prn_s, &remap_idx);
367-
LL_ASSERT((prn_s ^ 0x305F) == 1685);
365+
m = lll_chan_iso_event(1, chan_id, chan_map_1, chan_map_1_37_used, &prn_s, &remap_idx);
366+
LL_ASSERT((prn_s ^ chan_id) == 1685);
368367
LL_ASSERT(m == 20U);
369368
LL_ASSERT(remap_idx == 20U);
370369

371370
/* BIS subvent 2 */
372-
m = lll_chan_iso_subevent(0x305F, chan_map_1, 37, &prn_s, &remap_idx);
371+
m = lll_chan_iso_subevent(chan_id, chan_map_1, chan_map_1_37_used, &prn_s, &remap_idx);
373372
LL_ASSERT(remap_idx == 36U);
374373
LL_ASSERT(m == 36U);
375374

376375
/* BIS subvent 3 */
377-
m = lll_chan_iso_subevent(0x305F, chan_map_1, 37, &prn_s, &remap_idx);
376+
m = lll_chan_iso_subevent(chan_id, chan_map_1, chan_map_1_37_used, &prn_s, &remap_idx);
378377
LL_ASSERT(remap_idx == 12U);
379378
LL_ASSERT(m == 12U);
380379

381380
/* BIS subvent 4 */
382-
m = lll_chan_iso_subevent(0x305F, chan_map_1, 37, &prn_s, &remap_idx);
381+
m = lll_chan_iso_subevent(chan_id, chan_map_1, chan_map_1_37_used, &prn_s, &remap_idx);
383382
LL_ASSERT(remap_idx == 34U);
384383
LL_ASSERT(m == 34U);
385384

386-
387385
/* BIS subevent 1, event counter 2 */
388-
m = lll_chan_iso_event(2, 0x305F, chan_map_1, 37, &prn_s, &remap_idx);
389-
LL_ASSERT((prn_s ^ 0x305F) == 38301);
386+
m = lll_chan_iso_event(2, chan_id, chan_map_1, chan_map_1_37_used, &prn_s, &remap_idx);
387+
LL_ASSERT((prn_s ^ chan_id) == 38301);
390388
LL_ASSERT(m == 6U);
391389
LL_ASSERT(remap_idx == 6U);
392390

393391
/* BIS subvent 2 */
394-
m = lll_chan_iso_subevent(0x305F, chan_map_1, 37, &prn_s, &remap_idx);
392+
m = lll_chan_iso_subevent(chan_id, chan_map_1, chan_map_1_37_used, &prn_s, &remap_idx);
395393
LL_ASSERT(remap_idx == 18U);
396394
LL_ASSERT(m == 18U);
397395

398396
/* BIS subvent 3 */
399-
m = lll_chan_iso_subevent(0x305F, chan_map_1, 37, &prn_s, &remap_idx);
397+
m = lll_chan_iso_subevent(chan_id, chan_map_1, chan_map_1_37_used, &prn_s, &remap_idx);
400398
LL_ASSERT(remap_idx == 32U);
401399
LL_ASSERT(m == 32U);
402400

403401
/* BIS subvent 4 */
404-
m = lll_chan_iso_subevent(0x305F, chan_map_1, 37, &prn_s, &remap_idx);
402+
m = lll_chan_iso_subevent(chan_id, chan_map_1, chan_map_1_37_used, &prn_s, &remap_idx);
405403
LL_ASSERT(remap_idx == 21U);
406404
LL_ASSERT(m == 21U);
407405

408-
409406
/* BIS subevent 1, event counter 3 */
410-
m = lll_chan_iso_event(3, 0x305F, chan_map_1, 37, &prn_s, &remap_idx);
411-
LL_ASSERT((prn_s ^ 0x305F) == 27475);
407+
m = lll_chan_iso_event(3, chan_id, chan_map_1, chan_map_1_37_used, &prn_s, &remap_idx);
408+
LL_ASSERT((prn_s ^ chan_id) == 27475);
412409
LL_ASSERT(m == 21U);
413410
LL_ASSERT(remap_idx == 21U);
414411

415412
/* BIS subvent 2 */
416-
m = lll_chan_iso_subevent(0x305F, chan_map_1, 37, &prn_s, &remap_idx);
413+
m = lll_chan_iso_subevent(chan_id, chan_map_1, chan_map_1_37_used, &prn_s, &remap_idx);
417414
LL_ASSERT(remap_idx == 4U);
418415
LL_ASSERT(m == 4U);
419416

420417
/* BIS subvent 3 */
421-
m = lll_chan_iso_subevent(0x305F, chan_map_1, 37, &prn_s, &remap_idx);
418+
m = lll_chan_iso_subevent(chan_id, chan_map_1, chan_map_1_37_used, &prn_s, &remap_idx);
422419
LL_ASSERT(remap_idx == 22U);
423420
LL_ASSERT(m == 22U);
424421

425422
/* BIS subvent 4 */
426-
m = lll_chan_iso_subevent(0x305F, chan_map_1, 37, &prn_s, &remap_idx);
423+
m = lll_chan_iso_subevent(chan_id, chan_map_1, chan_map_1_37_used, &prn_s, &remap_idx);
427424
LL_ASSERT(remap_idx == 8U);
428425
LL_ASSERT(m == 8U);
429426

430-
431-
432427
/* BIS subevent 1, event counter 6 */
433-
m = lll_chan_iso_event(6, 0x305F, chan_map_2, 9, &prn_s, &remap_idx);
434-
LL_ASSERT((prn_s ^ 0x305F) == 10975);
428+
m = lll_chan_iso_event(6, chan_id, chan_map_2, chan_map_2_9_used, &prn_s, &remap_idx);
429+
LL_ASSERT((prn_s ^ chan_id) == 10975);
435430
LL_ASSERT(remap_idx == 4U);
436431
LL_ASSERT(m == 23U);
437432

438433
/* BIS subvent 2 */
439-
m = lll_chan_iso_subevent(0x305F, chan_map_2, 9, &prn_s, &remap_idx);
434+
m = lll_chan_iso_subevent(chan_id, chan_map_2, chan_map_2_9_used, &prn_s, &remap_idx);
440435
LL_ASSERT(remap_idx == 7U);
441436
LL_ASSERT(m == 35U);
442437

443438
/* BIS subvent 3 */
444-
m = lll_chan_iso_subevent(0x305F, chan_map_2, 9, &prn_s, &remap_idx);
439+
m = lll_chan_iso_subevent(chan_id, chan_map_2, chan_map_2_9_used, &prn_s, &remap_idx);
445440
LL_ASSERT(remap_idx == 2U);
446441
LL_ASSERT(m == 21U);
447442

448443
/* BIS subvent 4 */
449-
m = lll_chan_iso_subevent(0x305F, chan_map_2, 9, &prn_s, &remap_idx);
444+
m = lll_chan_iso_subevent(chan_id, chan_map_2, chan_map_2_9_used, &prn_s, &remap_idx);
450445
LL_ASSERT(remap_idx == 8U);
451446
LL_ASSERT(m == 36U);
452447

453-
454448
/* BIS subevent 1, event counter 7 */
455-
m = lll_chan_iso_event(7, 0x305F, chan_map_2, 9, &prn_s, &remap_idx);
456-
LL_ASSERT((prn_s ^ 0x305F) == 5490);
449+
m = lll_chan_iso_event(7, chan_id, chan_map_2, chan_map_2_9_used, &prn_s, &remap_idx);
450+
LL_ASSERT((prn_s ^ chan_id) == 5490);
457451
LL_ASSERT(remap_idx == 0U);
458452
LL_ASSERT(m == 9U);
459453

460454
/* BIS subvent 2 */
461-
m = lll_chan_iso_subevent(0x305F, chan_map_2, 9, &prn_s, &remap_idx);
455+
m = lll_chan_iso_subevent(chan_id, chan_map_2, chan_map_2_9_used, &prn_s, &remap_idx);
462456
LL_ASSERT(remap_idx == 3U);
463457
LL_ASSERT(m == 22U);
464458

465459
/* BIS subvent 3 */
466-
m = lll_chan_iso_subevent(0x305F, chan_map_2, 9, &prn_s, &remap_idx);
460+
m = lll_chan_iso_subevent(chan_id, chan_map_2, chan_map_2_9_used, &prn_s, &remap_idx);
467461
LL_ASSERT(remap_idx == 8U);
468462
LL_ASSERT(m == 36U);
469463

470464
/* BIS subvent 4 */
471-
m = lll_chan_iso_subevent(0x305F, chan_map_2, 9, &prn_s, &remap_idx);
465+
m = lll_chan_iso_subevent(chan_id, chan_map_2, chan_map_2_9_used, &prn_s, &remap_idx);
472466
LL_ASSERT(remap_idx == 5U);
473467
LL_ASSERT(m == 33U);
474468

475-
476469
/* BIS subevent 1, event counter 8 */
477-
m = lll_chan_iso_event(8, 0x305F, chan_map_2, 9, &prn_s, &remap_idx);
478-
LL_ASSERT((prn_s ^ 0x305F) == 46970);
470+
m = lll_chan_iso_event(8, chan_id, chan_map_2, chan_map_2_9_used, &prn_s, &remap_idx);
471+
LL_ASSERT((prn_s ^ chan_id) == 46970);
479472
LL_ASSERT(remap_idx == 6U);
480473
LL_ASSERT(m == 34U);
481474

482475
/* BIS subvent 2 */
483-
m = lll_chan_iso_subevent(0x305F, chan_map_2, 9, &prn_s, &remap_idx);
476+
m = lll_chan_iso_subevent(chan_id, chan_map_2, chan_map_2_9_used, &prn_s, &remap_idx);
484477
LL_ASSERT(remap_idx == 0U);
485478
LL_ASSERT(m == 9U);
486479

487480
/* BIS subvent 3 */
488-
m = lll_chan_iso_subevent(0x305F, chan_map_2, 9, &prn_s, &remap_idx);
481+
m = lll_chan_iso_subevent(chan_id, chan_map_2, chan_map_2_9_used, &prn_s, &remap_idx);
489482
LL_ASSERT(remap_idx == 5U);
490483
LL_ASSERT(m == 33U);
491484

492485
/* BIS subvent 4 */
493-
m = lll_chan_iso_subevent(0x305F, chan_map_2, 9, &prn_s, &remap_idx);
486+
m = lll_chan_iso_subevent(chan_id, chan_map_2, chan_map_2_9_used, &prn_s, &remap_idx);
494487
LL_ASSERT(remap_idx == 1U);
495488
LL_ASSERT(m == 10U);
496489
#endif /* CONFIG_BT_CTLR_ADV_ISO || CONFIG_BT_CTLR_SYNC_ISO */

0 commit comments

Comments
 (0)