Rpi-hw  0.7.2
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
rpihw::gpio Class Reference

Virtual GPIO controller. More...

#include <gpio.hpp>

Public Member Functions

virtual ~gpio ()
 Destructor method.
 
template<typename T >
void expand (uint8_t pin_base, T &expander)
 Adds a I/O expander to the standard GPIO connector. More...
 
void setup (uint8_t pin, uint8_t mode, uint8_t pull_mode=PULL_OFF)
 Sets the mode of a GPIO pin. More...
 
void write (uint8_t pin, bool value)
 Sets the value of a output pin. More...
 
bool read (uint8_t pin)
 Returns the value of a input pin. More...
 
bool checkEvent (uint8_t pin)
 Returns the event state of a GPIO pin. More...
 
void setRisingEvent (uint8_t pin, bool enabled)
 Enables/disables the rising edge event on a GPIO pin. More...
 
void setFallingEvent (uint8_t pin, bool enabled)
 Enables/disables the falling edge event on a GPIO pin. More...
 
void setHighEvent (uint8_t pin, bool enabled)
 Enables/disables the high event on a GPIO pin. More...
 
void setLowEvent (uint8_t pin, bool enabled)
 Enables/disables the low event on a GPIO pin. More...
 
void setPullUpDown (uint8_t pin, uint8_t mode)
 Enables/disables the pull-up/down control on a GPIO pin. More...
 

Static Public Member Functions

static gpioget ()
 Returns the singleton instance.
 

Private Member Functions

expander_slotfindExpander (uint8_t pin)
 Finds the I/O expander with a specific pin index. More...
 
 gpio ()
 Constructor method.
 
 gpio (const gpio &other)=delete
 Disables the copy constructor.
 
void operator= (const gpio &other)=delete
 Disables the copy constructor.
 

Private Attributes

driver::bcm2835m_bcm2835
 Broadcom BCM2835 controller.
 
std::vector< expander_slotm_expanders
 List of I/O expanders.
 

Detailed Description

Virtual GPIO controller.

Examples:
blink.cpp, driver/mcp23017.cpp, and driver/mcp23s17.cpp.

Definition at line 63 of file gpio.hpp.

Member Function Documentation

bool rpihw::gpio::checkEvent ( uint8_t  pin)

Returns the event state of a GPIO pin.

Parameters
[in]pinThe GPIO pin.
Returns
The event state.
template<typename T >
void rpihw::gpio::expand ( uint8_t  pin_base,
T &  expander 
)

Adds a I/O expander to the standard GPIO connector.

Parameters
[in]pin_baseThe user-defined pin base for the I/O expander.
[in]expanderThe I/O expander.
Examples:
driver/mcp23017.cpp, and driver/mcp23s17.cpp.

Definition at line 29 of file gpio-inl.hpp.

expander_slot& rpihw::gpio::findExpander ( uint8_t  pin)
private

Finds the I/O expander with a specific pin index.

Parameters
[in]pinThe GPIO pin.
Returns
A pointer to the I/O expander.
bool rpihw::gpio::read ( uint8_t  pin)

Returns the value of a input pin.

Parameters
[in]pinThe input pin.
Returns
The value of input pin.
void rpihw::gpio::setFallingEvent ( uint8_t  pin,
bool  enabled 
)

Enables/disables the falling edge event on a GPIO pin.

Parameters
[in]pinThe GPIO pin.
[in]enabledIf true enable the falling edge event.
void rpihw::gpio::setHighEvent ( uint8_t  pin,
bool  enabled 
)

Enables/disables the high event on a GPIO pin.

Parameters
[in]pinThe GPIO pin.
[in]enabledIf true enable the high event.
void rpihw::gpio::setLowEvent ( uint8_t  pin,
bool  enabled 
)

Enables/disables the low event on a GPIO pin.

Parameters
[in]pinThe GPIO pin.
[in]enabledIf true enable the low event.
void rpihw::gpio::setPullUpDown ( uint8_t  pin,
uint8_t  mode 
)

Enables/disables the pull-up/down control on a GPIO pin.

Parameters
[in]pinThe GPIO pin.
[in]modeThe pull resistor mode.
void rpihw::gpio::setRisingEvent ( uint8_t  pin,
bool  enabled 
)

Enables/disables the rising edge event on a GPIO pin.

Parameters
[in]pinThe GPIO pin.
[in]enabledIf true enable the rising edge event.
void rpihw::gpio::setup ( uint8_t  pin,
uint8_t  mode,
uint8_t  pull_mode = PULL_OFF 
)

Sets the mode of a GPIO pin.

Parameters
[in]pinThe GPIO pin.
[in]modeThe GPIO mode.
[in]pull_modeThe pull resistor mode.
Examples:
blink.cpp, driver/mcp23017.cpp, and driver/mcp23s17.cpp.
void rpihw::gpio::write ( uint8_t  pin,
bool  value 
)

Sets the value of a output pin.

Parameters
[in]pinThe output pin.
[in]valueThe value of output pin.
Examples:
blink.cpp, driver/mcp23017.cpp, and driver/mcp23s17.cpp.

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