Just saving

This commit is contained in:
2025-07-10 17:23:22 +02:00
parent 222ffea568
commit c1622bb01c
11 changed files with 352 additions and 104 deletions

View File

@@ -1,23 +1,17 @@
#include <zephyr/dt-bindings/gpio/gpio.h>
/ {
/* VND7050AJ Sensor Multiplexer - Centralized configuration */
vnd7050aj_mux: sensor-multiplexer {
compatible = "vnd7050aj,sensor-mux";
vnd7050aj: vnd7050aj {
compatible = "vnd7050aj-valve-controller";
status = "okay";
/* Shared ADC configuration */
io-channels = <&adc1 1>; /* ADC1 channel 1 (PA0) */
io-channel-names = "sensor-input";
reference-mv = <3300>;
/* VND7050AJ GPIO pin definitions - shared by all sensors */
sen-gpios = <&gpiob 4 GPIO_ACTIVE_HIGH>; /* SEN (PB4) - Sense Enable */
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 */
/* Valve control pins (separate from sensor mux) */
in0-gpios = <&gpiob 7 GPIO_ACTIVE_HIGH>; /* IN0 (PB7) - Valve input 0 */
in1-gpios = <&gpiob 9 GPIO_ACTIVE_HIGH>; /* IN1 (PB9) - Valve input 1 */
rst-gpios = <&gpiob 3 GPIO_ACTIVE_HIGH>; /* RST (PB3) - Reset pin */
// VND7050AJ GPIO pin definitions
in0-gpios = <&gpiob 7 GPIO_ACTIVE_HIGH>; // IN0 (PB7) - Input 0 control signal
in1-gpios = <&gpiob 9 GPIO_ACTIVE_HIGH>; // IN1 (PB9) - Input 1 control signal
rst-gpios = <&gpiob 3 GPIO_ACTIVE_HIGH>; // RST (PB3) - Reset pin for VND7050AJ
sen-gpios = <&gpiob 4 GPIO_ACTIVE_HIGH>; // SEN (PB4) - Sense Enable for current monitoring
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 {
@@ -25,22 +19,49 @@
supply_voltage: supply-voltage {
compatible = "custom,supply-voltage";
sensor-mux = <&vnd7050aj_mux>; /* Reference to shared mux config */
/* Sensor-specific configuration */
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 */
mux-channel = <0>; /* Channel 0: s1=0, s0=0 */
measurement-delay-ms = <5>; /* 5ms delay after GPIO setup */
/* 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 {
motor_current_open: motor-current-open {
compatible = "custom,motor-current";
sensor-mux = <&vnd7050aj_mux>; /* Reference to shared mux config */
io-channels = <&adc1 1>; /* Same ADC channel, different mux setting */
io-channel-names = "current";
reference-mv = <3300>;
current-sense-resistor-mohm = <1500000>; /* 1.5kΩ sense resistor in mΩ */
k-factor = <10>; /* Current sense amplification factor */
/* Sensor-specific configuration */
current-sense-resistor-mohm = <100>; /* 100mΩ sense resistor */
mux-channel = <1>; /* Channel 1: s1=0, s0=1 */
measurement-delay-ms = <10>; /* 10ms delay for current settling */
/* 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 */
};
motor_current_close: motor-current-close {
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 = <1500000>; /* 1.5kΩ sense resistor in mΩ */
k-factor = <10>; /* Current sense amplification factor */
/* 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 */
};
};
};

View File

@@ -1,3 +1,78 @@
#include <zephyr/dt-bindings/gpio/gpio.h>
/ {
vnd7050aj: vnd7050aj {
compatible = "vnd7050aj-valve-controller";
status = "okay";
// VND7050AJ GPIO pin definitions
in0-gpios = <&gpiob 7 GPIO_ACTIVE_HIGH>; // IN0 (PB7) - Input 0 control signal
in1-gpios = <&gpiob 9 GPIO_ACTIVE_HIGH>; // IN1 (PB9) - Input 1 control signal
rst-gpios = <&gpiob 3 GPIO_ACTIVE_HIGH>; // RST (PB3) - Reset pin for VND7050AJ
sen-gpios = <&gpiob 4 GPIO_ACTIVE_HIGH>; // SEN (PB4) - Sense Enable for current monitoring
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 */
sensor-mux = <&vnd7050aj>; /* Reference to VND7050AJ mux */
mux-channel = <3>; /* VCC sense channel */
measurement-delay-ms = <5>; /* 5ms delay after GPIO setup */
};
motor_current_open: motor-current-open {
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 = <1500000>; /* 1.5kΩ sense resistor in mΩ */
k-factor = <10>; /* Current sense amplification factor */
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 */
};
motor_current_close: motor-current-close {
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 = <1500000>; /* 1.5kΩ sense resistor in mΩ */
k-factor = <10>; /* Current sense amplification factor */
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 */
};
};
};
&adc1 { // ADC1 wird für PA0 verwendet
status = "okay"; // ADC1 aktivieren
pinctrl-0 = <&adc1_in1_pa0>; // Pinmux für PA0 als ADC1_IN1
pinctrl-names = "default";
st,adc-clock-source = "SYNC";
st,adc-prescaler = <4>;
#address-cells = <1>;
#size-cells = <0>;
};
&pinctrl {
// Pinmux für PA0 als ADC1_IN1 (Analogmodus)
adc1_in1_pa0: adc1_in1_pa0 {
pinmux = <STM32_PINMUX('A', 0, ANALOG)>; // PA0 in den Analogmodus setzen
};
};
&zephyr_udc0 {
cdc_acm_uart0: cdc_acm_uart0 {
compatible = "zephyr,cdc-acm-uart";

View File

@@ -4,29 +4,48 @@ description: Motor current sensor using VND7050AJ multiplexer
compatible: "custom,motor-current"
properties:
sensor-mux:
type: phandle
io-channels:
type: phandle-array
required: true
description: Reference to the VND7050AJ sensor multiplexer node
description: ADC channel phandle and specifier
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
current-sense-resistor-mohm:
type: int
required: true
description: Current sense resistor value in milliohms
amplifier-gain:
type: int
required: false
default: 1
description: Current sense amplifier gain
mux-channel:
k-factor:
type: int
required: true
description: Multiplexer channel number (0-3) for this sensor
description: Current sense amplification factor for VND7050AJ
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)
measurement-delay-ms:
type: int
required: false
default: 10
description: Delay in milliseconds after GPIO setup before measurement
description: Delay in milliseconds after setting GPIO pins before reading ADC

View File

@@ -4,6 +4,21 @@ description: Supply voltage sensor using VND7050AJ multiplexer
compatible: "custom,supply-voltage"
properties:
io-channels:
type: phandle-array
required: true
description: ADC channel phandle and specifier
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
sensor-mux:
type: phandle
required: true

View File

@@ -48,3 +48,13 @@ properties:
type: phandle-array
required: false
description: GPIO for reset control (RST pin)
sense-resistor-ohm:
type: int
required: true
description: Current sense resistor value in ohms
k-factor:
type: int
required: true
description: Current sense ratio for VND7050AJ (typical ~1200:1)