InetrfaceProducts NXP / PCA995xA

Dependencies:   CompLedDvrCC

Dependents:   PCA9956A_Hello pca9956b_two_demoboards PCA9955A_Gradation_control PCA9955A_Gradation_control ... more

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers PCA995xA.h Source File

PCA995xA.h

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