semf
DigitalOut

General

The class semf::DigitalOut is used to handle a digital output signal. To configure an inverted output, call the setInverted() function. This class depends on a semf supplied interface class semf::Gpio which links the hardware output pin of the microcontroller and the semf library. The interface semf::app::DigitalOut abstracts this class for application usage.

In the class constructor output inversion option can be passed.

The hardware semf::Gpio pins can easily be configured either by using the vendors hardware configuration tool e.g. Stm32CubeMX or by calling the hardware functions for setting the pin.

Initialization

The first step for setting up the semf::DigitalOut object is to configure a hardware semf::Gpio pin to a digital output. The second step is to create a semf::Gpio object and pass the port number and the pin number to it. Thirdly the semf::Gpio object is passed to semf::DigitalOut object via Constructor.

In this example, we consider the hardware port A and pin 01.

// Microcontroller pin definitions are stored in 'main.h'.
#include "main.h"
semf::Stm32L0Gpio outPin(GPIOA, GPIO_PIN_1); // Interface class for the Gpio pin.
// Input parameter is the inversion option.
semf::DigOut digOutPin(outPin, false);

Usage

digOutPin.set();
digOutPin.reset();
digOutPin.toggle();