1 /*
2 * Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include <app_demo_pwm.h>
17
pwm_0_demo(hi_void)18 hi_void pwm_0_demo(hi_void)
19 {
20 hi_pwm_init(HI_PWM_PORT_PWM0);
21 hi_pwm_set_clock(PWM_CLK_160M);
22 hi_pwm_start(HI_PWM_PORT_PWM0, 750, 1500); /* duty: 750 freq:1500 */
23 }
24
pwm_1_demo(hi_void)25 hi_void pwm_1_demo(hi_void)
26 {
27 hi_pwm_init(HI_PWM_PORT_PWM1);
28 hi_pwm_set_clock(PWM_CLK_160M);
29 hi_pwm_start(HI_PWM_PORT_PWM1, 750, 1500); /* duty: 750 freq:1500 */
30 }
31
pwm_2_demo(hi_void)32 hi_void pwm_2_demo(hi_void)
33 {
34 hi_pwm_init(HI_PWM_PORT_PWM2);
35 hi_pwm_set_clock(PWM_CLK_160M);
36 hi_pwm_start(HI_PWM_PORT_PWM2, 750, 1500); /* duty: 750 freq:1500 */
37 }
38
pwm_3_demo(hi_void)39 hi_void pwm_3_demo(hi_void)
40 {
41 hi_pwm_init(HI_PWM_PORT_PWM3);
42 hi_pwm_set_clock(PWM_CLK_160M);
43 hi_pwm_start(HI_PWM_PORT_PWM3, 750, 1500); /* duty: 750 freq:1500 */
44 }
45
pwm_4_demo(hi_void)46 hi_void pwm_4_demo(hi_void)
47 {
48 hi_pwm_init(HI_PWM_PORT_PWM4);
49 hi_pwm_set_clock(PWM_CLK_160M);
50 hi_pwm_start(HI_PWM_PORT_PWM4, 750, 1500); /* duty: 750 freq:1500 */
51 }
52
pwm_5_demo(hi_void)53 hi_void pwm_5_demo(hi_void)
54 {
55 hi_pwm_init(HI_PWM_PORT_PWM5);
56 hi_pwm_set_clock(PWM_CLK_160M);
57 hi_pwm_start(HI_PWM_PORT_PWM5, 750, 1500); /* duty: 750 freq:1500 */
58 }
59
app_demo_pwm(hi_void)60 hi_void app_demo_pwm(hi_void)
61 {
62 printf("start test pwm");
63
64 pwm_0_demo();
65 pwm_1_demo();
66 pwm_2_demo();
67 pwm_3_demo();
68 pwm_4_demo();
69 pwm_5_demo();
70
71 printf("please use an oscilloscope to check the output waveform!");
72 }
73
74