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 PCA9956A.cpp Source File

PCA9956A.cpp

00001 #include    "mbed.h"
00002 #include    "PCA9956A.h"
00003 
00004 PCA9956A::PCA9956A( PinName i2c_sda, PinName i2c_scl, char i2c_address )
00005     : PCA995xA( i2c_sda, i2c_scl, i2c_address ), n_of_ports( 24 )
00006 {
00007     initialize();
00008 }
00009 
00010 PCA9956A::PCA9956A( I2C &i2c_obj, char i2c_address )
00011     : PCA995xA( i2c_obj, i2c_address ), n_of_ports( 24 )
00012 {
00013     initialize();
00014 }
00015 
00016 PCA9956A::~PCA9956A()
00017 {
00018 }
00019 
00020 void PCA9956A::initialize( void )
00021 {
00022     char init_array[] = {
00023         PCA995xA::AUTO_INCREMENT | REGISTER_START,  //  Command
00024         0x00, 0x00,                                 //  MODE1, MODE2
00025         0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA,         //  LEDOUT[5:0]
00026         0x80, 0x00,                                 //  GRPPWM, GRPFREQ
00027     };
00028 
00029     pwm( ALLPORTS, 0.0 );    
00030     current( ALLPORTS, 0.1 );    
00031 
00032     write( init_array, sizeof( init_array ) );
00033 }
00034 
00035 char PCA9956A::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 char PCA9956A::current_register_access( int port )
00044 {
00045     if ( port < n_of_ports )
00046         return ( IREF_REGISTER_START + port );
00047 
00048     return ( IREFALL );
00049 }
00050 
00051 int PCA9956A::number_of_ports( void )
00052 {
00053     return ( n_of_ports );
00054 }