硬汉嵌入式论坛

 找回密码
 立即注册
查看: 2407|回复: 0
收起左侧

[GPIO] 将GPIO的速度等级设置为最低也可以一定程度上降低功耗

[复制链接]

1万

主题

6万

回帖

10万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
107049
QQ
发表于 2019-1-2 10:53:32 | 显示全部楼层 |阅读模式



void HAL_LPTIM_MspInit(LPTIM_HandleTypeDef *hlptim)
{
  GPIO_InitTypeDef     GPIO_InitStruct;

  /* ## - 1 - Enable LPTIM clock ############################################ */
  __HAL_RCC_LPTIM1_CLK_ENABLE();

  /* ## - 2 - Force & Release the LPTIM Periheral Clock Reset ############### */
  /* Force the LPTIM Periheral Clock Reset */
  __HAL_RCC_LPTIM1_FORCE_RESET();

  /* Release the LPTIM Periheral Clock Reset */
  __HAL_RCC_LPTIM1_RELEASE_RESET();

  /* ## - 3 - Enable & Configure LPTIM Ultra Low Power ################# */
  /* Configure PD.13 (LPTIM1_OUT) in alternate function (AF1), Low speed
  push-pull mode and pull-up enabled.
Note: In order to reduce power consumption: GPIO Speed is configured in  <-----------------------------------------
  LowSpeed */

  /* Enable GPIO PORT */
  __HAL_RCC_GPIOD_CLK_ENABLE();

  /* Configure PD.13 */
  GPIO_InitStruct.Pin = GPIO_PIN_13;
  GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  GPIO_InitStruct.Pull = GPIO_PULLUP;
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM;
  GPIO_InitStruct.Alternate = GPIO_AF1_LPTIM1;
  HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
}

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|Archiver|手机版|硬汉嵌入式论坛

GMT+8, 2024-5-16 01:33 , Processed in 0.158552 second(s), 25 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表