Atmel Software Framework

tc.c File Reference

SAM Timer Counter (TC) driver.

Copyright (c) 2011-2015 Atmel Corporation. All rights reserved.

#include <assert.h>
#include "tc.h"

Macros

#define FREQ_SLOW_CLOCK_EXT   32768 /* External slow clock frequency (hz) */
 
#define TC_DIV_FACTOR   65536
 
#define TC_WPMR_WPKEY_PASSWD   TC_WPMR_WPKEY((uint32_t)0x54494D)
 

Functions

void tc_disable_interrupt (Tc *p_tc, uint32_t ul_channel, uint32_t ul_sources)
 Disable TC interrupts on the specified channel. More...
 
void tc_disable_qdec_interrupt (Tc *p_tc, uint32_t ul_sources)
 Disable TC QDEC interrupts. More...
 
void tc_enable_interrupt (Tc *p_tc, uint32_t ul_channel, uint32_t ul_sources)
 Enable the TC interrupts on the specified channel. More...
 
void tc_enable_qdec_interrupt (Tc *p_tc, uint32_t ul_sources)
 Enable TC QDEC interrupts. More...
 
uint32_t tc_find_mck_divisor (uint32_t ul_freq, uint32_t ul_mck, uint32_t *p_uldiv, uint32_t *p_ultcclks, uint32_t ul_boardmck)
 Find the best MCK divisor. More...
 
uint32_t tc_get_feature (Tc *p_tc)
 Indicate TC features. More...
 
uint32_t tc_get_interrupt_mask (Tc *p_tc, uint32_t ul_channel)
 Read the TC interrupt mask for the specified channel. More...
 
uint32_t tc_get_qdec_interrupt_mask (Tc *p_tc)
 Read TC QDEC interrupt mask. More...
 
uint32_t tc_get_qdec_interrupt_status (Tc *p_tc)
 Get current TC QDEC interrupt status. More...
 
uint32_t tc_get_status (Tc *p_tc, uint32_t ul_channel)
 Get the current status for the specified TC channel. More...
 
uint32_t tc_get_version (Tc *p_tc)
 Indicate TC version. More...
 
void tc_init (Tc *p_tc, uint32_t ul_channel, uint32_t ul_mode)
 Configure TC for timer, waveform generation, or capture. More...
 
uint32_t tc_init_2bit_gray (Tc *p_tc, uint32_t ul_channel, uint32_t ul_steppermode)
 Configure TC for 2-bit Gray Counter for Stepper Motor. More...
 
uint32_t tc_read_cv (Tc *p_tc, uint32_t ul_channel)
 Read the counter value on the specified channel. More...
 
uint32_t tc_read_ra (Tc *p_tc, uint32_t ul_channel)
 Read TC Register A (RA) on the specified channel. More...
 
uint32_t tc_read_rb (Tc *p_tc, uint32_t ul_channel)
 Read TC Register B (RB) on the specified channel. More...
 
uint32_t tc_read_rc (Tc *p_tc, uint32_t ul_channel)
 Read TC Register C (RC) on the specified channel. More...
 
void tc_set_block_mode (Tc *p_tc, uint32_t ul_blockmode)
 Configure the TC Block mode. More...
 
void tc_set_writeprotect (Tc *p_tc, uint32_t ul_enable)
 Enable or disable write protection of TC registers. More...
 
void tc_start (Tc *p_tc, uint32_t ul_channel)
 Start the TC clock on the specified channel. More...
 
void tc_stop (Tc *p_tc, uint32_t ul_channel)
 Stop the TC clock on the specified channel. More...
 
void tc_sync_trigger (Tc *p_tc)
 Asserts a SYNC signal to generate a software trigger on all channels. More...
 
void tc_write_ra (Tc *p_tc, uint32_t ul_channel, uint32_t ul_value)
 Write to TC Register A (RA) on the specified channel. More...
 
void tc_write_rb (Tc *p_tc, uint32_t ul_channel, uint32_t ul_value)
 Write to TC Register B (RB) on the specified channel. More...
 
void tc_write_rc (Tc *p_tc, uint32_t ul_channel, uint32_t ul_value)
 Write to TC Register C (RC) on the selected channel. More...
 

#define FREQ_SLOW_CLOCK_EXT   32768 /* External slow clock frequency (hz) */

Referenced by tc_find_mck_divisor().

#define TC_DIV_FACTOR   65536

Referenced by tc_find_mck_divisor().

#define TC_WPMR_WPKEY_PASSWD   TC_WPMR_WPKEY((uint32_t)0x54494D)

Referenced by tc_set_writeprotect().