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

#include <GPIO.hh>

Collaboration diagram for GPIO:
Collaboration graph

Public Types

enum  Mode { OUTPUT_MODE, INPUT_MODE, PULLUP_INPUT_MODE }
 

Public Member Functions

 GPIO (Board::DigitalPin pin, Mode mode=INPUT_MODE, bool value=0)
 
void mode (Mode mode) const
 
Mode mode () const
 
 operator bool () const
 
GPIOoperator= (bool value)
 
GPIOoperator= (const GPIO &rhs)
 
void operator~ () const
 

Static Public Member Functions

static void mode (Board::DigitalPin pin, Mode mode)
 
static Mode mode (Board::DigitalPin pin)
 
static bool read (Board::DigitalPin pin)
 
static void write (Board::DigitalPin pin, bool value)
 
static void toggle (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)
 

Protected Member Functions

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

Protected Attributes

volatile uint8_t *const m_sfr
 
const uint8_t m_mask
 

Detailed Description

High Performance General Purpose Input Output (GPIO) Pin abstraction.

Definition at line 30 of file GPIO.hh.

Member Enumeration Documentation

enum GPIO::Mode

Pin modes.

Enumerator
OUTPUT_MODE 
INPUT_MODE 
PULLUP_INPUT_MODE 

Definition at line 35 of file GPIO.hh.

Constructor & Destructor Documentation

GPIO::GPIO ( Board::DigitalPin  pin,
Mode  mode = INPUT_MODE,
bool  value = 0 
)
inline

Construct general purpose pin object for given digital pin with given input/output mode and initial value.

Parameters
[in]pinidentity.
[in]modeinput/output mode.
[in]valueinitial value of port.
Note
atomic

Definition at line 49 of file GPIO.hh.

Member Function Documentation

volatile uint8_t* GPIO::DDR ( ) const
inlineprotected

Return pointer to Data Direction Register.

Returns
DDR register pointer.

Definition at line 294 of file GPIO.hh.

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

Return pointer to Data Direction Register for given pin identity.

Parameters
[in]pinidentity.
Returns
DDR register pointer.

Definition at line 336 of file GPIO.hh.

static uint8_t GPIO::MASK ( uint8_t  pin)
inlinestatic

Return bit mask for given pin identity.

Parameters
[in]pinidentity.
Returns
pin bit mask.

Definition at line 314 of file GPIO.hh.

void GPIO::mode ( Mode  mode) const
inline

Set pin input/output mode.

Parameters
modeinput or output mode.
Note
atomic

Definition at line 74 of file GPIO.hh.

Mode GPIO::mode ( ) const
inline

Get pin input/output mode.

Returns
mode.

Definition at line 92 of file GPIO.hh.

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

Set pin input/output mode. Does not require an instance.

Parameters
modeinput or output mode.
Note
atomic

Definition at line 166 of file GPIO.hh.

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

Get pin input/output mode. Does not require an instance.

Returns
mode.

Definition at line 185 of file GPIO.hh.

GPIO::operator bool ( ) const
inline

Read pin state and return true(1) if set else false(0).

Returns
bool.

Definition at line 106 of file GPIO.hh.

GPIO& GPIO::operator= ( bool  value)
inline

Set the pin to the given value.

Parameters
[in]valueto set.
Note
atomic

Definition at line 117 of file GPIO.hh.

GPIO& GPIO::operator= ( const GPIO rhs)
inline

Set the pin state with value of given pin.

Parameters
[in]rhspin value to set.
Note
atomic

Definition at line 136 of file GPIO.hh.

void GPIO::operator~ ( ) const
inline

Toggle the pin state.

Note
atomic

Definition at line 155 of file GPIO.hh.

volatile uint8_t* GPIO::PIN ( ) const
inlineprotected

Return pointer to PIN register.

Returns
PIN register pointer.

Definition at line 285 of file GPIO.hh.

static volatile uint8_t* GPIO::PIN ( uint8_t  pin)
inlinestatic

Return pointer to PIN register for given pin identity.

Parameters
[in]pinidentity.
Returns
PIN register pointer.

Definition at line 324 of file GPIO.hh.

volatile uint8_t* GPIO::PORT ( ) const
inlineprotected

Return pointer to data PORT register.

Returns
PORT register pointer.

Definition at line 303 of file GPIO.hh.

static volatile uint8_t* GPIO::PORT ( uint8_t  pin)
inlinestatic

Return pointer to data PORT register for given pin identity.

Parameters
[in]pinidentity.
Returns
PORT register pointer.

Definition at line 347 of file GPIO.hh.

static bool GPIO::read ( Board::DigitalPin  pin)
inlinestatic

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

Parameters
[in]pinidentity.
Returns
bool.

Definition at line 202 of file GPIO.hh.

static void GPIO::toggle ( Board::DigitalPin  pin)
inlinestatic

Use pin identity directly to toggle pin state. Does not require an instance.

Parameters
[in]pinidentity.
Note
atomic

Definition at line 254 of file GPIO.hh.

static void GPIO::write ( Board::DigitalPin  pin,
bool  value 
)
inlinestatic

Use pin identity directly to write pin state. Does not require an instance.

Parameters
[in]pinidentity..
[in]valueto write.
Note
atomic

Definition at line 215 of file GPIO.hh.

Member Data Documentation

const uint8_t GPIO::m_mask
protected

Pin mask in port.

Definition at line 279 of file GPIO.hh.

volatile uint8_t* const GPIO::m_sfr
protected

Special function register pointer.

Definition at line 276 of file GPIO.hh.


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