BLDC control on ATAVRMC303 with ATxMega128A1
TC_driver.h
Go to the documentation of this file.
1 /* This file has been prepared for Doxygen automatic documentation generation.*/
59 #ifndef TC_DRIVER_H
60 #define TC_DRIVER_H
61 
62 #include "avr_compiler.h"
63 
64 /* Definition of macros. */
65 
74 #define TC_EnableEventDelay( _tc ) ( (_tc)->CTRLD |= TC0_EVDLY_bm )
75 
80 #define TC_DisableEventDelay( _tc ) ( (_tc)->CTRLD &= ~TC0_EVDLY_bm )
81 
90 #define TC_LockCompareUpdate( _tc ) ( (_tc)->CTRLFSET = TC0_LUPD_bm )
91 
102 #define TC_UnlockCompareUpdate( _tc ) ( (_tc)->CTRLFCLR = TC0_LUPD_bm )
103 
104 
114 #define TC_ForceUpdate( _tc ) ( (_tc)->CTRLFSET = TC_CMD_UPDATE_gc )
115 
126 #define TC_Restart( _tc ) ( (_tc)->CTRLFSET = TC_CMD_RESTART_gc )
127 
137 #define TC_SetCount( _tc, _count ) ( (_tc)->CNT = (_count) )
138 
148 #define TC_SetPeriod( _tc, _period ) ( (_tc)->PER = (_period) )
149 
158 #define TC_SetPeriodBuffered( _tc, _period ) ( (_tc)->PERBUF = (_period) )
159 
169 #define TC_SetCompareA( _tc, _compareValue ) ( (_tc)->CCABUF = (_compareValue) )
170 
180 #define TC_SetCompareB( _tc, _compareValue ) ( (_tc)->CCBBUF = (_compareValue) )
181 
193 #define TC_SetCompareC( _tc, _compareValue ) ( (_tc)->CCCBUF = (_compareValue) )
194 
206 #define TC_SetCompareD( _tc, _compareValue ) ( (_tc)->CCDBUF = (_compareValue) )
207 
216 #define TC_GetOverflowFlag( _tc ) ( (_tc)->INTFLAGS & TC0_OVFIF_bm )
217 
224 #define TC_ClearOverflowFlag( _tc ) ( (_tc)->INTFLAGS = TC0_OVFIF_bm )
225 
234 #define TC_GetErrorFlag( _tc ) ( (_tc)->INTFLAGS & TC0_ERRIF_bm )
235 
242 #define TC_ClearErrorFlag( _tc ) ( (_tc)->INTFLAGS = TC0_ERRIF_bm )
243 
258 #define TC_GetCCAFlag( _tc ) ( (_tc)->INTFLAGS & TC0_CCAIF_bm )
259 
264 #define TC_ClearCCAFlag( _tc ) ( (_tc)->INTFLAGS = TC0_CCAIF_bm )
265 
280 #define TC_GetCCBFlag( _tc ) ( (_tc)->INTFLAGS & TC0_CCBIF_bm )
281 
286 #define TC_ClearCCBFlag( _tc ) ( (_tc)->INTFLAGS = TC0_CCBIF_bm )
287 
304 #define TC_GetCCCFlag( _tc ) ( (_tc)->INTFLAGS & TC0_CCCIF_bm )
305 
314 #define TC_ClearCCCFlag( _tc ) ( (_tc)->INTFLAGS = TC0_CCCIF_bm )
315 
332 #define TC_GetCCDFlag( _tc ) ( (_tc)->INTFLAGS & TC0_CCDIF_bm )
333 
342 #define TC_ClearCCDFlag( _tc ) ( (_tc)->INTFLAGS = TC0_CCDIF_bm )
343 
344 
354 #define TC_GetCaptureA( _tc ) ( (_tc)->CCA )
355 
365 #define TC_GetCaptureB( _tc ) ( (_tc)->CCB )
366 
378 #define TC_GetCaptureC( _tc ) ( (_tc)->CCC )
379 
391 #define TC_GetCaptureD( _tc ) ( (_tc)->CCD )
392 
393 
394 /* Prototyping of functions. Documentation can be found in source file. */
395 
396 void TC0_ConfigClockSource( volatile TC0_t * tc, TC_CLKSEL_t clockSelection );
397 void TC0_ConfigWGM( volatile TC0_t * tc, TC_WGMODE_t wgm );
398 void TC0_ConfigInputCapture( volatile TC0_t * tc, TC_EVSEL_t eventSource );
399 void TC0_EnableCCChannels( volatile TC0_t * tc, uint8_t enableMask );
400 void TC0_DisableCCChannels( volatile TC0_t * tc, uint8_t disableMask );
401 void TC0_SetOverflowIntLevel( volatile TC0_t * tc, TC_OVFINTLVL_t intLevel );
402 void TC0_SetErrorIntLevel( volatile TC0_t * tc, TC_ERRINTLVL_t intLevel );
403 void TC0_SetCCAIntLevel( volatile TC0_t * tc, TC_CCAINTLVL_t intLevel );
404 void TC0_SetCCBIntLevel( volatile TC0_t * tc, TC_CCBINTLVL_t intLevel );
405 void TC0_SetCCCIntLevel( volatile TC0_t * tc, TC_CCCINTLVL_t intLevel );
406 void TC0_SetCCDIntLevel( volatile TC0_t * tc, TC_CCDINTLVL_t intLevel );
407 void TC0_Reset( volatile TC0_t * tc );
408 
409 void TC1_ConfigClockSource( volatile TC1_t * tc, TC_CLKSEL_t clockSelection );
410 void TC1_ConfigWGM( volatile TC1_t * tc, TC_WGMODE_t wgm );
411 void TC1_ConfigInputCapture( volatile TC1_t * tc, TC_EVSEL_t eventSource );
412 void TC1_EnableCCChannels( volatile TC1_t * tc, uint8_t enableMask );
413 void TC1_DisableCCChannels( volatile TC1_t * tc, uint8_t disableMask );
414 void TC1_SetOverflowIntLevel( volatile TC1_t * tc, TC_OVFINTLVL_t intLevel );
415 void TC1_SetErrorIntLevel( volatile TC1_t * tc, TC_ERRINTLVL_t intLevel );
416 void TC1_SetCCAIntLevel( volatile TC1_t * tc, TC_CCAINTLVL_t intLevel );
417 void TC1_SetCCBIntLevel( volatile TC1_t * tc, TC_CCBINTLVL_t intLevel );
418 void TC1_SetCCCIntLevel( volatile TC1_t * tc, TC_CCCINTLVL_t intLevel );
419 void TC1_SetCCDIntLevel( volatile TC1_t * tc, TC_CCDINTLVL_t intLevel );
420 void TC1_Reset( volatile TC1_t * tc );
421 
422 
423 #endif
void TC0_SetOverflowIntLevel(volatile TC0_t *tc, TC_OVFINTLVL_t intLevel)
Sets the overflow interrupt level.
Definition: TC_driver.c:271
void TC1_ConfigInputCapture(volatile TC1_t *tc, TC_EVSEL_t eventSource)
Configures the Timer/Counter 1 for input capture operation.
Definition: TC_driver.c:156
void TC1_EnableCCChannels(volatile TC1_t *tc, uint8_t enableMask)
Enables compare/capture channels for Timer/Counter 1.
Definition: TC_driver.c:207
void TC0_EnableCCChannels(volatile TC0_t *tc, uint8_t enableMask)
Enables compare/capture channels for Timer/Counter 0.
Definition: TC_driver.c:182
void TC1_ConfigClockSource(volatile TC1_t *tc, TC_CLKSEL_t clockSelection)
Configures clock source for the Timer/Counter 1.
Definition: TC_driver.c:92
void TC0_SetCCCIntLevel(volatile TC0_t *tc, TC_CCCINTLVL_t intLevel)
Sets the interrupt level for compare/capture channel C interrupt.
Definition: TC_driver.c:380
void TC0_DisableCCChannels(volatile TC0_t *tc, uint8_t disableMask)
Disables compare/capture channels on Timer/Counter 0.
Definition: TC_driver.c:232
void TC1_SetErrorIntLevel(volatile TC1_t *tc, TC_ERRINTLVL_t intLevel)
Sets the Error interrupt level.
Definition: TC_driver.c:310
void TC0_SetCCAIntLevel(volatile TC0_t *tc, TC_CCAINTLVL_t intLevel)
Sets the interrupt level for compare/capture channel A interrupt.
Definition: TC_driver.c:324
void TC1_Reset(volatile TC1_t *tc)
Resets the Timer/Counter 1.
Definition: TC_driver.c:426
This file implements some macros that makes the IAR C-compiler and avr-gcc work with the same code ba...
void TC1_SetCCDIntLevel(volatile TC1_t *tc, TC_CCDINTLVL_t intLevel)
void TC0_ConfigWGM(volatile TC0_t *tc, TC_WGMODE_t wgm)
Configures the Waveform Generation Mode for the Timer/Counter 0.
Definition: TC_driver.c:106
void TC1_ConfigWGM(volatile TC1_t *tc, TC_WGMODE_t wgm)
Configures the Waveform Generation Mode for the Timer/Counter 1.
Definition: TC_driver.c:120
void TC0_Reset(volatile TC0_t *tc)
Resets the Timer/Counter 0.
Definition: TC_driver.c:408
void TC1_SetOverflowIntLevel(volatile TC1_t *tc, TC_OVFINTLVL_t intLevel)
Sets the overflow interrupt level.
Definition: TC_driver.c:284
void TC0_ConfigClockSource(volatile TC0_t *tc, TC_CLKSEL_t clockSelection)
Configures clock source for the Timer/Counter 0.
Definition: TC_driver.c:79
void TC1_SetCCBIntLevel(volatile TC1_t *tc, TC_CCBINTLVL_t intLevel)
Sets the interrupt level for compare/capture channel B interrupt.
Definition: TC_driver.c:366
void TC0_SetCCDIntLevel(volatile TC0_t *tc, TC_CCDINTLVL_t intLevel)
Sets the interrupt level for compare/capture channel D interrupt.
Definition: TC_driver.c:394
void TC0_SetCCBIntLevel(volatile TC0_t *tc, TC_CCBINTLVL_t intLevel)
Sets the interrupt level for compare/capture channel B interrupt.
Definition: TC_driver.c:352
void TC0_SetErrorIntLevel(volatile TC0_t *tc, TC_ERRINTLVL_t intLevel)
Sets the Error interrupt level.
Definition: TC_driver.c:297
void TC0_ConfigInputCapture(volatile TC0_t *tc, TC_EVSEL_t eventSource)
Configures the Timer/Counter 0 for input capture operation.
Definition: TC_driver.c:137
void TC1_SetCCCIntLevel(volatile TC1_t *tc, TC_CCCINTLVL_t intLevel)
void TC1_SetCCAIntLevel(volatile TC1_t *tc, TC_CCAINTLVL_t intLevel)
Sets the interrupt level for compare/capture channel A interrupt.
Definition: TC_driver.c:338
void TC1_DisableCCChannels(volatile TC1_t *tc, uint8_t disableMask)
Disables compare/capture channels on Timer/Counter 1.
Definition: TC_driver.c:255