COSA
An Object-Oriented Platform for Arduino Programming
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
InputCapture.cpp
Go to the documentation of this file.
1
21
#include "
Cosa/InputCapture.hh
"
22
23
#if !defined(BOARD_ATTINY)
24
25
InputCapture
* InputCapture::s_capture =
NULL
;
26
27
InputCapture::InputCapture
(
InterruptMode
mode)
28
{
29
// This is the active input capture
30
s_capture =
this
;
31
32
// Use no prescale; timer runs at system clock frequency
33
TCCR1B = _BV(CS10);
34
35
// Set trigger on rising or falling on input capture pin
36
if
(mode ==
ON_RISING_MODE
)
37
TCCR1B |= _BV(ICES1);
38
else
39
TCCR1B &= ~_BV(ICES1);
40
}
41
42
void
43
InputCapture::on_interrupt
(uint16_t arg)
44
{
45
UNUSED
(arg);
46
}
47
48
void
49
InputCapture::enable
()
50
{
51
// Enable input capture interrupt
52
TIMSK1
|= _BV(ICIE1);
53
}
54
55
void
56
InputCapture::disable
()
57
{
58
// Disable input capture interrupt
59
TIMSK1
&= ~_BV(ICIE1);
60
}
61
62
void
63
InputCapture::clear
()
64
{
65
// Clear input capture interrupt flag if set
66
TIFR1 = _BV(ICF1);
67
}
68
69
ISR
(
TIMER1_CAPT_vect
)
70
{
71
if
(
UNLIKELY
(InputCapture::s_capture ==
NULL
))
return
;
72
InputCapture::s_capture->
on_interrupt
(ICR1);
73
}
74
#endif
InputCapture.hh
NULL
#define NULL
Definition:
Types.h:101
InputCapture::disable
virtual void disable()
Definition:
InputCapture.cpp:56
InputCapture
Definition:
InputCapture.hh:40
TIMSK1
#define TIMSK1
Definition:
ATtinyX5.hh:229
InputCapture::on_interrupt
virtual void on_interrupt(uint16_t arg=0)
Definition:
InputCapture.cpp:43
UNUSED
#define UNUSED(x)
Definition:
ATmega328P.hh:31
InputCapture::InterruptMode
InterruptMode
Definition:
InputCapture.hh:42
InputCapture::TIMER1_CAPT_vect
friend void TIMER1_CAPT_vect(void)
InputCapture::clear
virtual void clear()
Definition:
InputCapture.cpp:63
InputCapture::enable
virtual void enable()
Definition:
InputCapture.cpp:49
UNLIKELY
#define UNLIKELY(x)
Definition:
Types.h:153
ISR
ISR(TIMER1_CAPT_vect)
Definition:
InputCapture.cpp:69
InputCapture::ON_RISING_MODE
Definition:
InputCapture.hh:44
InputCapture::InputCapture
InputCapture(InterruptMode mode=ON_FALLING_MODE)
Definition:
InputCapture.cpp:27
cores
cosa
Cosa
InputCapture.cpp
Generated on Thu Aug 31 2017 17:02:02 for COSA by
1.8.11