InetrfaceProducts NXP / PCA962x

Dependencies:   CompLedDvr

Dependents:   PCA9626_Hello PCA9624_Hello PCA9622_Hello

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers PCA962x.h Source File

PCA962x.h

00001 /** PCA962x PWM control LED driver family
00002  *
00003  *  Abstract class for PCA962x family
00004  *  No instance can be made from this class
00005  *
00006  *  @class   PCA962x
00007  *  @author  Akifumi (Tedd) OKANO, NXP Semiconductors
00008  *  @version 0.6
00009  *  @date    04-Mar-2015
00010  *
00011  *  Released under the Apache 2 license License
00012  */
00013 
00014 #ifndef     MBED_PCA962x
00015 #define     MBED_PCA962x
00016 
00017 #include    "mbed.h"
00018 #include    "CompLedDvr.h"
00019 
00020 #define     ALLPORTS        0xFF
00021 #define     DEFAULT_PWM     1.0
00022 
00023 /** PCA962x class
00024  *
00025  *  Abstract class for PCA962x family
00026  *  No instance can be made from this class
00027  */
00028 class PCA962x : public CompLedDvr
00029 {
00030 public:
00031     PCA962x( PinName i2c_sda, PinName i2c_scl, char i2c_address = DEFAULT_I2C_ADDR );
00032     PCA962x( I2C &i2c_obj, char i2c_address = DEFAULT_I2C_ADDR );
00033     virtual ~PCA962x();
00034 
00035     void            reset( void );
00036 
00037     virtual void    pwm( int port, float v );
00038     
00039     void            pwm( float *vp );
00040     virtual int     number_of_ports( void )             = 0;
00041 
00042     void            write( char reg_addr, char data );
00043     void            write( char *data, int length );
00044     char            read( char reg_addr );
00045     void            read( char reg_addr, char *data, int length );
00046 
00047 protected:
00048     enum {
00049         DEFAULT_I2C_ADDR    = 0xC0,
00050         AUTO_INCREMENT      = 0x80,
00051         PWMALL              = 0xFF
00052     };
00053 
00054 private:
00055     virtual void    initialize( void )                  = 0;
00056     virtual char    pwm_register_access( int port )     = 0;
00057 
00058     I2C             *i2c_p;
00059     I2C             &i2c;
00060     char            address;    //  I2C slave address
00061 }
00062 ;
00063 
00064 #endif  //  MBED_PCA962x