Skip to content

Commit e59d168

Browse files
authored
Merge pull request #110 from mkbel/fix_drv_uvlo_read
Fix drv uvlo read
2 parents a959200 + 8cc1e53 commit e59d168

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

MM-control-01/main.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ void setup()
236236
{
237237
motion_set_idler(filament);
238238
}
239+
tmc2130_read_gstat(); //consume reset after power up
239240

240241
if (digitalRead(A1) == 1) isFilamentLoaded = true;
241242

MM-control-01/tmc2130.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,17 @@ uint8_t tmc2130_rx(uint8_t axis, uint8_t addr, uint32_t* rval)
340340
return stat;
341341
}
342342

343-
//! @brief Read global error flags for all axes
343+
//! @brief Read global error flags for all axis
344+
//!
345+
//! Error is detected if any of following flags is set.
346+
//! * reset
347+
//! * IC has been reset since the last read access to GSTAT.
348+
//! All registers have been cleared to reset values.
349+
//! * drv_err
350+
//! * Overtemperature or short circuit. Driver has been shut down.
351+
//! * uv_cp
352+
//! * Undervoltage on the charge pump. The driver is disabled in this case.
353+
//!
344354
//! @retval 0 no error
345355
//! @retval >0 error, bit flag set for each axis
346356
uint8_t tmc2130_read_gstat()
@@ -350,7 +360,7 @@ uint8_t tmc2130_read_gstat()
350360
{
351361
uint32_t result;
352362
tmc2130_rd(axis, TMC2130_REG_GSTAT, &result);
353-
if (result && 0x6) retval += (1 << axis);
363+
if (result & 0x7) retval += (1 << axis);
354364
}
355365
return retval;
356366
}

0 commit comments

Comments
 (0)