Output Pin#

Hardware Interface#

Defined in namespace hal

#include <libhal/output_pin.hpp>

class output_pin#

Digital output pin hardware abstraction.

Use this to drive a pin HIGH or LOW in order to send a control signal or turn off or on an LED.

Implementations of this interface can be backed by external devices such as I/O expanders or other micro-controllers.

Subclassed by hal::lpc40::output_pin, hal::mock::output_pin, hal::soft::inert_output_pin, hal::soft::output_pin_inverter, hal::stm32f1::output_pin, hal::stm32f411::output_pin

Public Functions

inline void configure(settings const &p_settings)#

Configure the output pin to match the settings supplied.

Parameters:

p_settings – - settings to apply to output pin

Throws:

hal::operation_not_supported – - if the settings could not be achieved.

inline void level(bool p_high)#

Set the state of the pin.

Parameters:

p_high – - if true then the pin state is set to HIGH voltage. If false, the pin state is set to LOW voltage.

inline bool level()#

Implementations must read the pin state from hardware and will not simply cache the results from the execution of level(bool).

This pin may not equal the state set by level(bool) when the pin is configured as open-drain.

Returns:

true - if the level of the pin is HIGH

Returns:

false - if the level of the pin is LOW

struct settings#

Generic settings for output pins.

Public Members

pin_resistor resistor = pin_resistor::none#

Pull resistor for the pin. This generally only helpful when open drain is enabled.

bool open_drain = false#

Starting level of the output pin. HIGH voltage defined as true and LOW voltage defined as false.

Utilities#

Defined in namespace hal

#include <libhal-util/output_pin.hpp>

group OutputPin

Functions

constexpr auto operator==(output_pin::settings const &p_lhs, output_pin::settings const &p_rhs)#

Compares two output pin states, compares both resistor and open drain.

Parameters:
  • p_lhs – An output pin

  • p_rhs – An output pin

Returns:

A boolean if they are the same or not.