Merge branch 'Isak_part1' of ssh://gitea.cs.ru.is:2222/helgie22/ESP_Project4_H26 into Isak_part1

This commit is contained in:
2026-10-15 12:18:35 +00:00
3 changed files with 31 additions and 2 deletions
+14
View File
@@ -125,6 +125,20 @@ void MotorDriver::set(double pwm)
} }
// bool MotorDriver::fault_active()
// {
// //return !(PIND & (1 << PIND4));
// if (!initialized) {
// return true; // Fail safe if the driver did not initialize.
// }
// // The overlay marks FLT as active low. gpio_pin_get_dt() returns
// // the logical active state, so 1 means a fault is active.
// const int fault = gpio_pin_get_dt(&motor_flt);
// return fault < 0 || fault != 0;
// }
bool MotorDriver::fault_active() bool MotorDriver::fault_active()
{ {
if (!initialized) { if (!initialized) {
+8 -1
View File
@@ -3,6 +3,13 @@
#include <errno.h> #include <errno.h>
#include <zephyr/kernel.h> #include <zephyr/kernel.h>
#include <zephyr/sys/util.h> #include <zephyr/sys/util.h>
#include <zephyr/devicetree.h>
#include <zephyr/drivers/gpio.h>
//#define ISR_PROBE_NODE DT_PATH(zephyr_user)
static const struct gpio_dt_spec isr_probe =
GPIO_DT_SPEC_GET(DT_ALIAS(encoder_isr_probe), gpios);
RotaryEncoderDriver::RotaryEncoderDriver() RotaryEncoderDriver::RotaryEncoderDriver()
: count(0), : count(0),
@@ -35,8 +42,8 @@ int RotaryEncoderDriver::begin()
timer.set_callback(timer_expired, this); timer.set_callback(timer_expired, this);
timer.init(SAMPLE_PERIOD_US); timer.init(SAMPLE_PERIOD_US);
reset_speed_measurement(); reset_speed_measurement();
return 0; return 0;
} }
+8
View File
@@ -45,6 +45,11 @@
gpios = <&gpioa 1 GPIO_ACTIVE_HIGH>; /* A1, PA1 */ gpios = <&gpioa 1 GPIO_ACTIVE_HIGH>; /* A1, PA1 */
label = "Motor sleep"; label = "Motor sleep";
}; };
encoder_isr_probe: encoder_isr_probe {
gpios = <&gpioa 12 GPIO_ACTIVE_HIGH>; /* D2, PA12 */
label = "Encoder ISR probe";
};
}; };
motor_pwm_outputs { motor_pwm_outputs {
@@ -63,6 +68,9 @@
label = "Motor BIN2 PWM"; label = "Motor BIN2 PWM";
}; };
}; };
zephyr,user {
encoder-isr-probe-gpios = <&gpioa 12 GPIO_ACTIVE_HIGH>; /* D2, PA12 */
};
}; };
&timers1 { &timers1 {