Xmega Application Note


TC_driver.c

Go to the documentation of this file.
00001 /* This file has been prepared for Doxygen automatic documentation generation.*/
00068 #include "avr_compiler.h"
00069 #include "TC_driver.h"
00070 
00079 void TC0_ConfigClockSource( volatile TC0_t * tc, TC_CLKSEL_t clockSelection )
00080 {
00081         tc->CTRLA = ( tc->CTRLA & ~TC0_CLKSEL_gm ) | clockSelection;
00082 }
00083 
00092 void TC1_ConfigClockSource( volatile TC1_t * tc, TC_CLKSEL_t clockSelection )
00093 {
00094         tc->CTRLA = ( tc->CTRLA & ~TC1_CLKSEL_gm ) | clockSelection;
00095 }
00096 
00097 
00106 void TC0_ConfigWGM( volatile TC0_t * tc, TC_WGMODE_t wgm )
00107 {
00108         tc->CTRLB = ( tc->CTRLB & ~TC0_WGMODE_gm ) | wgm;
00109 }
00110 
00111 
00120 void TC1_ConfigWGM( volatile TC1_t * tc, TC_WGMODE_t wgm )
00121 {
00122         tc->CTRLB = ( tc->CTRLB & ~TC1_WGMODE_gm ) | wgm;
00123 }
00124 
00125 
00137 void TC0_ConfigInputCapture( volatile TC0_t * tc, TC_EVSEL_t eventSource )
00138 {
00139         tc->CTRLD = ( tc->CTRLD & ~( TC0_EVSEL_gm | TC0_EVACT_gm ) ) |
00140                     eventSource |
00141                     TC_EVACT_CAPT_gc;
00142 }
00143 
00144 
00156 void TC1_ConfigInputCapture( volatile TC1_t * tc, TC_EVSEL_t eventSource )
00157 {
00158         tc->CTRLD = ( tc->CTRLD & ~( TC1_EVSEL_gm | TC1_EVACT_gm ) ) |
00159                     eventSource |
00160                     TC_EVACT_CAPT_gc;
00161 }
00162 
00163 
00182 void TC0_EnableCCChannels( volatile TC0_t * tc, uint8_t enableMask )
00183 {
00184         /* Make sure only CCxEN bits are set in enableMask. */
00185         enableMask &= ( TC0_CCAEN_bm | TC0_CCBEN_bm | TC0_CCCEN_bm | TC0_CCDEN_bm );
00186 
00187         /* Enable channels. */
00188         tc->CTRLB |= enableMask;
00189 }
00190 
00207 void TC1_EnableCCChannels( volatile TC1_t * tc, uint8_t enableMask )
00208 {
00209         /* Make sure only CCxEN bits are set in enableMask. */
00210         enableMask &= ( TC1_CCAEN_bm | TC1_CCBEN_bm );
00211 
00212         /* Enable channels. */
00213         tc->CTRLB |= enableMask;
00214 }
00215 
00216 
00232 void TC0_DisableCCChannels( volatile TC0_t * tc, uint8_t disableMask )
00233 {
00234         /* Make sure only CCxEN bits are set in disableMask. */
00235         disableMask &= ( TC0_CCAEN_bm | TC0_CCBEN_bm | TC0_CCCEN_bm | TC0_CCDEN_bm );
00236 
00237         /* Disable channels. */
00238         tc->CTRLB &= ~disableMask;
00239 }
00240 
00241 
00255 void TC1_DisableCCChannels( volatile TC1_t * tc, uint8_t disableMask )
00256 {
00257         /* Make sure only CCxEN bits are set in disableMask. */
00258         disableMask &= ( TC1_CCAEN_bm | TC1_CCBEN_bm );
00259 
00260         /* Disable channels. */
00261         tc->CTRLB &= ~disableMask;
00262 }
00263 
00271 void TC0_SetOverflowIntLevel( volatile TC0_t * tc, TC_OVFINTLVL_t intLevel )
00272 {
00273         tc->INTCTRLA = ( tc->INTCTRLA & ~TC0_OVFINTLVL_gm ) | intLevel;
00274 }
00275 
00276 
00284 void TC1_SetOverflowIntLevel( volatile TC1_t * tc, TC_OVFINTLVL_t intLevel )
00285 {
00286         tc->INTCTRLA = ( tc->INTCTRLA & ~TC1_OVFINTLVL_gm ) | intLevel;
00287 }
00288 
00289 
00297 void TC0_SetErrorIntLevel( volatile TC0_t * tc, TC_ERRINTLVL_t intLevel )
00298 {
00299         tc->INTCTRLA = ( tc->INTCTRLA & ~TC0_ERRINTLVL_gm ) | intLevel;
00300 }
00301 
00302 
00310 void TC1_SetErrorIntLevel( volatile TC1_t * tc, TC_ERRINTLVL_t intLevel )
00311 {
00312         tc->INTCTRLA = ( tc->INTCTRLA & ~TC1_ERRINTLVL_gm ) | intLevel;
00313 }
00314 
00315 
00324 void TC0_SetCCAIntLevel( volatile TC0_t * tc, TC_CCAINTLVL_t intLevel )
00325 {
00326         tc->INTCTRLB = ( tc->INTCTRLB & ~TC0_CCAINTLVL_gm ) | intLevel;
00327 }
00328 
00329 
00338 void TC1_SetCCAIntLevel( volatile TC1_t * tc, TC_CCAINTLVL_t intLevel )
00339 {
00340         tc->INTCTRLB = ( tc->INTCTRLB & ~TC1_CCAINTLVL_gm ) | intLevel;
00341 }
00342 
00343 
00352 void TC0_SetCCBIntLevel( volatile TC0_t * tc, TC_CCBINTLVL_t intLevel )
00353 {
00354         tc->INTCTRLB = ( tc->INTCTRLB & ~TC0_CCBINTLVL_gm ) | intLevel;
00355 }
00356 
00357 
00366 void TC1_SetCCBIntLevel( volatile TC1_t * tc, TC_CCBINTLVL_t intLevel )
00367 {
00368         tc->INTCTRLB = ( tc->INTCTRLB & ~TC1_CCBINTLVL_gm ) | intLevel;
00369 }
00370 
00371 
00380 void TC0_SetCCCIntLevel( volatile TC0_t * tc, TC_CCCINTLVL_t intLevel )
00381 {
00382         tc->INTCTRLB = ( tc->INTCTRLB & ~TC0_CCCINTLVL_gm ) | intLevel;
00383 }
00384 
00385 
00394 void TC0_SetCCDIntLevel( volatile TC0_t * tc, TC_CCDINTLVL_t intLevel )
00395 {
00396         tc->INTCTRLB = ( tc->INTCTRLB & ~TC0_CCDINTLVL_gm ) | intLevel;
00397 }
00398 
00399 
00408 void TC0_Reset( volatile TC0_t * tc )
00409 {
00410         /* TC must be turned off before a Reset command. */
00411         tc->CTRLA = ( tc->CTRLA & ~TC0_CLKSEL_gm ) | TC_CLKSEL_OFF_gc;
00412 
00413         /* Issue Reset command. */
00414         tc->CTRLFSET = TC_CMD_RESET_gc;
00415 }
00416 
00417 
00426 void TC1_Reset( volatile TC1_t * tc )
00427 {
00428         /* TC must be turned off before a Reset command. */
00429         tc->CTRLA = ( tc->CTRLA & ~TC1_CLKSEL_gm ) | TC_CLKSEL_OFF_gc;
00430 
00431         /* Issue Reset command. */
00432         tc->CTRLFSET = TC_CMD_RESET_gc;
00433 }
@DOC_TITLE@
Generated on Wed Apr 23 07:45:44 2008 for AVR1306 Using the XMEGA Timer/Counter by doxygen 1.5.5