InetrfaceProducts NXP / PCA962x

Dependencies:   CompLedDvr

Dependents:   PCA9626_Hello PCA9624_Hello PCA9622_Hello

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers PCA9626.cpp Source File

PCA9626.cpp

00001 #include    "mbed.h"
00002 #include    "PCA9626.h"
00003 
00004 PCA9626::PCA9626( PinName i2c_sda, PinName i2c_scl, char i2c_address )
00005     : PCA962x( i2c_sda, i2c_scl, i2c_address ), n_of_ports( 24 )
00006 {
00007     initialize();
00008 }
00009 
00010 PCA9626::PCA9626( I2C &i2c_obj, char i2c_address )
00011     : PCA962x( i2c_obj, i2c_address ), n_of_ports( 24 )
00012 {
00013     initialize();
00014 }
00015 
00016 PCA9626::~PCA9626()
00017 {
00018 }
00019 
00020 void PCA9626::initialize( void )
00021 {
00022     char init_array0[] = {
00023             PCA962x::AUTO_INCREMENT | REGISTER_START,           //  Command
00024             0x01, 0x00,                                         //  MODE1, MODE2
00025         };
00026     char init_array1[] = {
00027             PCA962x::AUTO_INCREMENT | LEDOUT_REGISTER_START,    //  Command
00028             0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA,                 //  LEDOUT[5:0]
00029         };
00030 
00031     write( init_array0, sizeof( init_array0 ) );
00032     write( init_array1, sizeof( init_array1 ) );
00033 }
00034 
00035 char PCA9626::pwm_register_access( int port )
00036 {
00037     if ( port < n_of_ports )
00038         return ( PWM_REGISTER_START + port );
00039 
00040     return ( PWMALL );
00041 }
00042 
00043 int PCA9626::number_of_ports( void )
00044 {
00045     return ( n_of_ports );
00046 }