ATtiny85 Template Code
Code snippets for the ATtiny85
 All Files Functions Variables Typedefs Enumerations Enumerator Macros
systicks.h File Reference
#include <stdint.h>
#include <stdbool.h>
Include dependency graph for systicks.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define TICKS_PER_SECOND   60
 

Functions

void ticksInit ()
 
uint16_t ticks ()
 
uint16_t ticksElapsed (uint16_t reference)
 

Macro Definition Documentation

#define TICKS_PER_SECOND   60

Number of ticks per second

Defines the approximate number of ticks that occur every second.

Definition at line 23 of file systicks.h.

Function Documentation

uint16_t ticks ( )

Get the current tick count

Returns
the current tick count. The count wraps around once it reaches 65535.

Definition at line 70 of file systicks.c.

uint16_t ticksElapsed ( uint16_t  reference)

Calculate the ticks elapsed since the given sample.

This function calculates the number of ticks that have elapsed since the reference sample was taken. The function takes into account the wrap around of the counter (but it cannot detect multiple wrap arounds).

Parameters
referencethe reference tick count to calculate against.
Returns
the number of ticks elapsed since the reference count.

Definition at line 84 of file systicks.c.

void ticksInit ( )

Initialise the 'ticks' subsystem.

This function sets up the required interrupts and initialises the tick counter. There are approximately TICKS_PER_SECOND ticks every second that elapses (depending on interrupt activity and clock accuracy) and they are tracked by a 16 bit counter. A program can use the difference between samples of the counter to measure longer periods of time.

The ticks system uses TIMER1 to provide the interrupt used to update the time count (this interrupt is shared with the software PWM implementation as well).

Definition at line 54 of file systicks.c.

Here is the caller graph for this function: