|
| 1 | +.. _comparator_api: |
| 2 | + |
| 3 | +Comparator |
| 4 | +########## |
| 5 | + |
| 6 | +Overview |
| 7 | +******** |
| 8 | + |
| 9 | +An analog comparator compares the voltages of two analog signals connected to its negative and |
| 10 | +positive inputs. If the voltage at the positive input is higher than the negative input, the |
| 11 | +comparator's output will be high, otherwise, it will be low. |
| 12 | + |
| 13 | +Comparators can typically set a trigger which triggers on output changes. This trigger can |
| 14 | +either invoke a callback, or its status can be polled. |
| 15 | + |
| 16 | +Related configuration options: |
| 17 | + |
| 18 | +* :kconfig:option:`CONFIG_COMPARATOR` |
| 19 | + |
| 20 | +Configuration |
| 21 | +************* |
| 22 | + |
| 23 | +Embedded comparators can typically be configured at runtime. When enabled, an initial |
| 24 | +configuration must be provided using the devicetree. At runtime, comparators can have their |
| 25 | +configuration updated using device driver specific APIs. The configuration will be applied |
| 26 | +when the comparator is resumed. |
| 27 | + |
| 28 | +Power management |
| 29 | +**************** |
| 30 | + |
| 31 | +Comparators are enabled using power management. When resumed, the comparator will actively |
| 32 | +compare its inputs, producing an output and detecting edges. When suspended, the comparator |
| 33 | +will be inactive. |
| 34 | + |
| 35 | +Comparator shell |
| 36 | +**************** |
| 37 | + |
| 38 | +The comparator shell provides the ``comp`` command with a set of subcommands for the |
| 39 | +:ref:`shell <shell_api>` module. |
| 40 | + |
| 41 | +The ``comp`` shell command provides the following subcommands: |
| 42 | + |
| 43 | +* ``get_output`` See :c:func:`comparator_get_output` |
| 44 | +* ``set_trigger`` See :c:func:`comparator_set_trigger` |
| 45 | +* ``await_trigger`` Awaits trigger using the following flow: |
| 46 | + * Set trigger callback using :c:func:`comparator_set_trigger_callback` |
| 47 | + * Await callback or time out after default or optionally provided timeout |
| 48 | + * Clear trigger callback using :c:func:`comparator_set_trigger_callback` |
| 49 | +* ``trigger_is_pending`` See :c:func:`comparator_trigger_is_pending` |
| 50 | + |
| 51 | +Related configuration options: |
| 52 | + |
| 53 | +* :kconfig:option:`CONFIG_SHELL` |
| 54 | +* :kconfig:option:`CONFIG_COMPARATOR_SHELL` |
| 55 | +* :kconfig:option:`CONFIG_COMPARATOR_SHELL_AWAIT_TRIGGER_DEFAULT_TIMEOUT` |
| 56 | +* :kconfig:option:`CONFIG_COMPARATOR_SHELL_AWAIT_TRIGGER_MAX_TIMEOUT` |
| 57 | + |
| 58 | +.. note:: |
| 59 | + The power management shell can optionally be enabled alongside the comparator shell. |
| 60 | + |
| 61 | + Related configuration options: |
| 62 | + |
| 63 | + * :kconfig:option:`CONFIG_PM_DEVICE` |
| 64 | + * :kconfig:option:`CONFIG_PM_DEVICE_SHELL` |
| 65 | + |
| 66 | +API Reference |
| 67 | +************* |
| 68 | + |
| 69 | +.. doxygengroup:: comparator_interface |
0 commit comments