stm32f103
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
GPIO Class Reference

HAL implementation for GPIO pins. More...

#include <gpio.h>

Classes

struct  Config
 Configuration for an individual GPIO pin. More...
 

Public Member Functions

 GPIO (const Config &config)
 Constructor for Gpio class. More...
 
void Set (bool state)
 Sets this GPIO state based on passed in boolean. More...
 
void Toggle ()
 Toggles GPIO state, Logic High -> Logic Low and vice versa. More...
 
bool Read ()
 Read the current logic state of GPIO. More...
 
uint16_t GetPinSource ()
 
GPIO_TypeDef * GetPort ()
 
uint16_t GetPin ()
 

Protected Member Functions

void Init (GPIOMode_TypeDef mode, GPIOSpeed_TypeDef speed, uint32_t rcc=0)
 Performs initialization of this GPIO. More...
 
void Rcc (FunctionalState state, uint32_t rcc=0)
 Enables/Disables RCC. More...
 

Detailed Description

HAL implementation for GPIO pins.

Constructor & Destructor Documentation

GPIO::GPIO ( const Config config)
explicit

Constructor for Gpio class.

Parameters
configGPIO configuration settings

Here is the call graph for this function:

Member Function Documentation

uint16_t GPIO::GetPin ( )
Returns
Pin mask representation of currently configured pin.

Under the hood this returns the value of GPIO_Pin_X where X is the pin number. This differs from GPIO_PinSourceX in that it returns the register mask value ( 1 << X ) of the pin eg. Pin 15 -> 0x8000 whereas GPIO_PinSourceX returns the actual pin number eg. 0x000F

uint16_t GPIO::GetPinSource ( )
Returns
Pin number representation of currently configured pin.

Under the hood this returns the value of GPIO_PinSourceX where X is the pin number. This differs from GPIO_Pin_X in that it returns the actual number of the pin eg. Pin 15 -> 0x000F, whereas GPIO_Pin_X returns a register mask value, eg. ( 1 << X )

GPIO_TypeDef * GPIO::GetPort ( )
Returns
Port for the current GPIO
void GPIO::Init ( GPIOMode_TypeDef  mode,
GPIOSpeed_TypeDef  speed,
uint32_t  rcc = 0 
)
protected

Performs initialization of this GPIO.

Parameters
modeGPIO mode
speedGPIO maximum output speed
rccExtra configuration values for Reset and Clock Control

Here is the call graph for this function:

Here is the caller graph for this function:

void GPIO::Rcc ( FunctionalState  state,
uint32_t  rcc = 0 
)
protected

Enables/Disables RCC.

Parameters
stateENABLE or DISABLE
rccExtra configuration values for Reset and Clock Control

Here is the caller graph for this function:

bool GPIO::Read ( )

Read the current logic state of GPIO.

Returns
Current state of GPIO, where true represents a high value, and false represents a low value.

Here is the caller graph for this function:

void GPIO::Set ( bool  state)

Sets this GPIO state based on passed in boolean.

Parameters
stateNew state of GPIO
Value Effect
true Drives the GPIO pin to logic high
false Drives the GPIO pin to logic low

Here is the caller graph for this function:

void GPIO::Toggle ( )

Toggles GPIO state, Logic High -> Logic Low and vice versa.

Here is the call graph for this function:


The documentation for this class was generated from the following files: