Rpi-hw  0.7.2
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
rpihw::driver::mcp23x08 Class Referenceabstract

8-bit I/O Expander with SPI/I2C (skeleton). More...

#include <mcp23x08.hpp>

+ Inheritance diagram for rpihw::driver::mcp23x08:

Public Types

enum  Commands { WRITE = 0x40, READ = 0x41 }
 The controller command set. More...
 
enum  Registers {
  IODIR = 0x00, IPOL = 0x02, GPINTEN = 0x04, DEFVAL = 0x06,
  INTCON = 0x08, IOCON = 0x0a, GPPU = 0x0c, INTF = 0x0e,
  INTCAP = 0x10, GPIO = 0x12, OLAT = 0x14
}
 Device registers. More...
 
enum  Settings {
  INTPOL = 0x02, ODR = 0x04, HAEN = 0x08, DISSLW = 0x10,
  SEQOP = 0x20, MIRROR = 0x40, BANK = 0x80
}
 The controller configuration set (bit flags). More...
 

Public Member Functions

 mcp23x08 (const std::string &dev_path)
 Constructor method. More...
 
virtual ~mcp23x08 ()
 Destructor method.
 
void init ()
 Initialize the expander.
 
virtual void setup (uint8_t pin, uint8_t mode, uint8_t pull_mode=PULL_OFF)
 Sets the mode of a GPIO pin. More...
 
virtual void write (uint8_t pin, bool value)
 Sets the value of a output pin. More...
 
virtual bool read (uint8_t pin)
 Returns the value of a input pin. More...
 
virtual void setPullUpDown (uint8_t pin, uint8_t mode)
 Enables/disables the pull-up control on a GPIO pin. More...
 
- Public Member Functions inherited from rpihw::driver::io_expander
virtual bool checkEvent (uint8_t pin)
 Returns the event state of a GPIO pin. More...
 
virtual void setRisingEvent (uint8_t pin, bool enabled)
 Enables/disables the rising edge event on a GPIO pin. More...
 
virtual void setFallingEvent (uint8_t pin, bool enabled)
 Enables/disables the falling edge event on a GPIO pin. More...
 
virtual void setHighEvent (uint8_t pin, bool enabled)
 Enables/disables the high event on a GPIO pin. More...
 
virtual void setLowEvent (uint8_t pin, bool enabled)
 Enables/disables the low event on a GPIO pin. More...
 

Protected Member Functions

virtual void send (uint8_t reg, uint8_t data)=0
 Sends data to the device.
 
virtual uint8_t receive (uint8_t reg)=0
 Receives data from the device.
 

Protected Attributes

uint8_t m_states [4]
 Local registers.
 
std::string m_dev_path
 Device path.
 

Detailed Description

8-bit I/O Expander with SPI/I2C (skeleton).

Definition at line 42 of file mcp23x08.hpp.

Member Enumeration Documentation

The controller command set.

Enumerator
WRITE 

Writes on the register.

READ 

Reads from the register.

Definition at line 47 of file mcp23x08.hpp.

Device registers.

Enumerator
IODIR 

Controls the direction of the data I/O.

IPOL 

Configures the polarity on the corresponding GPIO port bits.

GPINTEN 

Controls the interrupt-on-change feature for each pin.

DEFVAL 

Sets the default comparison value.

INTCON 

Controls how the associated pin value is compared for the interrupt-on-change feature.

IOCON 

Configures the device.

GPPU 

Controls the pull-up resistors for the port pins.

INTF 

Reflects the interrupt condition on the port pins of any pin that is enabled for interrupts.

INTCAP 

Captures the GPIO port value at the time the interrupt occurred.

GPIO 

Reflects the value on the port.

OLAT 

Provides access to the output latches.

Definition at line 54 of file mcp23x08.hpp.

The controller configuration set (bit flags).

Enumerator
INTPOL 

Sets the polarity of the INT output pin.

ODR 

Configures the INT pin as an open-drain output.

HAEN 

Hardware address enable.

DISSLW 

Slew Rate control bit for SDA output.

SEQOP 

Sequential operation mode.

MIRROR 

Pins mirror.

BANK 

Controls how the registers are addressed.

Definition at line 70 of file mcp23x08.hpp.

Constructor & Destructor Documentation

rpihw::driver::mcp23x08::mcp23x08 ( const std::string &  dev_path)

Constructor method.

Parameters
[in]dev_pathThe device path.

Member Function Documentation

virtual bool rpihw::driver::mcp23x08::read ( uint8_t  pin)
virtual

Returns the value of a input pin.

Parameters
[in]pinThe input pin.
Returns
The value of input pin.

Reimplemented from rpihw::driver::io_expander.

virtual void rpihw::driver::mcp23x08::setPullUpDown ( uint8_t  pin,
uint8_t  mode 
)
virtual

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

Parameters
[in]pinThe GPIO pin.
[in]modeThe pull resistor mode.

Reimplemented from rpihw::driver::io_expander.

virtual void rpihw::driver::mcp23x08::setup ( uint8_t  pin,
uint8_t  mode,
uint8_t  pull_mode = PULL_OFF 
)
virtual

Sets the mode of a GPIO pin.

Parameters
[in]pinThe GPIO pin.
[in]modeThe GPIO mode.
[in]pull_modeThe pull resistor mode.

Reimplemented from rpihw::driver::io_expander.

virtual void rpihw::driver::mcp23x08::write ( uint8_t  pin,
bool  value 
)
virtual

Sets the value of a output pin.

Parameters
[in]pinThe output pin.
[in]valueThe value of output pin.

Reimplemented from rpihw::driver::io_expander.


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