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

#include <Pin.hh>

Inheritance diagram for Pin:
Inheritance graph
Collaboration diagram for Pin:
Collaboration graph

Public Types

enum  Direction { MSB_FIRST = 0, LSB_FIRST = 1 }
 

Public Member Functions

 Pin (uint8_t pin)
 
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 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

Arduino pins abstractions; abstract, input, output, interrupt and analog pin. Captures the mapping from Arduino to processor pins. Forces declarative programming of pins in sketches.

Definition at line 35 of file Pin.hh.

Member Enumeration Documentation

Serialization directions; most or least significant bit first.

Enumerator
MSB_FIRST 
LSB_FIRST 

Definition at line 84 of file Pin.hh.

Constructor & Destructor Documentation

Pin::Pin ( uint8_t  pin)
inline

Construct abstract pin given Arduino pin number.

Parameters
[in]pinnumber.

Definition at line 93 of file Pin.hh.

Member Function Documentation

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

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
inlineprotected

Return pointer to Data Direction Register.

Returns
DDR register pointer.

Definition at line 245 of file Pin.hh.

bool Pin::is_clear ( ) const
inline

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
inline

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
inline

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
inline

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
inline

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
inline

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)
inlinestatic

Return bit mask for given Arduino pin number.

Parameters
[in]pinnumber.
Returns
pin bit mask.

Definition at line 42 of file Pin.hh.

Pin::operator bool ( ) const
inline

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)
inline

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
inlineprotected

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)
inlinestatic

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
inline

Return Arduino pin number of abstract pin.

Returns
pin number.

Definition at line 103 of file Pin.hh.

volatile uint8_t* Pin::PIN ( ) const
inlineprotected

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)
inlinestatic

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
inlineprotected

Return pointer to data PORT register.

Returns
PORT register pointer.

Definition at line 254 of file Pin.hh.

bool Pin::read ( ) const
inline

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

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)
inlinestatic

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
protected

Pin mask in port.

Definition at line 227 of file Pin.hh.

const uint8_t Pin::m_pin
protected

Pin identity.

Definition at line 230 of file Pin.hh.

volatile uint8_t* const Pin::m_sfr
protected

Special function register pointer.

Definition at line 224 of file Pin.hh.


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