Digital Potentiometers
The digital potentiometer driver is split into an “upper half” character
driver (drivers/analog/pot.c) and chip-specific “lower half” drivers.
The application interface is defined in include/nuttx/analog/pot.h.
Device model
A potentiometer is modeled as a set of wipers, each with a position in
[0, max]. Optional capabilities are advertised in pot_info_s.caps
so applications can discover what a given chip supports instead of
probing commands:
POT_CAP_READBACK- wiper position can be read backPOT_CAP_MOVE- relative wiper move (the only interface available on up/down-pin devices without readback, e.g. Renesas X9C10x)POT_CAP_ENABLE- wiper enable/shutdownPOT_CAP_NV- non-volatile wiper store/recall
If pot_info_s.rab (terminal A-B resistance in ohms) is non-zero, the
wiper resistance is ohms = val * rab / max. The value is supplied by
board logic to the lower half initializer, since the resistance variant
of a chip is not runtime-discoverable.
Application interface
All commands take a pointer argument. Optional commands return
-ENOTSUP when the lower half does not implement them.
IOCTL |
Argument |
Description |
|---|---|---|
|
|
Device properties |
|
|
Set wiper position |
|
|
Get wiper position |
|
|
Move wiper by signed number of steps |
|
|
Enable or shut down a wiper |
|
|
Store wiper to a non-volatile slot |
|
|
Recall wiper from a non-volatile slot |
Vendor-specific features (e.g. per-terminal switches, register access,
wiper lock) are not part of the common interface: lower halves expose
them through chip-specific ioctl commands forwarded via po_ioctl.
Supported chips
Chip |
Bus |
Notes |
|---|---|---|
MCP445X |
I2C |
Quad wiper, 257 taps. Terminal control via the
|