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

standby_stm32wb15.c « Src « Core « BLE_TransparentMode « BLE « Applications « NUCLEO-WB15CC « Projects - github.com/Flipper-Zero/STM32CubeWB.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ffdf88a5bdfb9c144de5d393e82a9efe287a660b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
/* USER CODE BEGIN Header */
/**
  ******************************************************************************
  * File Name          : standby_stm32wb15.c
  * Description        : Application configuration file for STM32WPAN Middleware.
  ******************************************************************************
  * @attention
  *
  * <h2><center>&copy; Copyright (c) 2021 STMicroelectronics.
  * All rights reserved.</center></h2>
  *
  * This software component is licensed by ST under Ultimate Liberty license
  * SLA0044, the "License"; You may not use this file except in compliance with
  * the License. You may obtain a copy of the License at:
  *                             www.st.com/SLA0044
  *
  ******************************************************************************
  */
/* 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 */
extern void SystemClock_Config(void); 
/* 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();

  SystemClock_Config();

  HAL_Init();

  /* In this user section add MX init functions present in main.c , except MX_RTC_Init() */
  /* USER CODE BEGIN standby_hw_restore_2 */
  
  Init_Exti();
  MX_GPIO_Init();
  MX_DMA_Init();
  MX_USART1_UART_Init();
  
  /* USER CODE END standby_hw_restore_2 */

  HW_IPCC_Init();
  HW_IPCC_Enable();
  WRITE_REG(IPCC->C1MR, backup_IPCC_C1MR);

  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 )
  if( __HAL_PWR_GET_FLAG(PWR_FLAG_SB) != RESET )
  {
    __disable_irq( );

    boot_after_standby = 1;
    __HAL_PWR_CLEAR_FLAG(PWR_FLAG_SB);
  }else{
    boot_after_standby = 0;
  }
#else
  boot_after_standby = 0;
#endif

  return boot_after_standby;
}

/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/