diff --git a/src/motor_driver.cpp b/src/motor_driver.cpp index d0e7289..d04a119 100644 --- a/src/motor_driver.cpp +++ b/src/motor_driver.cpp @@ -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() { if (!initialized) { diff --git a/src/rotary_encoder_driver.cpp b/src/rotary_encoder_driver.cpp index ac10556..44d3415 100644 --- a/src/rotary_encoder_driver.cpp +++ b/src/rotary_encoder_driver.cpp @@ -3,6 +3,13 @@ #include #include #include +#include +#include + +//#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() : count(0), @@ -35,8 +42,8 @@ int RotaryEncoderDriver::begin() timer.set_callback(timer_expired, this); timer.init(SAMPLE_PERIOD_US); - reset_speed_measurement(); + return 0; } diff --git a/zephyr/boards/nucleo_l432kc.overlay b/zephyr/boards/nucleo_l432kc.overlay index c9b8f66..b8070f4 100644 --- a/zephyr/boards/nucleo_l432kc.overlay +++ b/zephyr/boards/nucleo_l432kc.overlay @@ -31,7 +31,7 @@ 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"; @@ -45,6 +45,11 @@ gpios = <&gpioa 1 GPIO_ACTIVE_HIGH>; /* A1, PA1 */ label = "Motor sleep"; }; + + encoder_isr_probe: encoder_isr_probe { + gpios = <&gpioa 12 GPIO_ACTIVE_HIGH>; /* D2, PA12 */ + label = "Encoder ISR probe"; + }; }; motor_pwm_outputs { @@ -63,6 +68,9 @@ label = "Motor BIN2 PWM"; }; }; + zephyr,user { + encoder-isr-probe-gpios = <&gpioa 12 GPIO_ACTIVE_HIGH>; /* D2, PA12 */ + }; }; &timers1 {