RaspberrPi project source code
guowenxue
2024-04-11 69b42a43ca4b2d93be203c34f6b45f5de1e32a15
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
/*********************************************************************************
 *      Copyright:  (C) 2021 LingYun IoT System Studio
 *                  All rights reserved.
 *
 *       Filename:  pwm.h
 *    Description:  This file is used to control PWM buzzer/Led
 *
 * Pin connection:
 *               PWM Module              Raspberry Pi Board
 *                  VCC       <----->      5V
 *                 buzzer     <----->      #Pin32(BCM GPIO12)
 *                  Led       <----->      #Pin33(BCM GPIO13)
 *                  GND       <----->      GND
 *
 * /boot/config.txt:
 *
 *          dtoverlay=pwm,pin=12,func=4 (Buzzer)
 *          dtoverlay=pwm,pin=13,func=4 (Led)
 *
 ********************************************************************************/
 
 
#ifndef  _PWM_H_
#define  _PWM_H_
 
#define PWMCHIP_PATH      "/sys/class/pwm/pwmchip0"
 
#define ENABLE            1
#define DISABLE           0
 
#define CHN_BEEPER        0
#define FRQ_BEEPER        2700
 
#define CHN_RGBLED        1
#define FRQ_RGBLED        100
 
extern int init_pwm(int channel, int freq, int duty);
extern int turn_pwm(int channel, int status);
extern int term_pwm(int channel);
 
extern int turn_beep(int times);
 
#endif   /* ----- #ifndef _PWM_H_  ----- */