Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Flipper-Zero/STM32CubeWB.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'Projects/STM32WB5MM-DK/Applications/BLE/BLE_Mesh_Model_Sensor/STM32_WPAN/app/svcctl_conf.c')
-rw-r--r--Projects/STM32WB5MM-DK/Applications/BLE/BLE_Mesh_Model_Sensor/STM32_WPAN/app/svcctl_conf.c80
1 files changed, 80 insertions, 0 deletions
diff --git a/Projects/STM32WB5MM-DK/Applications/BLE/BLE_Mesh_Model_Sensor/STM32_WPAN/app/svcctl_conf.c b/Projects/STM32WB5MM-DK/Applications/BLE/BLE_Mesh_Model_Sensor/STM32_WPAN/app/svcctl_conf.c
new file mode 100644
index 000000000..87b4944bd
--- /dev/null
+++ b/Projects/STM32WB5MM-DK/Applications/BLE/BLE_Mesh_Model_Sensor/STM32_WPAN/app/svcctl_conf.c
@@ -0,0 +1,80 @@
+/**
+ ******************************************************************************
+ * @file svctl_conf.c
+ * @author MCD Application Team
+ * @brief Configuration of the BLE service controller
+ ******************************************************************************
+ * @attention
+ *
+ * Copyright (c) 2019-2021 STMicroelectronics.
+ * All rights reserved.
+ *
+ * This software is licensed under terms that can be found in the LICENSE file
+ * in the root directory of this software component.
+ * If no LICENSE file comes with this software, it is provided AS-IS.
+ *
+ ******************************************************************************
+ */
+
+#include "app_common.h"
+
+#include "otp.h"
+
+/* Private defines -----------------------------------------------------------*/
+#define BD_ADDR_SIZE_LOCAL 6
+
+/* Private variables ---------------------------------------------------------*/
+static const uint8_t M_bd_addr[BD_ADDR_SIZE_LOCAL] =
+{
+ (uint8_t)((CFG_ADV_BD_ADDRESS & 0x0000000000FF)),
+ (uint8_t)((CFG_ADV_BD_ADDRESS & 0x00000000FF00) >> 8),
+ (uint8_t)((CFG_ADV_BD_ADDRESS & 0x000000FF0000) >> 16),
+ (uint8_t)((CFG_ADV_BD_ADDRESS & 0x0000FF000000) >> 24),
+ (uint8_t)((CFG_ADV_BD_ADDRESS & 0x00FF00000000) >> 32),
+ (uint8_t)((CFG_ADV_BD_ADDRESS & 0xFF0000000000) >> 40)
+};
+
+static uint8_t bd_addr_udn[BD_ADDR_SIZE_LOCAL];
+
+const uint8_t* SVCCTL_GetBdAddress( void )
+{
+ uint8_t *otp_addr;
+ const uint8_t *bd_addr;
+ uint32_t udn;
+ uint32_t company_id;
+ uint32_t device_id;
+
+ udn = LL_FLASH_GetUDN();
+
+ if(udn != 0xFFFFFFFF)
+ {
+ company_id = LL_FLASH_GetSTCompanyID();
+ device_id = LL_FLASH_GetDeviceID();
+
+ bd_addr_udn[0] = (uint8_t)(udn & 0x000000FF);
+ bd_addr_udn[1] = (uint8_t)( (udn & 0x0000FF00) >> 8 );
+ bd_addr_udn[2] = (uint8_t)( (udn & 0x00FF0000) >> 16 );
+ bd_addr_udn[3] = (uint8_t)device_id;
+ bd_addr_udn[4] = (uint8_t)(company_id & 0x000000FF);;
+ bd_addr_udn[5] = (uint8_t)( (company_id & 0x0000FF00) >> 8 );
+
+ bd_addr = (const uint8_t *)bd_addr_udn;
+ }
+ else
+ {
+ otp_addr = OTP_Read(0);
+ if(otp_addr)
+ {
+ bd_addr = ((OTP_ID0_t*)otp_addr)->bd_address;
+ }
+ else
+ {
+ bd_addr = M_bd_addr;
+ }
+
+ }
+
+ return bd_addr;
+}
+
+