Firmware/FFBoard/UserExtensions/Src/TMC4671.cpp
/*
 * Changes the encoder type and calls init methods for the encoder types.
 * Setup the specific parameters (abnconf, aencconf...) first.
 */
Changes the encoder type and calls init methods for the encoder types.
Setup the specific parameters (abnconf, aencconf...) first.
Changes the encoder type and calls init methods for the encoder types . Setup the specific parameters ( abnconf aencconf ... ) first .
void TMC4671::setEncoderType(EncoderType_TMC type){
	this->conf.motconf.enctype = type;
	if(type == EncoderType_TMC::abn){
		if(this->abnconf.cpr == 0){
			return;
		}
		changeState(TMC_ControlState::ABN_init);
		encstate = ENC_InitState::uninitialized;
	}else if(type == EncoderType_TMC::sincos){
		changeState(TMC_ControlState::AENC_init);
		encstate = ENC_InitState::uninitialized;
		this->aencconf.uvwmode = false; 
	}else if(type == EncoderType_TMC::uvw){
		changeState(TMC_ControlState::AENC_init);
		encstate = ENC_InitState::uninitialized;
		this->aencconf.uvwmode = true; 
	}else if(type == EncoderType_TMC::hall){ 
		changeState(TMC_ControlState::Running);
		setPosSel(PosSelection::PhiM_hal);
		encstate = ENC_InitState::OK;
		setPhiEtype(PhiE::hall);
	}
}
void TMC4671 :: setEncoderType ( EncoderType_TMC type ) { this -> conf . motconf . enctype = type ; if ( type == EncoderType_TMC :: abn ) { if ( this -> abnconf . cpr == 0 ) { return ; } changeState ( TMC_ControlState :: ABN_init ) ; encstate = ENC_InitState :: uninitialized ; } else if ( type == EncoderType_TMC :: sincos ) { changeState ( TMC_ControlState :: AENC_init ) ; encstate = ENC_InitState :: uninitialized ; this -> aencconf . uvwmode = false ; } else if ( type == EncoderType_TMC :: uvw ) { changeState ( TMC_ControlState :: AENC_init ) ; encstate = ENC_InitState :: uninitialized ; this -> aencconf . uvwmode = true ; } else if ( type == EncoderType_TMC :: hall ) { changeState ( TMC_ControlState :: Running ) ; setPosSel ( PosSelection :: PhiM_hal ) ; encstate = ENC_InitState :: OK ; setPhiEtype ( PhiE :: hall ) ; } }
Changes the encoder type and calls init methods for the encoder types.
Changes the encoder type and calls init methods for the encoder types .
// Not initialized if cpr not set // SinCos encoder // sincos mode // Analog UVW encoder // uvw mode // Hall sensor. Just trust it