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
GpioDigitalInOut Class Reference
GpioDigitalInOut class. More...
#include <GpioDigitalInOut.h>
Inherited by GpioDigitalIn, and GpioDigitalOut.
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 | |
GpioDigitalInOut (CompGpioExp &gpiop, GpioPinName pin_name) | |
Create a GpioDigitalInOut connected to the specified pin. | |
virtual | ~GpioDigitalInOut () |
Destractor. | |
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. | |
GpioDigitalInOut & | operator= (int rhs) |
A shorthand for write() | |
virtual | operator int (void) |
A shorthand for read() |
Detailed Description
GpioDigitalInOut class.
"GpioDigitalInOut" class works like "DigitalInOut" 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, 0x40 ); // SDA, SCL, Slave_address(option) GpioDigitalInOut pin( gpio_exp, X0_0 ); int main() { pin.output(); pin = 0; wait_us( 500 ); pin.input(); wait_us( 500 ); }
Definition at line 42 of file GpioDigitalInOut.h.
Member Enumeration Documentation
enum GpioPinName |
GPIO-Expander pin names.
- Enumerator:
Reimplemented in GpioDigitalIn, and GpioDigitalOut.
Definition at line 48 of file GpioDigitalInOut.h.
Constructor & Destructor Documentation
GpioDigitalInOut | ( | CompGpioExp & | gpiop, |
GpioPinName | pin_name | ||
) |
Create a GpioDigitalInOut connected to the specified pin.
- Parameters:
-
gpiop Instance of GPIO expander device pin_name DigitalInOut pin to connect to
Definition at line 4 of file GpioDigitalInOut.cpp.
~GpioDigitalInOut | ( | ) | [virtual] |
Destractor.
Definition at line 10 of file GpioDigitalInOut.cpp.
Member Function Documentation
void input | ( | void | ) |
Set as an input.
Definition at line 34 of file GpioDigitalInOut.cpp.
operator int | ( | void | ) | [virtual] |
A shorthand for read()
Definition at line 58 of file GpioDigitalInOut.cpp.
GpioDigitalInOut & operator= | ( | int | rhs ) |
A shorthand for write()
Reimplemented in GpioDigitalOut.
Definition at line 46 of file GpioDigitalInOut.cpp.
void output | ( | void | ) |
Set as an output.
Definition at line 40 of file GpioDigitalInOut.cpp.
int read | ( | void | ) | [virtual] |
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] |
Set the output, specified as 0 or 1 (int)
- Parameters:
-
v An 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.
Generated on Tue Jul 12 2022 18:40:41 by 1.7.2