[STM32H7] 点亮一颗LED

[复制链接]
 楼主| 李清波10 发表于 2025-4-15 08:38 | 显示全部楼层 |阅读模式
BSP 驱动
LED.C
  1. #include "./BSP/Inc/led.h"  


  2. void LED_Init(void)
  3. {
  4.         GPIO_InitTypeDef GPIO_InitStruct = {0};

  5.         __HAL_RCC_LED1_CLK_ENABLE;                // 初始化LED GPIO时钟       


  6.         HAL_GPIO_WritePin(LED_PORT, LED_PIN, GPIO_PIN_RESET);                // LED引脚输出低,即点亮LED


  7.         GPIO_InitStruct.Pin                 = LED_PIN;                                        // LED引脚
  8.         GPIO_InitStruct.Mode         = GPIO_MODE_OUTPUT_PP;        // 推挽输出模式
  9.         GPIO_InitStruct.Pull         = GPIO_NOPULL;                                // 不上下拉
  10.         GPIO_InitStruct.Speed         = GPIO_SPEED_FREQ_LOW;        // 低速模式
  11.         HAL_GPIO_Init(LED_PORT, &GPIO_InitStruct);


  12. }

LED.H
  1. #ifndef __LED_H
  2. #define __LED_H
  3. #include "./SYS/Inc/sys.h"   
  4. /*------------------------------------------ LED配置宏 ----------------------------------*/

  5. #define LED_PIN                                     GPIO_PIN_13                                                 // LED 引脚      
  6. #define LED_PORT                                    GPIOC                                                  // LED GPIO端口     
  7. #define __HAL_RCC_LED1_CLK_ENABLE    __HAL_RCC_GPIOC_CLK_ENABLE()         // LED GPIO端口时钟


  8.   

  9. void LED_Init(void);

  10. #endif




powerantone 发表于 2025-5-13 16:39 | 显示全部楼层
惜字如金咧
您需要登录后才可以回帖 登录 | 注册

本版积分规则

2

主题

10

帖子

0

粉丝

2

主题

10

帖子

0

粉丝
快速回复 在线客服 返回列表 返回顶部