TMCStepper
GCONF.cpp
Go to the documentation of this file.
1 #include "TMCStepper.h"
2 #include "TMC_MACROS.h"
3 
4 #define SET_REG(SETTING) GCONF_register.SETTING = B; write(GCONF_register.address, GCONF_register.sr)
5 
6 // GCONF
8  return read(GCONF_register.address);
9 }
10 void TMC2130Stepper::GCONF(uint32_t input) {
11  GCONF_register.sr = input;
12  write(GCONF_register.address, GCONF_register.sr);
13 }
14 
15 void TMC2130Stepper::I_scale_analog(bool B) { SET_REG(i_scale_analog); }
16 void TMC2130Stepper::internal_Rsense(bool B) { SET_REG(internal_rsense); }
28 void TMC2130Stepper::diag1_pushpull(bool B) { SET_REG(diag1_poscomp_pushpull); }
32 
33 bool TMC2130Stepper::I_scale_analog() { GCONF_t r{0}; r.sr = GCONF(); return r.i_scale_analog; }
34 bool TMC2130Stepper::internal_Rsense() { GCONF_t r{0}; r.sr = GCONF(); return r.internal_rsense; }
35 bool TMC2130Stepper::en_pwm_mode() { GCONF_t r{0}; r.sr = GCONF(); return r.en_pwm_mode; }
36 bool TMC2130Stepper::enc_commutation() { GCONF_t r{0}; r.sr = GCONF(); return r.enc_commutation; }
37 bool TMC2130Stepper::shaft() { GCONF_t r{0}; r.sr = GCONF(); return r.shaft; }
38 bool TMC2130Stepper::diag0_error() { GCONF_t r{0}; r.sr = GCONF(); return r.diag0_error; }
39 bool TMC2130Stepper::diag0_otpw() { GCONF_t r{0}; r.sr = GCONF(); return r.diag0_otpw; }
40 bool TMC2130Stepper::diag0_stall() { GCONF_t r{0}; r.sr = GCONF(); return r.diag0_stall; }
41 bool TMC2130Stepper::diag1_stall() { GCONF_t r{0}; r.sr = GCONF(); return r.diag1_stall; }
42 bool TMC2130Stepper::diag1_index() { GCONF_t r{0}; r.sr = GCONF(); return r.diag1_index; }
43 bool TMC2130Stepper::diag1_onstate() { GCONF_t r{0}; r.sr = GCONF(); return r.diag1_onstate; }
44 bool TMC2130Stepper::diag1_steps_skipped() { GCONF_t r{0}; r.sr = GCONF(); return r.diag1_steps_skipped; }
45 bool TMC2130Stepper::diag0_int_pushpull() { GCONF_t r{0}; r.sr = GCONF(); return r.diag0_int_pushpull; }
46 bool TMC2130Stepper::diag1_pushpull() { GCONF_t r{0}; r.sr = GCONF(); return r.diag1_poscomp_pushpull;}
47 bool TMC2130Stepper::small_hysteresis() { GCONF_t r{0}; r.sr = GCONF(); return r.small_hysteresis; }
48 bool TMC2130Stepper::stop_enable() { GCONF_t r{0}; r.sr = GCONF(); return r.stop_enable; }
49 bool TMC2130Stepper::direct_mode() { GCONF_t r{0}; r.sr = GCONF(); return r.direct_mode; }
50 
51 /*
52 bit 18 not implemented:
53 test_mode 0:
54 Normal operation 1:
55 Enable analog test output on pin DCO. IHOLD[1..0] selects the function of DCO:
56 0…2: T120, DAC, VDDH Attention:
57 Not for user, set to 0 for normal operation!
58 */
59 
63 bool TMC5160Stepper::recalibrate() { GCONF_t r{0}; r.sr = GCONF(); return r.recalibrate; }
64 bool TMC5160Stepper::faststandstill() { GCONF_t r{0}; r.sr = GCONF(); return r.faststandstill; }
65 bool TMC5160Stepper::multistep_filt() { GCONF_t r{0}; r.sr = GCONF(); return r.multistep_filt; }
66 
68  return read(GCONF_register.address);
69 }
70 void TMC2208Stepper::GCONF(uint32_t input) {
71  GCONF_register.sr = input;
72  write(GCONF_register.address, GCONF_register.sr);
73 }
74 
75 void TMC2208Stepper::I_scale_analog(bool B) { SET_REG(i_scale_analog); }
76 void TMC2208Stepper::internal_Rsense(bool B) { SET_REG(internal_rsense); }
77 void TMC2208Stepper::en_spreadCycle(bool B) { SET_REG(en_spreadcycle); }
84 
85 bool TMC2208Stepper::I_scale_analog() { TMC2208_n::GCONF_t r{0}; r.sr = GCONF(); return r.i_scale_analog; }
86 bool TMC2208Stepper::internal_Rsense() { TMC2208_n::GCONF_t r{0}; r.sr = GCONF(); return r.internal_rsense; }
87 bool TMC2208Stepper::en_spreadCycle() { TMC2208_n::GCONF_t r{0}; r.sr = GCONF(); return r.en_spreadcycle; }
88 bool TMC2208Stepper::shaft() { TMC2208_n::GCONF_t r{0}; r.sr = GCONF(); return r.shaft; }
89 bool TMC2208Stepper::index_otpw() { TMC2208_n::GCONF_t r{0}; r.sr = GCONF(); return r.index_otpw; }
90 bool TMC2208Stepper::index_step() { TMC2208_n::GCONF_t r{0}; r.sr = GCONF(); return r.index_step; }
91 bool TMC2208Stepper::pdn_disable() { TMC2208_n::GCONF_t r{0}; r.sr = GCONF(); return r.pdn_disable; }
92 bool TMC2208Stepper::mstep_reg_select() { TMC2208_n::GCONF_t r{0}; r.sr = GCONF(); return r.mstep_reg_select; }
93 bool TMC2208Stepper::multistep_filt() { TMC2208_n::GCONF_t r{0}; r.sr = GCONF(); return r.multistep_filt; }
TMC2130Stepper::diag0_stall
bool diag0_stall()
Definition: GCONF.cpp:40
TMC2130Stepper::internal_Rsense
bool internal_Rsense()
Definition: GCONF.cpp:34
TMC2208Stepper::read
uint32_t read(uint8_t)
Definition: TMC2208Stepper.cpp:221
TMC2130Stepper::I_scale_analog
bool I_scale_analog()
Definition: GCONF.cpp:33
GCONF_t
Definition: TMC2130_bitfields.h:4
TMC5160Stepper::recalibrate
bool recalibrate()
Definition: GCONF.cpp:63
TMC2130Stepper::diag1_steps_skipped
bool diag1_steps_skipped()
Definition: GCONF.cpp:44
TMC2208Stepper::internal_Rsense
bool internal_Rsense()
Definition: GCONF.cpp:86
TMCStepper.h
SET_REG
#define SET_REG(SETTING)
Definition: GCONF.cpp:4
TMC2130Stepper::enc_commutation
bool enc_commutation()
Definition: GCONF.cpp:36
TMC5160Stepper::multistep_filt
bool multistep_filt()
Definition: GCONF.cpp:65
TMC2208Stepper::en_spreadCycle
bool en_spreadCycle()
Definition: GCONF.cpp:87
TMC2130Stepper::diag0_error
bool diag0_error()
Definition: GCONF.cpp:38
TMC2130Stepper::diag1_index
bool diag1_index()
Definition: GCONF.cpp:42
TMC2130Stepper::read
uint32_t read(uint8_t addressByte)
Definition: TMC2130Stepper.cpp:65
TMC2130Stepper::GCONF
uint32_t GCONF()
Definition: GCONF.cpp:7
TMC_MACROS.h
TMC2208Stepper::multistep_filt
bool multistep_filt()
Definition: GCONF.cpp:93
TMC2208Stepper::pdn_disable
bool pdn_disable()
Definition: GCONF.cpp:91
TMC2208Stepper::GCONF
uint32_t GCONF()
Definition: GCONF.cpp:67
TMC5160Stepper::faststandstill
bool faststandstill()
Definition: GCONF.cpp:64
TMC2208Stepper::shaft
bool shaft()
Definition: GCONF.cpp:88
TMC2208_n::GCONF_t
Definition: TMC2208_bitfields.h:5
TMC2130Stepper::diag1_pushpull
bool diag1_pushpull()
Definition: GCONF.cpp:46
TMC2208Stepper::index_otpw
bool index_otpw()
Definition: GCONF.cpp:89
TMC2130Stepper::en_pwm_mode
bool en_pwm_mode()
Definition: GCONF.cpp:35
TMC2208_n::GCONF_t::sr
uint16_t sr
Definition: TMC2208_bitfields.h:8
TMC2130Stepper::diag0_int_pushpull
bool diag0_int_pushpull()
Definition: GCONF.cpp:45
GCONF_t::sr
uint32_t sr
Definition: TMC2130_bitfields.h:7
TMC2208Stepper::mstep_reg_select
bool mstep_reg_select()
Definition: GCONF.cpp:92
TMC2208Stepper::write
void write(uint8_t, uint32_t)
Definition: TMC2208Stepper.cpp:118
TMC2130Stepper::shaft
bool shaft()
Definition: GCONF.cpp:37
TMC2208Stepper::I_scale_analog
bool I_scale_analog()
Definition: GCONF.cpp:85
TMC2130Stepper::diag1_stall
bool diag1_stall()
Definition: GCONF.cpp:41
TMC2208Stepper::index_step
bool index_step()
Definition: GCONF.cpp:90
TMC2130Stepper::write
void write(uint8_t addressByte, uint32_t config)
Definition: TMC2130Stepper.cpp:148
TMC2130Stepper::direct_mode
bool direct_mode()
Definition: GCONF.cpp:49
TMC2130Stepper::small_hysteresis
bool small_hysteresis()
Definition: GCONF.cpp:47
TMC2130Stepper::diag1_onstate
bool diag1_onstate()
Definition: GCONF.cpp:43
TMC2130Stepper::diag0_otpw
bool diag0_otpw()
Definition: GCONF.cpp:39
TMC2130Stepper::stop_enable
bool stop_enable()
Definition: GCONF.cpp:48