WXK
2023-09-08 00fc23c0b2c7b7dfd6df3e9fb9e385ec949cd8cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/*******************************************************************************
 * 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;
}