You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
toaster-oven-bluepill/Core/Src/app_buzzer.c

41 lines
937 B

/**
* TODO file description
*/
#include "main.h"
#include "app_buzzer.h"
#include "tim.h"
#include "FreeRTOS.h"
#include "cmsis_os2.h"
#include "timers.h"
extern osTimerId_t beepTimerHandle;
//void app_beep_end(void *argument);
//static TimerHandle_t s_timer;
void app_buzzer_init()
{
/* Enable buzzer PWM */
LL_TIM_OC_SetCompareCH1(TIM_BUZZER, 0);
LL_TIM_EnableCounter(TIM_BUZZER);
LL_TIM_CC_EnableChannel(TIM_BUZZER, LL_TIM_CHANNEL_CH1);
// HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_1);
// s_timer = xTimerCreate("beep", 50, 0, NULL, app_beep_end);
}
void app_buzzer_beep() {
LL_TIM_SetAutoReload(TIM_BUZZER, 25714);
LL_TIM_OC_SetCompareCH1(TIM_BUZZER, 25714 / 2);
osTimerStop(beepTimerHandle);
osTimerStart(beepTimerHandle, pdMS_TO_TICKS(10));
// xTimerStart(s_timer, pdMS_TO_TICKS(1000));
}
void app_beep_end(TimerHandle_t timerHandle) {
LL_TIM_OC_SetCompareCH1(TIM_BUZZER, 0);
}