31 lines
1.1 KiB
C
31 lines
1.1 KiB
C
#include "Buzzer_LED.h"
|
|
|
|
/* 函数作用:初始化蜂鸣器、成功指示灯和板载状态 LED 对应 GPIO。 */
|
|
void Buzzer_LED_Init(void)
|
|
{
|
|
GPIO_InitTypeDef GPIO_InitStructure;
|
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO | RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOC, ENABLE);
|
|
|
|
// 释放PB4(默认是JTAG引脚),保留SWD调试
|
|
GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable, ENABLE);
|
|
|
|
// 根据连接图.md: LED=PB4, 蜂鸣器=PB5
|
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4 | GPIO_Pin_5;
|
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
|
|
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
|
GPIO_Init(GPIOB, &GPIO_InitStructure);
|
|
|
|
// PC13板载状态指示LED
|
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13;
|
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
|
|
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
|
GPIO_Init(GPIOC, &GPIO_InitStructure);
|
|
|
|
// 初始状态:LED和蜂鸣器都关闭
|
|
LED_SUCCESS_OFF();
|
|
BUZZER_OFF();
|
|
|
|
// PC13状态LED:初始化时点亮(表示系统正在初始化)
|
|
LED_STATUS_ON();
|
|
}
|