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
base_class/PCA962x.h@0:7a206e6db594, 2015-02-26 (annotated)
- Committer:
- nxp_ip
- Date:
- Thu Feb 26 09:16:41 2015 +0000
- Revision:
- 0:7a206e6db594
- Child:
- 1:6fcc4f604988
Initial version
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| nxp_ip | 0:7a206e6db594 | 1 | /** PCA962x PWM control LED driver family |
| nxp_ip | 0:7a206e6db594 | 2 | * |
| nxp_ip | 0:7a206e6db594 | 3 | * Abstract class for PCA962x family |
| nxp_ip | 0:7a206e6db594 | 4 | * No instance can be made from this class |
| nxp_ip | 0:7a206e6db594 | 5 | * |
| nxp_ip | 0:7a206e6db594 | 6 | * @class PCA9956A |
| nxp_ip | 0:7a206e6db594 | 7 | * @author Akifumi (Tedd) OKANO, NXP Semiconductors |
| nxp_ip | 0:7a206e6db594 | 8 | * @version 0.5 |
| nxp_ip | 0:7a206e6db594 | 9 | * @date 26-Feb-2015 |
| nxp_ip | 0:7a206e6db594 | 10 | * |
| nxp_ip | 0:7a206e6db594 | 11 | * Released under the Apache 2 license License |
| nxp_ip | 0:7a206e6db594 | 12 | */ |
| nxp_ip | 0:7a206e6db594 | 13 | |
| nxp_ip | 0:7a206e6db594 | 14 | #ifndef MBED_PCA962x |
| nxp_ip | 0:7a206e6db594 | 15 | #define MBED_PCA962x |
| nxp_ip | 0:7a206e6db594 | 16 | |
| nxp_ip | 0:7a206e6db594 | 17 | #include "mbed.h" |
| nxp_ip | 0:7a206e6db594 | 18 | |
| nxp_ip | 0:7a206e6db594 | 19 | #define ALLPORTS 0xFF |
| nxp_ip | 0:7a206e6db594 | 20 | #define DEFAULT_PWM 1.0 |
| nxp_ip | 0:7a206e6db594 | 21 | |
| nxp_ip | 0:7a206e6db594 | 22 | /** PCA962x class |
| nxp_ip | 0:7a206e6db594 | 23 | * |
| nxp_ip | 0:7a206e6db594 | 24 | * Abstract class for PCA962x family |
| nxp_ip | 0:7a206e6db594 | 25 | * No instance can be made from this class |
| nxp_ip | 0:7a206e6db594 | 26 | */ |
| nxp_ip | 0:7a206e6db594 | 27 | class PCA962x |
| nxp_ip | 0:7a206e6db594 | 28 | { |
| nxp_ip | 0:7a206e6db594 | 29 | public: |
| nxp_ip | 0:7a206e6db594 | 30 | PCA962x( PinName i2c_sda, PinName i2c_scl, char i2c_address = DEFAULT_I2C_ADDR ); |
| nxp_ip | 0:7a206e6db594 | 31 | PCA962x( I2C &i2c_obj, char i2c_address = DEFAULT_I2C_ADDR ); |
| nxp_ip | 0:7a206e6db594 | 32 | virtual ~PCA962x(); |
| nxp_ip | 0:7a206e6db594 | 33 | |
| nxp_ip | 0:7a206e6db594 | 34 | void reset( void ); |
| nxp_ip | 0:7a206e6db594 | 35 | |
| nxp_ip | 0:7a206e6db594 | 36 | void pwm( int port, float v ); |
| nxp_ip | 0:7a206e6db594 | 37 | void pwm( float *vp ); |
| nxp_ip | 0:7a206e6db594 | 38 | virtual int number_of_ports( void ) = 0; |
| nxp_ip | 0:7a206e6db594 | 39 | |
| nxp_ip | 0:7a206e6db594 | 40 | void write( char reg_addr, char data ); |
| nxp_ip | 0:7a206e6db594 | 41 | void write( char *data, int length ); |
| nxp_ip | 0:7a206e6db594 | 42 | char read( char reg_addr ); |
| nxp_ip | 0:7a206e6db594 | 43 | void read( char reg_addr, char *data, int length ); |
| nxp_ip | 0:7a206e6db594 | 44 | |
| nxp_ip | 0:7a206e6db594 | 45 | protected: |
| nxp_ip | 0:7a206e6db594 | 46 | enum { |
| nxp_ip | 0:7a206e6db594 | 47 | DEFAULT_I2C_ADDR = 0xC0, |
| nxp_ip | 0:7a206e6db594 | 48 | AUTO_INCREMENT = 0x80, |
| nxp_ip | 0:7a206e6db594 | 49 | PWMALL = 0xFF |
| nxp_ip | 0:7a206e6db594 | 50 | }; |
| nxp_ip | 0:7a206e6db594 | 51 | |
| nxp_ip | 0:7a206e6db594 | 52 | private: |
| nxp_ip | 0:7a206e6db594 | 53 | virtual void initialize( void ) = 0; |
| nxp_ip | 0:7a206e6db594 | 54 | virtual char pwm_register_access( int port ) = 0; |
| nxp_ip | 0:7a206e6db594 | 55 | |
| nxp_ip | 0:7a206e6db594 | 56 | I2C *i2c_p; |
| nxp_ip | 0:7a206e6db594 | 57 | I2C &i2c; |
| nxp_ip | 0:7a206e6db594 | 58 | char address; // I2C slave address |
| nxp_ip | 0:7a206e6db594 | 59 | } |
| nxp_ip | 0:7a206e6db594 | 60 | ; |
| nxp_ip | 0:7a206e6db594 | 61 | |
| nxp_ip | 0:7a206e6db594 | 62 | #endif // MBED_PCA962x |
PCA9622, PCA9624, PCA9626 : 8, 16 & 24ch LED driver (Voltage switch type)