Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: PCA9626_Hello PCA9624_Hello PCA9622_Hello
PCA9626/PCA9626.cpp@7:7ebf563f6e6c, 2015-03-19 (annotated)
- Committer:
- nxp_ip
- Date:
- Thu Mar 19 10:02:57 2015 +0000
- Revision:
- 7:7ebf563f6e6c
- Parent:
- 3:40f83904f0a8
API document update
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
nxp_ip | 0:7a206e6db594 | 1 | #include "mbed.h" |
nxp_ip | 0:7a206e6db594 | 2 | #include "PCA9626.h" |
nxp_ip | 0:7a206e6db594 | 3 | |
nxp_ip | 0:7a206e6db594 | 4 | PCA9626::PCA9626( PinName i2c_sda, PinName i2c_scl, char i2c_address ) |
nxp_ip | 0:7a206e6db594 | 5 | : PCA962x( i2c_sda, i2c_scl, i2c_address ), n_of_ports( 24 ) |
nxp_ip | 0:7a206e6db594 | 6 | { |
nxp_ip | 0:7a206e6db594 | 7 | initialize(); |
nxp_ip | 0:7a206e6db594 | 8 | } |
nxp_ip | 0:7a206e6db594 | 9 | |
nxp_ip | 0:7a206e6db594 | 10 | PCA9626::PCA9626( I2C &i2c_obj, char i2c_address ) |
nxp_ip | 0:7a206e6db594 | 11 | : PCA962x( i2c_obj, i2c_address ), n_of_ports( 24 ) |
nxp_ip | 0:7a206e6db594 | 12 | { |
nxp_ip | 0:7a206e6db594 | 13 | initialize(); |
nxp_ip | 0:7a206e6db594 | 14 | } |
nxp_ip | 0:7a206e6db594 | 15 | |
nxp_ip | 0:7a206e6db594 | 16 | PCA9626::~PCA9626() |
nxp_ip | 0:7a206e6db594 | 17 | { |
nxp_ip | 0:7a206e6db594 | 18 | } |
nxp_ip | 0:7a206e6db594 | 19 | |
nxp_ip | 0:7a206e6db594 | 20 | void PCA9626::initialize( void ) |
nxp_ip | 0:7a206e6db594 | 21 | { |
nxp_ip | 0:7a206e6db594 | 22 | char init_array0[] = { |
nxp_ip | 0:7a206e6db594 | 23 | PCA962x::AUTO_INCREMENT | REGISTER_START, // Command |
nxp_ip | 3:40f83904f0a8 | 24 | 0x01, 0x00, // MODE1, MODE2 |
nxp_ip | 0:7a206e6db594 | 25 | }; |
nxp_ip | 0:7a206e6db594 | 26 | char init_array1[] = { |
nxp_ip | 0:7a206e6db594 | 27 | PCA962x::AUTO_INCREMENT | LEDOUT_REGISTER_START, // Command |
nxp_ip | 0:7a206e6db594 | 28 | 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, // LEDOUT[5:0] |
nxp_ip | 0:7a206e6db594 | 29 | }; |
nxp_ip | 0:7a206e6db594 | 30 | |
nxp_ip | 0:7a206e6db594 | 31 | write( init_array0, sizeof( init_array0 ) ); |
nxp_ip | 0:7a206e6db594 | 32 | write( init_array1, sizeof( init_array1 ) ); |
nxp_ip | 0:7a206e6db594 | 33 | } |
nxp_ip | 0:7a206e6db594 | 34 | |
nxp_ip | 0:7a206e6db594 | 35 | char PCA9626::pwm_register_access( int port ) |
nxp_ip | 0:7a206e6db594 | 36 | { |
nxp_ip | 0:7a206e6db594 | 37 | if ( port < n_of_ports ) |
nxp_ip | 0:7a206e6db594 | 38 | return ( PWM_REGISTER_START + port ); |
nxp_ip | 0:7a206e6db594 | 39 | |
nxp_ip | 0:7a206e6db594 | 40 | return ( PWMALL ); |
nxp_ip | 0:7a206e6db594 | 41 | } |
nxp_ip | 0:7a206e6db594 | 42 | |
nxp_ip | 0:7a206e6db594 | 43 | int PCA9626::number_of_ports( void ) |
nxp_ip | 0:7a206e6db594 | 44 | { |
nxp_ip | 0:7a206e6db594 | 45 | return ( n_of_ports ); |
nxp_ip | 0:7a206e6db594 | 46 | } |