/** * 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 */ TIM2->CCR1 = 0; HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_1); // s_timer = xTimerCreate("beep", 50, 0, NULL, app_beep_end); } void app_buzzer_beep() { TIM2->ARR = 25714; TIM2->CCR1 = TIM2->ARR/2; osTimerStop(beepTimerHandle); osTimerStart(beepTimerHandle, pdMS_TO_TICKS(10)); // xTimerStart(s_timer, pdMS_TO_TICKS(1000)); } void app_beep_end(TimerHandle_t timerHandle) { TIM2->CCR1 = 0; }