RaspberrPi project source code
guowenxue
2024-05-27 2c971f2fcf6c6322a0ea584b2af4c3cef20d3d63
commit | author | age
d6b4a7 1 /*********************************************************************************
G 2  *      Copyright:  (C) 2021 LingYun IoT System Studio
3  *                  All rights reserved.
4  *
5  *       Filename:  pwm.h
6  *    Description:  This file is used to control PWM buzzer/Led
7  *
8  * Pin connection:
9  *               PWM Module              Raspberry Pi Board
10  *                  VCC       <----->      5V
11  *                 buzzer     <----->      #Pin32(BCM GPIO12)
12  *                  Led       <----->      #Pin33(BCM GPIO13)
13  *                  GND       <----->      GND
14  *
15  * /boot/config.txt:
16  *
17  *          dtoverlay=pwm,pin=12,func=4 (Buzzer)
18  *          dtoverlay=pwm,pin=13,func=4 (Led)
19  *
20  ********************************************************************************/
21
22
23 #ifndef  _PWM_H_
24 #define  _PWM_H_
25
26 #define PWMCHIP_PATH      "/sys/class/pwm/pwmchip0"
27
28 #define ENABLE            1
29 #define DISABLE           0
30
31 #define CHN_BEEPER        0
32 #define FRQ_BEEPER        2700
33
34 #define CHN_RGBLED        1
35 #define FRQ_RGBLED        100
36
37 extern int init_pwm(int channel, int freq, int duty);
38 extern int turn_pwm(int channel, int status);
39 extern int term_pwm(int channel);
40
41 extern int turn_beep(int times);
42
43 #endif   /* ----- #ifndef _PWM_H_  ----- */
44