BSP 驱动
LED.C- #include "./BSP/Inc/led.h"
- void LED_Init(void)
- {
- GPIO_InitTypeDef GPIO_InitStruct = {0};
- __HAL_RCC_LED1_CLK_ENABLE; // 初始化LED GPIO时钟
- HAL_GPIO_WritePin(LED_PORT, LED_PIN, GPIO_PIN_RESET); // LED引脚输出低,即点亮LED
- GPIO_InitStruct.Pin = LED_PIN; // LED引脚
- GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; // 推挽输出模式
- GPIO_InitStruct.Pull = GPIO_NOPULL; // 不上下拉
- GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; // 低速模式
- HAL_GPIO_Init(LED_PORT, &GPIO_InitStruct);
- }
LED.H- #ifndef __LED_H
- #define __LED_H
- #include "./SYS/Inc/sys.h"
- /*------------------------------------------ LED配置宏 ----------------------------------*/
- #define LED_PIN GPIO_PIN_13 // LED 引脚
- #define LED_PORT GPIOC // LED GPIO端口
- #define __HAL_RCC_LED1_CLK_ENABLE __HAL_RCC_GPIOC_CLK_ENABLE() // LED GPIO端口时钟
-
-
- void LED_Init(void);
- #endif
|