From edd5e40e1566079dc260cbdf405a8ece4692dba0 Mon Sep 17 00:00:00 2001 From: isakg22 Date: Thu, 8 Oct 2026 15:24:04 +0000 Subject: [PATCH] =?UTF-8?q?laga=C3=B0i=20villu,=20vanta=C3=B0i=20bil=20?= =?UTF-8?q?=C3=A1=20einum=20sta=C3=B0=20=C3=AD=20rotary=20encoder=20driver?= =?UTF-8?q?=20h=20og=20svo=20lag=C3=B0i=20a=C3=B0eins=20=C3=AD=20overlay?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/rotary_encoder_driver.h | 2 +- zephyr/boards/nucleo_l432kc.overlay | 52 +++++++++++++++++++---------- 2 files changed, 36 insertions(+), 18 deletions(-) diff --git a/include/rotary_encoder_driver.h b/include/rotary_encoder_driver.h index ce1a5f3..f6006bd 100644 --- a/include/rotary_encoder_driver.h +++ b/include/rotary_encoder_driver.h @@ -44,7 +44,7 @@ private: Timer_usec timer; static void gpio_edge_handler( - const structdevice *dev, + const struct device *dev, struct gpio_callback *callback, uint32_t pins); diff --git a/zephyr/boards/nucleo_l432kc.overlay b/zephyr/boards/nucleo_l432kc.overlay index 0e90f33..5d27c9f 100644 --- a/zephyr/boards/nucleo_l432kc.overlay +++ b/zephyr/boards/nucleo_l432kc.overlay @@ -12,28 +12,46 @@ motor-slp = &motor_slp; }; - encoder_c1: encoder_c1 { - gpios = <&gpiob 7 GPIO_ACTIVE_HIGH>; /* D4, PB7 */ + 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"; + }; }; - encoder_c2: encoder_c2 { - gpios = <&gpiob 6 GPIO_ACTIVE_HIGH>; /* D5, PB6 */ + motor_gpio_outputs { + compatible = "gpio-leds"; + + motor_bin2: motor_bin2 { + gpios = <&gpiob 1 GPIO_ACTIVE_HIGH>; /* D6, PB1 */ + label = "Motor BIN2"; + }; + + motor_slp: motor_slp { + gpios = <&gpioa 1 GPIO_ACTIVE_HIGH>; /* A1, PA1 */ + label = "Motor sleep"; + }; }; - motor_bin1_pwm: motor_bin1_pwm { - pwms = <&pwm1 1 PWM_USEC(50) 0>; /* D9, PA8; 20 kHz */ - }; + motor_pwm_outputs { + compatible = "pwm-leds"; - motor_bin2: motor_bin2 { - gpios = <&gpiob 1 GPIO_ACTIVE_HIGH>; /* D6, PB1 */ - }; - - motor_flt: motor_flt { - gpios = <&gpioa 0 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>; /* A0, PA0 */ - }; - - motor_slp: motor_slp { - gpios = <&gpioa 1 GPIO_ACTIVE_HIGH>; /* A1, PA1 */ + motor_bin1_pwm: motor_bin1_pwm { + pwms = <&pwm1 1 PWM_USEC(50) 0>; /* D9, PA8; 20 kHz */ + label = "Motor BIN1 PWM"; + }; }; };