tmc2130: pull TMC2130_CNSTOFF_E outside tmc2130_setup_chopper

We can probably improve tmc2130_chopper_config further by adding
a constructor.

No change in memory
This commit is contained in:
Guðni Már Gilbert 2023-07-21 16:25:50 +00:00 committed by DRracer
parent 664d4e2bbe
commit a87faba2bd
2 changed files with 40 additions and 13 deletions

View File

@ -143,11 +143,45 @@ uint8_t tmc2130_home_fsteps[2] = {48, 48};
uint8_t tmc2130_wave_fac[4] = {0, 0, 0, 0}; uint8_t tmc2130_wave_fac[4] = {0, 0, 0, 0};
tmc2130_chopper_config_t tmc2130_chopper_config[4] = { tmc2130_chopper_config_t tmc2130_chopper_config[NUM_AXIS] = {
{TMC2130_TOFF_XYZ, 5, 1, 2, 0}, { // X axis
{TMC2130_TOFF_XYZ, 5, 1, 2, 0}, .toff = TMC2130_TOFF_XYZ,
{TMC2130_TOFF_XYZ, 5, 1, 2, 0}, .hstr = 5,
{TMC2130_TOFF_E, 5, 1, 2, 0} .hend = 1,
.tbl = 2,
.res = 0
},
{ // Y axis
.toff = TMC2130_TOFF_XYZ,
.hstr = 5,
.hend = 1,
.tbl = 2,
.res = 0
},
{ // Z axis
.toff = TMC2130_TOFF_XYZ,
.hstr = 5,
.hend = 1,
.tbl = 2,
.res = 0
},
#ifdef TMC2130_CNSTOFF_E
{ // E axis
.toff = TMC2130_TOFF_E,
.hstr = 0,
.hend = 0,
.tbl = 2,
.res = 0
}
#else // !TMC2130_CNSTOFF_E
{ // E axis
.toff = TMC2130_TOFF_E,
.hstr = 5,
.hend = 1,
.tbl = 2,
.res = 0
}
#endif
}; };
bool tmc2130_sg_stop_on_crash = true; bool tmc2130_sg_stop_on_crash = true;
@ -500,13 +534,6 @@ void tmc2130_setup_chopper(uint8_t axis, uint8_t mres, uint8_t current_h, uint8_
chopconf.s.hend = tmc2130_chopper_config[axis].hend; // original value = 1 chopconf.s.hend = tmc2130_chopper_config[axis].hend; // original value = 1
chopconf.s.tbl = tmc2130_chopper_config[axis].tbl; //blanking time, original value = 2 chopconf.s.tbl = tmc2130_chopper_config[axis].tbl; //blanking time, original value = 2
#ifdef TMC2130_CNSTOFF_E
if (axis == E_AXIS) {
chopconf.s.hstrt = 0; // fd0..2
chopconf.s.hend = 0; // sine wave offset
}
#endif //TMC2130_CNSTOFF_E
tmc2130_wr_CHOPCONF(axis, chopconf.dw); tmc2130_wr_CHOPCONF(axis, chopconf.dw);
tmc2130_wr(axis, TMC2130_REG_IHOLD_IRUN, 0x000f0000 | ((current_r & 0x1f) << 8) | (current_h & 0x1f)); tmc2130_wr(axis, TMC2130_REG_IHOLD_IRUN, 0x000f0000 | ((current_r & 0x1f) << 8) | (current_h & 0x1f));
} }

View File

@ -58,7 +58,7 @@ typedef struct
} tmc2130_chopper_config_t; } tmc2130_chopper_config_t;
#pragma pack(pop) #pragma pack(pop)
extern tmc2130_chopper_config_t tmc2130_chopper_config[4]; extern tmc2130_chopper_config_t tmc2130_chopper_config[NUM_AXIS];
//initialize tmc2130 //initialize tmc2130