Atmel Software Framework

qdec.c File Reference

AVR XMEGA Quadrature Decoder Driver file.

Copyright (C) 2014-2015 Atmel Corporation. All rights reserved.

#include "sysclk.h"
#include "qdec.h"
#include "tc.h"

Macros

#define EVSYS_PRESCFILT_CH04_gc   (1<<4)
 
#define EVSYS_PRESCFILT_CH15_gc   (2<<4)
 
#define EVSYS_PRESCFILT_CH26_gc   (4<<4)
 
#define EVSYS_PRESCFILT_CH37_gc   (8<<4)
 
#define QDEC_PIN_INDEX_MASK   (1 << 2)
 
#define QDEC_PIN_PH0_MASK   (1 << 0)
 
#define QDEC_PIN_PH90_MASK   (1 << 1)
 
#define QDEC_PIN_PHASES_MASK   (QDEC_PIN_PH0_MASK | QDEC_PIN_PH90_MASK)
 
#define TC_EVACT_FRQ_gc   (0x05<<5) /* Frequency Capture */
 

Functions

void qdec_config_disable_index_pin (qdec_config_t *config)
 Disables index line. More...
 
void qdec_config_enable_freq (qdec_config_t *config, uint32_t unit)
 Defines frequency option. More...
 
void qdec_config_enable_index_pin (qdec_config_t *config, bool pin_invert, enum QDec_index_rec_state state)
 Defines index line to enable the automaticaly position reset. More...
 
void qdec_config_event_channel (qdec_config_t *config, uint8_t event_channel)
 Selects the event channel to use for quadrature decoder. More...
 
void qdec_config_freq_event_channel (qdec_config_t *config, uint8_t event_channel)
 Selects the event channel to use for frequency quadrature decoder. More...
 
void qdec_config_freq_tc (qdec_config_t *config, volatile void *timer)
 Selects the event channel to use for frequency quadrature decoder. More...
 
void qdec_config_phase_pins (qdec_config_t *config, PORT_t *port, uint8_t pin_base, bool pins_invert, uint16_t filter_us)
 This function set up the needed configuration to the port, used for the quadrature decoding. More...
 
void qdec_config_revolution (qdec_config_t *config, uint16_t revolution)
 Defines the revolution of quadrature decoder. More...
 
void qdec_config_tc (qdec_config_t *config, volatile void *timer)
 Selects the event channel to use for quadrature decoder. More...
 
void qdec_enabled (qdec_config_t *config)
 Loads and enables QDec system. More...
 
static void qdec_enabled_evsys (qdec_config_t *config)
 
static void qdec_enabled_pins (qdec_config_t *config)
 
static void qdec_enabled_tc (qdec_config_t *config)
 
static void qdec_enabled_tc_freq (qdec_config_t *config)
 
static void qdec_evsys_pin_2_chmux (PORT_t *port, uint8_t pins_base, uint8_t event_channel)
 
void qdec_get_config_defaults (qdec_config_t *config)
 This function initializes the configuration structure with the identified as commonly use case. More...
 
bool qdec_get_direction (qdec_config_t *config)
 Returns the direction of the quadrature decoding counter. More...
 
uint16_t qdec_get_frequency (qdec_config_t *config)
 Returns the frequency of quadrature encoder. More...
 
uint16_t qdec_get_position (qdec_config_t *config)
 Returns the position of quadrature encoder. More...
 
void qdec_reset_position (qdec_config_t *config)
 Returns the position of quadrature encoder. More...
 

#define EVSYS_PRESCFILT_CH04_gc   (1<<4)
#define EVSYS_PRESCFILT_CH15_gc   (2<<4)
#define EVSYS_PRESCFILT_CH26_gc   (4<<4)

Referenced by qdec_enabled_tc_freq().

#define EVSYS_PRESCFILT_CH37_gc   (8<<4)

Referenced by qdec_enabled_tc_freq().

#define QDEC_PIN_INDEX_MASK   (1 << 2)

Referenced by qdec_enabled_pins().

#define QDEC_PIN_PH0_MASK   (1 << 0)
#define QDEC_PIN_PH90_MASK   (1 << 1)
#define QDEC_PIN_PHASES_MASK   (QDEC_PIN_PH0_MASK | QDEC_PIN_PH90_MASK)

Referenced by qdec_enabled_pins().

#define TC_EVACT_FRQ_gc   (0x05<<5) /* Frequency Capture */

static void qdec_evsys_pin_2_chmux ( PORT_t *  port,
uint8_t  pins_base,
uint8_t  event_channel 
)
static