@@ -302,7 +302,7 @@ bool TMC4671::initialize(){
302302// }
303303 // Check if a TMC4671 is active and replies correctly
304304 if (!pingDriver ()){
305- ErrorHandler::addError (communicationError );
305+ ErrorHandler::addError (COMMUNICATION_ERROR );
306306 return false ;
307307 }
308308
@@ -345,7 +345,7 @@ bool TMC4671::initialize(){
345345 setAdcOffset (conf.adc_I0_offset , conf.adc_I1_offset );
346346 setAdcScale (conf.adc_I0_scale , conf.adc_I1_scale );
347347 setTorqueFilter (torqueFilterConf);
348- setBiquadFlux (TMC4671Biquad (Biquad (BiquadType::lowpass, fluxFilterFreq / getPwmFreq (), 0.7 ,0.0 ), true )); // Create flux filter
348+ setBiquadFlux (TMC4671Biquad (Biquad (BiquadType::lowpass, FLUX_FILTER_FREQ / getPwmFreq (), 0.7 ,0.0 ), true )); // Create flux filter
349349
350350 // Initial adc calibration and check without PWM if power off to get basic offsets. PWM is off!
351351 if (!hasPower ()){
@@ -542,7 +542,7 @@ void TMC4671::Run(){
542542 bool tmc_en = ((pins >> 15 ) & 0x01 ) && pins != 0xffffffff ;
543543 if (tmc_en){
544544 // Emergency stop reset
545- ErrorHandler::clearError (estopError );
545+ ErrorHandler::clearError (ESTOP_ERROR );
546546 this ->estopTriggered = false ; // TODO resume correctly
547547 changeState (TMC_ControlState::uninitialized,true );
548548 }
@@ -625,7 +625,7 @@ void TMC4671::Run(){
625625 if (!hasPower () && state != TMC_ControlState::waitPower && initialized && powerInitialized){ // low voltage or overvoltage
626626
627627 requestedState = state;
628- ErrorHandler::addError (lowVoltageError );
628+ ErrorHandler::addError (LOW_VOLTAGE_ERROR );
629629 setMotionMode (MotionMode::stop,true ); // Disable tmc
630630 changeState (TMC_ControlState::waitPower,true );
631631 allowStateChange = false ;
@@ -753,7 +753,7 @@ bool TMC4671::findEncoderIndex(int32_t speed, uint16_t power,bool offsetPhiM,boo
753753 runOpenLoop (0 , 0 , 0 , 10 , true );
754754 if (!encoderIndexHitFlag){
755755 pulseErrLed ();
756- ErrorHandler::addError (indexNotHitError );
756+ ErrorHandler::addError (INDEX_NOT_HIT_ERROR );
757757 }
758758
759759 // If zero count on index write a phiM offset so that phiM is 0 on index and we don't need to change the raw encoder count (possible timing danger)
@@ -1368,7 +1368,7 @@ void TMC4671::encoderInit(){
13681368
13691369 // Check encoder
13701370 if (!checkEncoder ()){
1371- if (++enc_retry > enc_retry_max ){
1371+ if (++enc_retry > ENC_RETRY_MAX ){
13721372 encoderAligned = false ;
13731373 Error err = Error (ErrorCode::encoderAlignmentFailed,ErrorType::critical," Encoder alignment failed" );
13741374 ErrorHandler::addError (err);
@@ -1613,7 +1613,7 @@ void TMC4671::emergencyStop(bool reset){
16131613int16_t TMC4671::controlFluxDissipate (){
16141614
16151615 int32_t vDiff = getIntV () - getExtV ();
1616- if (vDiff > fluxDissipationLimit ){
1616+ if (vDiff > FLUX_DISSIPATION_LIMIT ){
16171617 // Reaches limit at +5v if scaler is 1
16181618 return (clip<int32_t ,int32_t >(vDiff * conf.hwconf .fluxDissipationScaler * curLimits.pid_torque_flux * 0.0002 ,0 ,curLimits.pid_torque_flux ));
16191619 }
@@ -3236,7 +3236,7 @@ void TMC4671::handleStateRunning() {
32363236 if (!tmc_en && motorEnabledRequested) { // Hardware emergency.
32373237 this ->estopTriggered = true ;
32383238 this ->emergencyStop (false );
3239- ErrorHandler::addError (estopError );
3239+ ErrorHandler::addError (ESTOP_ERROR );
32403240 }
32413241
32423242 // Temperature sense
0 commit comments