DigitalOut
General
The class DigitalOut has as main goal the handling of a digital output signal. To configure an inverted output, please do that by calling the setInverted function. This class is dependent on a semf-supplied interface class Gpio, which links the hardware output pin of the microcontroller and the semf library.
Initialization
The first step for setting up the DigitalOut object is to configure a hardware GPIO pin to a digital output. The second step is creating a Gpio object and passing the port number and the pin number to it. Thirdly, the Gpio object is passed to DigitalOut object by registerInterface function.imer resolution via setTicksPerSecond(). This value must correspond to the hardware configuration.
In this example, we consider the hardware port A and pin 01.
// Inclusion of the predeclared and predefined class in the project. #include "stm32l0gpio.h" #include "Components/Input/digitalout.h" // 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();