Skip to content

Commit

Permalink
dts: bindings: lock: lock-servo: use microvolt suffix for fb-offset
Browse files Browse the repository at this point in the history
Signed-off-by: Gerard Marull-Paretas <[email protected]>
  • Loading branch information
gmarull committed May 19, 2024
1 parent bbfe392 commit cd41489
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/boards/nrf52840dk_nrf52840.overlay
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
closed-pulse-us = <1250>;
io-channels = <&adc 0>;
fb-gain = <(-1765)>;
fb-offset = <4206250>;
fb-offset-microvolt = <4206250>;
max-target-err-us = <50>;
max-action-time-ms = <2000>;
};
Expand Down
6 changes: 3 additions & 3 deletions drivers/lock/servo.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ struct lock_servo_config {
uint32_t closed_pulse_us;
struct adc_dt_spec adc;
int32_t fb_gain;
int32_t fb_offset;
int32_t fb_offset_uv;
int32_t max_target_err_us;
uint32_t max_action_time_ms;
};
Expand Down Expand Up @@ -80,7 +80,7 @@ static int servo_set_pulse(const struct device *dev, uint32_t target_pulse_us)
}

/* convert to usec */
pulse_us = ((pulse_mv * 1000) - config->fb_offset) /
pulse_us = ((pulse_mv * 1000) - config->fb_offset_uv) /
config->fb_gain;

if (target_pulse_us >= (pulse_us - config->max_target_err_us) &&
Expand Down Expand Up @@ -159,7 +159,7 @@ static int lock_servo_init(const struct device *dev)
.closed_pulse_us = DT_INST_PROP(i, closed_pulse_us), \
.adc = ADC_DT_SPEC_INST_GET(i), \
.fb_gain = DT_INST_PROP(i, fb_gain), \
.fb_offset = DT_INST_PROP(i, fb_offset), \
.fb_offset_uv = DT_INST_PROP(i, fb_offset_microvolt), \
.max_target_err_us = DT_INST_PROP(i, max_target_err_us), \
.max_action_time_ms = DT_INST_PROP(i, max_action_time_ms), \
}; \
Expand Down
2 changes: 1 addition & 1 deletion dts/bindings/lock/lock-servo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ properties:
description: |
Servo feedback gain (uV/usec).
fb-offset:
fb-offset-microvolt:
required: true
type: int
description: |
Expand Down

0 comments on commit cd41489

Please sign in to comment.