初级会员

- 积分
- 123
- 金钱
- 123
- 注册时间
- 2018-5-9
- 在线时间
- 22 小时
|
发表于 2020-12-11 13:45:40
|
显示全部楼层
进入stop模式前 改时钟源,改GPIO模式,关GPIO时钟,配置唤醒中断......
- void StopMode_Config(void)
- {
- GPIO_InitTypeDef GPIO_InitStructure;
- /* Enable Power Control clock */
- __HAL_RCC_PWR_CLK_ENABLE();
- /* Enable Ultra low power mode */
- HAL_PWREx_EnableUltraLowPower();
-
- /* Enable the fast wake up from Ultra low power mode */
- HAL_PWREx_EnableFastWakeUp();
- /* Select MSI as system clock source after Wake Up from Stop mode */
- __HAL_RCC_WAKEUPSTOP_CLK_CONFIG(RCC_STOP_WAKEUPCLOCK_MSI);
- /* Enable GPIOs clock */
- __HAL_RCC_GPIOA_CLK_ENABLE();
- __HAL_RCC_GPIOB_CLK_ENABLE();
- __HAL_RCC_GPIOC_CLK_ENABLE();
- /* Configure all GPIO port pins in Analog Input mode (floating input trigger OFF) */
- /* Note: Debug using ST-Link is not possible during the execution of this */
- /* example because communication between ST-link and the device */
- /* under test is done through UART. All GPIO pins are disabled (set */
- /* to analog input mode) including UART I/O pins. */
- GPIO_InitStructure.Pin = GPIO_PIN_All;
- GPIO_InitStructure.Mode = GPIO_MODE_ANALOG;
- GPIO_InitStructure.Pull = GPIO_NOPULL;
- HAL_GPIO_Init(GPIOA, &GPIO_InitStructure);
- HAL_GPIO_Init(GPIOB, &GPIO_InitStructure);
- HAL_GPIO_Init(GPIOC, &GPIO_InitStructure);
-
- /* Disable GPIOs clock */
- __HAL_RCC_GPIOA_CLK_DISABLE();
- __HAL_RCC_GPIOB_CLK_DISABLE();
- __HAL_RCC_GPIOC_CLK_DISABLE();
- }
复制代码
|
|