PiPower  ac0ff3c (Mon Feb 11 21:44:30 2019 -0500)
Functions | Variables
/home/travis/build/larsks/pipower/millis.c File Reference

Provide an analog of the Arduino millis() function. More...

#include <avr/interrupt.h>
#include <avr/io.h>
#include <util/atomic.h>

Functions

 ISR (TIMER0_COMPA_vect)
 Timer interrupt service routine. More...
 
void init_millis ()
 Initialize the millis service. More...
 
unsigned long millis ()
 Return milliseconds since mc boot. More...
 

Variables

volatile unsigned long timer_millis = 0
 

Detailed Description

Provide an analog of the Arduino millis() function.

This implementation uses TIMER0 with a /64 divider, which will allow it to operate with a clock frequency of up to 16Mhz.

Function Documentation

void init_millis ( )

Initialize the millis service.

Configure timer 0 in CTC mode. See the attiny85 datasheet for more information.

ISR ( TIMER0_COMPA_vect  )

Timer interrupt service routine.

This fires each time the timer counter (TCNT0) reaches the target value stored in OCR0A.

unsigned long millis ( )

Return milliseconds since mc boot.