Files
car_stm32f103vet6/Core/Bsp/bsp_beep.c
wangbeihong 8d2a0ea0c8 feat: 集成 EasyLogger 并更新 UART DMA 回调
- 集成 EasyLogger,增强日志功能。
- 更新 UART DMA 回调以使用 EasyLogger 记录日志。
- 重新格式化 README.md,提升可读性和清晰度。
- 添加新的 CMSIS DSP 和 FreeRTOS 源文件。
- 更新 CMake 配置以包含 EasyLogger 源文件。

此提交改进了日志功能,为后续开发做好了准备。
2026-04-02 00:27:58 +08:00

38 lines
803 B
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#include "bsp_beep.h"
#include "tim.h"
/**
* @brief 蜂鸣器初始化TIM3 CH1, PC6, 2.7KHz
*/
void BEEP_Init(void) {
// 假设 CubeMX 已配置好 TIM3 CH1 (PC6) 为 PWM 输出频率2.7KHz
// 这里只需启动 PWM
HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_1);
}
/**
* @brief 打开蜂鸣器输出PWM
*/
void BEEP_On(void) {
__HAL_TIM_SET_COMPARE(&htim3, TIM_CHANNEL_1, __HAL_TIM_GET_AUTORELOAD(&htim3) / 3); // 50% 占空比
}
/**
* @brief 关闭蜂鸣器无PWM输出
*/
void BEEP_Off(void) {
__HAL_TIM_SET_COMPARE(&htim3, TIM_CHANNEL_1, 0);
}
/**
* @brief 翻转蜂鸣器状态
*/
void BEEP_Toggle(void) {
uint32_t cmp = __HAL_TIM_GET_COMPARE(&htim3, TIM_CHANNEL_1);
if (cmp == 0) {
BEEP_On();
} else {
BEEP_Off();
}
}