![]() |
AVR1600 Using the XMEGA Quadrature Decoder
|
The XMEGA Quadrature Decoder driver source file. More...
#include "qdec_driver.h"
Go to the source code of this file.
Functions | |
| 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. More... | |
| uint8_t | QDEC_Get_Direction (TC0_t *qTimer) |
| This function return the direction of the counter/QDEC. More... | |
| 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. More... | |
| 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 from the event system. More... | |
| 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 measurement from the event system. More... | |
| 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. More... | |
The XMEGA Quadrature Decoder driver source file.
This file contains the function prototypes and enumerator definitions for various configuration parameters for the XMEGA Quadrature Decoder.
The driver is not intended for size and/or speed critical code. The driver is intended for rapid prototyping and documentation purposes for getting started with the XMEGA Quadrature Decoder.
For size and/or speed critical code, it is recommended to copy the function contents directly into your application instead of making a function call.
Several functions use the following construct: "some_register = ... | (some_parameter ? SOME_BIT_bm : 0) | ..." Although the use of the ternary operator ( if ? then : else ) is discouraged, in some occasions the operator makes it possible to write pretty clean and neat code. In this driver, the construct is used to set or not set a configuration bit based on a boolean input parameter, such as the "some_parameter" in the example above.
Copyright (c) 2012, Atmel Corporation All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Definition in file qdec_driver.c.
| 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.
| qEvMux | Which event channel to use. Only 0, 2 and 4 is available. |
| qPinInput | The pin input of QDPH0 to the EVSYS.CHMUX . |
| useIndex | True if an optional Index pin is used. |
| qIndexState | In which state the index signal will trigger. |
Definition at line 158 of file qdec_driver.c.
Referenced by QDEC_Total_Setup().
| uint8_t QDEC_Get_Direction | ( | TC0_t * | qTimer | ) |
This function return the direction of the counter/QDEC.
| qTimer | The timer used for QDEC. |
| CW_DIR | if clockwise/up counting, |
| CCW_DIR | if counter clockwise/down counting. |
Definition at line 255 of file qdec_driver.c.
References CCW_DIR, and CW_DIR.
| 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.
| qPort | The port to use. |
| qPin | The first input pin (QDPH0) to use (0 - 5/6). |
| useIndex | True if an optional Index pin is used. |
| invIO | True if IO pins should be inverted. |
Definition at line 118 of file qdec_driver.c.
Referenced by QDEC_Total_Setup().
| 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 from the event system.
| qTimer | The timer to use for QDEC. |
| qEventChannel | The event channel to listen to. |
| lineCount | The number of lines in the quadrature encoder. |
Definition at line 210 of file qdec_driver.c.
Referenced by QDEC_Total_Setup().
| 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 measurement from the event system.
| qTimer | The timer to use for QDEC. |
| qEventChannel | The event channel to listen to. |
| qPinInput | The pin input of QDPH0 to the EVSYS.CHMUX. |
| clksel | The clk div to use for timer. |
Definition at line 231 of file qdec_driver.c.
Referenced by main().
| 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.
This function combines the following functions for a total setup: QDEC_Port_Setup, QDEC_EVSYS_Setup and QDEC_TC_Dec_Setup.
| qPort | The port to use. |
| qPin | The first input pin (QDPH0) to use (0 - 5/6). |
| invIO | True if IO pins should be inverted. |
| qEvMux | Which event channel to use. Only 0, 2 and 4 is available. |
| qPinInput | The pin input of QDPH0 to the EVSYS.CHMUX . |
| useIndex | True if an optional Index pin is used. |
| qIndexState | In which state the index signal will trigger. |
| qTimer | The timer to use for QDEC. |
| qEventChannel | The event channel to listen to. |
| lineCount | The number of lines in the quadrature encoder. |
Definition at line 87 of file qdec_driver.c.
References QDEC_EVSYS_Setup(), QDEC_Port_Setup(), and QDEC_TC_Dec_Setup().
Referenced by main().

Generated on Thu Oct 26 2017 13:33:37 for AVR1600 Using the XMEGA Quadrature Decoder by 1.8.13
|