2023-06-23 17:11:10 +08:00
|
|
|
#ifndef BUZZER_H
|
|
|
|
#define BUZZER_H
|
2023-07-07 19:27:24 +08:00
|
|
|
#include "bsp_pwm.h"
|
|
|
|
#define BUZZER_DEVICE_CNT 5
|
|
|
|
|
|
|
|
#define DoFreq 523
|
|
|
|
#define ReFreq 587
|
|
|
|
#define MiFreq 659
|
|
|
|
#define FaFreq 698
|
|
|
|
#define SoFreq 784
|
|
|
|
#define LaFreq 880
|
|
|
|
#define SiFreq 988
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
OCTAVE_1 = 0,
|
|
|
|
OCTAVE_2,
|
|
|
|
OCTAVE_3,
|
|
|
|
OCTAVE_4,
|
|
|
|
OCTAVE_5,
|
|
|
|
OCTAVE_6,
|
|
|
|
OCTAVE_7,
|
|
|
|
OCTAVE_8,
|
|
|
|
}octave_e;
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
ALARM_LEVEL_HIGH = 0,
|
|
|
|
ALARM_LEVEL_ABOVE_MEDIUM,
|
|
|
|
ALARM_LEVEL_MEDIUM,
|
|
|
|
ALARM_LEVEL_BELOW_MEDIUM,
|
|
|
|
ALARM_LEVEL_LOW,
|
|
|
|
}AlarmLevel_e;
|
2023-06-23 17:11:10 +08:00
|
|
|
|
2023-07-07 19:27:24 +08:00
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
ALARM_OFF = 0,
|
|
|
|
ALARM_ON,
|
|
|
|
}AlarmState_e;
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
AlarmLevel_e alarm_level;
|
|
|
|
octave_e octave;
|
|
|
|
float loudness;
|
|
|
|
}Buzzer_config_s;
|
2023-06-23 17:11:10 +08:00
|
|
|
|
2023-07-07 19:27:24 +08:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
float loudness;
|
|
|
|
octave_e octave;
|
|
|
|
AlarmLevel_e alarm_level;
|
|
|
|
AlarmState_e alarm_state;
|
|
|
|
}BuzzzerInstance;
|
|
|
|
|
|
|
|
|
2023-07-14 17:24:44 +08:00
|
|
|
void BuzzerInit();
|
2023-07-07 19:27:24 +08:00
|
|
|
void BuzzerTask();
|
|
|
|
BuzzzerInstance *BuzzerRegister(Buzzer_config_s *config);
|
|
|
|
void AlarmSetStatus(BuzzzerInstance *buzzer, AlarmState_e state);
|
2023-06-23 17:11:10 +08:00
|
|
|
#endif // !BUZZER_H
|