From 7a06dab17a4c64e15a5d003a5f5d1e1382229087 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=8D=E5=90=83=E6=B2=B9=E7=82=B8=E9=B8=A1?= <1425962791@qq.com> Date: Mon, 18 Aug 2025 14:11:27 +0800 Subject: [PATCH] update beep pwm drive --- Power_Pico/BSP/BEEP/beep.c | 10 ++++++++++ Power_Pico/BSP/BEEP/beep.h | 18 ++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 Power_Pico/BSP/BEEP/beep.c create mode 100644 Power_Pico/BSP/BEEP/beep.h diff --git a/Power_Pico/BSP/BEEP/beep.c b/Power_Pico/BSP/BEEP/beep.c new file mode 100644 index 0000000..8b647bd --- /dev/null +++ b/Power_Pico/BSP/BEEP/beep.c @@ -0,0 +1,10 @@ +#include "beep.h" +#include "tim.h" + +void beep_open(void) { + HAL_TIM_PWM_Start(&htim4, TIM_CHANNEL_4); // 启动PWM通道4用于蜂鸣器 +} + +void beep_close(void) { + HAL_TIM_PWM_Stop(&htim4, TIM_CHANNEL_4); // 停止PWM通道4 +} diff --git a/Power_Pico/BSP/BEEP/beep.h b/Power_Pico/BSP/BEEP/beep.h new file mode 100644 index 0000000..67a4a4e --- /dev/null +++ b/Power_Pico/BSP/BEEP/beep.h @@ -0,0 +1,18 @@ +#ifndef __BEEP_H__ +#define __BEEP_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "main.h" + +void beep_open(void); +void beep_close(void); + + +#ifdef __cplusplus +} +#endif +#endif +