/*
 * buzzer.c
 *
 *  Created on: May 8, 2025
 *      Author: 911BL
 */
#include "globals.h"
#include "tim.h"


void buzzer_on(uint8_t duty_percent) { // Turns on the buzzer
    uint32_t pulse = (__HAL_TIM_GET_AUTORELOAD(&htim16) + 1) * duty_percent / 100;
    __HAL_TIM_SET_COMPARE(&htim16, TIM_CHANNEL_1, pulse);
    HAL_TIM_PWM_Start(&htim16, TIM_CHANNEL_1);
}

void buzzer_off(void) { / Turns off the buzzer
    HAL_TIM_PWM_Stop(&htim16, TIM_CHANNEL_1);
}
