56 lines
1.9 KiB
C
56 lines
1.9 KiB
C
|
#ifndef _SYNC_TIMER_H
|
||
|
#define _SYNC_TIMER_H
|
||
|
|
||
|
/**************************************************************************
|
||
|
* Written by Marcin O'BenY Benka <obeny@obeny.net>
|
||
|
* Version 1.5 (20100225)
|
||
|
*
|
||
|
* NOTE:
|
||
|
*
|
||
|
* Timer for main event loop synchronization.
|
||
|
* sync ticks presents following equotation:
|
||
|
* sync = fcpu/(SYNC_TIMER_PRESCALER*SYNC_TIMER_PRESCALER_OCR*SYNC_TIMER_COUNT)
|
||
|
* sync value should give execution each 1/100 of second.
|
||
|
*
|
||
|
* IMPORTANT:
|
||
|
* This library need to set following constants to work:
|
||
|
* - SYNC_TIMER_COUNT - additional divider for reaching desired sync times
|
||
|
* - SYNC_TIMER_PRESCALER - value to divide fcpu signal for timer
|
||
|
* supported values: 1, 8, 32, 64, 128, 256 and 1024
|
||
|
* - SYNC_TIMER_PRESCALER_OCR - max value for counter
|
||
|
* - SYNC_TIMER_PRESCALER_EDGE - set it for MCUs that sets
|
||
|
* edge reaction via CSXX bits.
|
||
|
**************************************************************************/
|
||
|
|
||
|
|
||
|
/***************************************************************************
|
||
|
* INCLUDES
|
||
|
***************************************************************************/
|
||
|
|
||
|
#include <avr/interrupt.h>
|
||
|
|
||
|
#include "global.h"
|
||
|
|
||
|
|
||
|
/***************************************************************************
|
||
|
* FUNCTIONS
|
||
|
***************************************************************************/
|
||
|
|
||
|
/* tells whether 1/100 of second expired */
|
||
|
/* -----------------------------------------------------------------------
|
||
|
RETURN VAL : TRUE if 10ms from previous execution elapsed, FALSE otherwise
|
||
|
ARGS : NONE
|
||
|
* ----------------------------------------------------------------------- */
|
||
|
BOOL sync();
|
||
|
|
||
|
/* initialization of timer */
|
||
|
/* -----------------------------------------------------------------------
|
||
|
RETURN VAL : NONE
|
||
|
ARGS : NONE
|
||
|
* ----------------------------------------------------------------------- */
|
||
|
void initSyncTimer();
|
||
|
|
||
|
|
||
|
#endif /* _SYNC_TIMER_H */
|
||
|
/* END */
|