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

#include <InputPin.hh>

Inheritance diagram for InputPin:
Inheritance graph
Collaboration diagram for InputPin:
Collaboration graph

Public Types

enum  Mode { NORMAL_MODE = 0, PULLUP_MODE = 1 }
 
enum  Direction { MSB_FIRST = 0, LSB_FIRST = 1 }
 

Public Member Functions

 InputPin (Board::DigitalPin pin, Mode mode=NORMAL_MODE)
 
Mode mode () const
 
uint8_t pin () const
 
bool is_set () const
 
bool is_high () const
 
bool is_on () const
 
bool is_clear () const
 
bool is_low () const
 
bool is_off () const
 
bool read () const
 
uint8_t read (OutputPin &clk, Direction order=MSB_FIRST) const
 
 operator bool () const
 
Pinoperator>> (uint8_t &var)
 

Static Public Member Functions

static void mode (Board::DigitalPin pin, Mode mode)
 
static Mode mode (Board::DigitalPin pin)
 
static uint8_t MASK (uint8_t pin)
 
static volatile uint8_t * PIN (uint8_t pin)
 
static volatile uint8_t * DDR (uint8_t pin)
 
static volatile uint8_t * PORT (uint8_t pin)
 
static bool read (Board::DigitalPin pin)
 

Protected Member Functions

volatile uint8_t * PIN () const
 
volatile uint8_t * DDR () const
 
volatile uint8_t * PORT () const
 
volatile uint8_t * PCIMR () const
 

Protected Attributes

volatile uint8_t *const m_sfr
 
const uint8_t m_mask
 
const uint8_t m_pin
 

Detailed Description

Abstract input pin. Allows pullup mode.

Definition at line 29 of file InputPin.hh.

Member Enumeration Documentation

enum Pin::Direction
inherited

Serialization directions; most or least significant bit first.

Enumerator
MSB_FIRST 
LSB_FIRST 

Definition at line 84 of file Pin.hh.

Enumerator
NORMAL_MODE 
PULLUP_MODE 

Definition at line 31 of file InputPin.hh.

Constructor & Destructor Documentation

InputPin::InputPin ( Board::DigitalPin  pin,
Mode  mode = NORMAL_MODE 
)
inline

Construct abstract input pin given Arduino pin number.

Parameters
[in]pinnumber (digital pin).
[in]modepin mode (default NORMAL_MODE).

Definition at line 41 of file InputPin.hh.

Member Function Documentation

static volatile uint8_t* Pin::DDR ( uint8_t  pin)
inlinestaticinherited

Return pointer to Data Direction Register.

Parameters
[in]pinnumber.
Returns
DDR register pointer.

Definition at line 64 of file Pin.hh.

volatile uint8_t* Pin::DDR ( ) const
inlineprotectedinherited

Return pointer to Data Direction Register.

Returns
DDR register pointer.

Definition at line 245 of file Pin.hh.

bool Pin::is_clear ( ) const
inlineinherited

Return true(1) if the pin is clear otherwise false(0).

Returns
boolean.

Definition at line 142 of file Pin.hh.

bool Pin::is_high ( ) const
inlineinherited

Return true(1) if the pin is set otherwise false(0).

Returns
boolean.

Definition at line 122 of file Pin.hh.

bool Pin::is_low ( ) const
inlineinherited

Return true(1) if the pin is clear otherwise false(0).

Returns
boolean.

Definition at line 152 of file Pin.hh.

bool Pin::is_off ( ) const
inlineinherited

Return true(1) if the pin is clear otherwise false(0).

Returns
boolean.

Definition at line 162 of file Pin.hh.

bool Pin::is_on ( ) const
inlineinherited

Return true(1) if the pin is set otherwise false(0).

Returns
boolean.

Definition at line 132 of file Pin.hh.

bool Pin::is_set ( ) const
inlineinherited

Return true(1) if the pin is set otherwise false(0).

Returns
boolean.

Definition at line 112 of file Pin.hh.

static uint8_t Pin::MASK ( uint8_t  pin)
inlinestaticinherited

Return bit mask for given Arduino pin number.

Parameters
[in]pinnumber.
Returns
pin bit mask.

Definition at line 42 of file Pin.hh.

Mode InputPin::mode ( ) const
inline

Get current input pin mode.

Returns
mode.

Definition at line 52 of file InputPin.hh.

static void InputPin::mode ( Board::DigitalPin  pin,
Mode  mode 
)
inlinestatic

Set input pin to given mode.

Parameters
[in]pinnumber.
[in]modepin mode.
Note
atomic

Definition at line 64 of file InputPin.hh.

static Mode InputPin::mode ( Board::DigitalPin  pin)
inlinestatic

Get input pin mode.

Parameters
[in]pinnumber.
Returns
mode.

Definition at line 80 of file InputPin.hh.

Pin::operator bool ( ) const
inlineinherited

Read input pin and assign variable.

Parameters
[out]varto assign.
Returns
pin.

Definition at line 204 of file Pin.hh.

Pin& Pin::operator>> ( uint8_t &  var)
inlineinherited

Read input pin and assign variable.

Parameters
[out]varto assign.
Returns
pin.

Definition at line 215 of file Pin.hh.

volatile uint8_t* Pin::PCIMR ( ) const
inlineprotectedinherited

Return pin change interrupt mask register.

Returns
pin change mask register pointer.

Definition at line 263 of file Pin.hh.

static volatile uint8_t* Pin::PIN ( uint8_t  pin)
inlinestaticinherited

Return pointer to PIN register.

Parameters
[in]pinnumber.
Returns
PIN register pointer.

Definition at line 53 of file Pin.hh.

uint8_t Pin::pin ( ) const
inlineinherited

Return Arduino pin number of abstract pin.

Returns
pin number.

Definition at line 103 of file Pin.hh.

volatile uint8_t* Pin::PIN ( ) const
inlineprotectedinherited

Return pointer to PIN register.

Returns
PIN register pointer.

Definition at line 236 of file Pin.hh.

static volatile uint8_t* Pin::PORT ( uint8_t  pin)
inlinestaticinherited

Return pointer to data PORT register.

Parameters
[in]pinnumber.
Returns
PORT register pointer.

Definition at line 75 of file Pin.hh.

volatile uint8_t* Pin::PORT ( ) const
inlineprotectedinherited

Return pointer to data PORT register.

Returns
PORT register pointer.

Definition at line 254 of file Pin.hh.

bool Pin::read ( ) const
inlineinherited

Return true(1) if the pin is set otherwise false(0).

Returns
boolean.

Definition at line 172 of file Pin.hh.

uint8_t Pin::read ( OutputPin clk,
Direction  order = MSB_FIRST 
) const
inherited

Shift in a byte from the input pin using the given clock output pin. Shift in according to given direction.

Parameters
[in]clkoutput pin.
[in]orderbit first.
Returns
value.

Definition at line 25 of file Pin.cpp.

static bool Pin::read ( Board::DigitalPin  pin)
inlinestaticinherited

Use pin number directly to read value. Does not require an instance. Return true(1) if the pin is set otherwise false(0).

Parameters
[in]pinnumber.
Returns
boolean.

Definition at line 193 of file Pin.hh.

Member Data Documentation

const uint8_t Pin::m_mask
protectedinherited

Pin mask in port.

Definition at line 227 of file Pin.hh.

const uint8_t Pin::m_pin
protectedinherited

Pin identity.

Definition at line 230 of file Pin.hh.

volatile uint8_t* const Pin::m_sfr
protectedinherited

Special function register pointer.

Definition at line 224 of file Pin.hh.


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