Microchip® Advanced Software Framework

tc_qdec_example.c File Reference

TC Quadrature Decoder Example for SAM4E.

Copyright (c) 2011-2018 Microchip Technology Inc. and its subsidiaries.

#include "asf.h"
#include "conf_example.h"
#include "conf_board.h"
#include "conf_clock.h"

Data Structures

struct  tc_qdec_config
 TC QDEC configuration structure. More...
 
struct  tc_qdec_pins_config
 Configuration struct for the TCC module output pins. More...
 
struct  tc_qdec_results
 TC QDEC configuration structure. More...
 

Macros

#define STRING_EOL   "\r"
 
#define STRING_HEADER
 

Functions

static void config_tc_qdec_iopins (Tc *const hw, const struct tc_qdec_config *const config)
 configure TC QDEC IO pins. More...
 
static void config_tc_qdec_mode_position (Tc *const hw, const struct tc_qdec_config *const config)
 configure TC QDEC for position mode. More...
 
static void config_tc_qdec_mode_speed (Tc *const hw, const struct tc_qdec_config *const config)
 configure TC QDEC for speed mode. More...
 
static void config_tc_qdec_mode_test_basetimer (Tc *const hw, const struct tc_qdec_config *const config)
 configure TC QDEC for test_basetimer mode. More...
 
static void configure_console (void)
 Configure UART console. More...
 
static void configure_tc_qdec (void)
 configure TC QDEC. More...
 
static void display_menu (void)
 Display the user menu on the UART. More...
 
int main (void)
 Application entry point for tc_capture_waveform example. More...
 
static void tc_qdec_getresult (void)
 TC QDEC get results. More...
 
static void tc_qdec_init (Tc *const hw, const struct tc_qdec_config *const config)
 Initialize TC QDEC. More...
 
static void tc_qdec_printresults (void)
 TC QDEC print results. More...
 

Variables

static const uint32_t divisors [5] = { 2, 8, 32, 128, 0}
 
struct tc_qdec_config qdec_config [QDEC_INSTANCE_MAX]
 
struct tc_qdec_results qdec_results [QDEC_INSTANCE_MAX]
 current values of position, speed, direction More...
 

#define STRING_EOL   "\r"
#define STRING_HEADER
Value:
"--TC Quadrature Decoder Example --\r\n" \
"-- "BOARD_NAME " --\r\n" \
"-- Compiled: "__DATE__ " "__TIME__ " --"STRING_EOL
#define BOARD_NAME
Definition: app_init.h:140
#define STRING_EOL
Definition: tc_qdec_example.c:90

static void config_tc_qdec_mode_position ( Tc *const  hw,
const struct tc_qdec_config *const  config 
)
static
static void config_tc_qdec_mode_speed ( Tc *const  hw,
const struct tc_qdec_config *const  config 
)
static
static void configure_console ( void  )
static

Configure UART console.

References uart_rs232_options::baudrate, and stdio_serial_init().

Referenced by main().

static void configure_tc_qdec ( void  )
static

configure TC QDEC.

References tc_qdec_init().

Referenced by main().

static void display_menu ( void  )
static

Display the user menu on the UART.

References BOARD_NAME.

Referenced by main().

int main ( void  )

Application entry point for tc_capture_waveform example.

Returns
Unused (ANSI-C compatibility).

References board_init(), configure_console(), configure_tc_qdec(), display_menu(), gpio_toggle_pin, sysclk_init(), tc_qdec_getresult(), tc_qdec_printresults(), and wdt_disable().

static void tc_qdec_getresult ( void  )
static
static void tc_qdec_init ( Tc *const  hw,
const struct tc_qdec_config *const  config 
)
static
static void tc_qdec_printresults ( void  )
static

const uint32_t divisors[5] = { 2, 8, 32, 128, 0}
static
struct tc_qdec_config qdec_config[QDEC_INSTANCE_MAX]
struct tc_qdec_results qdec_results[QDEC_INSTANCE_MAX]

current values of position, speed, direction

Referenced by tc_qdec_getresult(), and tc_qdec_printresults().