semf
semf::Stm32Gpio Class Reference

Gpio implementation for STM32. More...

#include <stm32gpio.h>

Inheritance diagram for semf::Stm32Gpio:
Inheritance graph
Collaboration diagram for semf::Stm32Gpio:
Collaboration graph

Public Member Functions

 Stm32Gpio (GPIO_TypeDef *port, uint16_t pin)
 Constructor. More...
 
 Stm32Gpio (const Stm32Gpio &other)=delete
 
virtual ~Stm32Gpio ()=default
 
void set () override
 
void reset () override
 
bool state () const override
 Returns the current state of the pin. More...
 
Direction direction () const override
 Returns the direction setting of a GPIO. More...
 
void setDirection (Direction direction) override
 Sets the direction of a GPIO. More...
 
PullUpPullDown pullUpPullDown () const override
 Returns the pullup or pulldown setting of a GPIO. More...
 
void setPullUpPullDown (PullUpPullDown pullUpPullDown) override
 Sets the pullup or pulldown setting of a GPIO. More...
 
- Public Member Functions inherited from semf::Gpio
virtual ~Gpio ()=default
 
virtual void set ()=0
 
virtual void reset ()=0
 
virtual bool state () const =0
 Returns the current state of the pin. More...
 
virtual Direction direction () const =0
 Returns the direction setting of a GPIO. More...
 
virtual void setDirection (Direction direction)=0
 Sets the direction of a GPIO. More...
 
virtual PullUpPullDown pullUpPullDown () const =0
 Returns the pullup or pulldown setting of a GPIO. More...
 
virtual void setPullUpPullDown (PullUpPullDown pullUpPullDown)=0
 Sets the pullup or pulldown setting of a GPIO. More...
 

Protected Member Functions

GPIO_TypeDef * port () const
 Returns the GPIO handler. More...
 
GPIO_TypeDef * port ()
 Returns the GPIO handler. More...
 
uint16_t pin () const
 Returns pin number. More...
 
uint16_t pinNumberToIOPosition (uint16_t pin) const
 Returns the io position based on the pin number. More...
 

Additional Inherited Members

- Public Types inherited from semf::Gpio
enum  Direction { Input = 0 , OutputPushpull , OutputOpendrain }
 
enum  PullUpPullDown { NoPullupPulldown = 0 , Pullup , Pulldown }
 
- Public Attributes inherited from semf::Gpio
Signal< Errorerror
 

Detailed Description

Gpio implementation for STM32.

Definition at line 22 of file stm32gpio.h.

Constructor & Destructor Documentation

◆ Stm32Gpio() [1/2]

semf::Stm32Gpio::Stm32Gpio ( GPIO_TypeDef *  port,
uint16_t  pin 
)

Constructor.

Parameters
portPort of GPIO.
pinPin of GPIO.

Definition at line 16 of file stm32gpio.cpp.

◆ Stm32Gpio() [2/2]

semf::Stm32Gpio::Stm32Gpio ( const Stm32Gpio other)
explicitdelete

◆ ~Stm32Gpio()

virtual semf::Stm32Gpio::~Stm32Gpio ( )
virtualdefault

Member Function Documentation

◆ direction()

Gpio::Direction semf::Stm32Gpio::direction ( ) const
overridevirtual

Returns the direction setting of a GPIO.

Returns
INPUT or OUTPUT.

Implements semf::Gpio.

Definition at line 50 of file stm32gpio.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pin()

uint16_t semf::Stm32Gpio::pin ( ) const
protected

Returns pin number.

Returns
Pin number.

Definition at line 148 of file stm32gpio.cpp.

Here is the caller graph for this function:

◆ pinNumberToIOPosition()

uint16_t semf::Stm32Gpio::pinNumberToIOPosition ( uint16_t  pin) const
protected

Returns the io position based on the pin number.

Parameters
pinNumber of pin, given by STM HAL.
Returns
Bit position to set IO registers.

Definition at line 153 of file stm32gpio.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ port() [1/2]

GPIO_TypeDef * semf::Stm32Gpio::port ( )
protected

Returns the GPIO handler.

Returns
Pointer to the GPIO handler.

Definition at line 143 of file stm32gpio.cpp.

◆ port() [2/2]

GPIO_TypeDef * semf::Stm32Gpio::port ( ) const
protected

Returns the GPIO handler.

Returns
Pointer to the GPIO handler.

Definition at line 138 of file stm32gpio.cpp.

◆ pullUpPullDown()

Gpio::PullUpPullDown semf::Stm32Gpio::pullUpPullDown ( ) const
overridevirtual

Returns the pullup or pulldown setting of a GPIO.

Returns
NoPullupPulldown, Pullup or Pulldown.

Implements semf::Gpio.

Definition at line 93 of file stm32gpio.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reset()

void semf::Stm32Gpio::reset ( )
overridevirtual

Sets the output to a low level.

Implements semf::Gpio.

Definition at line 28 of file stm32gpio.cpp.

◆ set()

void semf::Stm32Gpio::set ( )
overridevirtual

Sets the output to a high level.

Implements semf::Gpio.

Definition at line 22 of file stm32gpio.cpp.

◆ setDirection()

void semf::Stm32Gpio::setDirection ( Direction  direction)
overridevirtual

Sets the direction of a GPIO.

Parameters
directiondirection to set.

Implements semf::Gpio.

Definition at line 63 of file stm32gpio.cpp.

Here is the call graph for this function:

◆ setPullUpPullDown()

void semf::Stm32Gpio::setPullUpPullDown ( PullUpPullDown  pullUpPullDown)
overridevirtual

Sets the pullup or pulldown setting of a GPIO.

Parameters
pullUpPullDownpullup/pulldown for setting up.

Implements semf::Gpio.

Definition at line 113 of file stm32gpio.cpp.

Here is the call graph for this function:

◆ state()

bool semf::Stm32Gpio::state ( ) const
overridevirtual

Returns the current state of the pin.

Returns
true for high level, false for low level.

Implements semf::Gpio.

Definition at line 34 of file stm32gpio.cpp.

Here is the call graph for this function:
Here is the caller graph for this function: