blob: 522acb5afa33ed44bdcc237636b102ccae8c7413 [file] [log] [blame]
Emil Kronborg8c3cfac2024-08-15 08:21:22 +00001.. SPDX-License-Identifier: GPL-2.0-or-later
2
3.. index::
4 single: pwm (command)
5
6pwm command
7===========
8
9Synopsis
10--------
11
12::
13
14 pwm invert <pwm_dev_num> <channel> <polarity>
15 pwm config <pwm_dev_num> <channel> <period_ns> <duty_ns>
16 pwm enable <pwm_dev_num> <channel>
17 pwm disable <pwm_dev_num> <channel>
18
19
20Description
21-----------
22
23The ``pwm`` command is used to access and configure PWM (Pulse Width Modulation)
24signals.
25
26pwm invert
27----------
28
29* If the value of ``polarity`` is 0, the default polarity is used.
30* If the value of ``polarity`` is 1, the polarity is inverted.
31
32pwm config
33----------
34
35Configure the period and duty period in nanoseconds.
36
37pwm enable
38----------
39
40Enable output on the configured device and channel.
41
42pwm disable
43-----------
44
45Disable output on the configured device and channel.
46
47pwm_dev_num
48 Device number of the pulse width modulation device
49
50channel
51 Output channel of the PWM device
52
53polarity
54 * 0 - Use normal polarity
55 * 1 - Use inverted polarity
56
57duty_ns
58 Duty period in ns
59
60period_ns
61 Period time in ns
62
63Examples
64--------
65
66Configure device 0, channel 0 to 20 µs period and 14 µs (that is, 70%) duty period::
67
68 => pwm config 0 0 20000 14000
69
70Enable output on the configured device and channel::
71
72 => pwm enable 0 0
73
74Disable output on the configured device and channel::
75
76 => pwm disable 0 0
77
78Invert the signal on the configured device and channel::
79
80 => pwm invert 0 0 1
81
82Configuration
83-------------
84
85The ``pwm`` command is only available if CONFIG_CMD_PWM=y.
86
87Return value
88------------
89
90If the command succeeds, the return value ``$?`` is set to 0. If an error occurs, the
91return value ``$?`` is set to 1.