Exemplo n.º 1
0
void Encoder::begin(int sifmode, unsigned long bits, unsigned long clk, unsigned long wtime, bool gray2bin) {
#if defined (DMP_LINUX)
	lockMCMSIF();
	if(mode != MODE_NOSET) {unLockMCMSIF(); return;}
#else
	if(mode != MODE_NOSET) return;
#endif

	OSSPININIT(encvar);

	mode = sifmode;
	if(mode == MODE_CWCCW)            _cwccwInit(1);
	else if(mode == MODE_AB_PHASE)    _pabInit(1);
	else if(mode == MODE_STEP_DIR_x2) _pdirInit(2);
	else if(mode == MODE_CWCCW_x2)    _cwccwInit(2);
	else if(mode == MODE_AB_PHASE_x2) _pabInit(2);
	else if(mode == MODE_CAPTURE)     _pcapInit();
	else if(mode == MODE_SSI)         _ssiInit(bits, clk, wtime, gray2bin);
	else 
	{
		mode = MODE_STEP_DIR;
		_pdirInit(1);
	}
	
	open_mcm_crossbar(mcn);
	open_encoder_pin(mcn, 0);
	open_encoder_pin(mcn, 1);
	open_encoder_pin(mcn, 2);
	
	mcsif_Enable(mcn, mdn);

#if defined (DMP_LINUX)
	unLockMCMSIF();
#endif
}
Exemplo n.º 2
0
void Encoder::begin(int sifmode, unsigned long bits, unsigned long clk, unsigned long wtime, bool gray2bin) {
	if(mode != MODE_NOSET) return;
	
	mode = sifmode;
	if(mode == MODE_CWCCW)            _cwccwInit(1);
	else if(mode == MODE_AB_PHASE)    _pabInit(1);
	else if(mode == MODE_STEP_DIR_x2) _pdirInit(2);
	else if(mode == MODE_CWCCW_x2)    _cwccwInit(2);
	else if(mode == MODE_AB_PHASE_x2) _pabInit(2);
	else if(mode == MODE_CAPTURE)     _pcapInit();
	else if(mode == MODE_SSI)         _ssiInit(bits, clk, wtime, gray2bin);
	else 
	{
		mode = MODE_STEP_DIR;
		_pdirInit(1);
	}
	
	open_mcm_crossbar(mcn);
	open_encoder_pin(mcn, 0);
	open_encoder_pin(mcn, 1);
	open_encoder_pin(mcn, 2);
	
	mcsif_Enable(mcn, mdn);
}