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
What is this?
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.
How to use?
Wiring
Wiring between mbed and 16-bit GPIO expander
Wiring between mbed and 8-bit GPIO expander
Very basic register level I/O bit operation
PCAL9555 and PCAL9554 are class libraries for those compatible GPIO expander chips.
Those class libraries provides interface for bit operation of its I/O port.
For 16-bit GPIO expanders, the input/output access and its direction setting can be done by 16-bit data. For 8-bit GPIO expanders, those can be done by 8-bit data.
#include "mbed.h" #include "PCAL9555.h" PCAL9555 gpio( p28, p27, 0xE8 ); // using PCA9539 int main() { gpio.configure( 0xFFFF ); // Set all pins: input printf( " 0x%04X\r\n", (int)gpio );// Print pins state gpio.configure( 0x0000 ); // Set all pins: output int count = 0; while(1) { gpio.write( count++ ); } }
High level APIs
To use the GPIO expanders more simple, this library is including mbed-SDK-style APIs.
APIs that similar to DigitaiInOut
, DigitalOut
, DigitalIn
, BusInOut
, BusOut
and BusIn
are available.
GpioDigitalOut, GpioDigitaiInOut, GpioDigitalIn
Next code shows sample of DigitalOut
equivalent API GpioDigitalOut
usage.
A pin on the PCAL9555 is defined as pin and its state is changed by assignment.
(For single pin operation, GpioDigitaiInOut
and GpioDigitalIn
are available also.)
#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 ); } }
GpioBusOut, GpioBusInOut, GpioBusIn
BusOut
equivalent API GpioBusOut
is available too.
In next code, pins are grouped as mypins to manage the output as bus output.
(Same as GpioDigitalInOut and GpioDigitalIn APIs, GpioBusInOut
and GpioBusIn
are available also.)
#include "mbed.h" #include "PCAL9555.h" PCAL9555 gpio_exp( p28, p27, 0xE8 ); // SDA, SCL, Slave_address(option) GpioBusOut mypins( gpio_exp, X0_0, X0_1, X0_2, X0_3 ); int main() { while( 1 ) { for( int i = 0; i < 16; i++ ) { mypins = i; wait( 0.25 ); } } }
The high level APIs can be used in combination
Those high level APIs can be used in combination.
Each pins can be managed by instances.
#include "mbed.h" #include "PCAL9555.h" PCAL9555 gpio( p28, p27, 0xE8 ); // using PCA9539 // The GPIO pins are grouped in some groups and operated as bus I/O GpioBusIn bus_in( gpio, X0_0, X0_1, X0_2, X0_3 ); GpioBusOut bus_out( gpio, X0_4, X0_5, X0_6 ); GpioBusInOut bus_io( gpio, X1_7, X1_6, X1_5, X1_4, X1_3, X1_2, X1_1, X1_0 ); GpioDigitalOut myled( gpio, X0_7 ); int main() { bus_io.input(); printf( "I/O = 0x%02X\r\n", (int)bus_io ); printf( "In = 0x%01X\r\n", (int)bus_in ); bus_io.output(); int count = 0; while(1) { bus_out = count; bus_io = count; myled = count & 0x1; count++; wait( 0.1 ); } }
PCAL9554/PCAL9554.h@0:6c9a51a50eea, 2015-03-07 (annotated)
- Committer:
- nxp_ip
- Date:
- Sat Mar 07 12:56:05 2015 +0000
- Revision:
- 0:6c9a51a50eea
- Child:
- 1:fd7cfa821b6a
Initial version
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
nxp_ip | 0:6c9a51a50eea | 1 | /** PCA(L)9554 8-bit I2C-bus GPIO expander |
nxp_ip | 0:6c9a51a50eea | 2 | * |
nxp_ip | 0:6c9a51a50eea | 3 | * An operation sample of PCA(L)9554 and PCA9538. |
nxp_ip | 0:6c9a51a50eea | 4 | * mbed accesses the PCAL9554 registers through I2C. |
nxp_ip | 0:6c9a51a50eea | 5 | * |
nxp_ip | 0:6c9a51a50eea | 6 | * @class PCAL9554 |
nxp_ip | 0:6c9a51a50eea | 7 | * @author Akifumi (Tedd) OKANO, NXP Semiconductors |
nxp_ip | 0:6c9a51a50eea | 8 | * @version 0.5 |
nxp_ip | 0:6c9a51a50eea | 9 | * @date 07-Mar-2015 |
nxp_ip | 0:6c9a51a50eea | 10 | * |
nxp_ip | 0:6c9a51a50eea | 11 | * Released under the Apache 2 license |
nxp_ip | 0:6c9a51a50eea | 12 | * |
nxp_ip | 0:6c9a51a50eea | 13 | * About PCAL9554: |
nxp_ip | 0:6c9a51a50eea | 14 | * http://www.jp.nxp.com/products/interface_and_connectivity/i2c/i2c_general_purpose_i_o/series/PCAL9554B_PCAL9554C.html |
nxp_ip | 0:6c9a51a50eea | 15 | */ |
nxp_ip | 0:6c9a51a50eea | 16 | |
nxp_ip | 0:6c9a51a50eea | 17 | #ifndef MBED_PCAL9554 |
nxp_ip | 0:6c9a51a50eea | 18 | #define MBED_PCAL9554 |
nxp_ip | 0:6c9a51a50eea | 19 | |
nxp_ip | 0:6c9a51a50eea | 20 | #include "mbed.h" |
nxp_ip | 0:6c9a51a50eea | 21 | #include "PCAL955x.h" |
nxp_ip | 0:6c9a51a50eea | 22 | #include "CompGpioExpAPI.h" |
nxp_ip | 0:6c9a51a50eea | 23 | |
nxp_ip | 0:6c9a51a50eea | 24 | /** PCAL9554 class |
nxp_ip | 0:6c9a51a50eea | 25 | * |
nxp_ip | 0:6c9a51a50eea | 26 | * This is a driver code for the Low-voltage 8-bit I2C-bus GPIO with Agile I/O. |
nxp_ip | 0:6c9a51a50eea | 27 | * This class provides interface for PCAL9554 operation. |
nxp_ip | 0:6c9a51a50eea | 28 | * Detail information is available on next URL. |
nxp_ip | 0:6c9a51a50eea | 29 | * http://www.jp.nxp.com/products/interface_and_connectivity/i2c/i2c_general_purpose_i_o/series/PCAL9554B_PCAL9554C.html |
nxp_ip | 0:6c9a51a50eea | 30 | * |
nxp_ip | 0:6c9a51a50eea | 31 | * |
nxp_ip | 0:6c9a51a50eea | 32 | * PCAL9554 library's basic IO operation is compatible to PCA9554, PCA9538. |
nxp_ip | 0:6c9a51a50eea | 33 | * This library can be used for those GPIO expander chips also. |
nxp_ip | 0:6c9a51a50eea | 34 | * |
nxp_ip | 0:6c9a51a50eea | 35 | * Example: |
nxp_ip | 0:6c9a51a50eea | 36 | * @code |
nxp_ip | 0:6c9a51a50eea | 37 | * #include "mbed.h" |
nxp_ip | 0:6c9a51a50eea | 38 | * #include "PCAL9555.h" |
nxp_ip | 0:6c9a51a50eea | 39 | * |
nxp_ip | 0:6c9a51a50eea | 40 | * PCAL9555 gpio( p28, p27, 0xE8 ); // using PCA9539 |
nxp_ip | 0:6c9a51a50eea | 41 | * |
nxp_ip | 0:6c9a51a50eea | 42 | * int main() { |
nxp_ip | 0:6c9a51a50eea | 43 | * gpio.configure( 0xFFFF ); // Set all pins: input |
nxp_ip | 0:6c9a51a50eea | 44 | * printf( " 0x%04X\r\n", (int)gpio );// Print pins state |
nxp_ip | 0:6c9a51a50eea | 45 | * |
nxp_ip | 0:6c9a51a50eea | 46 | * gpio.configure( 0x0000 ); // Set all pins: output |
nxp_ip | 0:6c9a51a50eea | 47 | * int count = 0; |
nxp_ip | 0:6c9a51a50eea | 48 | * while(1) { |
nxp_ip | 0:6c9a51a50eea | 49 | * gpio.write( count++ ); |
nxp_ip | 0:6c9a51a50eea | 50 | * } |
nxp_ip | 0:6c9a51a50eea | 51 | * } |
nxp_ip | 0:6c9a51a50eea | 52 | * @endcode |
nxp_ip | 0:6c9a51a50eea | 53 | * |
nxp_ip | 0:6c9a51a50eea | 54 | * GpioDigitalInOut, GpioDigitalOut, GpioDigitalIn, |
nxp_ip | 0:6c9a51a50eea | 55 | * GpioBusInOut, GpioBusOut and GpioBusIn API class are available also. |
nxp_ip | 0:6c9a51a50eea | 56 | * For those API details, please find those class library page. |
nxp_ip | 0:6c9a51a50eea | 57 | * The GpioDigital* and GpioBus* APIs can be used as next sample code. |
nxp_ip | 0:6c9a51a50eea | 58 | * |
nxp_ip | 0:6c9a51a50eea | 59 | * @code |
nxp_ip | 0:6c9a51a50eea | 60 | * #include "mbed.h" |
nxp_ip | 0:6c9a51a50eea | 61 | * #include "PCAL9554.h" |
nxp_ip | 0:6c9a51a50eea | 62 | * |
nxp_ip | 0:6c9a51a50eea | 63 | * PCAL9555 gpio( p28, p27, 0xE0 ); // using PCA9538 |
nxp_ip | 0:6c9a51a50eea | 64 | * |
nxp_ip | 0:6c9a51a50eea | 65 | * // The GPIO pins are grouped in some groups and operated as bus I/O |
nxp_ip | 0:6c9a51a50eea | 66 | * GpioBusIn bus_in( gpio, X0, X1, X2, X3 ); |
nxp_ip | 0:6c9a51a50eea | 67 | * GpioBusOut bus_out( gpio, X4, X5, X6 ); |
nxp_ip | 0:6c9a51a50eea | 68 | * GpioDigitalOut myled( gpio, X7 ); |
nxp_ip | 0:6c9a51a50eea | 69 | * |
nxp_ip | 0:6c9a51a50eea | 70 | * int main() { |
nxp_ip | 0:6c9a51a50eea | 71 | * int count = 0; |
nxp_ip | 0:6c9a51a50eea | 72 | * while(1) { |
nxp_ip | 0:6c9a51a50eea | 73 | * printf( "In = 0x%01X\r\n", (int)bus_in ); |
nxp_ip | 0:6c9a51a50eea | 74 | * bus_out = count; |
nxp_ip | 0:6c9a51a50eea | 75 | * myled = count & 0x1; |
nxp_ip | 0:6c9a51a50eea | 76 | * count++; |
nxp_ip | 0:6c9a51a50eea | 77 | * wait( 0.1 ); |
nxp_ip | 0:6c9a51a50eea | 78 | * } |
nxp_ip | 0:6c9a51a50eea | 79 | * } |
nxp_ip | 0:6c9a51a50eea | 80 | * @endcode |
nxp_ip | 0:6c9a51a50eea | 81 | */ |
nxp_ip | 0:6c9a51a50eea | 82 | class PCAL9554 : public PCAL955x |
nxp_ip | 0:6c9a51a50eea | 83 | { |
nxp_ip | 0:6c9a51a50eea | 84 | #if DOXYGEN_ONLY |
nxp_ip | 0:6c9a51a50eea | 85 | //* GPIO-Expander pin names */ |
nxp_ip | 0:6c9a51a50eea | 86 | typedef enum { |
nxp_ip | 0:6c9a51a50eea | 87 | X0_0, /**< P0_0 pin */ |
nxp_ip | 0:6c9a51a50eea | 88 | X0_1, /**< P0_1 pin */ |
nxp_ip | 0:6c9a51a50eea | 89 | X0_2, /**< P0_2 pin */ |
nxp_ip | 0:6c9a51a50eea | 90 | X0_3, /**< P0_3 pin */ |
nxp_ip | 0:6c9a51a50eea | 91 | X0_4, /**< P0_4 pin */ |
nxp_ip | 0:6c9a51a50eea | 92 | X0_5, /**< P0_5 pin */ |
nxp_ip | 0:6c9a51a50eea | 93 | X0_6, /**< P0_6 pin */ |
nxp_ip | 0:6c9a51a50eea | 94 | X0_7, /**< P0_7 pin */ |
nxp_ip | 0:6c9a51a50eea | 95 | X0 = X0_0, /**< P0_0 pin */ |
nxp_ip | 0:6c9a51a50eea | 96 | X1 = X0_1, /**< P0_1 pin */ |
nxp_ip | 0:6c9a51a50eea | 97 | X2 = X0_2, /**< P0_2 pin */ |
nxp_ip | 0:6c9a51a50eea | 98 | X3 = X0_3, /**< P0_3 pin */ |
nxp_ip | 0:6c9a51a50eea | 99 | X4 = X0_4, /**< P0_4 pin */ |
nxp_ip | 0:6c9a51a50eea | 100 | X5 = X0_5, /**< P0_5 pin */ |
nxp_ip | 0:6c9a51a50eea | 101 | X6 = X0_6, /**< P0_6 pin */ |
nxp_ip | 0:6c9a51a50eea | 102 | X7 = X0_7, /**< P0_7 pin */ |
nxp_ip | 0:6c9a51a50eea | 103 | X_NC = ~0x0L /**< for when the pin is left no-connection */ |
nxp_ip | 0:6c9a51a50eea | 104 | } GpioPinName; |
nxp_ip | 0:6c9a51a50eea | 105 | #endif |
nxp_ip | 0:6c9a51a50eea | 106 | public: |
nxp_ip | 0:6c9a51a50eea | 107 | /** Name of the PCAL9554 registers */ |
nxp_ip | 0:6c9a51a50eea | 108 | enum command_reg { |
nxp_ip | 0:6c9a51a50eea | 109 | InputPort = 0x00, |
nxp_ip | 0:6c9a51a50eea | 110 | OutoutPort, |
nxp_ip | 0:6c9a51a50eea | 111 | PolarityInversionPort, |
nxp_ip | 0:6c9a51a50eea | 112 | ConfigurationPort, |
nxp_ip | 0:6c9a51a50eea | 113 | OutputDriveStrength0 = 0x40, |
nxp_ip | 0:6c9a51a50eea | 114 | OutputDriveStrength1, |
nxp_ip | 0:6c9a51a50eea | 115 | InputLatch, |
nxp_ip | 0:6c9a51a50eea | 116 | PullUpPullDowmEnable, |
nxp_ip | 0:6c9a51a50eea | 117 | PullUpPullDowmSelection, |
nxp_ip | 0:6c9a51a50eea | 118 | InterruptMask, |
nxp_ip | 0:6c9a51a50eea | 119 | InterruptStatus, |
nxp_ip | 0:6c9a51a50eea | 120 | OutputPortConfiguration = 0x4F, |
nxp_ip | 0:6c9a51a50eea | 121 | }; |
nxp_ip | 0:6c9a51a50eea | 122 | |
nxp_ip | 0:6c9a51a50eea | 123 | /** Create a PCAL9554 instance connected to specified I2C pins with specified address |
nxp_ip | 0:6c9a51a50eea | 124 | * |
nxp_ip | 0:6c9a51a50eea | 125 | * @param i2c_sda I2C-bus SDA pin |
nxp_ip | 0:6c9a51a50eea | 126 | * @param i2c_sda I2C-bus SCL pin |
nxp_ip | 0:6c9a51a50eea | 127 | * @param i2c_address I2C-bus address (default: 0x40) |
nxp_ip | 0:6c9a51a50eea | 128 | */ |
nxp_ip | 0:6c9a51a50eea | 129 | PCAL9554( PinName i2c_sda, PinName i2c_scl, char i2c_address = PCAL955x::DEFAULT_I2C_ADDR ); |
nxp_ip | 0:6c9a51a50eea | 130 | |
nxp_ip | 0:6c9a51a50eea | 131 | /** Create a PCAL9554 instance connected to specified I2C pins with specified address |
nxp_ip | 0:6c9a51a50eea | 132 | * |
nxp_ip | 0:6c9a51a50eea | 133 | * @param i2c_obj I2C object (instance) |
nxp_ip | 0:6c9a51a50eea | 134 | * @param i2c_address I2C-bus address (default: 0x40) |
nxp_ip | 0:6c9a51a50eea | 135 | */ |
nxp_ip | 0:6c9a51a50eea | 136 | PCAL9554( I2C &i2c_obj, char i2c_address = PCAL955x::DEFAULT_I2C_ADDR ); |
nxp_ip | 0:6c9a51a50eea | 137 | |
nxp_ip | 0:6c9a51a50eea | 138 | /** Destractor |
nxp_ip | 0:6c9a51a50eea | 139 | */ |
nxp_ip | 0:6c9a51a50eea | 140 | virtual ~PCAL9554(); |
nxp_ip | 0:6c9a51a50eea | 141 | |
nxp_ip | 0:6c9a51a50eea | 142 | /** Returns the number of I/O pins |
nxp_ip | 0:6c9a51a50eea | 143 | * |
nxp_ip | 0:6c9a51a50eea | 144 | * @returns |
nxp_ip | 0:6c9a51a50eea | 145 | * The number of I/O pins |
nxp_ip | 0:6c9a51a50eea | 146 | */ |
nxp_ip | 0:6c9a51a50eea | 147 | virtual int number_of_pins( void ); |
nxp_ip | 0:6c9a51a50eea | 148 | |
nxp_ip | 0:6c9a51a50eea | 149 | #if DOXYGEN_ONLY |
nxp_ip | 0:6c9a51a50eea | 150 | |
nxp_ip | 0:6c9a51a50eea | 151 | /** Set output port bits |
nxp_ip | 0:6c9a51a50eea | 152 | * |
nxp_ip | 0:6c9a51a50eea | 153 | * @param bit_pattern 16-bit output pattern for port1 and port0. |
nxp_ip | 0:6c9a51a50eea | 154 | * |
nxp_ip | 0:6c9a51a50eea | 155 | * @note |
nxp_ip | 0:6c9a51a50eea | 156 | * The data for pins, given as integer. |
nxp_ip | 0:6c9a51a50eea | 157 | * The 16-bit MSB goes to P1_7 pin and LSB goes to P0_0 pin. |
nxp_ip | 0:6c9a51a50eea | 158 | * Data will not come out from the pin if it is configured as input. |
nxp_ip | 0:6c9a51a50eea | 159 | * |
nxp_ip | 0:6c9a51a50eea | 160 | * @see configure() |
nxp_ip | 0:6c9a51a50eea | 161 | */ |
nxp_ip | 0:6c9a51a50eea | 162 | void write( int bit_pattern ); |
nxp_ip | 0:6c9a51a50eea | 163 | |
nxp_ip | 0:6c9a51a50eea | 164 | /** Read pin states |
nxp_ip | 0:6c9a51a50eea | 165 | * |
nxp_ip | 0:6c9a51a50eea | 166 | * @return |
nxp_ip | 0:6c9a51a50eea | 167 | * 16-bit pattern from port1 and port0. |
nxp_ip | 0:6c9a51a50eea | 168 | * |
nxp_ip | 0:6c9a51a50eea | 169 | * @note |
nxp_ip | 0:6c9a51a50eea | 170 | * The data from pins, given as integer. |
nxp_ip | 0:6c9a51a50eea | 171 | * The 16-bit port data comes from IO pins, P1_7 as MSB, P0_0 as LSB. |
nxp_ip | 0:6c9a51a50eea | 172 | * Data cannot be read if the port is configured as output. |
nxp_ip | 0:6c9a51a50eea | 173 | * |
nxp_ip | 0:6c9a51a50eea | 174 | * @see configure() |
nxp_ip | 0:6c9a51a50eea | 175 | */ |
nxp_ip | 0:6c9a51a50eea | 176 | int read( void ); |
nxp_ip | 0:6c9a51a50eea | 177 | |
nxp_ip | 0:6c9a51a50eea | 178 | /** Polarity setting |
nxp_ip | 0:6c9a51a50eea | 179 | * |
nxp_ip | 0:6c9a51a50eea | 180 | * @param bit_pattern 16-bit polarity setting pattern for port1 and port0. |
nxp_ip | 0:6c9a51a50eea | 181 | * If the bit is set to '1', the state will be inverted. |
nxp_ip | 0:6c9a51a50eea | 182 | * (Default state is all '0') |
nxp_ip | 0:6c9a51a50eea | 183 | * |
nxp_ip | 0:6c9a51a50eea | 184 | * @see configure() |
nxp_ip | 0:6c9a51a50eea | 185 | */ |
nxp_ip | 0:6c9a51a50eea | 186 | void polarity( int bit_pattern ); |
nxp_ip | 0:6c9a51a50eea | 187 | |
nxp_ip | 0:6c9a51a50eea | 188 | /** Set IO congiguration |
nxp_ip | 0:6c9a51a50eea | 189 | * |
nxp_ip | 0:6c9a51a50eea | 190 | * @param bit_pattern 16-bit IO direction setting pattern for port1 and port0. |
nxp_ip | 0:6c9a51a50eea | 191 | * |
nxp_ip | 0:6c9a51a50eea | 192 | * @note |
nxp_ip | 0:6c9a51a50eea | 193 | * The data for pins, given as integer. |
nxp_ip | 0:6c9a51a50eea | 194 | * The 16-bit MSB goes to P1_7 pin and LSB goes to P0_0 pin. |
nxp_ip | 0:6c9a51a50eea | 195 | * Data will not come out from the pin if it is configured as input. |
nxp_ip | 0:6c9a51a50eea | 196 | * |
nxp_ip | 0:6c9a51a50eea | 197 | * @see write() |
nxp_ip | 0:6c9a51a50eea | 198 | * @see read() |
nxp_ip | 0:6c9a51a50eea | 199 | */ |
nxp_ip | 0:6c9a51a50eea | 200 | void configure( int bit_pattern ); |
nxp_ip | 0:6c9a51a50eea | 201 | |
nxp_ip | 0:6c9a51a50eea | 202 | /** Set interrupt mask |
nxp_ip | 0:6c9a51a50eea | 203 | * |
nxp_ip | 0:6c9a51a50eea | 204 | * @param bit_pattern 16-bit interrupt mask |
nxp_ip | 0:6c9a51a50eea | 205 | * |
nxp_ip | 0:6c9a51a50eea | 206 | * @see interrupt_status() |
nxp_ip | 0:6c9a51a50eea | 207 | */ |
nxp_ip | 0:6c9a51a50eea | 208 | void interrupt_mask( int bit_pattern ); |
nxp_ip | 0:6c9a51a50eea | 209 | |
nxp_ip | 0:6c9a51a50eea | 210 | /** Read interrupt status |
nxp_ip | 0:6c9a51a50eea | 211 | * |
nxp_ip | 0:6c9a51a50eea | 212 | * @return |
nxp_ip | 0:6c9a51a50eea | 213 | * 16-bit data from interrupt status registers |
nxp_ip | 0:6c9a51a50eea | 214 | * |
nxp_ip | 0:6c9a51a50eea | 215 | * @see interrupt_status() |
nxp_ip | 0:6c9a51a50eea | 216 | */ |
nxp_ip | 0:6c9a51a50eea | 217 | int interrupt_status( void ); |
nxp_ip | 0:6c9a51a50eea | 218 | |
nxp_ip | 0:6c9a51a50eea | 219 | /** A shorthand for read() |
nxp_ip | 0:6c9a51a50eea | 220 | */ |
nxp_ip | 0:6c9a51a50eea | 221 | operator int( void ); |
nxp_ip | 0:6c9a51a50eea | 222 | |
nxp_ip | 0:6c9a51a50eea | 223 | #endif |
nxp_ip | 0:6c9a51a50eea | 224 | |
nxp_ip | 0:6c9a51a50eea | 225 | /** Write 16-bit data into registers |
nxp_ip | 0:6c9a51a50eea | 226 | * |
nxp_ip | 0:6c9a51a50eea | 227 | * @param reg_index Direst access to registers. |
nxp_ip | 0:6c9a51a50eea | 228 | * The registers can be referenced by regiser index |
nxp_ip | 0:6c9a51a50eea | 229 | * @param data 16-bit data. Data will be written into two 8-bit registers |
nxp_ip | 0:6c9a51a50eea | 230 | */ |
nxp_ip | 0:6c9a51a50eea | 231 | virtual void reg_index_write( char register_index, int data ); |
nxp_ip | 0:6c9a51a50eea | 232 | |
nxp_ip | 0:6c9a51a50eea | 233 | /** Read 16-bit data from registers |
nxp_ip | 0:6c9a51a50eea | 234 | * |
nxp_ip | 0:6c9a51a50eea | 235 | * @param reg_index Direst access to registers. |
nxp_ip | 0:6c9a51a50eea | 236 | * The registers can be referenced by regiser index |
nxp_ip | 0:6c9a51a50eea | 237 | * |
nxp_ip | 0:6c9a51a50eea | 238 | * @return |
nxp_ip | 0:6c9a51a50eea | 239 | * 16-bit data from two registers. |
nxp_ip | 0:6c9a51a50eea | 240 | * The register which has lower address will be upper 8-bit data. |
nxp_ip | 0:6c9a51a50eea | 241 | */ |
nxp_ip | 0:6c9a51a50eea | 242 | virtual int reg_index_read( char register_index ); |
nxp_ip | 0:6c9a51a50eea | 243 | |
nxp_ip | 0:6c9a51a50eea | 244 | /** A shorthand for write() |
nxp_ip | 0:6c9a51a50eea | 245 | */ |
nxp_ip | 0:6c9a51a50eea | 246 | PCAL9554& operator= ( int bit_pattern ); |
nxp_ip | 0:6c9a51a50eea | 247 | PCAL9554& operator= ( PCAL9554& rhs ); |
nxp_ip | 0:6c9a51a50eea | 248 | |
nxp_ip | 0:6c9a51a50eea | 249 | private: |
nxp_ip | 0:6c9a51a50eea | 250 | |
nxp_ip | 0:6c9a51a50eea | 251 | static const char regmap[]; |
nxp_ip | 0:6c9a51a50eea | 252 | const int n_of_pins; |
nxp_ip | 0:6c9a51a50eea | 253 | } |
nxp_ip | 0:6c9a51a50eea | 254 | ; |
nxp_ip | 0:6c9a51a50eea | 255 | |
nxp_ip | 0:6c9a51a50eea | 256 | #endif // MBED_PCAL9554 |