Ubuntu12.04.4_lts
2023-08-01 961efe36f62f7eba688d504ec0cdf3e1daa4dd74
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
#include "buzzerdrv.h"
//---------------------------------------------------------------------------------------
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <termios.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include "arm-include/at91_ioctl.h"
#include "arm-include/at91_gpio.h"
//---------------------------------------------------------------------------------------
#define DEV_BUZZER "/dev/qiyang_buzzer"
//---------------------------------------------------------------------------------------
#define IOCTL_BUZZER_ON             _IOW('Q', 0x0, int)
#define IOCTL_BUZZER_OFF            _IOW('Q', 0x1, int)
#define MOTOR_MAGIC 'L'
#define BUZZER_ON         _IOW(MOTOR_MAGIC, 0,int)
#define BUZZER_OFF         _IOW(MOTOR_MAGIC, 1,int)
#define IOCTL_BZR_BEEP        _IOW('Q', 0x31, int)
 
 
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
BuzzerDrv::~BuzzerDrv()
{
    wait();
}
//---------------------------------------------------------------------
void BuzzerDrv::run()
{
//#ifdef  SOFT_ARM
    int fd = -1;
    //int arg = 0;
 
    fd = open(DEV_BUZZER, O_RDWR);
    if (fd < 0) {
            qDebug("open BUZZER device error! %d", fd);
            return;
    }
 
    ioctl(fd, BUZZER_ON, BUZZER_ON);
    //ioctl(fd, IOCTL_PIO_SETSTA, 1);
    msleep(beep_ms);
    //ioctl(fd, IOCTL_PIO_SETSTA, 0);
    ioctl(fd, BUZZER_OFF, BUZZER_OFF);
 
    close (fd);
//#endif
}
//---------------------------------------------------------------------------------------
void BuzzerDrv::BuzzerBeep(const unsigned int ms)
{
    beep_ms = ms;
    if(beep_ms > 10000)
        beep_ms = 10000;
 
    this->start();
}
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------