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