feat: Add ADC sensor device tree bindings and configuration
Introduces device tree bindings for custom ADC voltage and current sensors, allowing for flexible configuration of sensor inputs and associated GPIOs. This enables proper hardware abstraction for ADC measurements. The example overlay file has been removed as its content is now integrated or superseded by the new binding definitions.
This commit is contained in:
@@ -11,6 +11,40 @@
|
||||
s0-gpios = <&gpiob 6 GPIO_ACTIVE_HIGH>; // S0 (PB6) - Status/Select 0 output from VND7050AJ
|
||||
s1-gpios = <&gpiob 5 GPIO_ACTIVE_HIGH>; // S1 (PB5) - Status/Select 1 output from VND7050AJ
|
||||
};
|
||||
|
||||
adc_sensors {
|
||||
compatible = "adc-sensors";
|
||||
|
||||
supply_voltage: supply-voltage {
|
||||
compatible = "custom,supply-voltage";
|
||||
io-channels = <&adc1 1>; /* ADC1 channel 1 (PA0) */
|
||||
io-channel-names = "voltage";
|
||||
reference-mv = <3300>;
|
||||
voltage-divider-ratio = <4>; /* Adjust based on your voltage divider */
|
||||
|
||||
/* GPIO control pins using VND7050AJ pins */
|
||||
sen-gpios = <&gpiob 4 GPIO_ACTIVE_HIGH>; /* SEN (PB4) - enable sensor */
|
||||
s0-gpios = <&gpiob 6 GPIO_ACTIVE_HIGH>; /* S0 (PB6) - mux select bit 0 */
|
||||
s1-gpios = <&gpiob 5 GPIO_ACTIVE_HIGH>; /* S1 (PB5) - mux select bit 1 */
|
||||
|
||||
measurement-delay-ms = <5>; /* 5ms delay after GPIO setup */
|
||||
};
|
||||
|
||||
motor_current: motor-current {
|
||||
compatible = "custom,motor-current";
|
||||
io-channels = <&adc1 1>; /* Same ADC channel, different mux setting */
|
||||
io-channel-names = "current";
|
||||
reference-mv = <3300>;
|
||||
current-sense-resistor-mohm = <100>; /* 100mΩ sense resistor */
|
||||
|
||||
/* GPIO control pins using VND7050AJ pins */
|
||||
sen-gpios = <&gpiob 4 GPIO_ACTIVE_HIGH>; /* SEN (PB4) - enable sensor */
|
||||
s0-gpios = <&gpiob 6 GPIO_ACTIVE_HIGH>; /* S0 (PB6) - mux select bit 0 */
|
||||
s1-gpios = <&gpiob 5 GPIO_ACTIVE_HIGH>; /* S1 (PB5) - mux select bit 1 */
|
||||
|
||||
measurement-delay-ms = <10>; /* 10ms delay for current settling */
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
// Clock configuration: Uncomment the following section to use calibrated HSI instead of HSE
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
description: Custom motor current measurement with GPIO control
|
||||
|
||||
compatible: "custom,motor-current"
|
||||
|
||||
properties:
|
||||
io-channels:
|
||||
type: phandle-array
|
||||
required: true
|
||||
description: ADC channel for current measurement
|
||||
|
||||
io-channel-names:
|
||||
type: string-array
|
||||
description: Names for the ADC channels
|
||||
|
||||
current-sense-resistor-mohm:
|
||||
type: int
|
||||
required: true
|
||||
description: Current sense resistor value in milliohms
|
||||
|
||||
amplifier-gain:
|
||||
type: int
|
||||
default: 1
|
||||
description: Current sense amplifier gain
|
||||
|
||||
reference-mv:
|
||||
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
|
||||
|
||||
measurement-delay-ms:
|
||||
type: int
|
||||
default: 10
|
||||
description: Delay in milliseconds after setting GPIOs before ADC measurement
|
||||
@@ -0,0 +1,63 @@
|
||||
description: Custom supply voltage measurement with GPIO control
|
||||
|
||||
compatible: "custom,supply-voltage"
|
||||
|
||||
properties:
|
||||
io-channels:
|
||||
type: phandle-array
|
||||
required: true
|
||||
description: ADC channel for voltage measurement
|
||||
|
||||
io-channel-names:
|
||||
type: string-array
|
||||
description: Names for the ADC channels
|
||||
|
||||
voltage-divider-ratio:
|
||||
type: int
|
||||
required: true
|
||||
description: Voltage divider ratio for scaling
|
||||
|
||||
reference-mv:
|
||||
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
|
||||
|
||||
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
|
||||
@@ -20,3 +20,6 @@ CONFIG_MODBUS=y
|
||||
CONFIG_MODBUS_ROLE_SERVER=y
|
||||
CONFIG_MODBUS_BUFFER_SIZE=256
|
||||
|
||||
# ADC Sensor Configuration - Use real ADC readings
|
||||
CONFIG_ADC_SENSOR_SIMULATED=n
|
||||
|
||||
|
||||
Reference in New Issue
Block a user