#pragma once #ifdef __cplusplus extern "C" { #endif /* Includes ----------------------------------------------------------------- */ #include #include "tim.h" #include "bsp.h" /* Exported constants ------------------------------------------------------- */ /* Exported macro ----------------------------------------------------------- */ /* Exported types ----------------------------------------------------------- */ /* BUZZER灯状态,设置用 */ typedef enum { BSP_BUZZER_ON, BSP_BUZZER_OFF, BSP_BUZZER_TAGGLE, } BSP_BUZZER_Status_t; /*常用音调频率*/ typedef enum { BSP_BUZZER_C5 = 523, BSP_BUZZER_D5 = 587, BSP_BUZZER_E5 = 659, BSP_BUZZER_F5 = 698, BSP_BUZZER_G5 = 783, BSP_BUZZER_A5 = 880, BSP_BUZZER_B5 = 988, } BSP_BUZZER_USUAL_TONE_t; /* Exported functions prototypes -------------------------------------------- */ int32_t BSP_BUZ_GetTIMxFrequency(TIM_HandleTypeDef *htim); int8_t BSP_BUZZER_Start(void); int8_t BSP_BUZZER_Stop(void); int8_t BSP_BUZZER_Set_Duty_Cycle(float duty_cycle); int8_t BSP_BUZZER_Set_Freq(uint16_t psc, uint16_t arr); int8_t BSP_BUZZER_Set(BSP_BUZZER_Status_t s, BSP_BUZZER_USUAL_TONE_t tone, float volume); void Buzzer_On(uint16_t freq_hz, uint8_t volume); void Buzzer_Off(void); #ifdef __cplusplus } #endif