gfdgd

Dependencies:   CompLedDvrCC

Fork of PCA995xA by InetrfaceProducts NXP

Committer:
tb942
Date:
Tue Aug 14 18:26:35 2018 +0000
Revision:
7:56a45c690801
Parent:
0:a624e2eeccac
removed #include mbed.h - it's not needed;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nxp_ip 0:a624e2eeccac 1 #include "mbed.h"
nxp_ip 0:a624e2eeccac 2 #include "PCA9956A.h"
nxp_ip 0:a624e2eeccac 3
nxp_ip 0:a624e2eeccac 4 PCA9956A::PCA9956A( PinName i2c_sda, PinName i2c_scl, char i2c_address )
nxp_ip 0:a624e2eeccac 5 : PCA995xA( i2c_sda, i2c_scl, i2c_address ), n_of_ports( 24 )
nxp_ip 0:a624e2eeccac 6 {
nxp_ip 0:a624e2eeccac 7 initialize();
nxp_ip 0:a624e2eeccac 8 }
nxp_ip 0:a624e2eeccac 9
nxp_ip 0:a624e2eeccac 10 PCA9956A::PCA9956A( I2C &i2c_obj, char i2c_address )
nxp_ip 0:a624e2eeccac 11 : PCA995xA( i2c_obj, i2c_address ), n_of_ports( 24 )
nxp_ip 0:a624e2eeccac 12 {
nxp_ip 0:a624e2eeccac 13 initialize();
nxp_ip 0:a624e2eeccac 14 }
nxp_ip 0:a624e2eeccac 15
nxp_ip 0:a624e2eeccac 16 PCA9956A::~PCA9956A()
nxp_ip 0:a624e2eeccac 17 {
nxp_ip 0:a624e2eeccac 18 }
nxp_ip 0:a624e2eeccac 19
nxp_ip 0:a624e2eeccac 20 void PCA9956A::initialize( void )
nxp_ip 0:a624e2eeccac 21 {
nxp_ip 0:a624e2eeccac 22 char init_array[] = {
nxp_ip 0:a624e2eeccac 23 PCA995xA::AUTO_INCREMENT | REGISTER_START, // Command
nxp_ip 0:a624e2eeccac 24 0x00, 0x00, // MODE1, MODE2
nxp_ip 0:a624e2eeccac 25 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, // LEDOUT[5:0]
nxp_ip 0:a624e2eeccac 26 0x80, 0x00, // GRPPWM, GRPFREQ
nxp_ip 0:a624e2eeccac 27 };
nxp_ip 0:a624e2eeccac 28
nxp_ip 0:a624e2eeccac 29 pwm( ALLPORTS, 0.0 );
nxp_ip 0:a624e2eeccac 30 current( ALLPORTS, 0.1 );
nxp_ip 0:a624e2eeccac 31
nxp_ip 0:a624e2eeccac 32 write( init_array, sizeof( init_array ) );
nxp_ip 0:a624e2eeccac 33 }
nxp_ip 0:a624e2eeccac 34
nxp_ip 0:a624e2eeccac 35 char PCA9956A::pwm_register_access( int port )
nxp_ip 0:a624e2eeccac 36 {
nxp_ip 0:a624e2eeccac 37 if ( port < n_of_ports )
nxp_ip 0:a624e2eeccac 38 return ( PWM_REGISTER_START + port );
nxp_ip 0:a624e2eeccac 39
nxp_ip 0:a624e2eeccac 40 return ( PWMALL );
nxp_ip 0:a624e2eeccac 41 }
nxp_ip 0:a624e2eeccac 42
nxp_ip 0:a624e2eeccac 43 char PCA9956A::current_register_access( int port )
nxp_ip 0:a624e2eeccac 44 {
nxp_ip 0:a624e2eeccac 45 if ( port < n_of_ports )
nxp_ip 0:a624e2eeccac 46 return ( IREF_REGISTER_START + port );
nxp_ip 0:a624e2eeccac 47
nxp_ip 0:a624e2eeccac 48 return ( IREFALL );
nxp_ip 0:a624e2eeccac 49 }
nxp_ip 0:a624e2eeccac 50
nxp_ip 0:a624e2eeccac 51 int PCA9956A::number_of_ports( void )
nxp_ip 0:a624e2eeccac 52 {
nxp_ip 0:a624e2eeccac 53 return ( n_of_ports );
nxp_ip 0:a624e2eeccac 54 }