FastArduino v1.10
C++ library to build fast but small Arduino/AVR projects
Loading...
Searching...
No Matches
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. More...
 
using PORT_TYPE = FastPort< PORT >
 The exact FastPort parameterized type that DPIN IO pin belongs to. More...
 

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. More...
 
static constexpr const board::Port PORT = TRAIT::PORT
 The port to which DPIN belongs. More...
 
static constexpr const uint8_t BIT = TRAIT::BIT
 The bit position of DPIN within its port. More...
 
static constexpr const uint8_t MASK = bits::BV8(BIT)
 The bit-mask to use when accessing DPIN through PORT. More...
 

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();
}
API that manipulates one digital IO pin of a given port.
Definition: gpio.h:90
@ OUTPUT
Digital pin is configured as output.

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

void f()
{
...
}
static void set_mode(PinMode mode, bool value=false)
Set mode (direction) and value (if output) of DPIN.
Definition: gpio.h:580
@ INPUT
Digital pin is configured as high-impedance (open drain) input.
Template Parameters
DPIN_a unique digital pin for the MCU target
See also
gpio::DigitalPin
gpio::FastPin
FAST_PIN

Definition at line 550 of file gpio.h.

Member Typedef Documentation

◆ TYPE

template<board::DigitalPin DPIN_>
using gpio::FastPinType< DPIN_ >::TYPE = FastPin<PORT, BIT>

The exact FastPin parameterized type for DPIN IO pin.

Definition at line 569 of file gpio.h.

◆ PORT_TYPE

template<board::DigitalPin DPIN_>
using gpio::FastPinType< DPIN_ >::PORT_TYPE = FastPort<PORT>

The exact FastPort parameterized type that DPIN IO pin belongs to.

Definition at line 571 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 580 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 596 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 605 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 615 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 625 of file gpio.h.

Member Data Documentation

◆ DPIN

template<board::DigitalPin DPIN_>
constexpr const board::DigitalPin gpio::FastPinType< DPIN_ >::DPIN = DPIN_
staticconstexpr

The digital pin for this FastPinType.

Definition at line 560 of file gpio.h.

◆ PORT

template<board::DigitalPin DPIN_>
constexpr const board::Port gpio::FastPinType< DPIN_ >::PORT = TRAIT::PORT
staticconstexpr

The port to which DPIN belongs.

Definition at line 562 of file gpio.h.

◆ BIT

template<board::DigitalPin DPIN_>
constexpr const uint8_t gpio::FastPinType< DPIN_ >::BIT = TRAIT::BIT
staticconstexpr

The bit position of DPIN within its port.

Definition at line 564 of file gpio.h.

◆ MASK

template<board::DigitalPin DPIN_>
constexpr const uint8_t gpio::FastPinType< DPIN_ >::MASK = bits::BV8(BIT)
staticconstexpr

The bit-mask to use when accessing DPIN through PORT.

Definition at line 566 of file gpio.h.


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