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

Show/hide line numbers PCAL955x.h Source File

PCAL955x.h

00001 /** PCAL955x GPIO with Agile I/O, interrupt and weak pull-up family
00002  *
00003  *  Abstract class for PCAL955x family
00004  *  No instance can be made from this class
00005  *
00006  *  @class   PCAL955x
00007  *  @author  Akifumi (Tedd) OKANO, NXP Semiconductors
00008  *  @version 0.5
00009  *  @date    07-Mar-2015
00010  *
00011  *  Released under the Apache 2 license
00012  */
00013 
00014 #ifndef     MBED_PCAL955x
00015 #define     MBED_PCAL955x
00016 
00017 #include    "mbed.h"
00018 #include    "CompGpioExp.h"
00019 
00020 /** Abstract class for PCAL955x family
00021  *  
00022  *  No instance can be made from this class
00023  */
00024 class PCAL955x : public CompGpioExp
00025 {
00026 public:
00027     enum register_index {
00028         INPUT,
00029         OUTPUT,
00030         POLARITY,
00031         CONFIG,
00032         ODS0,
00033         ODS1,
00034         IN_LATCH,
00035         PULL_EN,
00036         PULL_SEL,
00037         INT_MASK,
00038         INT_STAT,
00039         OPC
00040     };
00041 
00042     PCAL955x( PinName i2c_sda, PinName i2c_scl, char i2c_address = DEFAULT_I2C_ADDR );
00043     PCAL955x( I2C &i2c_obj, char i2c_address = DEFAULT_I2C_ADDR );
00044     virtual ~PCAL955x();
00045 
00046     virtual void    write( int pin, int value );
00047     virtual int     read( int pin );
00048     virtual void    configure( int pin, int value );
00049     virtual int     read( void );   
00050     virtual void    write_with_mask( int bitpattern, int mask_bits );
00051     virtual void    configure_with_mask( int bitpattern, int mask_bits );
00052     
00053     void            write( int bit_pattern );
00054     void            polarity( int bit_pattern );
00055     void            configure( int bit_pattern );
00056 
00057     void            interrupt_mask( int bit_pattern );
00058     int             interrupt_status( void );
00059 
00060     virtual int     number_of_pins( void )                     = 0;
00061     virtual void    reg_index_write( char reg_addr, int data )  = 0;
00062     virtual int     reg_index_read( char reg_addr )             = 0;
00063                     operator int( void );
00064 
00065 protected:
00066     enum {
00067         DEFAULT_I2C_ADDR    = 0x40,
00068     };
00069 
00070     void bus_write( char *dp, int length );
00071     void bus_read( char reg_addr, char *dp, int length );
00072 
00073 private:
00074     I2C             *i2c_p;
00075     I2C             &i2c;
00076     char            address;    //  I2C slave address
00077     int             pin_state;
00078     int             pin_direction;
00079 }
00080 ;
00081 
00082 #endif  //  MBED_PCAL955x
00083 
00084