Skip to content

Class hal::output_pin

ClassList > hal > output_pin

Digital output pin hardware abstraction. More...

  • #include <output_pin.hpp>

Inherited by the following classes: hal::lpc40::output_pin, hal::mock::output_pin, hal::soft::inert_output_pin, hal::soft::output_pin_inverter, hal::stm32f1::output_pin

Classes

Type Name
struct level_t
Pin level reading structure.
struct set_level_t
Feedback from setting the pin state.
struct settings
Generic settings for output pins.

Public Functions

Type Name
status configure (const settings & p_settings)
Configure the output pin to match the settings supplied.
result< set_level_t > level (bool p_high)
Set the state of the pin.
result< level_t > level ()
Read the current state of the output pin.
virtual ~output_pin () = default

Detailed Description

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.

Public Functions Documentation

function configure

Configure the output pin to match the settings supplied.

inline status hal::output_pin::configure (
    const settings & p_settings
) 

Parameters:

  • p_settings - settings to apply to output pin

Returns:

status - success or failure

Exception:

  • std::errc::invalid_argument if the settings could not be achieved.

function level [1/2]

Set the state of the pin.

inline result< set_level_t > hal::output_pin::level (
    bool p_high
) 

Parameters:

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

Returns:

result<set_level_t> - success or failure

function level [2/2]

Read the current state of the output pin.

inline result< level_t > hal::output_pin::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:

result<level_t> - return the current level state of the output pin

function ~output_pin

virtual hal::output_pin::~output_pin () = default

The documentation for this class was generated from the following file libraries/include/libhal/output_pin.hpp