Driver for the QDEC (Quadrature Decoder).
The QDEC handles three input channels: two phase signals (QEPA, QEPB) and one index pulse (QEPI). It has a 16-bit position counter and a 16-bit revolution counter and supports 32-bit timer/counter mode.
Modules | |
Related Project(s) | |
In this section you can find all the projects related to the QDEC - Quadrature Decoder. | |
Data Structures | |
struct | qdec_interrupt_t |
QDEC interrupts. More... | |
struct | qdec_quadrature_decoder_opt_t |
Parameters when initializing a QDEC in Quadrature Decoder mode. More... | |
struct | qdec_timer_opt_t |
Parameters when initializing a QDEC in Counter mode. More... | |
Macros | |
#define | QDEC_INVALID_ARGUMENT (-1) |
QDEC driver functions return value in case of invalid argument(s). More... | |
#define | QDEC_QDEC_MODE 1 |
QDEC Mode Selection. More... | |
#define | QDEC_TIMER_MODE 0 |
TIMER Mode Selection. More... | |
#define | QDEC_TSIR_DOWN 1 |
Direction Down In TIMER Mode. More... | |
#define | QDEC_TSIR_UP 0 |
Direction Up In TIMER Mode. More... | |
#define | QDEC_UPD_EVNT 1 |
EVENT Changes Input In TIMER Mode. More... | |
#define | QDEC_UPD_TSDIR 0 |
TSDIR Changes Input In TIMER Mode. More... | |
Functions | |
int | qdec_configure_interrupts (volatile avr32_qdec_t *qdec, const qdec_interrupt_t *bitfield) |
Enables various QDEC interrupts. More... | |
int | qdec_get_interrupt_settings (volatile avr32_qdec_t *qdec) |
Get the QDEC current interrupt settings. More... | |
int | qdec_init_quadrature_decoder_mode (volatile avr32_qdec_t *qdec, const qdec_quadrature_decoder_opt_t *opt) |
Sets options for QDEC quadrature decoder initialization. More... | |
int | qdec_init_timer_mode (volatile avr32_qdec_t *qdec, const qdec_timer_opt_t *opt) |
Sets options for QDEC Timer mode initialization. More... | |
unsigned short int | qdec_read_pc (volatile avr32_qdec_t *qdec) |
Read value of the channel's QDEC Position Current Counter register. More... | |
unsigned short int | qdec_read_pc_cap (volatile avr32_qdec_t *qdec) |
Read value of the channel's QDEC Position Capture Counter register. More... | |
unsigned short int | qdec_read_rc (volatile avr32_qdec_t *qdec) |
Read value of the channel's QDEC Revolution Current Counter register. More... | |
unsigned short int | qdec_read_rc_cap (volatile avr32_qdec_t *qdec) |
Read value of the channel's QDEC Revolution Capture register. More... | |
int | qdec_software_trigger (volatile avr32_qdec_t *qdec) |
Software Trigger Condition to start QDEC service. More... | |
int | qdec_stop (volatile avr32_qdec_t *qdec) |
Stops a QDEC. More... | |
unsigned short int | qdec_write_pc_cmp (volatile avr32_qdec_t *qdec, unsigned short int value) |
Writes a value to the channel's QDEC Position Counter Compare register. More... | |
unsigned short int | qdec_write_pc_cnt (volatile avr32_qdec_t *qdec, unsigned short int value) |
Write value of the channel's QDEC Position Current Counter register. More... | |
unsigned short int | qdec_write_pc_top (volatile avr32_qdec_t *qdec, unsigned short int value) |
Writes a value to the channel's QDEC Position Counter Top register. More... | |
unsigned short int | qdec_write_rc_cmp (volatile avr32_qdec_t *qdec, unsigned short int value) |
Writes a value to the channel's QDEC Revolution Counter Compare register. More... | |
unsigned short int | qdec_write_rc_cnt (volatile avr32_qdec_t *qdec, unsigned short int value) |
Write value of the channel's QDEC Revolution Current Counter register. More... | |
unsigned short int | qdec_write_rc_top (volatile avr32_qdec_t *qdec, unsigned short int value) |
Writes a value to the channel's QDEC Revolution Counter Top register. More... | |
QDEC Index Phase Detection | |
#define | QDEC_IDXPHS_QEPB_0_QEPA_0 |
#define | QDEC_IDXPHS_QEPB_0_QEPA_1 |
#define | QDEC_IDXPHS_QEPB_1_QEPA_0 |
#define | QDEC_IDXPHS_QEPB_1_QEPA_1 |
#define QDEC_IDXPHS_QEPB_0_QEPA_0 |
#define QDEC_IDXPHS_QEPB_0_QEPA_1 |
#define QDEC_IDXPHS_QEPB_1_QEPA_0 |
#define QDEC_IDXPHS_QEPB_1_QEPA_1 |
#define QDEC_INVALID_ARGUMENT (-1) |
QDEC driver functions return value in case of invalid argument(s).
#define QDEC_QDEC_MODE 1 |
QDEC Mode Selection.
#define QDEC_TIMER_MODE 0 |
TIMER Mode Selection.
#define QDEC_TSIR_DOWN 1 |
Direction Down In TIMER Mode.
Referenced by main().
#define QDEC_TSIR_UP 0 |
Direction Up In TIMER Mode.
#define QDEC_UPD_EVNT 1 |
EVENT Changes Input In TIMER Mode.
#define QDEC_UPD_TSDIR 0 |
TSDIR Changes Input In TIMER Mode.
int qdec_configure_interrupts | ( | volatile avr32_qdec_t * | qdec, |
const qdec_interrupt_t * | bitfield | ||
) |
Enables various QDEC interrupts.
qdec | Pointer to the QDEC instance to access. |
bitfield | The interrupt enable configuration. |
0 | Success. |
References AVR32_ENTER_CRITICAL_REGION, AVR32_LEAVE_CRITICAL_REGION, qdec_interrupt_t::cap, qdec_interrupt_t::cmp, qdec_interrupt_t::dirinv, qdec_interrupt_t::idexerr, qdec_interrupt_t::ovr, qdec_interrupt_t::pcro, qdec_interrupt_t::qepi, and qdec_interrupt_t::rcro.
Referenced by main().
int qdec_get_interrupt_settings | ( | volatile avr32_qdec_t * | qdec | ) |
Get the QDEC current interrupt settings.
qdec | Pointer to the QDEC instance to access. |
>=0 | The interrupt enable configuration organized according to qdec_interrupt_t. |
Interrupt | Settings Value. |
int qdec_init_quadrature_decoder_mode | ( | volatile avr32_qdec_t * | qdec, |
const qdec_quadrature_decoder_opt_t * | opt | ||
) |
Sets options for QDEC quadrature decoder initialization.
qdec | Pointer to the QDEC instance to access. |
opt | Options for quadrature decoder mode. |
0 | Success. |
References qdec_quadrature_decoder_opt_t::evtrge, qdec_quadrature_decoder_opt_t::filten, qdec_quadrature_decoder_opt_t::idxe, qdec_quadrature_decoder_opt_t::idxinv, qdec_quadrature_decoder_opt_t::idxphs, qdec_quadrature_decoder_opt_t::pcce, qdec_quadrature_decoder_opt_t::phsinva, qdec_quadrature_decoder_opt_t::phsinvb, and qdec_quadrature_decoder_opt_t::rcce.
int qdec_init_timer_mode | ( | volatile avr32_qdec_t * | qdec, |
const qdec_timer_opt_t * | opt | ||
) |
Sets options for QDEC Timer mode initialization.
qdec | Pointer to the QDEC instance to access. |
opt | Options for quadrature decoder mode. |
0 | Success. |
References qdec_timer_opt_t::evtrge, qdec_timer_opt_t::filten, qdec_timer_opt_t::pcce, qdec_timer_opt_t::rcce, qdec_timer_opt_t::tsdir, and qdec_timer_opt_t::upd.
Referenced by main().
unsigned short int qdec_read_pc | ( | volatile avr32_qdec_t * | qdec | ) |
Read value of the channel's QDEC Position Current Counter register.
qdec | Pointer to the QDEC instance to access. |
>=0 | Status register value. |
unsigned short int qdec_read_pc_cap | ( | volatile avr32_qdec_t * | qdec | ) |
Read value of the channel's QDEC Position Capture Counter register.
qdec | Pointer to the QDEC instance to access. |
>=0 | Status register value. |
QDEC_INVALID_ARGUMENT | Invalid argument(s). |
unsigned short int qdec_read_rc | ( | volatile avr32_qdec_t * | qdec | ) |
Read value of the channel's QDEC Revolution Current Counter register.
qdec | Pointer to the QDEC instance to access. |
>=0 | Status register value. |
unsigned short int qdec_read_rc_cap | ( | volatile avr32_qdec_t * | qdec | ) |
Read value of the channel's QDEC Revolution Capture register.
qdec | Pointer to the QDEC instance to access. |
>=0 | Status register value. |
QDEC_INVALID_ARGUMENT | Invalid argument(s). |
int qdec_software_trigger | ( | volatile avr32_qdec_t * | qdec | ) |
Software Trigger Condition to start QDEC service.
qdec | Pointer to the QDEC instance to access. |
0 | Success. |
Referenced by main().
int qdec_stop | ( | volatile avr32_qdec_t * | qdec | ) |
Stops a QDEC.
qdec | Pointer to the QDEC instance to access. |
0 | Success. |
unsigned short int qdec_write_pc_cmp | ( | volatile avr32_qdec_t * | qdec, |
unsigned short int | value | ||
) |
Writes a value to the channel's QDEC Position Counter Compare register.
qdec | Pointer to the QDEC instance to access. |
value | Value to write to the RC register. |
>=0 | Written value. |
QDEC_INVALID_ARGUMENT | Invalid argument(s). |
Referenced by main().
unsigned short int qdec_write_pc_cnt | ( | volatile avr32_qdec_t * | qdec, |
unsigned short int | value | ||
) |
Write value of the channel's QDEC Position Current Counter register.
qdec | Pointer to the QDEC instance to access. |
value | Value to write to the PC register. |
>=0 | Status register value. |
Referenced by main(), and qdec_int_handler().
unsigned short int qdec_write_pc_top | ( | volatile avr32_qdec_t * | qdec, |
unsigned short int | value | ||
) |
Writes a value to the channel's QDEC Position Counter Top register.
qdec | Pointer to the QDEC instance to access. |
value | Value to write to the RC register. |
>=0 | Written value. |
QDEC_INVALID_ARGUMENT | Invalid argument(s). |
unsigned short int qdec_write_rc_cmp | ( | volatile avr32_qdec_t * | qdec, |
unsigned short int | value | ||
) |
Writes a value to the channel's QDEC Revolution Counter Compare register.
qdec | Pointer to the QDEC instance to access. |
value | Value to write to the RC register. |
>=0 | Written value. |
QDEC_INVALID_ARGUMENT | Invalid argument(s). |
Referenced by main().
unsigned short int qdec_write_rc_cnt | ( | volatile avr32_qdec_t * | qdec, |
unsigned short int | value | ||
) |
Write value of the channel's QDEC Revolution Current Counter register.
qdec | Pointer to the QDEC instance to access. |
value | Value to write to the RC register. |
>=0 | Status register value. |
Referenced by main(), and qdec_int_handler().
unsigned short int qdec_write_rc_top | ( | volatile avr32_qdec_t * | qdec, |
unsigned short int | value | ||
) |
Writes a value to the channel's QDEC Revolution Counter Top register.
qdec | Pointer to the QDEC instance to access. |
value | Value to write to the RC register. |
>=0 | Written value. |