ATtiny85 Template Code
Code snippets for the ATtiny85
|
#include <stdint.h>
#include <stdbool.h>
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) |
#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.
uint16_t ticks | ( | ) |
Get the current tick count
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).
reference | the reference tick count to calculate against. |
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.