[PATCH v3] doc: document the pwm command

Emil Kronborg emil.kronborg at protonmail.com
Thu Aug 1 12:07:57 CEST 2024


Signed-off-by: Emil Kronborg <emil.kronborg at protonmail.com>
---
Changes in v3:
- The help text for 'pwm config' in the examples section is more
  explicit about 20 us and 14 us for the period and duty cycle,
  respectively.
- Fixed 'pwm enable' and 'pwm disable' in the examples section to only
  expect 2 arguments.
- Rebased on top of master.

 doc/usage/cmd/pwm.rst | 80 +++++++++++++++++++++++++++++++++++++++++++
 doc/usage/index.rst   |  1 +
 2 files changed, 81 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..bd1255d82186
--- /dev/null
+++ b/doc/usage/cmd/pwm.rst
@@ -0,0 +1,80 @@
+.. SPDX-License-Identifier: GPL-2.0+:
+
+.. index::
+   single: pwm (command)
+
+pwm command
+===========
+
+Synopsis
+--------
+
+::
+
+    pwm invert <pwm_dev_num> <channel> <polarity> - invert polarity
+    pwm config <pwm_dev_num> <channel> <period_ns> <duty_ns> - config PWM
+    pwm enable <pwm_dev_num> <channel> - enable PWM output
+    pwm disable <pwm_dev_num> <channel> - disable PWM output
+
+
+Description
+-----------
+
+The ``pwm`` command is used to access and configure PWM (Pulse Width Modulation)
+signals. For all subcommands, the following arguments are common:
+
+pwm_dev_num
+    device number
+
+channel
+    channel on chosen device
+
+pwm invert
+----------
+
+The signal's active and inactive states are swapped.
+
+pwm config
+----------
+
+Configure the period and duty cycle in nanoseconds.
+
+pwm enable
+----------
+
+Enable output on the configured device and channel.
+
+pwm disable
+-----------
+
+Disable output on the configured device and channel.
+
+Examples
+--------
+
+Configure device 0 channel 0 to 20 us period and 14 us (that is, 70%) duty cycle::
+
+    => 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 49b354e6ffd2..1adab5283950 100644
--- a/doc/usage/index.rst
+++ b/doc/usage/index.rst
@@ -92,6 +92,7 @@ Shell commands
    cmd/pinmux
    cmd/printenv
    cmd/pstore
+   cmd/pwm
    cmd/qfw
    cmd/read
    cmd/reset

base-commit: 7010f22eba35b2a6b66ba37ce565e566ca08c68f
-- 
2.46.0




More information about the U-Boot mailing list