The PCAL6416A is a low-voltage 16-bit general purpose I/O (GPIO) expander with interrupt. This component library is compatible to basic operation as GPIO expanders: PCAL6416A, 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.

Embed: (wiki syntax)

« Back to documentation index

GpioDigitalOut Class Reference

GpioDigitalOut Class Reference

GpioDigitalOut class. More...

#include <GpioDigitalOut.h>

Inherits GpioDigitalInOut.

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

 GpioDigitalOut (CompGpioExp &gpiop, GpioPinName pin_name)
 Create a GpioDigitalOut connected to the specified pin.
virtual ~GpioDigitalOut ()
 Destractor.
GpioDigitalOutoperator= (int rhs)
 A shorthand for write()
virtual void write (int v)
 Set the output, specified as 0 or 1 (int)
virtual int read (void)
 Return the output setting, represented as 0 or 1 (int)
void output (void)
 Set as an output.
void input (void)
 Set as an input.
virtual operator int (void)
 A shorthand for read()

Detailed Description

GpioDigitalOut class.

"GpioDigitalOut" class works like "DigitalOut" 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)
  GpioDigitalOut  pin( gpio_exp, X0_0 );
   
  int main() {
      while( 1 ) {
          pin = 1;
          wait( 0.2 );
          pin = 0;
          wait( 0.2 );
      }
  }

Definition at line 41 of file GpioDigitalOut.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 from GpioDigitalInOut.

Definition at line 47 of file GpioDigitalOut.h.


Constructor & Destructor Documentation

GpioDigitalOut ( CompGpioExp gpiop,
GpioPinName  pin_name 
)

Create a GpioDigitalOut connected to the specified pin.

Parameters:
gpiopInstance of GPIO expander device
pin_nameDigitalInOut pin to connect to

Definition at line 4 of file GpioDigitalOut.cpp.

~GpioDigitalOut (  ) [virtual]

Destractor.

Definition at line 11 of file GpioDigitalOut.cpp.


Member Function Documentation

void input ( void   ) [inherited]

Set as an input.

Definition at line 34 of file GpioDigitalInOut.cpp.

operator int ( void   ) [virtual, inherited]

A shorthand for read()

Definition at line 58 of file GpioDigitalInOut.cpp.

GpioDigitalOut & operator= ( int  rhs )

A shorthand for write()

Reimplemented from GpioDigitalInOut.

Definition at line 15 of file GpioDigitalOut.cpp.

void output ( void   ) [inherited]

Set as an output.

Definition at line 40 of file GpioDigitalInOut.cpp.

int read ( void   ) [virtual, inherited]

Return the output setting, represented as 0 or 1 (int)

Returns:
an integer representing the output setting of the pin if it is an output, or read the input if set as an input

Definition at line 26 of file GpioDigitalInOut.cpp.

void write ( int  v ) [virtual, inherited]

Set the output, specified as 0 or 1 (int)

Parameters:
vAn integer specifying the pin output value, 0 for logical 0, 1 (or any other non-zero value) for logical 1

Definition at line 14 of file GpioDigitalInOut.cpp.