Refactor VND7050AJ sensor configuration to eliminate redundancy

- Create centralized sensor multiplexer node (vnd7050aj_mux) with shared configuration
- Consolidate ADC channel, GPIO pins, and reference voltage in single location
- Update sensor bindings to reference centralized mux via sensor-mux property
- Add channel-based sensor selection using mux-channel property (0-3)
- Refactor ADC sensor library to use centralized GPIO and channel control
- Update valve library to use new vnd7050aj_mux node reference
- Eliminate duplicate ADC/GPIO definitions between voltage and current sensors
- Ensure configuration consistency and prevent mismatched settings

Benefits:
- Single source of truth for VND7050AJ hardware configuration
- Impossible to have inconsistent GPIO/ADC settings between sensors
- Simplified maintenance and scalability for additional sensors
- Clean channel-based multiplexer selection interface
This commit is contained in:
2025-07-08 17:05:34 +02:00
parent a9a0626913
commit 222ffea568
6 changed files with 185 additions and 240 deletions

View File

@@ -1,16 +1,13 @@
description: Custom motor current measurement with GPIO control
# Custom motor current sensor binding
description: Motor current sensor using VND7050AJ multiplexer
compatible: "custom,motor-current"
properties:
io-channels:
type: phandle-array
sensor-mux:
type: phandle
required: true
description: ADC channel for current measurement
io-channel-names:
type: string-array
description: Names for the ADC channels
description: Reference to the VND7050AJ sensor multiplexer node
current-sense-resistor-mohm:
type: int
@@ -19,30 +16,17 @@ properties:
amplifier-gain:
type: int
required: false
default: 1
description: Current sense amplifier gain
reference-mv:
mux-channel:
type: int
default: 3300
description: ADC reference voltage in millivolts
sen-gpios:
type: phandle-array
required: true
description: GPIO to enable/disable the current measurement sensor
s0-gpios:
type: phandle-array
required: true
description: GPIO for multiplexer control bit 0
s1-gpios:
type: phandle-array
required: true
description: GPIO for multiplexer control bit 1
description: Multiplexer channel number (0-3) for this sensor
measurement-delay-ms:
type: int
required: false
default: 10
description: Delay in milliseconds after setting GPIOs before ADC measurement
description: Delay in milliseconds after GPIO setup before measurement

View File

@@ -1,63 +1,26 @@
description: Custom supply voltage measurement with GPIO control
# Custom supply voltage sensor binding
description: Supply voltage sensor using VND7050AJ multiplexer
compatible: "custom,supply-voltage"
properties:
io-channels:
type: phandle-array
sensor-mux:
type: phandle
required: true
description: ADC channel for voltage measurement
io-channel-names:
type: string-array
description: Names for the ADC channels
description: Reference to the VND7050AJ sensor multiplexer node
voltage-divider-ratio:
type: int
required: true
description: Voltage divider ratio for scaling
description: Voltage divider ratio for scaling measurements
reference-mv:
mux-channel:
type: int
default: 3300
description: ADC reference voltage in millivolts
sen-gpios:
type: phandle-array
required: true
description: GPIO to enable/disable the voltage measurement sensor
s0-gpios:
type: phandle-array
required: true
description: GPIO for multiplexer control bit 0
s1-gpios:
type: phandle-array
required: true
description: GPIO for multiplexer control bit 1
description: Multiplexer channel number (0-3) for this sensor
measurement-delay-ms:
type: int
default: 10
description: Delay in milliseconds after setting GPIOs before ADC measurement
sen-gpios:
type: phandle-array
required: true
description: GPIO for SEN (Sense Enable) pin
s0-gpios:
type: phandle-array
required: true
description: GPIO for S0 (Select 0) pin
s1-gpios:
type: phandle-array
required: true
description: GPIO for S1 (Select 1) pin
measurement-delay-ms:
type: int
default: 10
description: Delay in milliseconds after setting control pins before ADC reading
required: false
default: 5
description: Delay in milliseconds after GPIO setup before measurement

View File

@@ -0,0 +1,50 @@
# VND7050AJ Sensor Multiplexer binding
description: VND7050AJ sensor multiplexer for ADC channel selection
compatible: "vnd7050aj,sensor-mux"
properties:
io-channels:
type: phandle-array
required: true
description: ADC channel phandle and specifier for sensor input
io-channel-names:
type: string-array
required: true
description: Names for the ADC channels
reference-mv:
type: int
required: true
description: ADC reference voltage in millivolts
sen-gpios:
type: phandle-array
required: true
description: GPIO for sensor enable (SEN pin)
s0-gpios:
type: phandle-array
required: true
description: GPIO for multiplexer select bit 0 (S0 pin)
s1-gpios:
type: phandle-array
required: true
description: GPIO for multiplexer select bit 1 (S1 pin)
in0-gpios:
type: phandle-array
required: false
description: GPIO for valve input 0 control (IN0 pin)
in1-gpios:
type: phandle-array
required: false
description: GPIO for valve input 1 control (IN1 pin)
rst-gpios:
type: phandle-array
required: false
description: GPIO for reset control (RST pin)