void Encoder::setRange(unsigned long val, bool condition) { if(mode == MODE_NOSET || mode == MODE_CAPTURE || mode == MODE_SSI) return; if(val == 0L) return; mcsif_Disable(mcn, mdn); if(condition == true) { mcenc_SetCapMode(mcn, mdn, MCENC_CAP_PCNT_DISABLE + MCENC_CAP_EXTRIG_DISABLE + MCENC_CAP_IDXCOND_ENABLE); // start to use FIFO (mean that capture event will occur) io_DisableINT(); _encmode[mcn] |= INTR_OVERFLOW; _encmode[mcn] |= INTR_UNDERFLOW; io_RestoreINT(); } else { if((_encmode[mcn] & (INTR_INDEX | INTR_OVERFLOW | INTR_UNDERFLOW)) == 0 && condition == false) mcenc_SetCapMode(mcn, mdn, MCENC_CAP_PCNT_DISABLE + MCENC_CAP_EXTRIG_DISABLE + MCENC_CAP_IDXCOND_DISABLE); io_DisableINT(); _encmode[mcn] &= ~(INTR_OVERFLOW); _encmode[mcn] &= ~(INTR_UNDERFLOW); io_RestoreINT(); } mcenc_SetCntMax(mcn, mdn, val); mcsif_Enable(mcn, mdn); }
static void _defaultEncoderSetting(int mc, int md) { mcenc_SetIdxCond(mc, md, MCENC_PDIR_IDXCOND_DISABLE, 0L); mcenc_SetCapMode(mc, md, MCENC_CAP_PCNT_DISABLE + MCENC_CAP_EXTRIG_DISABLE + MCENC_CAP_IDXCOND_DISABLE); mcenc_SetCntMin(mc, md, 0L); mcenc_SetCntMax(mc, md, 0xffffffffL); mcenc_SetResetMode(mc, md, MCENC_RESET_INC_CNTMIN + MCENC_RESET_DEC_CNTMAX); mcenc_SetTrigResetMode(mc, md, MCENC_TRIGRESET_IDXCOND_0TO1); mcenc_SetPulCnt(mc, md, 0L); }