48 lines
1.7 KiB
C
48 lines
1.7 KiB
C
#include "led.h"
|
||
//-----------------------------------------------------------------
|
||
GPIO_TypeDef* GPIO_PORT[LEDn] = {LEDB_GPIO_PORT,LEDG_GPIO_PORT,LEDR_GPIO_PORT};
|
||
const uint16_t GPIO_PIN[LEDn] = {LEDB_PIN,LEDG_PIN,LEDR_PIN};
|
||
//-----------------------------------------------------------------
|
||
// void LED_Init(void)
|
||
//-----------------------------------------------------------------
|
||
//
|
||
// 函数功能: LED GPIO配置
|
||
// 入口参数: 无
|
||
// 返 回 值: 无
|
||
// 注意事项: 无
|
||
//
|
||
//-----------------------------------------------------------------
|
||
void LED_Init(void)
|
||
{
|
||
BSP_LED_Init(LEDB); // LED_B(蓝灯):PB14
|
||
BSP_LED_Init(LEDG); // LED_G(绿灯):PF7
|
||
BSP_LED_Init(LEDR); // LED_R(红灯):PI3
|
||
}
|
||
|
||
//-----------------------------------------------------------------
|
||
// void BSP_LED_Init(Led_TypeDef Led)
|
||
//-----------------------------------------------------------------
|
||
//
|
||
// 函数功能: 配置指定的LED
|
||
// 入口参数: Led:指定要配置的LED(值:LEDB、LEDG、LEDR)
|
||
// 返 回 值: 无
|
||
// 注意事项: 无
|
||
//
|
||
//-----------------------------------------------------------------
|
||
void BSP_LED_Init(Led_TypeDef Led)
|
||
{
|
||
GPIO_InitTypeDef GPIO_InitStruct;
|
||
LEDx_GPIO_CLK_ENABLE(Led); // 开启Led时钟
|
||
|
||
GPIO_InitStruct.Pin = GPIO_PIN[Led]; // 配置Led
|
||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; // 推挽输出
|
||
GPIO_InitStruct.Pull = GPIO_PULLUP; // 上拉
|
||
GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; // 高速
|
||
HAL_GPIO_Init(GPIO_PORT[Led], &GPIO_InitStruct); // 初始化Led
|
||
|
||
HAL_GPIO_WritePin(GPIO_PORT[Led], GPIO_PIN[Led], GPIO_PIN_SET); // LED置高
|
||
}
|
||
//-----------------------------------------------------------------
|
||
// End Of File
|
||
//-----------------------------------------------------------------
|