/*******************************************************************************
|
* File Name : Beep.c
|
* Description :
|
* Created on : 2021Äê3ÔÂ25ÈÕ
|
* Author : www.hido-studio.com
|
*******************************************************************************/
|
|
/*******************************************************************************
|
* Include Files *
|
*******************************************************************************/
|
#include "Beep.h"
|
#include "HIDO_Lock.h"
|
#include "HIDO_Timer.h"
|
#include "stm32l0xx_hal.h"
|
#include "string.h"
|
|
/*******************************************************************************
|
* Macro *
|
*******************************************************************************/
|
#define BEEP_TIMER_ARR (100 - 1)
|
#define BEEP_TIMER_CCR 60
|
|
/*******************************************************************************
|
* Type Definition *
|
*******************************************************************************/
|
|
/*******************************************************************************
|
* Local Variable *
|
*******************************************************************************/
|
static TIM_HandleTypeDef *l_pstBeepTimer = HIDO_NULL;
|
static HIDO_UINT32 l_u32TimerChannel = 0;
|
|
/*******************************************************************************
|
* Local Function Declaration *
|
*******************************************************************************/
|
|
/*******************************************************************************
|
* Local Function *
|
*******************************************************************************/
|
|
/*******************************************************************************
|
* Global Function *
|
*******************************************************************************/
|
|
/*******************************************************************************
|
* Function Name : Beep_TimerRegister
|
* Description :
|
* Input :
|
* Output :
|
* Return :
|
* Author : www.hido-studio.com
|
* Modified Date: : 2021Äê3ÔÂ25ÈÕ
|
*******************************************************************************/
|
HIDO_INT32 Beep_TimerRegister(HIDO_VOID *_pTimer, HIDO_UINT32 _u32Channel)
|
{
|
l_pstBeepTimer = (TIM_HandleTypeDef *)_pTimer;
|
l_u32TimerChannel = _u32Channel;
|
|
return HIDO_OK;
|
}
|
|
/*******************************************************************************
|
* Function Name : Beep_Off
|
* Description :
|
* Input :
|
* Output :
|
* Return :
|
* Author : www.hido-studio.com
|
* Modified Date: : 2021Äê3ÔÂ25ÈÕ
|
*******************************************************************************/
|
HIDO_INT32 Beep_Off(HIDO_VOID)
|
{
|
__HAL_TIM_SET_COMPARE(l_pstBeepTimer, l_u32TimerChannel, 0);
|
HAL_TIM_PWM_Stop(l_pstBeepTimer, l_u32TimerChannel);
|
HAL_TIM_Base_Stop_IT(l_pstBeepTimer);
|
|
return HIDO_OK;
|
}
|
|
/*******************************************************************************
|
* Function Name : Beep_On
|
* Description :
|
* Input :
|
* Output :
|
* Return :
|
* Author : www.hido-studio.com
|
* Modified Date: : 2021Äê3ÔÂ25ÈÕ
|
*******************************************************************************/
|
HIDO_INT32 Beep_On(HIDO_VOID)
|
{
|
HAL_TIM_Base_Start_IT(l_pstBeepTimer);
|
HAL_TIM_PWM_Start(l_pstBeepTimer, l_u32TimerChannel);
|
__HAL_TIM_SET_COMPARE(l_pstBeepTimer, l_u32TimerChannel, BEEP_TIMER_CCR);
|
|
return HIDO_OK;
|
}
|