The sample did not use PWM in a proper way: it relied on a PWM device
handle, but channel or flags were hardcoded in the code. This patch
changes the sample to use a local binding ("pwm-servo") where the `pwms`
property is defined. This allows to make use of pwm_dt_spec facilities,
reducing the overall sample complexity and making it more portable
without editing the source code. The custom binding also requires to
provide the minimum/maximum pulse width so that different servos can be
easily plugged in without the need to edit sources.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
16 lines
327 B
Plaintext
16 lines
327 B
Plaintext
/* SPDX-License-Identifier: Apache-2.0 */
|
|
/ {
|
|
servo: servo {
|
|
compatible = "pwm-servo";
|
|
pwms = <&sw_pwm 0 PWM_MSEC(20) PWM_POLARITY_NORMAL>;
|
|
min-pulse = <PWM_USEC(700)>;
|
|
max-pulse = <PWM_USEC(2500)>;
|
|
};
|
|
};
|
|
|
|
&sw_pwm {
|
|
status = "okay";
|
|
clock-prescaler = <3>;
|
|
channel-gpios = <&edge_connector 19 GPIO_ACTIVE_HIGH>;
|
|
};
|