The PCAL9555, PCAL9554 series is a low-voltage 16-bit/8-bit General Purpose Input/Output (GPIO) expander with interrupt. This conponent library is compatible to basic operation os GPIO expanders: PCAL9555, PCA9555, PCA9535, PCA9539, PCAL9554, PCA9554 and PCA9538. On addition to this, this library is including mbed-SDK-style APIs. APIs that similar to DigitaiInOut, DigitalOut, DigitalIn, BusInOUt, BusOut and BusIn are available.

Dependents:   PCAL9555_Hello OM13082-JoyStick OM13082_LED OM13082-test ... more

Embed: (wiki syntax)

« Back to documentation index

GpioBusInOut Class Reference

GpioBusInOut Class Reference

GpioBusInOut class. More...

#include <GpioBusInOut.h>

Inherited by GpioBusIn, and GpioBusOut.

Public Types

enum  GpioPinName {
  X0_0, X0_1, X0_2, X0_3,
  X0_4, X0_5, X0_6, X0_7,
  X1_0, X1_1, X1_2, X1_3,
  X1_4, X1_5, X1_6, X1_7,
  X0 = X0_0, X1 = X0_1, X2 = X0_2, X3 = X0_3,
  X4 = X0_4, X5 = X0_5, X6 = X0_6, X7 = X0_7,
  X8 = X1_0, X9 = X1_1, X10 = X1_2, X11 = X1_3,
  X12 = X1_4, X13 = X1_5, X14 = X1_6, X15 = X1_7,
  X_NC = ~0x0L
}
 

GPIO-Expander pin names.

More...

Public Member Functions

 GpioBusInOut (CompGpioExp &gpiop, GpioPinName p0, GpioPinName p1=X_NC, GpioPinName p2=X_NC, GpioPinName p3=X_NC, GpioPinName p4=X_NC, GpioPinName p5=X_NC, GpioPinName p6=X_NC, GpioPinName p7=X_NC, GpioPinName p8=X_NC, GpioPinName p9=X_NC, GpioPinName p10=X_NC, GpioPinName p11=X_NC, GpioPinName p12=X_NC, GpioPinName p13=X_NC, GpioPinName p14=X_NC, GpioPinName p15=X_NC)
 Create an GpioBusInOut, connected to the specified pins.
virtual ~GpioBusInOut ()
 Destractor.
void write (int value)
 Write the value to the output bus.
int read ()
 Read the value currently output on the bus.
void output ()
 Set as an output.
void input ()
 Set as an input.
GpioBusInOutoperator= (int rhs)
 A shorthand for write()
 operator int (void)
 A shorthand for read()

Detailed Description

GpioBusInOut class.

"GpioBusInOut" class works like "BusInOut" class of mbed-SDK. This class provides pin oriented API, abstracting the GPIO-expander chip.

Example:

  #include "mbed.h"
  #include "PCAL9555.h"
  
  PCAL9555        gpio_exp( p28, p27, 0xE8 );    //  SDA, SCL, Slave_address(option)
  GpioBusInOut    pins( gpio_exp, X0_0, X0_1, X0_2 );
   
  int main() {
      while(1) {
          pins.output();
          pins    = 0x3;
          wait( 1 );
          pins.input();
          wait( 1 );
          if( pins == 0x6 ) {
              printf( "Hello!\n" );
          }
      }
  } *  

Definition at line 44 of file GpioBusInOut.h.


Member Enumeration Documentation

GPIO-Expander pin names.

Enumerator:
X0_0 

P0_0 pin.

X0_1 

P0_1 pin.

X0_2 

P0_2 pin.

X0_3 

P0_3 pin.

X0_4 

P0_4 pin.

X0_5 

P0_5 pin.

X0_6 

P0_6 pin.

X0_7 

P0_7 pin.

X1_0 

P1_0 pin (for 16-bit GPIO device only)

X1_1 

P1_1 pin (for 16-bit GPIO device only)

X1_2 

P1_2 pin (for 16-bit GPIO device only)

X1_3 

P1_3 pin (for 16-bit GPIO device only)

X1_4 

P1_4 pin (for 16-bit GPIO device only)

X1_5 

P1_5 pin (for 16-bit GPIO device only)

X1_6 

P1_6 pin (for 16-bit GPIO device only)

X1_7 

P1_7 pin (for 16-bit GPIO device only)

X0 

P0_0 pin.

X1 

P0_1 pin.

X2 

P0_2 pin.

X3 

P0_3 pin.

X4 

P0_4 pin.

X5 

P0_5 pin.

X6 

P0_6 pin.

X7 

P0_7 pin.

X8 

P1_0 pin (for 16-bit GPIO device only)

X9 

P1_1 pin (for 16-bit GPIO device only)

X10 

P1_2 pin (for 16-bit GPIO device only)

X11 

P1_3 pin (for 16-bit GPIO device only)

X12 

P1_4 pin (for 16-bit GPIO device only)

X13 

P1_5 pin (for 16-bit GPIO device only)

X14 

P1_6 pin (for 16-bit GPIO device only)

X15 

P1_7 pin (for 16-bit GPIO device only)

X_NC 

for when the pin is left no-connection

Reimplemented in GpioBusIn, and GpioBusOut.

Definition at line 50 of file GpioBusInOut.h.


Constructor & Destructor Documentation

GpioBusInOut ( CompGpioExp gpiop,
GpioPinName  p0,
GpioPinName  p1 = X_NC,
GpioPinName  p2 = X_NC,
GpioPinName  p3 = X_NC,
GpioPinName  p4 = X_NC,
GpioPinName  p5 = X_NC,
GpioPinName  p6 = X_NC,
GpioPinName  p7 = X_NC,
GpioPinName  p8 = X_NC,
GpioPinName  p9 = X_NC,
GpioPinName  p10 = X_NC,
GpioPinName  p11 = X_NC,
GpioPinName  p12 = X_NC,
GpioPinName  p13 = X_NC,
GpioPinName  p14 = X_NC,
GpioPinName  p15 = X_NC 
)

Create an GpioBusInOut, connected to the specified pins.

Parameters:
gpiopInstance of GPIO expander device
p<n>DigitalInOut pin to connect to bus bit p<n> (GpioPinName)
Note:
It is only required to specify as many pin variables as is required for the bus; the rest will default to NC (not connected)

Definition at line 3 of file GpioBusInOut.cpp.

~GpioBusInOut (  ) [virtual]

Destractor.

Definition at line 28 of file GpioBusInOut.cpp.


Member Function Documentation

void input ( void   )

Set as an input.

Definition at line 68 of file GpioBusInOut.cpp.

operator int ( void   )

A shorthand for read()

Reimplemented in GpioBusIn.

Definition at line 86 of file GpioBusInOut.cpp.

GpioBusInOut & operator= ( int  rhs )

A shorthand for write()

Reimplemented in GpioBusOut.

Definition at line 73 of file GpioBusInOut.cpp.

void output ( void   )

Set as an output.

Definition at line 63 of file GpioBusInOut.cpp.

int read ( void   )

Read the value currently output on the bus.

Returns:
An integer with each bit corresponding to associated DigitalInOut pin setting

Definition at line 50 of file GpioBusInOut.cpp.

void write ( int  value )

Write the value to the output bus.

Parameters:
valueAn integer specifying a bit to write for every corresponding DigitalInOut pin

Definition at line 32 of file GpioBusInOut.cpp.