COSA
An Object-Oriented Platform for Arduino Programming
InputCapture Class Reference

#include <InputCapture.hh>

Inheritance diagram for InputCapture:
Inheritance graph
Collaboration diagram for InputCapture:
Collaboration graph

Public Types

enum  InterruptMode { ON_FALLING_MODE, ON_RISING_MODE }
 

Public Member Functions

 InputCapture (InterruptMode mode=ON_FALLING_MODE)
 
InterruptMode mode () const
 
void mode (InterruptMode mode)
 
uint16_t count ()
 
virtual void on_interrupt (uint16_t arg=0)
 
virtual void enable ()
 
virtual void disable ()
 
virtual void clear ()
 

Static Public Member Functions

static void begin ()
 
static void end ()
 

Friends

void TIMER1_CAPT_vect (void)
 

Detailed Description

Input Capture Unit. Allows timer capture and interrupt handling on the input capture pin value changes. The pin is hardwired (ICP1/PB0 on ATmega328p, D8).

Limitations

Uses Timer1. Cannot be used with libraries that use the same Timer; Tone, VWI. Compiles for Mega but the ICP1 pin is not available on the Arduino Mega board.

Definition at line 40 of file InputCapture.hh.

Member Enumeration Documentation

Enumerator
ON_FALLING_MODE 
ON_RISING_MODE 

Definition at line 42 of file InputCapture.hh.

Constructor & Destructor Documentation

InputCapture::InputCapture ( InterruptMode  mode = ON_FALLING_MODE)

Construct input capture unit with given capture mode and with no prescale. Pin is D8 on ATmega328 based boards.

Parameters
[in]modecapture mode (Default ON_FALLING_MODE).

Definition at line 27 of file InputCapture.cpp.

Member Function Documentation

static void InputCapture::begin ( )
inlinestatic

Start input capture timer.

Definition at line 57 of file InputCapture.hh.

void InputCapture::clear ( )
virtual

Clear input capture interrupt flag.

Note
atomic

Reimplemented from Interrupt::Handler.

Definition at line 63 of file InputCapture.cpp.

uint16_t InputCapture::count ( )
inline

Get current timer count.

Returns
mode.

Definition at line 99 of file InputCapture.hh.

void InputCapture::disable ( )
virtual

Disable input capture handler.

Note
atomic

Reimplemented from Interrupt::Handler.

Definition at line 56 of file InputCapture.cpp.

void InputCapture::enable ( )
virtual

Enable input capture handler.

Note
atomic

Reimplemented from Interrupt::Handler.

Definition at line 49 of file InputCapture.cpp.

static void InputCapture::end ( )
inlinestatic

Stop input capture timer.

Definition at line 65 of file InputCapture.hh.

InterruptMode InputCapture::mode ( ) const
inline

Get current capture mode.

Returns
mode.

Definition at line 74 of file InputCapture.hh.

void InputCapture::mode ( InterruptMode  mode)
inline

Set capture mode.

Parameters
[in]new_mode.

Definition at line 86 of file InputCapture.hh.

void InputCapture::on_interrupt ( uint16_t  arg = 0)
virtual

Interrupt service callback on input capture. The parameter arg contains the timer value. The timer is incremented with the system clock (prescale is 1).

Parameters
[in]argtimer count on event.

Reimplemented from Interrupt::Handler.

Definition at line 43 of file InputCapture.cpp.

Friends And Related Function Documentation

void TIMER1_CAPT_vect ( void  )
friend

The documentation for this class was generated from the following files: