[PATCH v4] doc: document the pwm command
Emil Kronborg
emil.kronborg at protonmail.com
Thu Aug 15 10:21:22 CEST 2024
Signed-off-by: Emil Kronborg <emil.kronborg at protonmail.com>
---
Changes in v4:
- Changed license from GPL-2.0+ to GPL-2.0-or-later. Also, removed
trailing colon.
- Simplified the descriptions in the Synopsis section by removing the
text following the '-'.
- Reformulated the description of the invert subcommand to be more
precise and correct.
- %s/duty cycle/duty period to be consistent with pwm.h and to ensure
correctness, as duty cycle is dimensionless and <duty_ns> is given in
nanoseconds.
- Moved the common parameters, pwm_dev_num and channel, to the bottom of
the Description section, and added the remaining parameters.
- Added a comma in the Examples section and used 'µs' instead of 'us'.
- Rebased on top of master.
doc/usage/cmd/pwm.rst | 91 +++++++++++++++++++++++++++++++++++++++++++
doc/usage/index.rst | 1 +
2 files changed, 92 insertions(+)
create mode 100644 doc/usage/cmd/pwm.rst
diff --git a/doc/usage/cmd/pwm.rst b/doc/usage/cmd/pwm.rst
new file mode 100644
index 000000000000..522acb5afa33
--- /dev/null
+++ b/doc/usage/cmd/pwm.rst
@@ -0,0 +1,91 @@
+.. SPDX-License-Identifier: GPL-2.0-or-later
+
+.. index::
+ single: pwm (command)
+
+pwm command
+===========
+
+Synopsis
+--------
+
+::
+
+ pwm invert <pwm_dev_num> <channel> <polarity>
+ pwm config <pwm_dev_num> <channel> <period_ns> <duty_ns>
+ pwm enable <pwm_dev_num> <channel>
+ pwm disable <pwm_dev_num> <channel>
+
+
+Description
+-----------
+
+The ``pwm`` command is used to access and configure PWM (Pulse Width Modulation)
+signals.
+
+pwm invert
+----------
+
+* If the value of ``polarity`` is 0, the default polarity is used.
+* If the value of ``polarity`` is 1, the polarity is inverted.
+
+pwm config
+----------
+
+Configure the period and duty period in nanoseconds.
+
+pwm enable
+----------
+
+Enable output on the configured device and channel.
+
+pwm disable
+-----------
+
+Disable output on the configured device and channel.
+
+pwm_dev_num
+ Device number of the pulse width modulation device
+
+channel
+ Output channel of the PWM device
+
+polarity
+ * 0 - Use normal polarity
+ * 1 - Use inverted polarity
+
+duty_ns
+ Duty period in ns
+
+period_ns
+ Period time in ns
+
+Examples
+--------
+
+Configure device 0, channel 0 to 20 µs period and 14 µs (that is, 70%) duty period::
+
+ => pwm config 0 0 20000 14000
+
+Enable output on the configured device and channel::
+
+ => pwm enable 0 0
+
+Disable output on the configured device and channel::
+
+ => pwm disable 0 0
+
+Invert the signal on the configured device and channel::
+
+ => pwm invert 0 0 1
+
+Configuration
+-------------
+
+The ``pwm`` command is only available if CONFIG_CMD_PWM=y.
+
+Return value
+------------
+
+If the command succeeds, the return value ``$?`` is set to 0. If an error occurs, the
+return value ``$?`` is set to 1.
diff --git a/doc/usage/index.rst b/doc/usage/index.rst
index 1f6518b77c4b..6a218c46b4e4 100644
--- a/doc/usage/index.rst
+++ b/doc/usage/index.rst
@@ -93,6 +93,7 @@ Shell commands
cmd/pinmux
cmd/printenv
cmd/pstore
+ cmd/pwm
cmd/qfw
cmd/read
cmd/reset
base-commit: 90270e0f71c53cca9c0347ce3baedf26b8ec4cdb
--
2.46.0
More information about the U-Boot
mailing list