00001
00059 #ifndef TC_DRIVER_H
00060 #define TC_DRIVER_H
00061
00062 #include "avr_compiler.h"
00063
00064
00065
00074 #define TC_EnableEventDelay( _tc ) ( (_tc)->CTRLD |= TC0_EVDLY_bm )
00075
00080 #define TC_DisableEventDelay( _tc ) ( (_tc)->CTRLD &= ~TC0_EVDLY_bm )
00081
00090 #define TC_LockCompareUpdate( _tc ) ( (_tc)->CTRLFSET = TC0_LUPD_bm )
00091
00102 #define TC_UnlockCompareUpdate( _tc ) ( (_tc)->CTRLFCLR = TC0_LUPD_bm )
00103
00104
00114 #define TC_ForceUpdate( _tc ) ( (_tc)->CTRLFSET = TC_CMD_UPDATE_gc )
00115
00126 #define TC_Restart( _tc ) ( (_tc)->CTRLFSET = TC_CMD_RESTART_gc )
00127
00137 #define TC_SetCount( _tc, _count ) ( (_tc)->CNT = (_count) )
00138
00148 #define TC_SetPeriod( _tc, _period ) ( (_tc)->PER = (_period) )
00149
00158 #define TC_SetPeriodBuffered( _tc, _period ) ( (_tc)->PERBUF = (_period) )
00159
00169 #define TC_SetCompareA( _tc, _compareValue ) ( (_tc)->CCABUF = (_compareValue) )
00170
00180 #define TC_SetCompareB( _tc, _compareValue ) ( (_tc)->CCBBUF = (_compareValue) )
00181
00193 #define TC_SetCompareC( _tc, _compareValue ) ( (_tc)->CCCBUF = (_compareValue) )
00194
00206 #define TC_SetCompareD( _tc, _compareValue ) ( (_tc)->CCDBUF = (_compareValue) )
00207
00216 #define TC_GetOverflowFlag( _tc ) ( (_tc)->INTFLAGS & TC0_OVFIF_bm )
00217
00224 #define TC_ClearOverflowFlag( _tc ) ( (_tc)->INTFLAGS = TC0_OVFIF_bm )
00225
00234 #define TC_GetErrorFlag( _tc ) ( (_tc)->INTFLAGS & TC0_ERRIF_bm )
00235
00242 #define TC_ClearErrorFlag( _tc ) ( (_tc)->INTFLAGS = TC0_ERRIF_bm )
00243
00258 #define TC_GetCCAFlag( _tc ) ( (_tc)->INTFLAGS & TC0_CCAIF_bm )
00259
00264 #define TC_ClearCCAFlag( _tc ) ( (_tc)->INTFLAGS = TC0_CCAIF_bm )
00265
00280 #define TC_GetCCBFlag( _tc ) ( (_tc)->INTFLAGS & TC0_CCBIF_bm )
00281
00286 #define TC_ClearCCBFlag( _tc ) ( (_tc)->INTFLAGS = TC0_CCBIF_bm )
00287
00304 #define TC_GetCCCFlag( _tc ) ( (_tc)->INTFLAGS & TC0_CCCIF_bm )
00305
00314 #define TC_ClearCCCFlag( _tc ) ( (_tc)->INTFLAGS = TC0_CCCIF_bm )
00315
00332 #define TC_GetCCDFlag( _tc ) ( (_tc)->INTFLAGS & TC0_CCDIF_bm )
00333
00342 #define TC_ClearCCDFlag( _tc ) ( (_tc)->INTFLAGS = TC0_CCDIF_bm )
00343
00344
00354 #define TC_GetCaptureA( _tc ) ( (_tc)->CCA )
00355
00365 #define TC_GetCaptureB( _tc ) ( (_tc)->CCB )
00366
00378 #define TC_GetCaptureC( _tc ) ( (_tc)->CCC )
00379
00391 #define TC_GetCaptureD( _tc ) ( (_tc)->CCD )
00392
00393
00394
00395
00396 void TC0_ConfigClockSource( volatile TC0_t * tc, TC_CLKSEL_t clockSelection );
00397 void TC0_ConfigWGM( volatile TC0_t * tc, TC_WGMODE_t wgm );
00398 void TC0_ConfigInputCapture( volatile TC0_t * tc, TC_EVSEL_t eventSource );
00399 void TC0_EnableCCChannels( volatile TC0_t * tc, uint8_t enableMask );
00400 void TC0_DisableCCChannels( volatile TC0_t * tc, uint8_t disableMask );
00401 void TC0_SetOverflowIntLevel( volatile TC0_t * tc, TC_OVFINTLVL_t intLevel );
00402 void TC0_SetErrorIntLevel( volatile TC0_t * tc, TC_ERRINTLVL_t intLevel );
00403 void TC0_SetCCAIntLevel( volatile TC0_t * tc, TC_CCAINTLVL_t intLevel );
00404 void TC0_SetCCBIntLevel( volatile TC0_t * tc, TC_CCBINTLVL_t intLevel );
00405 void TC0_SetCCCIntLevel( volatile TC0_t * tc, TC_CCCINTLVL_t intLevel );
00406 void TC0_SetCCDIntLevel( volatile TC0_t * tc, TC_CCDINTLVL_t intLevel );
00407 void TC0_Reset( volatile TC0_t * tc );
00408
00409 void TC1_ConfigClockSource( volatile TC1_t * tc, TC_CLKSEL_t clockSelection );
00410 void TC1_ConfigWGM( volatile TC1_t * tc, TC_WGMODE_t wgm );
00411 void TC1_ConfigInputCapture( volatile TC1_t * tc, TC_EVSEL_t eventSource );
00412 void TC1_EnableCCChannels( volatile TC1_t * tc, uint8_t enableMask );
00413 void TC1_DisableCCChannels( volatile TC1_t * tc, uint8_t disableMask );
00414 void TC1_SetOverflowIntLevel( volatile TC1_t * tc, TC_OVFINTLVL_t intLevel );
00415 void TC1_SetErrorIntLevel( volatile TC1_t * tc, TC_ERRINTLVL_t intLevel );
00416 void TC1_SetCCAIntLevel( volatile TC1_t * tc, TC_CCAINTLVL_t intLevel );
00417 void TC1_SetCCBIntLevel( volatile TC1_t * tc, TC_CCBINTLVL_t intLevel );
00418 void TC1_SetCCCIntLevel( volatile TC1_t * tc, TC_CCCINTLVL_t intLevel );
00419 void TC1_SetCCDIntLevel( volatile TC1_t * tc, TC_CCDINTLVL_t intLevel );
00420 void TC1_Reset( volatile TC1_t * tc );
00421
00422
00423 #endif