TMCStepper
CHOPCONF.cpp
Go to the documentation of this file.
1 #include "TMCStepper.h"
2 #include "TMC_MACROS.h"
3 
4 #define SET_REG(SETTING) CHOPCONF_register.SETTING = B; write(CHOPCONF_register.address, CHOPCONF_register.sr)
5 
6 // CHOPCONF
8  return read(CHOPCONF_register.address);
9 }
10 void TMC2130Stepper::CHOPCONF(uint32_t input) {
11  CHOPCONF_register.sr = input;
12  write(CHOPCONF_register.address, CHOPCONF_register.sr);
13 }
14 
15 void TMC2130Stepper::toff( uint8_t B ) { SET_REG(toff); }
16 void TMC2130Stepper::hstrt( uint8_t B ) { SET_REG(hstrt); }
17 void TMC2130Stepper::hend( uint8_t B ) { SET_REG(hend); }
18 //void TMC2130Stepper::fd( uint8_t B ) { SET_REG(fd); }
20 void TMC2130Stepper::rndtf( bool B ) { SET_REG(rndtf); }
21 void TMC2130Stepper::chm( bool B ) { SET_REG(chm); }
22 void TMC2130Stepper::tbl( uint8_t B ) { SET_REG(tbl); }
26 void TMC2130Stepper::sync( uint8_t B ) { SET_REG(sync); }
27 void TMC2130Stepper::mres( uint8_t B ) { SET_REG(mres); }
29 void TMC2130Stepper::dedge( bool B ) { SET_REG(dedge); }
31 
32 uint8_t TMC2130Stepper::toff() { CHOPCONF_t r{0}; r.sr = CHOPCONF(); return r.toff; }
33 uint8_t TMC2130Stepper::hstrt() { CHOPCONF_t r{0}; r.sr = CHOPCONF(); return r.hstrt; }
34 uint8_t TMC2130Stepper::hend() { CHOPCONF_t r{0}; r.sr = CHOPCONF(); return r.hend; }
35 //uint8_t TMC2130Stepper::fd() { CHOPCONF_t r{0}; r.sr = CHOPCONF(); return r.fd; }
36 bool TMC2130Stepper::disfdcc() { CHOPCONF_t r{0}; r.sr = CHOPCONF(); return r.disfdcc; }
37 bool TMC2130Stepper::rndtf() { CHOPCONF_t r{0}; r.sr = CHOPCONF(); return r.rndtf; }
38 bool TMC2130Stepper::chm() { CHOPCONF_t r{0}; r.sr = CHOPCONF(); return r.chm; }
39 uint8_t TMC2130Stepper::tbl() { CHOPCONF_t r{0}; r.sr = CHOPCONF(); return r.tbl; }
40 bool TMC2130Stepper::vsense() { CHOPCONF_t r{0}; r.sr = CHOPCONF(); return r.vsense; }
41 bool TMC2130Stepper::vhighfs() { CHOPCONF_t r{0}; r.sr = CHOPCONF(); return r.vhighfs; }
42 bool TMC2130Stepper::vhighchm() { CHOPCONF_t r{0}; r.sr = CHOPCONF(); return r.vhighchm;}
43 uint8_t TMC2130Stepper::sync() { CHOPCONF_t r{0}; r.sr = CHOPCONF(); return r.sync; }
44 uint8_t TMC2130Stepper::mres() { CHOPCONF_t r{0}; r.sr = CHOPCONF(); return r.mres; }
45 bool TMC2130Stepper::intpol() { CHOPCONF_t r{0}; r.sr = CHOPCONF(); return r.intpol; }
46 bool TMC2130Stepper::dedge() { CHOPCONF_t r{0}; r.sr = CHOPCONF(); return r.dedge; }
47 bool TMC2130Stepper::diss2g() { CHOPCONF_t r{0}; r.sr = CHOPCONF(); return r.diss2g; }
48 
50 void TMC5160Stepper::tpfd(uint8_t B){ SET_REG(tpfd); }
51 bool TMC5160Stepper::diss2vs() { CHOPCONF_t r{0}; r.sr = CHOPCONF(); return r.diss2vs; }
52 uint8_t TMC5160Stepper::tpfd() { CHOPCONF_t r{0}; r.sr = CHOPCONF(); return r.tpfd; }
53 
54 void TMC2208Stepper::CHOPCONF(uint32_t input) {
55  CHOPCONF_register.sr = input;
56  write(CHOPCONF_register.address, CHOPCONF_register.sr);
57 }
59  return read(CHOPCONF_register.address);
60 }
61 void TMC2208Stepper::toff ( uint8_t B ) { SET_REG(toff); }
62 void TMC2208Stepper::hstrt ( uint8_t B ) { SET_REG(hstrt); }
63 void TMC2208Stepper::hend ( uint8_t B ) { SET_REG(hend); }
64 void TMC2208Stepper::tbl ( uint8_t B ) { SET_REG(tbl); }
65 void TMC2208Stepper::vsense ( bool B ) { SET_REG(vsense); }
66 void TMC2208Stepper::mres ( uint8_t B ) { SET_REG(mres); }
67 void TMC2208Stepper::intpol ( bool B ) { SET_REG(intpol); }
68 void TMC2208Stepper::dedge ( bool B ) { SET_REG(dedge); }
69 void TMC2208Stepper::diss2g ( bool B ) { SET_REG(diss2g); }
71 
72 uint8_t TMC2208Stepper::toff() { TMC2208_n::CHOPCONF_t r{0}; r.sr = CHOPCONF(); return r.toff; }
73 uint8_t TMC2208Stepper::hstrt() { TMC2208_n::CHOPCONF_t r{0}; r.sr = CHOPCONF(); return r.hstrt; }
74 uint8_t TMC2208Stepper::hend() { TMC2208_n::CHOPCONF_t r{0}; r.sr = CHOPCONF(); return r.hend; }
75 uint8_t TMC2208Stepper::tbl() { TMC2208_n::CHOPCONF_t r{0}; r.sr = CHOPCONF(); return r.tbl; }
76 bool TMC2208Stepper::vsense() { TMC2208_n::CHOPCONF_t r{0}; r.sr = CHOPCONF(); return r.vsense; }
77 uint8_t TMC2208Stepper::mres() { TMC2208_n::CHOPCONF_t r{0}; r.sr = CHOPCONF(); return r.mres; }
78 bool TMC2208Stepper::intpol() { TMC2208_n::CHOPCONF_t r{0}; r.sr = CHOPCONF(); return r.intpol; }
79 bool TMC2208Stepper::dedge() { TMC2208_n::CHOPCONF_t r{0}; r.sr = CHOPCONF(); return r.dedge; }
80 bool TMC2208Stepper::diss2g() { TMC2208_n::CHOPCONF_t r{0}; r.sr = CHOPCONF(); return r.diss2g; }
81 bool TMC2208Stepper::diss2vs() { TMC2208_n::CHOPCONF_t r{0}; r.sr = CHOPCONF(); return r.diss2vs; }
82 
83 #define GET_REG_2660(SETTING) return CHOPCONF_register.SETTING;
84 
85 uint32_t TMC2660Stepper::CHOPCONF() { return CHOPCONF_register.sr; }
86 void TMC2660Stepper::CHOPCONF(uint32_t data) {
87  CHOPCONF_register.sr = data;
88  write(CHOPCONF_register.address, CHOPCONF_register.sr);
89 }
90 
91 void TMC2660Stepper::toff(uint8_t B) {
92  SET_REG(toff);
93  if (B>0) _savedToff = B;
94 }
95 void TMC2660Stepper::hstrt(uint8_t B) { SET_REG(hstrt); }
96 void TMC2660Stepper::hend(uint8_t B) { SET_REG(hend); }
97 void TMC2660Stepper::hdec(uint8_t B) { SET_REG(hdec); }
99 void TMC2660Stepper::chm(bool B) { SET_REG(chm); }
100 void TMC2660Stepper::tbl(uint8_t B) { SET_REG(tbl); }
101 
TMC2208Stepper::hend
uint8_t hend()
Definition: CHOPCONF.cpp:74
TMC2130Stepper::toff
uint8_t toff()
Definition: CHOPCONF.cpp:32
TMC2208Stepper::diss2vs
bool diss2vs()
Definition: CHOPCONF.cpp:81
TMC2208Stepper::dedge
bool dedge()
Definition: CHOPCONF.cpp:79
TMC2208Stepper::read
uint32_t read(uint8_t)
Definition: TMC2208Stepper.cpp:221
TMC2208Stepper::diss2g
bool diss2g()
Definition: CHOPCONF.cpp:80
TMC2660Stepper::hend
uint8_t hend()
Definition: CHOPCONF.cpp:104
TMC2130Stepper::dedge
bool dedge()
Definition: CHOPCONF.cpp:46
TMC2660Stepper::toff
uint8_t toff()
Definition: CHOPCONF.cpp:102
SET_REG
#define SET_REG(SETTING)
Definition: CHOPCONF.cpp:4
TMC2130Stepper::disfdcc
bool disfdcc()
Definition: CHOPCONF.cpp:36
TMC2208_n::CHOPCONF_t::sr
uint32_t sr
Definition: TMC2208_bitfields.h:105
TMC2660Stepper::hdec
uint8_t hdec()
Definition: CHOPCONF.cpp:105
TMC5160Stepper::diss2vs
bool diss2vs()
Definition: CHOPCONF.cpp:51
TMC2130Stepper::vhighchm
bool vhighchm()
Definition: CHOPCONF.cpp:42
TMC2130Stepper::mres
uint8_t mres()
Definition: CHOPCONF.cpp:44
TMCStepper.h
TMC2208_n::CHOPCONF_t
Definition: TMC2208_bitfields.h:102
TMC2130Stepper::vhighfs
bool vhighfs()
Definition: CHOPCONF.cpp:41
TMC2660Stepper::tbl
uint8_t tbl()
Definition: CHOPCONF.cpp:108
TMC2130Stepper::chm
bool chm()
Definition: CHOPCONF.cpp:38
TMC2130Stepper::tbl
uint8_t tbl()
Definition: CHOPCONF.cpp:39
TMC2130Stepper::read
uint32_t read(uint8_t addressByte)
Definition: TMC2130Stepper.cpp:65
GET_REG_2660
#define GET_REG_2660(SETTING)
Definition: CHOPCONF.cpp:83
TMC_MACROS.h
TMC2208Stepper::intpol
bool intpol()
Definition: CHOPCONF.cpp:78
TMC5160Stepper::tpfd
uint8_t tpfd()
Definition: CHOPCONF.cpp:52
TMC2130Stepper::CHOPCONF
uint32_t CHOPCONF()
Definition: CHOPCONF.cpp:7
TMC2130Stepper::hstrt
uint8_t hstrt()
Definition: CHOPCONF.cpp:33
TMC2208Stepper::toff
uint8_t toff()
Definition: CHOPCONF.cpp:72
CHOPCONF_t::sr
uint32_t sr
Definition: TMC2130_bitfields.h:125
TMC2660Stepper::rndtf
bool rndtf()
Definition: CHOPCONF.cpp:106
TMC2130Stepper::intpol
bool intpol()
Definition: CHOPCONF.cpp:45
TMC2130Stepper::vsense
bool vsense()
Definition: CHOPCONF.cpp:40
TMC2660Stepper::chm
bool chm()
Definition: CHOPCONF.cpp:107
TMC2130Stepper::sync
uint8_t sync()
Definition: CHOPCONF.cpp:43
TMC2208Stepper::CHOPCONF
uint32_t CHOPCONF()
Definition: CHOPCONF.cpp:58
TMC2660Stepper::write
void write(uint8_t addressByte, uint32_t config)
Definition: TMC2660Stepper.cpp:54
TMC2208Stepper::hstrt
uint8_t hstrt()
Definition: CHOPCONF.cpp:73
TMC2208Stepper::tbl
uint8_t tbl()
Definition: CHOPCONF.cpp:75
TMC2208Stepper::write
void write(uint8_t, uint32_t)
Definition: TMC2208Stepper.cpp:118
TMC2660Stepper::hstrt
uint8_t hstrt()
Definition: CHOPCONF.cpp:103
TMC2660Stepper::CHOPCONF
uint32_t CHOPCONF()
Definition: CHOPCONF.cpp:85
TMC2130Stepper::rndtf
bool rndtf()
Definition: CHOPCONF.cpp:37
TMC2208Stepper::mres
uint8_t mres()
Definition: CHOPCONF.cpp:77
TMC2130Stepper::hend
uint8_t hend()
Definition: CHOPCONF.cpp:34
TMC2130Stepper::diss2g
bool diss2g()
Definition: CHOPCONF.cpp:47
TMC2130Stepper::write
void write(uint8_t addressByte, uint32_t config)
Definition: TMC2130Stepper.cpp:148
CHOPCONF_t
Definition: TMC2130_bitfields.h:122
TMC2208Stepper::vsense
bool vsense()
Definition: CHOPCONF.cpp:76