87 lines
2.4 KiB
Plaintext
87 lines
2.4 KiB
Plaintext
#include <zephyr/dt-bindings/gpio/gpio.h>
|
|
#include <zephyr/dt-bindings/pwm/pwm.h>
|
|
#include <zephyr/dt-bindings/pwm/stm32_pwm.h>
|
|
|
|
/ {
|
|
aliases {
|
|
encoder-c1 = &encoder_c1;
|
|
encoder-c2 = &encoder_c2;
|
|
|
|
motor-bin1-pwm = &motor_bin1_pwm;
|
|
motor-bin2-pwm = &motor_bin2_pwm;
|
|
motor-flt = &motor_flt;
|
|
motor-slp = &motor_slp;
|
|
fault-test-button = &fault_test_button;
|
|
};
|
|
|
|
buttons {
|
|
compatible = "gpio-keys";
|
|
|
|
encoder_c1: encoder_c1 {
|
|
gpios = <&gpiob 7 GPIO_ACTIVE_HIGH>; /* D4, PB7 */
|
|
label = "Encoder C1";
|
|
};
|
|
|
|
encoder_c2: encoder_c2 {
|
|
gpios = <&gpiob 6 GPIO_ACTIVE_HIGH>; /* D5, PB6 */
|
|
label = "Encoder C2";
|
|
};
|
|
|
|
motor_flt: motor_flt {
|
|
gpios = <&gpioa 0 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>; /* A0, PA0 */
|
|
label = "Motor fault";
|
|
};
|
|
|
|
fault_test_button: fault_test_button {
|
|
gpios = <&gpiob 0 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>; /* D3, PB0 */
|
|
label = "Fault test button";
|
|
};
|
|
};
|
|
|
|
motor_gpio_outputs {
|
|
compatible = "gpio-leds";
|
|
|
|
motor_slp: motor_slp {
|
|
gpios = <&gpioa 1 GPIO_ACTIVE_HIGH>; /* A1, PA1 */
|
|
label = "Motor sleep";
|
|
};
|
|
};
|
|
|
|
motor_pwm_outputs {
|
|
compatible = "pwm-leds";
|
|
|
|
motor_bin1_pwm: motor_bin1_pwm {
|
|
pwms = <&pwm1 1 PWM_USEC(50) 0>; /* D9, PA8; 20 kHz */
|
|
label = "Motor BIN1 PWM";
|
|
};
|
|
|
|
/* PB1 has no regular TIM1 channel, only the complementary output
|
|
* TIM1_CH3N. With CH3 itself disabled, CH3N outputs the
|
|
* non-inverted CH3 reference, so it behaves like a normal channel. */
|
|
motor_bin2_pwm: motor_bin2_pwm {
|
|
pwms = <&pwm1 3 PWM_USEC(50) (PWM_POLARITY_NORMAL | STM32_PWM_COMPLEMENTARY)>; /* D6, PB1; 20 kHz */
|
|
label = "Motor BIN2 PWM";
|
|
};
|
|
};
|
|
};
|
|
|
|
&timers1 {
|
|
status = "okay";
|
|
/* No prescaler: 80 MHz timer clock, so a 50 us period is 4000 counts. */
|
|
st,prescaler = <0>;
|
|
|
|
pwm1: pwm {
|
|
status = "okay";
|
|
pinctrl-0 = <&tim1_ch1_pa8 &tim1_ch3n_pb1>;
|
|
pinctrl-names = "default";
|
|
};
|
|
};
|
|
|
|
/* CAN1 to the transceiver: RX on D10 (PA11), TX on D2 (PA12).
|
|
* The bitrate is set in the code with can_set_bitrate(). */
|
|
&can1 {
|
|
pinctrl-0 = <&can1_rx_pa11 &can1_tx_pa12>;
|
|
pinctrl-names = "default";
|
|
status = "okay";
|
|
};
|