1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
31
32
33
34
35
42
43
44
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
75
76
77
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
102
107
108
114
125
126
131
137
138
143
144
145
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
216
217
218
219
220
221
222
223
226
227
228
229
230
233
234
235
236
237
238
239
240
241
242
243
244
245
246
265
268
269
/* ... */
#include "main.h"
/* ... */
/* ... */
Includes
void SystemClock_Config(void);
void Configure_PWR(void);
void LED_Init(void);
void LED_Off(void);
void LED_Blinking_5s(void);
void EnterSTOP_MAINREGUMode(void);Private function prototypes
/* ... */
int main(void)
{
SystemClock_Config();
LED_Init();
Configure_PWR();
LED_Blinking_5s();
LED_Off();
EnterSTOP_MAINREGUMode();
while (1)
{
}while (1) { ... }
}{ ... }
/* ... */
void LED_Init(void)
{
LED2_GPIO_CLK_ENABLE();
LL_GPIO_SetPinMode(LED2_GPIO_PORT, LED2_PIN, LL_GPIO_MODE_OUTPUT);
}{ ... }
/* ... */
void LED_Off(void)
{
LL_GPIO_ResetOutputPin(LED2_GPIO_PORT, LED2_PIN);
}{ ... }
/* ... */
void LED_Blinking_5s(void)
{
uint32_t i = 0;
for(i = 0; i < 25; i++)
{
LL_GPIO_TogglePin(LED2_GPIO_PORT, LED2_PIN);
LL_mDelay(200);
}for (i = 0; i < 25; i++) { ... }
}{ ... }
/* ... */
void Configure_PWR(void)
{
LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_PWR);
}{ ... }
/* ... */
void EnterSTOP_MAINREGUMode(void)
{
LL_GPIO_InitTypeDef gpio_initstruct = {LL_GPIO_PIN_ALL, LL_GPIO_MODE_ANALOG,
LL_GPIO_SPEED_FREQ_HIGH, LL_GPIO_OUTPUT_PUSHPULL,
LL_GPIO_PULL_NO, LL_GPIO_AF_0...};
LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_GPIOA |
LL_AHB1_GRP1_PERIPH_GPIOB |
LL_AHB1_GRP1_PERIPH_GPIOC |
LL_AHB1_GRP1_PERIPH_GPIOD |
LL_AHB1_GRP1_PERIPH_GPIOE |
LL_AHB1_GRP1_PERIPH_GPIOH);
LL_GPIO_Init(GPIOA, &gpio_initstruct);
LL_GPIO_Init(GPIOB, &gpio_initstruct);
LL_GPIO_Init(GPIOC, &gpio_initstruct);
LL_GPIO_Init(GPIOD, &gpio_initstruct);
LL_GPIO_Init(GPIOE, &gpio_initstruct);
LL_GPIO_Init(GPIOH, &gpio_initstruct);
LL_AHB1_GRP1_DisableClock(LL_AHB1_GRP1_PERIPH_GPIOA |
LL_AHB1_GRP1_PERIPH_GPIOB |
LL_AHB1_GRP1_PERIPH_GPIOC |
LL_AHB1_GRP1_PERIPH_GPIOD |
LL_AHB1_GRP1_PERIPH_GPIOE |
LL_AHB1_GRP1_PERIPH_GPIOH);
/* ... */
LL_PWR_SetPowerMode(LL_PWR_MODE_STOP_MAINREGU);
LL_LPM_EnableDeepSleep();
__WFI();
}{ ... }
/* ... */
void SystemClock_Config(void)
{
LL_RCC_HSE_EnableBypass();
LL_RCC_HSE_Enable();
while(LL_RCC_HSE_IsReady() != 1)
{
}while (LL_RCC_HSE_IsReady() != 1) { ... };
LL_FLASH_SetLatency(LL_FLASH_LATENCY_3);
LL_RCC_PLL_ConfigDomain_SYS(LL_RCC_PLLSOURCE_HSE, LL_RCC_PLLM_DIV_8, 400, LL_RCC_PLLP_DIV_4);
LL_RCC_PLL_Enable();
while(LL_RCC_PLL_IsReady() != 1)
{
}while (LL_RCC_PLL_IsReady() != 1) { ... };
LL_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_1);
LL_RCC_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_PLL);
while(LL_RCC_GetSysClkSource() != LL_RCC_SYS_CLKSOURCE_STATUS_PLL)
{
}while (LL_RCC_GetSysClkSource() != LL_RCC_SYS_CLKSOURCE_STATUS_PLL) { ... };
LL_RCC_SetAPB1Prescaler(LL_RCC_APB1_DIV_2);
LL_RCC_SetAPB2Prescaler(LL_RCC_APB2_DIV_1);
SysTick_Config(100000000 / 1000);
SystemCoreClock = 100000000;
}{ ... }
#ifdef USE_FULL_ASSERT
/* ... */
void assert_failed(uint8_t *file, uint32_t line)
{
/* ... */
while (1)
{
}while (1) { ... }
}assert_failed (uint8_t *file, uint32_t line) { ... }
/* ... */#endif
/* ... */
/* ... */