avr-classes
Public Member Functions | List of all members
GpioPortPin Class Reference

#include <gpioportpin.h>

Inheritance diagram for GpioPortPin:
GpioPin InputPin OutputPin

Public Member Functions

 GpioPortPin (GpioPort *port, uint8_t index)
 
virtual bool getValue (void) const override
 
virtual void setValue (bool value) override
 
virtual void setDirection (Direction dir) override
 
virtual void setPullup (bool state) override
 

Detailed Description

GPIO pin that can be used as input or output and allows changing direction at runtime. The GpioPortPin works with any GpioPort interface, as for example implemented by the PortA, PortB etc. classes that represent the AVR's GPIO ports.

Note
The GpioPortPin forwards its functions directly to the associated GpioPort device. That means for example when getting a value while configured as output, it will return the state that was set. When it is required to get the level that is actually applied, the direction must be changed to input first. Depending on the external circuit it also may take some time until a reliable value can be read.

Constructor & Destructor Documentation

◆ GpioPortPin()

GpioPortPin::GpioPortPin ( GpioPort port,
uint8_t  index 
)
inline

Constructor.

Parameters
portPointer to GPIO port the pin is located on.
indexZero based index of the pin within the port (e.g. index 2 on PortB results in the pin commonly called PB2).

Member Function Documentation

◆ getValue()

virtual bool GpioPortPin::getValue ( void  ) const
inlineoverridevirtual

Gets the value of the pin.

Returns
Value of the pin, true for HIGH level, false for LOW level.

Implements InputPin.

◆ setDirection()

virtual void GpioPortPin::setDirection ( Direction  dir)
inlineoverridevirtual

Configure direction (input/output) of pin.

Parameters
dirDirection to set.

Implements GpioPin.

◆ setPullup()

virtual void GpioPortPin::setPullup ( bool  state)
inlineoverridevirtual

Configure use of internal pullup resistors (if available) for pin.

Parameters
stateState of pullup resistors: true means active, false means inactive.

Implements GpioPin.

◆ setValue()

virtual void GpioPortPin::setValue ( bool  value)
inlineoverridevirtual

Sets the pin to the specified value.

Parameters
valueValue to set, true means HIGH level, false means LOW level.

Implements OutputPin.