FastArduino  v1.7
C++ library to build fast but small Arduino/AVR projects
gpio::FastPinType< DPIN_ > Class Template Reference

API that manipulates a given digital IO pin of a the target MCU. More...

#include <fastarduino/gpio.h>

Public Types

using TYPE = FastPin< PORT, BIT >
 The exact FastPin parameterized type for DPIN IO pin.
 
using PORT_TYPE = FastPort< PORT >
 The exact FastPort parameterized type that DPIN IO pin belongs to.
 

Static Public Member Functions

static void set_mode (PinMode mode, bool value=false)
 Set mode (direction) and value (if output) of DPIN. More...
 
static void set ()
 Set pin level to HIGH (i.e. More...
 
static void clear ()
 Set pin level to LOW (i.e. More...
 
static void toggle ()
 Toggle pin level, i.e. More...
 
static bool value ()
 Return the current level pin DPIN. More...
 

Static Public Attributes

static constexpr const board::DigitalPin DPIN = DPIN_
 The digital pin for this FastPinType.
 
static constexpr const board::Port PORT = TRAIT::PORT
 The port to which DPIN belongs.
 
static constexpr const uint8_t BIT = TRAIT::BIT
 The bit position of DPIN within its port.
 
static constexpr const uint8_t MASK = bits::BV8(BIT)
 The bit-mask to use when accessing DPIN through PORT.
 

Detailed Description

template<board::DigitalPin DPIN_>
class gpio::FastPinType< DPIN_ >

API that manipulates a given digital IO pin of a the target MCU.

It provides static methods to directly manipulate an IO pin (mode, level...) but it also helps you find out the exact FastPin type for a given IO pin.

Implementation is highly optimized for size and speed: it uses no SRAM at all, most common methods use only 1 AVR instruction.

The following snippet demonstrates usage of FastPinType to declare a FastPin instance for later use in a function:

void f()
{
led.clear();
...
led.set();
}

The next snippet demonstrate direct use of FastPinType static methods, when you don't need an instance of FastPin:

void f()
{
...
}
Template Parameters
DPIN_a unique digital pin for the MCU target
See also
gpio::DigitalPin
gpio::FastPin
FAST_PIN

Definition at line 544 of file gpio.h.

Member Function Documentation

◆ set_mode()

template<board::DigitalPin DPIN_>
static void gpio::FastPinType< DPIN_ >::set_mode ( PinMode  mode,
bool  value = false 
)
inlinestatic

Set mode (direction) and value (if output) of DPIN.

Parameters
modethe mode of PIN
valuethe initial pin level, if mode == PinMode::OUTPUT; not used otherwise.

Definition at line 574 of file gpio.h.

◆ set()

template<board::DigitalPin DPIN_>
static void gpio::FastPinType< DPIN_ >::set ( )
inlinestatic

Set pin level to HIGH (i.e.

Vcc). This method will generally use 1 single instruction in most cases.

Definition at line 590 of file gpio.h.

◆ clear()

template<board::DigitalPin DPIN_>
static void gpio::FastPinType< DPIN_ >::clear ( )
inlinestatic

Set pin level to LOW (i.e.

GND). This method will generally use 1 single instruction in most cases.

Definition at line 599 of file gpio.h.

◆ toggle()

template<board::DigitalPin DPIN_>
static void gpio::FastPinType< DPIN_ >::toggle ( )
inlinestatic

Toggle pin level, i.e.

set it to LOW if it was HIGH, and HIGH if it was LOW. This method will generally use 1 single instruction in most cases.

Definition at line 609 of file gpio.h.

◆ value()

template<board::DigitalPin DPIN_>
static bool gpio::FastPinType< DPIN_ >::value ( )
inlinestatic

Return the current level pin DPIN.

Return values
trueif current pin level is HIGH (i.e. Vcc)
falseif current pin level is LOW (i.e. GND)

Definition at line 619 of file gpio.h.


The documentation for this class was generated from the following file:
gpio::FastPinType::set_mode
static void set_mode(PinMode mode, bool value=false)
Set mode (direction) and value (if output) of DPIN.
Definition: gpio.h:574
gpio::FastPin
API that manipulates one digital IO pin of a given port.
Definition: gpio.h:90
gpio::PinMode::OUTPUT
@ OUTPUT
Digital pin is configured as output.