Comparator
Overview
An analog comparator compares the voltages of two analog signals connected to its negative and positive inputs. If the voltage at the positive input is higher than the negative input, the comparator’s output will be high, otherwise, it will be low.
Comparators can typically set a trigger which triggers on output changes. This trigger can either invoke a callback, or its status can be polled.
Related configuration options:
Configuration
Embedded comparators can typically be configured at runtime. When enabled, an initial configuration must be provided using the devicetree. At runtime, comparators can have their configuration updated using device driver specific APIs. The configuration will be applied when the comparator is resumed.
Power management
Comparators are enabled using power management. When resumed, the comparator will actively compare its inputs, producing an output and detecting edges. When suspended, the comparator will be inactive.
Comparator shell
The comparator shell provides the comp
command with a set of subcommands for the
shell module.
The comp
shell command provides the following subcommands:
get_output
Seecomparator_get_output()
set_trigger
Seecomparator_set_trigger()
await_trigger
Awaits trigger using the following flow:Set trigger callback using
comparator_set_trigger_callback()
Await callback or time out after default or optionally provided timeout
Clear trigger callback using
comparator_set_trigger_callback()
trigger_is_pending
Seecomparator_trigger_is_pending()
Related configuration options:
Note
The power management shell can optionally be enabled alongside the comparator shell.
Related configuration options: