#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();
|
}
|
//---------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------
|