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.

This is a copy of the PCA9555 library by Akifumi "Tedd" OKANO, which is compatible with PCAL6416A chip.

Committer:
andriym
Date:
Wed Feb 15 10:07:59 2017 +0000
Revision:
0:035111d3d631
A change of name for the PCAL955x library to make it searchable for people needing PCAL6416A library.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
andriym 0:035111d3d631 1 /** GpioDigitalInOut API for GPIO-expander component class
andriym 0:035111d3d631 2 *
andriym 0:035111d3d631 3 * @author Akifumi (Tedd) OKANO, NXP Semiconductors
andriym 0:035111d3d631 4 * @version 0.6
andriym 0:035111d3d631 5 * @date 19-Mar-2015
andriym 0:035111d3d631 6 *
andriym 0:035111d3d631 7 * Released under the Apache 2 license
andriym 0:035111d3d631 8 */
andriym 0:035111d3d631 9
andriym 0:035111d3d631 10 #ifndef MBED_GpioDigitalOut
andriym 0:035111d3d631 11 #define MBED_GpioDigitalOut
andriym 0:035111d3d631 12
andriym 0:035111d3d631 13 #include "mbed.h"
andriym 0:035111d3d631 14 #include "GpioDigitalInOut.h"
andriym 0:035111d3d631 15
andriym 0:035111d3d631 16 /** GpioDigitalOut class
andriym 0:035111d3d631 17 *
andriym 0:035111d3d631 18 * @class GpioDigitalOut
andriym 0:035111d3d631 19 *
andriym 0:035111d3d631 20 * "GpioDigitalOut" class works like "DigitalOut" class of mbed-SDK.
andriym 0:035111d3d631 21 * This class provides pin oriented API, abstracting the GPIO-expander chip.
andriym 0:035111d3d631 22 *
andriym 0:035111d3d631 23 * Example:
andriym 0:035111d3d631 24 * @code
andriym 0:035111d3d631 25 * #include "mbed.h"
andriym 0:035111d3d631 26 * #include "PCAL9555.h"
andriym 0:035111d3d631 27 *
andriym 0:035111d3d631 28 * PCAL9555 gpio_exp( p28, p27, 0xE8 ); // SDA, SCL, Slave_address(option)
andriym 0:035111d3d631 29 * GpioDigitalOut pin( gpio_exp, X0_0 );
andriym 0:035111d3d631 30 *
andriym 0:035111d3d631 31 * int main() {
andriym 0:035111d3d631 32 * while( 1 ) {
andriym 0:035111d3d631 33 * pin = 1;
andriym 0:035111d3d631 34 * wait( 0.2 );
andriym 0:035111d3d631 35 * pin = 0;
andriym 0:035111d3d631 36 * wait( 0.2 );
andriym 0:035111d3d631 37 * }
andriym 0:035111d3d631 38 * }
andriym 0:035111d3d631 39 * @endcode
andriym 0:035111d3d631 40 */
andriym 0:035111d3d631 41 class GpioDigitalOut : public GpioDigitalInOut
andriym 0:035111d3d631 42 {
andriym 0:035111d3d631 43 public:
andriym 0:035111d3d631 44
andriym 0:035111d3d631 45 #if DOXYGEN_ONLY
andriym 0:035111d3d631 46 /** GPIO-Expander pin names */
andriym 0:035111d3d631 47 typedef enum {
andriym 0:035111d3d631 48 X0_0, /**< P0_0 pin */
andriym 0:035111d3d631 49 X0_1, /**< P0_1 pin */
andriym 0:035111d3d631 50 X0_2, /**< P0_2 pin */
andriym 0:035111d3d631 51 X0_3, /**< P0_3 pin */
andriym 0:035111d3d631 52 X0_4, /**< P0_4 pin */
andriym 0:035111d3d631 53 X0_5, /**< P0_5 pin */
andriym 0:035111d3d631 54 X0_6, /**< P0_6 pin */
andriym 0:035111d3d631 55 X0_7, /**< P0_7 pin */
andriym 0:035111d3d631 56 X1_0, /**< P1_0 pin (for 16-bit GPIO device only) */
andriym 0:035111d3d631 57 X1_1, /**< P1_1 pin (for 16-bit GPIO device only) */
andriym 0:035111d3d631 58 X1_2, /**< P1_2 pin (for 16-bit GPIO device only) */
andriym 0:035111d3d631 59 X1_3, /**< P1_3 pin (for 16-bit GPIO device only) */
andriym 0:035111d3d631 60 X1_4, /**< P1_4 pin (for 16-bit GPIO device only) */
andriym 0:035111d3d631 61 X1_5, /**< P1_5 pin (for 16-bit GPIO device only) */
andriym 0:035111d3d631 62 X1_6, /**< P1_6 pin (for 16-bit GPIO device only) */
andriym 0:035111d3d631 63 X1_7, /**< P1_7 pin (for 16-bit GPIO device only) */
andriym 0:035111d3d631 64 X0 = X0_0, /**< P0_0 pin */
andriym 0:035111d3d631 65 X1 = X0_1, /**< P0_1 pin */
andriym 0:035111d3d631 66 X2 = X0_2, /**< P0_2 pin */
andriym 0:035111d3d631 67 X3 = X0_3, /**< P0_3 pin */
andriym 0:035111d3d631 68 X4 = X0_4, /**< P0_4 pin */
andriym 0:035111d3d631 69 X5 = X0_5, /**< P0_5 pin */
andriym 0:035111d3d631 70 X6 = X0_6, /**< P0_6 pin */
andriym 0:035111d3d631 71 X7 = X0_7, /**< P0_7 pin */
andriym 0:035111d3d631 72 X8 = X1_0, /**< P1_0 pin (for 16-bit GPIO device only) */
andriym 0:035111d3d631 73 X9 = X1_1, /**< P1_1 pin (for 16-bit GPIO device only) */
andriym 0:035111d3d631 74 X10 = X1_2, /**< P1_2 pin (for 16-bit GPIO device only) */
andriym 0:035111d3d631 75 X11 = X1_3, /**< P1_3 pin (for 16-bit GPIO device only) */
andriym 0:035111d3d631 76 X12 = X1_4, /**< P1_4 pin (for 16-bit GPIO device only) */
andriym 0:035111d3d631 77 X13 = X1_5, /**< P1_5 pin (for 16-bit GPIO device only) */
andriym 0:035111d3d631 78 X14 = X1_6, /**< P1_6 pin (for 16-bit GPIO device only) */
andriym 0:035111d3d631 79 X15 = X1_7, /**< P1_7 pin (for 16-bit GPIO device only) */
andriym 0:035111d3d631 80
andriym 0:035111d3d631 81 X_NC = ~0x0L /**< for when the pin is left no-connection */
andriym 0:035111d3d631 82 } GpioPinName;
andriym 0:035111d3d631 83 #endif
andriym 0:035111d3d631 84
andriym 0:035111d3d631 85 /** Create a GpioDigitalOut connected to the specified pin
andriym 0:035111d3d631 86 *
andriym 0:035111d3d631 87 * @param gpiop Instance of GPIO expander device
andriym 0:035111d3d631 88 * @param pin_name DigitalInOut pin to connect to
andriym 0:035111d3d631 89 */
andriym 0:035111d3d631 90 GpioDigitalOut( CompGpioExp &gpiop, GpioPinName pin_name );
andriym 0:035111d3d631 91
andriym 0:035111d3d631 92 /**
andriym 0:035111d3d631 93 * Destractor
andriym 0:035111d3d631 94 */
andriym 0:035111d3d631 95 virtual ~GpioDigitalOut();
andriym 0:035111d3d631 96
andriym 0:035111d3d631 97 /** A shorthand for write()
andriym 0:035111d3d631 98 */
andriym 0:035111d3d631 99 GpioDigitalOut& operator= ( int rhs );
andriym 0:035111d3d631 100 GpioDigitalOut& operator= ( GpioDigitalOut& rhs );
andriym 0:035111d3d631 101 }
andriym 0:035111d3d631 102 ;
andriym 0:035111d3d631 103
andriym 0:035111d3d631 104 #endif // MBED_GpioDigitalOut