COSA
An Object-Oriented Platform for Arduino Programming
|
#include <AnalogPin.hh>
Public Member Functions | |
AnalogPin (Board::AnalogPin pin, Board::Reference ref=Board::AVCC_REFERENCE) | |
void | reference (Board::Reference ref) |
Board::Reference | reference () const |
Board::AnalogPin | pin () const |
uint16_t | value () const |
uint16_t | sample () |
AnalogPin & | operator>> (uint16_t &var) |
operator uint16_t () | |
bool | sample_request (uint8_t event=Event::NULL_TYPE) |
uint16_t | sample_await () |
virtual void | on_interrupt (uint16_t arg) |
virtual void | on_change (uint16_t value) |
virtual void | enable () |
virtual void | disable () |
virtual void | clear () |
Static Public Member Functions | |
static void | prescale (uint8_t factor) |
static uint16_t | sample (Board::AnalogPin pin, Board::Reference ref=Board::AVCC_REFERENCE) |
static uint16_t | bandgap (uint16_t vref=1100) |
static void | powerup () |
static void | powerdown () |
Protected Member Functions | |
bool | sample_request (Board::AnalogPin pin, uint8_t ref) |
virtual void | on_event (uint8_t type, uint16_t value) |
Protected Attributes | |
const Board::AnalogPin | m_pin |
Analog channel number. More... | |
Board::Reference | m_reference |
ADC reference voltage type. More... | |
uint16_t | m_value |
Latest sample value. More... | |
uint8_t | m_event |
Event to push on completion. More... | |
Static Protected Attributes | |
static AnalogPin * | sampling_pin = NULL |
Current sampling pin if any. More... | |
Friends | |
void | ADC_vect (void) |
Abstract analog pin. Allows asynchronous sampling with interrupt and event handler.
Definition at line 32 of file AnalogPin.hh.
|
inline |
Construct abstract analog pin for given pin (channel) and reference voltage.
[in] | pin | number. |
[in] | ref | reference voltage (default VCC). |
Definition at line 40 of file AnalogPin.hh.
|
static |
Get power supply voltage in milli-volt. May be used for low battery detection. Uses the internal 1V1 bandgap reference.
[in] | vref | reference voltage in milli-volt (default is 1100 mv). |
Definition at line 33 of file AnalogPin_static.cpp.
|
inlinevirtualinherited |
Clear interrupt.
Reimplemented in InputCapture, and ExternalInterrupt.
Definition at line 59 of file Interrupt.hh.
|
inlinevirtualinherited |
Disable interrupt handler.
Reimplemented in InputCapture, AnalogComparator, PinChangeInterrupt, and ExternalInterrupt.
Definition at line 53 of file Interrupt.hh.
|
inlinevirtualinherited |
Enable interrupt handler.
Reimplemented in InputCapture, PinChangeInterrupt, ExternalInterrupt, and AnalogComparator.
Definition at line 47 of file Interrupt.hh.
|
inlinevirtual |
|
protectedvirtual |
Handle analog pin periodic sampling and sample completed event. Will call virtual method on_change() if the pin value has changed since latest sample.
[in] | type | the type of event. |
[in] | value | the event value. |
Reimplemented from Event::Handler.
Reimplemented in AnalogPins.
Definition at line 51 of file AnalogPin.cpp.
|
virtual |
Interrupt service on conversion completion.
[in] | arg | sample value. |
Reimplemented from Interrupt::Handler.
Reimplemented in AnalogPins.
Definition at line 65 of file AnalogPin.cpp.
|
inline |
Sample analog pin. Wait for conversion to complete before returning with sample value.
Definition at line 159 of file AnalogPin.hh.
|
inline |
Sample analog pin. Wait for conversion to complete before returning with sample value.
[out] | var | variable to receive the value. |
Definition at line 147 of file AnalogPin.hh.
|
inline |
|
inlinestatic |
Disable analog conversion.
Definition at line 123 of file AnalogPin.hh.
|
inlinestatic |
Enable analog conversion.
Definition at line 113 of file AnalogPin.hh.
|
static |
Set analog conversion clock prescale (2..128, step power 2).
[in] | factor | prescale. |
Definition at line 26 of file AnalogPin_static.cpp.
|
inline |
Set reference voltage for conversion.
[in] | ref | reference voltage. |
Definition at line 51 of file AnalogPin.hh.
|
inline |
Get reference voltage for conversion.
Definition at line 60 of file AnalogPin.hh.
|
static |
Sample analog pin. Wait for conversion to complete before returning with sample value.
[in] | pin | number. |
[in] | ref | reference voltage. |
Definition at line 50 of file AnalogPin_static.cpp.
|
inline |
Sample analog pin. Wait for conversion to complete before returning with sample value.
Definition at line 135 of file AnalogPin.hh.
uint16_t AnalogPin::sample_await | ( | ) |
Await conversion to complete. Returns sample value
Definition at line 38 of file AnalogPin.cpp.
|
inline |
Request sample of analog pin. Pushes given event on completion. Default event is null/no event pushed for sample_await().
[in] | event | to push on completion. |
Definition at line 171 of file AnalogPin.hh.
|
protected |
Internal request sample of analog pin. Set up sampling of given pin with given reference voltage.
[in] | pin | number. |
[in] | ref | reference voltage. |
Definition at line 24 of file AnalogPin.cpp.
|
inline |
|
friend |
Interrupt Service Routine
Forward declare interrupt service routines to allow them as friends.
|
protected |
Event to push on completion.
Definition at line 205 of file AnalogPin.hh.
|
protected |
Analog channel number.
Definition at line 202 of file AnalogPin.hh.
|
protected |
ADC reference voltage type.
Definition at line 203 of file AnalogPin.hh.
|
protected |
Latest sample value.
Definition at line 204 of file AnalogPin.hh.
Current sampling pin if any.
Definition at line 201 of file AnalogPin.hh.