STM32LIB
Public Types | Public Member Functions | Private Attributes | List of all members
STM32LIB::GPIO Class Reference

GPIO Access class. More...

#include <GPIO.hpp>

Public Types

enum  PinFunction { PIN_INPUT = 0x00, PIN_OUTPUT = 0x01, PIN_ALTERNATE = 0x02, PIN_ANALOG = 0x03 }
 
enum  PinMode {
  PullNone = 0, PullUp = 1, PullDown = 2, OpenDrain = 3,
  PullDefault = PullNone
}
 
enum  PortName {
  PortA = 0, PortB = 1, PortC = 2, PortD = 3,
  PortF = 5
}
 
enum  PinSpeed { Slow = 0x00, Medium = 0x01, Fast = 0x03 }
 

Public Member Functions

void init (PinName pin_name, PinFunction func, PinMode mode, PinSpeed speed)
 GPIO initiation function. More...
 
void change_dir (PinFunction func)
 Change the pin direction. More...
 
void change_speed (PinSpeed speed)
 Change the pin speed. More...
 
void change_mode (PinMode mode)
 Change the pin mode. More...
 
bool read ()
 Read the pin status. More...
 
void write (bool value)
 Write to the pin. More...
 
void toggle ()
 Toggle the pin status. More...
 
void enableInterrupt (EXTI_CONTROLER::_Mode mode, EXTI_CONTROLER::_Trigger trigger)
 
void disableInterrupt (void)
 
void bind (wink::slot< void(uint16_t)> handler)
 

Private Attributes

GPIO_TypeDef * gpioX
 
PinName pin
 
uint16_t pin_mask
 

Detailed Description

GPIO Access class.

usage:

GPIO LED;
LED.toggle();

Member Enumeration Documentation

Pin Function

Enumerator
PIN_INPUT 
PIN_OUTPUT 
PIN_ALTERNATE 
PIN_ANALOG 

Pin Mode

Enumerator
PullNone 
PullUp 
PullDown 
OpenDrain 
PullDefault 

Port Name

Enumerator
PortA 
PortB 
PortC 
PortD 
PortF 

Pin Speed

Enumerator
Slow 
Medium 
Fast 

Member Function Documentation

void STM32LIB::GPIO::init ( PinName  pin_name,
PinFunction  func,
PinMode  mode,
PinSpeed  speed 
)
inline

GPIO initiation function.

Initiates a specific pin, enabling the peripheral clock and setting it's properties

Parameters
pin_nameThe chip pin name
funcThe function of the pin (one of the PinFunction)
modeThe Pullup/Pulldown/OpenDrain of the pin
speedThe pin speed (more speed = more energy)
Returns
void STM32LIB::GPIO::change_dir ( PinFunction  func)
inline

Change the pin direction.

After the pin is initialized it allow to change the pin direction

Parameters
funcThe pin function as per PinFunction
void STM32LIB::GPIO::change_speed ( PinSpeed  speed)
inline

Change the pin speed.

After the pin is initialized it allow to change the pin speed

Parameters
funcThe pin speed as per PinSpeed
void STM32LIB::GPIO::change_mode ( PinMode  mode)
inline

Change the pin mode.

After the pin is initialized it allow to change the pin mode

Parameters
funcThe pin function as per PinMode
bool GPIO::read ( )
inline

Read the pin status.

Returns
True if pin voltage = vcc, false otherwise
void GPIO::write ( bool  value)
inline

Write to the pin.

Use atomic write

Parameters
valueThe value to write to the pin
void GPIO::toggle ( )
inline

Toggle the pin status.

It uses a more slowly method than the read() function

void STM32LIB::GPIO::enableInterrupt ( EXTI_CONTROLER::_Mode  mode,
EXTI_CONTROLER::_Trigger  trigger 
)
inline
void STM32LIB::GPIO::disableInterrupt ( void  )
inline
void STM32LIB::GPIO::bind ( wink::slot< void(uint16_t)>  handler)
inline

Member Data Documentation

GPIO_TypeDef* STM32LIB::GPIO::gpioX
private
PinName STM32LIB::GPIO::pin
private
uint16_t STM32LIB::GPIO::pin_mask
private

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