Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: TMCStepper mRotaryEncoder-os
source/TMC2130_bitfields.h@1:60419aa0c030, 2021-02-04 (annotated)
- Committer:
- charly
- Date:
- Thu Feb 04 21:35:45 2021 +0000
- Revision:
- 1:60419aa0c030
- Parent:
- 0:3f4cfbeda9d3
Fast version with ca. 2,5rpm
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| charly | 0:3f4cfbeda9d3 | 1 | #pragma once |
| charly | 0:3f4cfbeda9d3 | 2 | #pragma pack(push, 1) |
| charly | 0:3f4cfbeda9d3 | 3 | |
| charly | 0:3f4cfbeda9d3 | 4 | struct GCONF_t { |
| charly | 0:3f4cfbeda9d3 | 5 | constexpr static uint8_t address = 0x00; |
| charly | 0:3f4cfbeda9d3 | 6 | union { |
| charly | 0:3f4cfbeda9d3 | 7 | uint32_t sr : 18; |
| charly | 0:3f4cfbeda9d3 | 8 | struct { |
| charly | 0:3f4cfbeda9d3 | 9 | bool i_scale_analog : 1, // 2130, 5130 |
| charly | 0:3f4cfbeda9d3 | 10 | internal_rsense : 1, // 2130, 5130 |
| charly | 0:3f4cfbeda9d3 | 11 | en_pwm_mode : 1, |
| charly | 0:3f4cfbeda9d3 | 12 | enc_commutation : 1, // 2130, 5130 |
| charly | 0:3f4cfbeda9d3 | 13 | shaft : 1, |
| charly | 0:3f4cfbeda9d3 | 14 | diag0_error : 1, |
| charly | 0:3f4cfbeda9d3 | 15 | diag0_otpw : 1, |
| charly | 0:3f4cfbeda9d3 | 16 | diag0_stall : 1, |
| charly | 0:3f4cfbeda9d3 | 17 | diag1_stall : 1, |
| charly | 0:3f4cfbeda9d3 | 18 | diag1_index : 1, |
| charly | 0:3f4cfbeda9d3 | 19 | diag1_onstate : 1, |
| charly | 0:3f4cfbeda9d3 | 20 | diag1_steps_skipped : 1, |
| charly | 0:3f4cfbeda9d3 | 21 | diag0_int_pushpull : 1, |
| charly | 0:3f4cfbeda9d3 | 22 | diag1_pushpull : 1, |
| charly | 0:3f4cfbeda9d3 | 23 | small_hysteresis : 1, |
| charly | 0:3f4cfbeda9d3 | 24 | stop_enable : 1, |
| charly | 0:3f4cfbeda9d3 | 25 | direct_mode : 1; |
| charly | 0:3f4cfbeda9d3 | 26 | }; |
| charly | 0:3f4cfbeda9d3 | 27 | struct { // TMC5160 |
| charly | 0:3f4cfbeda9d3 | 28 | bool recalibrate : 1, |
| charly | 0:3f4cfbeda9d3 | 29 | faststandstill : 1, |
| charly | 0:3f4cfbeda9d3 | 30 | : 1, |
| charly | 0:3f4cfbeda9d3 | 31 | multistep_filt : 1, |
| charly | 0:3f4cfbeda9d3 | 32 | : 3, |
| charly | 0:3f4cfbeda9d3 | 33 | diag0_step : 1, |
| charly | 0:3f4cfbeda9d3 | 34 | diag1_dir : 1, |
| charly | 0:3f4cfbeda9d3 | 35 | : 4, |
| charly | 0:3f4cfbeda9d3 | 36 | diag1_poscomp_pushpull : 1; |
| charly | 0:3f4cfbeda9d3 | 37 | }; |
| charly | 0:3f4cfbeda9d3 | 38 | }; |
| charly | 0:3f4cfbeda9d3 | 39 | }; |
| charly | 0:3f4cfbeda9d3 | 40 | |
| charly | 0:3f4cfbeda9d3 | 41 | struct IHOLD_IRUN_t { |
| charly | 0:3f4cfbeda9d3 | 42 | constexpr static uint8_t address = 0x10; |
| charly | 0:3f4cfbeda9d3 | 43 | union { |
| charly | 0:3f4cfbeda9d3 | 44 | uint32_t sr : 20; |
| charly | 0:3f4cfbeda9d3 | 45 | struct { |
| charly | 0:3f4cfbeda9d3 | 46 | uint8_t ihold : 5, |
| charly | 0:3f4cfbeda9d3 | 47 | : 3, |
| charly | 0:3f4cfbeda9d3 | 48 | irun : 5, |
| charly | 0:3f4cfbeda9d3 | 49 | : 3, |
| charly | 0:3f4cfbeda9d3 | 50 | iholddelay : 4; |
| charly | 0:3f4cfbeda9d3 | 51 | }; |
| charly | 0:3f4cfbeda9d3 | 52 | }; |
| charly | 0:3f4cfbeda9d3 | 53 | }; |
| charly | 0:3f4cfbeda9d3 | 54 | |
| charly | 0:3f4cfbeda9d3 | 55 | struct GSTAT_t { |
| charly | 0:3f4cfbeda9d3 | 56 | constexpr static uint8_t address = 0x01; |
| charly | 0:3f4cfbeda9d3 | 57 | union { |
| charly | 0:3f4cfbeda9d3 | 58 | uint8_t sr : 3; |
| charly | 0:3f4cfbeda9d3 | 59 | struct { |
| charly | 0:3f4cfbeda9d3 | 60 | bool reset : 1, |
| charly | 0:3f4cfbeda9d3 | 61 | drv_err : 1, |
| charly | 0:3f4cfbeda9d3 | 62 | uv_cp : 1; |
| charly | 0:3f4cfbeda9d3 | 63 | }; |
| charly | 0:3f4cfbeda9d3 | 64 | }; |
| charly | 0:3f4cfbeda9d3 | 65 | }; |
| charly | 0:3f4cfbeda9d3 | 66 | |
| charly | 0:3f4cfbeda9d3 | 67 | struct IOIN_t { |
| charly | 0:3f4cfbeda9d3 | 68 | constexpr static uint8_t address = 0x04; |
| charly | 0:3f4cfbeda9d3 | 69 | union { |
| charly | 0:3f4cfbeda9d3 | 70 | uint32_t sr; |
| charly | 0:3f4cfbeda9d3 | 71 | struct { |
| charly | 0:3f4cfbeda9d3 | 72 | bool step : 1, |
| charly | 0:3f4cfbeda9d3 | 73 | dir : 1, |
| charly | 0:3f4cfbeda9d3 | 74 | dcen_cfg4 : 1, |
| charly | 0:3f4cfbeda9d3 | 75 | dcin_cfg5 : 1, |
| charly | 0:3f4cfbeda9d3 | 76 | drv_enn_cfg6 : 1, |
| charly | 0:3f4cfbeda9d3 | 77 | dco : 1, |
| charly | 0:3f4cfbeda9d3 | 78 | : 2; |
| charly | 0:3f4cfbeda9d3 | 79 | uint16_t : 16; |
| charly | 0:3f4cfbeda9d3 | 80 | uint8_t version : 8; |
| charly | 0:3f4cfbeda9d3 | 81 | }; |
| charly | 0:3f4cfbeda9d3 | 82 | }; |
| charly | 0:3f4cfbeda9d3 | 83 | }; |
| charly | 0:3f4cfbeda9d3 | 84 | |
| charly | 0:3f4cfbeda9d3 | 85 | struct TPOWERDOWN_t { |
| charly | 0:3f4cfbeda9d3 | 86 | constexpr static uint8_t address = 0x11; |
| charly | 0:3f4cfbeda9d3 | 87 | uint8_t sr : 8; |
| charly | 0:3f4cfbeda9d3 | 88 | }; |
| charly | 0:3f4cfbeda9d3 | 89 | |
| charly | 0:3f4cfbeda9d3 | 90 | struct TPWMTHRS_t { |
| charly | 0:3f4cfbeda9d3 | 91 | constexpr static uint8_t address = 0x13; |
| charly | 0:3f4cfbeda9d3 | 92 | uint32_t sr : 20; |
| charly | 0:3f4cfbeda9d3 | 93 | }; |
| charly | 0:3f4cfbeda9d3 | 94 | |
| charly | 0:3f4cfbeda9d3 | 95 | struct TCOOLTHRS_t { |
| charly | 0:3f4cfbeda9d3 | 96 | constexpr static uint8_t address = 0x14; |
| charly | 0:3f4cfbeda9d3 | 97 | uint32_t sr : 20; |
| charly | 0:3f4cfbeda9d3 | 98 | }; |
| charly | 0:3f4cfbeda9d3 | 99 | |
| charly | 0:3f4cfbeda9d3 | 100 | struct THIGH_t { |
| charly | 0:3f4cfbeda9d3 | 101 | constexpr static uint8_t address = 0x15; |
| charly | 0:3f4cfbeda9d3 | 102 | uint32_t sr : 20; |
| charly | 0:3f4cfbeda9d3 | 103 | }; |
| charly | 0:3f4cfbeda9d3 | 104 | |
| charly | 0:3f4cfbeda9d3 | 105 | struct XDIRECT_t { |
| charly | 0:3f4cfbeda9d3 | 106 | constexpr static uint8_t address = 0x2D; |
| charly | 0:3f4cfbeda9d3 | 107 | union { |
| charly | 0:3f4cfbeda9d3 | 108 | uint32_t sr : 25; |
| charly | 0:3f4cfbeda9d3 | 109 | struct { |
| charly | 0:3f4cfbeda9d3 | 110 | int16_t coil_A : 9; |
| charly | 0:3f4cfbeda9d3 | 111 | int8_t : 7; |
| charly | 0:3f4cfbeda9d3 | 112 | int16_t coil_B : 9; |
| charly | 0:3f4cfbeda9d3 | 113 | }; |
| charly | 0:3f4cfbeda9d3 | 114 | }; |
| charly | 0:3f4cfbeda9d3 | 115 | }; |
| charly | 0:3f4cfbeda9d3 | 116 | |
| charly | 0:3f4cfbeda9d3 | 117 | struct VDCMIN_t { |
| charly | 0:3f4cfbeda9d3 | 118 | constexpr static uint8_t address = 0x33; |
| charly | 0:3f4cfbeda9d3 | 119 | uint32_t sr : 23; |
| charly | 0:3f4cfbeda9d3 | 120 | }; |
| charly | 0:3f4cfbeda9d3 | 121 | |
| charly | 0:3f4cfbeda9d3 | 122 | struct CHOPCONF_t { |
| charly | 0:3f4cfbeda9d3 | 123 | constexpr static uint8_t address = 0x6C; |
| charly | 0:3f4cfbeda9d3 | 124 | union { |
| charly | 0:3f4cfbeda9d3 | 125 | uint32_t sr : 32; |
| charly | 0:3f4cfbeda9d3 | 126 | struct { |
| charly | 0:3f4cfbeda9d3 | 127 | uint8_t toff : 4, |
| charly | 0:3f4cfbeda9d3 | 128 | hstrt : 3, |
| charly | 0:3f4cfbeda9d3 | 129 | hend : 4, |
| charly | 0:3f4cfbeda9d3 | 130 | : 1; |
| charly | 0:3f4cfbeda9d3 | 131 | bool disfdcc : 1, |
| charly | 0:3f4cfbeda9d3 | 132 | rndtf : 1, |
| charly | 0:3f4cfbeda9d3 | 133 | chm : 1; |
| charly | 0:3f4cfbeda9d3 | 134 | uint8_t tbl : 2; |
| charly | 0:3f4cfbeda9d3 | 135 | bool vsense : 1, |
| charly | 0:3f4cfbeda9d3 | 136 | vhighfs : 1, |
| charly | 0:3f4cfbeda9d3 | 137 | vhighchm : 1; |
| charly | 0:3f4cfbeda9d3 | 138 | uint8_t sync : 4, // 2130, 5130 |
| charly | 0:3f4cfbeda9d3 | 139 | mres : 4; |
| charly | 0:3f4cfbeda9d3 | 140 | bool intpol : 1, |
| charly | 0:3f4cfbeda9d3 | 141 | dedge : 1, |
| charly | 0:3f4cfbeda9d3 | 142 | diss2g : 1; |
| charly | 0:3f4cfbeda9d3 | 143 | }; |
| charly | 0:3f4cfbeda9d3 | 144 | struct { // TMC5160 |
| charly | 0:3f4cfbeda9d3 | 145 | uint32_t : 20; |
| charly | 0:3f4cfbeda9d3 | 146 | uint8_t tpfd : 4; // 5160 |
| charly | 0:3f4cfbeda9d3 | 147 | uint16_t : 7; |
| charly | 0:3f4cfbeda9d3 | 148 | bool diss2vs : 1; // TMC5160 only |
| charly | 0:3f4cfbeda9d3 | 149 | }; |
| charly | 0:3f4cfbeda9d3 | 150 | }; |
| charly | 0:3f4cfbeda9d3 | 151 | }; |
| charly | 0:3f4cfbeda9d3 | 152 | |
| charly | 0:3f4cfbeda9d3 | 153 | struct COOLCONF_t { |
| charly | 0:3f4cfbeda9d3 | 154 | constexpr static uint8_t address = 0x6D; |
| charly | 0:3f4cfbeda9d3 | 155 | union { |
| charly | 0:3f4cfbeda9d3 | 156 | uint32_t sr : 25; |
| charly | 0:3f4cfbeda9d3 | 157 | struct { |
| charly | 0:3f4cfbeda9d3 | 158 | uint8_t semin : 4, |
| charly | 0:3f4cfbeda9d3 | 159 | : 1, |
| charly | 0:3f4cfbeda9d3 | 160 | seup : 2, |
| charly | 0:3f4cfbeda9d3 | 161 | : 1, |
| charly | 0:3f4cfbeda9d3 | 162 | semax : 4, |
| charly | 0:3f4cfbeda9d3 | 163 | : 1, |
| charly | 0:3f4cfbeda9d3 | 164 | sedn : 2; |
| charly | 0:3f4cfbeda9d3 | 165 | bool seimin : 1; |
| charly | 0:3f4cfbeda9d3 | 166 | int8_t sgt : 7, |
| charly | 0:3f4cfbeda9d3 | 167 | : 1; |
| charly | 0:3f4cfbeda9d3 | 168 | bool sfilt : 1; |
| charly | 0:3f4cfbeda9d3 | 169 | }; |
| charly | 0:3f4cfbeda9d3 | 170 | }; |
| charly | 0:3f4cfbeda9d3 | 171 | }; |
| charly | 0:3f4cfbeda9d3 | 172 | |
| charly | 0:3f4cfbeda9d3 | 173 | struct DCCTRL_t { |
| charly | 0:3f4cfbeda9d3 | 174 | constexpr static uint8_t address = 0x6E; |
| charly | 0:3f4cfbeda9d3 | 175 | union { |
| charly | 0:3f4cfbeda9d3 | 176 | uint32_t sr : 24; |
| charly | 0:3f4cfbeda9d3 | 177 | struct { |
| charly | 0:3f4cfbeda9d3 | 178 | uint16_t dc_time : 10, |
| charly | 0:3f4cfbeda9d3 | 179 | : 6; |
| charly | 0:3f4cfbeda9d3 | 180 | uint8_t dc_sg : 8; |
| charly | 0:3f4cfbeda9d3 | 181 | }; |
| charly | 0:3f4cfbeda9d3 | 182 | }; |
| charly | 0:3f4cfbeda9d3 | 183 | }; |
| charly | 0:3f4cfbeda9d3 | 184 | |
| charly | 0:3f4cfbeda9d3 | 185 | namespace TMC2130_n { |
| charly | 0:3f4cfbeda9d3 | 186 | struct DRV_STATUS_t { |
| charly | 0:3f4cfbeda9d3 | 187 | constexpr static uint8_t address = 0x6F; |
| charly | 0:3f4cfbeda9d3 | 188 | union { |
| charly | 0:3f4cfbeda9d3 | 189 | uint32_t sr; |
| charly | 0:3f4cfbeda9d3 | 190 | struct { |
| charly | 0:3f4cfbeda9d3 | 191 | uint16_t sg_result : 10; |
| charly | 0:3f4cfbeda9d3 | 192 | uint8_t : 5; |
| charly | 0:3f4cfbeda9d3 | 193 | bool fsactive : 1; |
| charly | 0:3f4cfbeda9d3 | 194 | uint8_t cs_actual : 5, |
| charly | 0:3f4cfbeda9d3 | 195 | : 3; |
| charly | 0:3f4cfbeda9d3 | 196 | bool stallGuard : 1, |
| charly | 0:3f4cfbeda9d3 | 197 | ot : 1, |
| charly | 0:3f4cfbeda9d3 | 198 | otpw : 1, |
| charly | 0:3f4cfbeda9d3 | 199 | s2ga : 1, |
| charly | 0:3f4cfbeda9d3 | 200 | s2gb : 1, |
| charly | 0:3f4cfbeda9d3 | 201 | ola : 1, |
| charly | 0:3f4cfbeda9d3 | 202 | olb : 1, |
| charly | 0:3f4cfbeda9d3 | 203 | stst : 1; |
| charly | 0:3f4cfbeda9d3 | 204 | }; |
| charly | 0:3f4cfbeda9d3 | 205 | }; |
| charly | 0:3f4cfbeda9d3 | 206 | }; |
| charly | 0:3f4cfbeda9d3 | 207 | } |
| charly | 0:3f4cfbeda9d3 | 208 | |
| charly | 0:3f4cfbeda9d3 | 209 | struct PWMCONF_t { |
| charly | 0:3f4cfbeda9d3 | 210 | constexpr static uint8_t address = 0x70; |
| charly | 0:3f4cfbeda9d3 | 211 | union { |
| charly | 0:3f4cfbeda9d3 | 212 | uint32_t sr : 22; |
| charly | 0:3f4cfbeda9d3 | 213 | struct { |
| charly | 0:3f4cfbeda9d3 | 214 | uint8_t pwm_ampl : 8, |
| charly | 0:3f4cfbeda9d3 | 215 | pwm_grad : 8, |
| charly | 0:3f4cfbeda9d3 | 216 | pwm_freq : 2; |
| charly | 0:3f4cfbeda9d3 | 217 | bool pwm_autoscale : 1, |
| charly | 0:3f4cfbeda9d3 | 218 | pwm_symmetric : 1; |
| charly | 0:3f4cfbeda9d3 | 219 | uint8_t freewheel : 2; |
| charly | 0:3f4cfbeda9d3 | 220 | }; |
| charly | 0:3f4cfbeda9d3 | 221 | }; |
| charly | 0:3f4cfbeda9d3 | 222 | }; |
| charly | 0:3f4cfbeda9d3 | 223 | |
| charly | 0:3f4cfbeda9d3 | 224 | struct ENCM_CTRL_t { |
| charly | 0:3f4cfbeda9d3 | 225 | constexpr static uint8_t address = 0x72; |
| charly | 0:3f4cfbeda9d3 | 226 | union { |
| charly | 0:3f4cfbeda9d3 | 227 | uint8_t sr : 2; |
| charly | 0:3f4cfbeda9d3 | 228 | struct { |
| charly | 0:3f4cfbeda9d3 | 229 | bool inv : 1, |
| charly | 0:3f4cfbeda9d3 | 230 | maxspeed : 1; |
| charly | 0:3f4cfbeda9d3 | 231 | }; |
| charly | 0:3f4cfbeda9d3 | 232 | }; |
| charly | 0:3f4cfbeda9d3 | 233 | }; |
| charly | 0:3f4cfbeda9d3 | 234 | |
| charly | 0:3f4cfbeda9d3 | 235 | #pragma pack(pop) |