TMCStepper
DRVSTATUS.cpp
Go to the documentation of this file.
1 #include "TMCStepper.h"
2 #include "TMC_MACROS.h"
3 
4 #define GET_REG00(SETTING) DRVSTATUS(); return READ_RDSEL00_register.SETTING
5 #define GET_REG01(SETTING) DRVSTATUS(); return READ_RDSEL01_register.SETTING
6 #define GET_REG10(SETTING) DRVSTATUS(); return READ_RDSEL10_register.SETTING
7 
9  uint32_t response = read()&0xFFCFF;
10  READ_RDSEL00_register.sr = response & 0xFF;
11  READ_RDSEL01_register.sr = response & 0xFF;
12  READ_RDSEL10_register.sr = response & 0xFF;
13  switch(rdsel()) {
14  case 0b00: READ_RDSEL00_register.sr |= response & 0xFFC00; break;
15  case 0b01: READ_RDSEL01_register.sr |= response & 0xFFC00; break;
16  case 0b10: READ_RDSEL10_register.sr |= response & 0xFFC00; break;
17  default: return 0;
18  }
19  return response;
20 }
21 
22 uint16_t TMC2660Stepper::mstep() { if(rdsel() != 0b00) rdsel(0b00); GET_REG00(mstep); }
23 uint8_t TMC2660Stepper::se() { if(rdsel() != 0b10) rdsel(0b10); GET_REG10(se); }
31 bool TMC2660Stepper::sg() { GET_REG00(sg_value); }
32 
34  uint16_t out = 0;
35  if (rdsel() == 0b00) rdsel(0b01);
36  DRVSTATUS();
37  switch(rdsel()) {
38  case 0b01: out = READ_RDSEL01_register.sg_result; break;
39  case 0b10: out = READ_RDSEL10_register.sg_result; break;
40  default: break;
41  }
42  return out;
43 }
TMC2660Stepper::s2ga
bool s2ga()
Definition: DRVSTATUS.cpp:28
TMC2660Stepper::stst
bool stst()
Definition: DRVSTATUS.cpp:24
TMC2660Stepper::mstep
uint16_t mstep()
Definition: DRVSTATUS.cpp:22
GET_REG10
#define GET_REG10(SETTING)
Definition: DRVSTATUS.cpp:6
TMC2660Stepper::sg
bool sg()
Definition: DRVSTATUS.cpp:31
GET_REG00
#define GET_REG00(SETTING)
Definition: DRVSTATUS.cpp:4
TMC2660Stepper::se
uint8_t se()
Definition: DRVSTATUS.cpp:23
TMCStepper.h
TMC_MACROS.h
TMC2660Stepper::ot
bool ot()
Definition: DRVSTATUS.cpp:30
TMC2660Stepper::read
uint32_t read()
Definition: TMC2660Stepper.cpp:30
TMC2660Stepper::DRVSTATUS
uint32_t DRVSTATUS()
Definition: DRVSTATUS.cpp:8
TMC2660Stepper::otpw
bool otpw()
Definition: DRVSTATUS.cpp:29
TMC2660Stepper::sg_result
uint16_t sg_result()
Definition: DRVSTATUS.cpp:33
TMC2660Stepper::ola
bool ola()
Definition: DRVSTATUS.cpp:26
TMC2660Stepper::olb
bool olb()
Definition: DRVSTATUS.cpp:25
TMC2660Stepper::s2gb
bool s2gb()
Definition: DRVSTATUS.cpp:27
TMC2660Stepper::rdsel
uint8_t rdsel()
Definition: DRVCONF.cpp:29