Bluetooth: Controller: Use a function to get unique DID

Refactor the implementation to use unique DID.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
diff --git a/subsys/bluetooth/controller/ll_sw/ull_adv_aux.c b/subsys/bluetooth/controller/ll_sw/ull_adv_aux.c
index 3bd207d..c761ba4 100644
--- a/subsys/bluetooth/controller/ll_sw/ull_adv_aux.c
+++ b/subsys/bluetooth/controller/ll_sw/ull_adv_aux.c
@@ -895,10 +895,8 @@
 	sec_adi->sid = adv->sid;
 
 	/* The DID for a specific SID shall be unique.
-	 * The DID is 12 bits and did_unique may overflow without any negative
-	 * consequences.
 	 */
-	did = did_unique[adv->sid]++;
+	did = ull_adv_aux_did_next_unique_get(adv->sid);
 
 	pri_adi->did = sys_cpu_to_le16(did);
 	sec_adi->did = sys_cpu_to_le16(did);
@@ -966,6 +964,14 @@
 	return 0;
 }
 
+uint16_t ull_adv_aux_did_next_unique_get(uint8_t sid)
+{
+	/* The DID is 12 bits and did_unique may overflow without any negative
+	 * consequences.
+	 */
+	return BIT_MASK(12) & did_unique[sid]++;
+}
+
 void ull_adv_aux_ptr_fill(struct pdu_adv_aux_ptr *aux_ptr, uint32_t offs_us,
 			  uint8_t phy_s)
 {
diff --git a/subsys/bluetooth/controller/ll_sw/ull_adv_internal.h b/subsys/bluetooth/controller/ll_sw/ull_adv_internal.h
index 3bd2d58..5507bb9 100644
--- a/subsys/bluetooth/controller/ll_sw/ull_adv_internal.h
+++ b/subsys/bluetooth/controller/ll_sw/ull_adv_internal.h
@@ -158,6 +158,9 @@
 
 }
 
+/* helper function to get next unique DID value */
+uint16_t ull_adv_aux_did_next_unique_get(uint8_t sid);
+
 /* helper function to fill the aux ptr structure in common ext adv payload */
 void ull_adv_aux_ptr_fill(struct pdu_adv_aux_ptr *aux_ptr, uint32_t offs_us,
 			  uint8_t phy_s);