From 2cdc3bfbc41fc40e47f4f01fd10b93d71df9573c Mon Sep 17 00:00:00 2001 From: Alex Voinea Date: Sun, 25 Jul 2021 20:15:27 +0300 Subject: [PATCH] tmc2130: report error during init --- src/hal/avr/tmc2130.cpp | 5 +++-- src/hal/tmc2130.h | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/hal/avr/tmc2130.cpp b/src/hal/avr/tmc2130.cpp index 01e615e..2a9af4b 100644 --- a/src/hal/avr/tmc2130.cpp +++ b/src/hal/avr/tmc2130.cpp @@ -10,7 +10,7 @@ TMC2130::TMC2130(const MotorParams ¶ms, // TODO } -void TMC2130::Init(const MotorParams ¶ms) { +bool TMC2130::Init(const MotorParams ¶ms) { gpio::Init(params.csPin, gpio::GPIO_InitTypeDef(gpio::Mode::output, gpio::Level::high)); gpio::Init(params.sgPin, gpio::GPIO_InitTypeDef(gpio::Mode::input, gpio::Pull::up)); gpio::Init(params.stepPin, gpio::GPIO_InitTypeDef(gpio::Mode::output, gpio::Level::low)); @@ -18,7 +18,7 @@ void TMC2130::Init(const MotorParams ¶ms) { ///check for compatible tmc driver (IOIN version field) uint32_t IOIN = ReadRegister(params, Registers::IOIN); if (((IOIN >> 24) != 0x11) | !(IOIN & (1 << 6))) ///if the version is incorrect or an always 1 bit is 0 (the supposed SD_MODE pin that doesn't exist on this driver variant) - return; // @todo return some kind of failure + return true; // @todo return some kind of failure ///clear reset flag as we are (re)initializing errorFlags.reset = false; @@ -62,6 +62,7 @@ void TMC2130::Init(const MotorParams ¶ms) { ///TPWMTHRS: switching velocity between stealthChop and spreadCycle. Stallguard is also disabled if the velocity falls below this. Should be set as high as possible when homing. SetMode(params, mode); + return false; } void TMC2130::SetMode(const MotorParams ¶ms, MotorMode mode) { diff --git a/src/hal/tmc2130.h b/src/hal/tmc2130.h index ce0b713..ca26333 100644 --- a/src/hal/tmc2130.h +++ b/src/hal/tmc2130.h @@ -74,7 +74,7 @@ public: MotorMode mode); /// (re)initialization of the chip - void Init(const MotorParams ¶ms); + bool Init(const MotorParams ¶ms); /// Get the current motor mode MotorMode Mode() const {