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/NUCLEO-WB15CC/Applications/BLE/BLE_MeshLightingLPN/Core/Src/standby_stm32wb15.c')
-rw-r--r--Projects/NUCLEO-WB15CC/Applications/BLE/BLE_MeshLightingLPN/Core/Src/standby_stm32wb15.c164
1 files changed, 164 insertions, 0 deletions
diff --git a/Projects/NUCLEO-WB15CC/Applications/BLE/BLE_MeshLightingLPN/Core/Src/standby_stm32wb15.c b/Projects/NUCLEO-WB15CC/Applications/BLE/BLE_MeshLightingLPN/Core/Src/standby_stm32wb15.c
new file mode 100644
index 000000000..f7172d804
--- /dev/null
+++ b/Projects/NUCLEO-WB15CC/Applications/BLE/BLE_MeshLightingLPN/Core/Src/standby_stm32wb15.c
@@ -0,0 +1,164 @@
+/* USER CODE BEGIN Header */
+/**
+ ******************************************************************************
+ * @file standby_stm32wb15.c
+ * @author MCD Application Team
+ * @brief Specific code for standby mode
+ ******************************************************************************
+ * @attention
+ *
+ * Copyright (c) 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.
+ *
+ ******************************************************************************
+ */
+/* USER CODE END Header */
+
+/* Includes ------------------------------------------------------------------*/
+#include "main.h"
+#include "app_entry.h"
+#include "app_common.h"
+#include "app_debug.h"
+
+/* Private includes ----------------------------------------------------------*/
+/* USER CODE BEGIN Includes */
+
+/* USER CODE END Includes */
+
+/* Private typedef -----------------------------------------------------------*/
+/* USER CODE BEGIN PTD */
+
+/* USER CODE END PTD */
+
+/* Private define ------------------------------------------------------------*/
+/* USER CODE BEGIN PD */
+
+/* USER CODE END PD */
+
+/* Private macro -------------------------------------------------------------*/
+/* USER CODE BEGIN PM */
+
+/* USER CODE END PM */
+
+/* Private variables ---------------------------------------------------------*/
+uint32_t backup_MSP;
+uint32_t backup_IPCC_C1MR;
+uint32_t boot_after_standby;
+extern RTC_HandleTypeDef hrtc;
+/* USER CODE BEGIN PV */
+
+/* USER CODE END PV */
+
+/* Private function prototypes -----------------------------------------------*/
+uint32_t standby_boot_mng(void);
+void standby_hw_save(void);
+void standby_hw_restore(void);
+/* USER CODE BEGIN PFP */
+
+/* USER CODE END PFP */
+
+/* Private user code ---------------------------------------------------------*/
+/* USER CODE BEGIN 0 */
+
+/* USER CODE END 0 */
+
+/*******************************************************************************
+ * This part may be updated by the user
+ ******************************************************************************/
+
+ /**
+ * @brief standby_hw_save function, saves hardware context to restore
+ * @param None
+ * @retval None
+ */
+void standby_hw_save(void)
+{
+ backup_IPCC_C1MR = READ_REG(IPCC->C1MR);
+
+ /* USER CODE BEGIN standby_hw_save */
+
+ /* USER CODE END standby_hw_save */
+ return;
+}
+
+ /**
+ * @brief standby_hw_restore function, restore and reconfigure hardware context
+ * @param None
+ * @retval None
+ */
+void standby_hw_restore(void)
+{
+ /* USER CODE BEGIN standby_hw_restore_1 */
+
+ /* USER CODE END standby_hw_restore_1 */
+
+ APPD_Init();
+ Init_Exti();
+ Init_Smps();
+ HAL_Init();
+
+ HW_IPCC_Init();
+ HW_IPCC_Enable();
+ WRITE_REG(IPCC->C1MR, backup_IPCC_C1MR);
+
+ if( !LL_HSEM_1StepLock( HSEM, CFG_HW_RCC_SEMID ) )
+ {
+ LL_RCC_SetClkAfterWakeFromStop(LL_RCC_STOP_WAKEUPCLOCK_HSI);
+ LL_HSEM_ReleaseLock( HSEM, CFG_HW_RCC_SEMID, 0 );
+ }
+ LL_HSEM_ReleaseLock( HSEM, CFG_HW_PWR_STANDBY_SEMID, 0 );
+
+ /* In this user section add MX init functions present in main.c , except MX_RTC_Init() */
+ /* USER CODE BEGIN standby_hw_restore_2 */
+
+ MX_GPIO_Init();
+
+ /* USER CODE END standby_hw_restore_2 */
+
+ HW_TS_Init(hw_ts_InitMode_Limited, &hrtc);
+
+ LL_PWR_EnableSRAM2Retention();
+
+ /* USER CODE BEGIN standby_hw_restore_3 */
+ APPE_Led_Init();
+ APPE_Button_Init();
+ /* USER CODE END standby_hw_restore_3 */
+
+ return;
+}
+
+/*******************************************************************************
+ * Do not update code from this limit.
+ ******************************************************************************/
+
+ /**
+ * @brief standby_boot_mng function, will restore MCU context if wakeup from standby
+ * @param None
+ * @retval None
+ */
+uint32_t standby_boot_mng(void)
+{
+#if ( CFG_LPM_STANDBY_SUPPORTED != 0 )
+ __HAL_RCC_HSEM_CLK_ENABLE();
+ while( LL_HSEM_1StepLock( HSEM, CFG_HW_PWR_STANDBY_SEMID ) );
+
+ if( __HAL_PWR_GET_FLAG(PWR_FLAG_SB) != RESET )
+ {
+ __disable_irq( );
+
+ boot_after_standby = 1;
+ }else{
+ boot_after_standby = 0;
+
+ LL_HSEM_ReleaseLock( HSEM, CFG_HW_PWR_STANDBY_SEMID, 0 );
+ }
+#else
+ boot_after_standby = 0;
+#endif
+
+ return boot_after_standby;
+}