91 EVSYS_CHMUX_t qPinInput,
93 EVSYS_QDIRM_t qIndexState,
95 TC_EVSEL_t qEventChannel,
125 qPort->DIRCLR = (0x07<<qPin);
128 PORTCFG.MPCMASK = (0x04<<qPin);
129 qPort->PIN0CTRL = (qPort->PIN0CTRL & ~PORT_ISC_gm) | PORT_ISC_BOTHEDGES_gc
130 | (invIO ? PORT_INVEN_bm : 0);
137 qPort->DIRCLR = (0x03<<qPin);
141 PORTCFG.MPCMASK = (0x03<<qPin);
142 qPort->PIN0CTRL = (qPort->PIN0CTRL & ~PORT_ISC_gm) | PORT_ISC_LEVEL_gc
143 | (invIO ? PORT_INVEN_bm : 0);
159 EVSYS_CHMUX_t qPinInput,
161 EVSYS_QDIRM_t qIndexState )
167 EVSYS.CH0MUX = qPinInput;
168 EVSYS.CH0CTRL = EVSYS_QDEN_bm | EVSYS_DIGFILT_2SAMPLES_gc;
173 EVSYS.CH1MUX = qPinInput + 2;
174 EVSYS.CH1CTRL = EVSYS_DIGFILT_2SAMPLES_gc;
175 EVSYS.CH0CTRL |= (uint8_t) qIndexState | EVSYS_QDIEN_bm;
180 EVSYS.CH2MUX = qPinInput;
181 EVSYS.CH2CTRL = EVSYS_QDEN_bm | EVSYS_DIGFILT_2SAMPLES_gc;
183 EVSYS.CH3MUX = qPinInput + 2;
184 EVSYS.CH3CTRL = EVSYS_DIGFILT_2SAMPLES_gc;
185 EVSYS.CH2CTRL |= (uint8_t) qIndexState | EVSYS_QDIEN_bm;
189 EVSYS.CH4MUX = qPinInput;
190 EVSYS.CH4CTRL = EVSYS_QDEN_bm | EVSYS_DIGFILT_2SAMPLES_gc;
192 EVSYS.CH5MUX = qPinInput + 2;
193 EVSYS.CH5CTRL = EVSYS_DIGFILT_2SAMPLES_gc;
194 EVSYS.CH4CTRL |= (uint8_t) qIndexState | EVSYS_QDIEN_bm;
213 qTimer->CTRLD = (uint8_t) TC_EVACT_QDEC_gc | qEventChannel;
214 qTimer->PER = (lineCount * 4) - 1;
215 qTimer->CTRLA = TC_CLKSEL_DIV1_gc;
232 TC_EVSEL_t qEventChannel,
233 EVSYS_CHMUX_t qPinInput,
237 EVSYS.CH2MUX = qPinInput;
238 EVSYS.CH2CTRL = EVSYS_DIGFILT_4SAMPLES_gc;
241 qTimer->CTRLD = (uint8_t) TC_EVACT_FRQ_gc | qEventChannel;
242 qTimer->PER = 0xFFFF;
243 qTimer->CTRLB = TC0_CCAEN_bm;
244 qTimer->CTRLA = clksel;
257 if (qTimer->CTRLFSET & TC0_DIR_bm){
bool QDEC_EVSYS_Setup(uint8_t qEvMux, EVSYS_CHMUX_t qPinInput, bool useIndex, EVSYS_QDIRM_t qIndexState)
This function configure the event system for quadrature decoding.
uint8_t QDEC_Get_Direction(TC0_t *qTimer)
This function return the direction of the counter/QDEC.
bool QDEC_Port_Setup(PORT_t *qPort, uint8_t qPin, bool useIndex, bool invIO)
This function set up the needed configuration for the port used for the quadrature decoding...
The XMEGA Quadrature Decoder driver header file.
bool QDEC_Total_Setup(PORT_t *qPort, uint8_t qPin, bool invIO, uint8_t qEvMux, EVSYS_CHMUX_t qPinInput, bool useIndex, EVSYS_QDIRM_t qIndexState, TC0_t *qTimer, TC_EVSEL_t qEventChannel, uint8_t lineCount)
Wrapperfunction to set up all parameters for the quadrature decoder.
uint8_t lineCount
Number of lines in the quadrature encoder.
void QDEC_TC_Dec_Setup(TC0_t *qTimer, TC_EVSEL_t qEventChannel, uint8_t lineCount)
This function set up the needed configuration for the Timer/Counter to handle the quadrature decoding...
void QDEC_TC_Freq_Setup(TC0_t *qTimer, TC_EVSEL_t qEventChannel, EVSYS_CHMUX_t qPinInput, TC_CLKSEL_t clksel)
This function set up the needed configuration for a Timer/Counter to handle the frequency/speed measu...