PCA9547: an I2C bus multiplexer control library. PCA9547 is an I2C multiplexer which enables to select 1:8 multiplexed I2C bus. The multiplexer is useful for deviding I2C bus to avoiding slave address conflict and separating capacitive loads. For more information about PCA9547: http://www.nxp.com/documents/data_sheet/PCA9547.pdf

Dependents:   pca9547_Hello m3Dpi

/media/uploads/okano/pca9547_connections.png

Information

For more information, please visit component page.

The PCA9547 is an octal bidirectional translating multiplexer controlled by the I2C-bus. The SCL/SDA upstream pair fans out to eight downstream pairs, or channels.

pca9547

Committer:
okano
Date:
Fri Apr 17 03:34:23 2015 +0000
Revision:
8:c716fb3ccb8d
Parent:
6:33ef755248e0
Parent:
7:995f209b8707
re-publishing to correct revision

Who changed what in which revision?

UserRevisionLine numberNew contents of line
okano 3:7e884a7805b1 1 /**
okano 3:7e884a7805b1 2 * PCA9547 library
okano 1:47f2cf4c6619 3 *
okano 3:7e884a7805b1 4 * @author Tedd OKANO
okano 6:33ef755248e0 5 * @version 0.2
okano 6:33ef755248e0 6 * @date Feb-2015
okano 3:7e884a7805b1 7 *
okano 3:7e884a7805b1 8 * PCA9547: an I2C bus multiplexer control library
okano 1:47f2cf4c6619 9 *
okano 3:7e884a7805b1 10 * PCA9547 is an I2C multiplexer which enables to select 1:8 multiplexed I2C bus.
okano 3:7e884a7805b1 11 * The multiplexer is useful for deviding I2C bus to avoiding slave address conflict and separating capacitive loads.
okano 1:47f2cf4c6619 12 *
okano 4:3c0af4c37587 13 * For more information about PCA9547:
okano 3:7e884a7805b1 14 * http://www.nxp.com/documents/data_sheet/PCA9547.pdf
okano 3:7e884a7805b1 15 *
okano 1:47f2cf4c6619 16 */
okano 3:7e884a7805b1 17
okano 0:662ab6a5aa97 18 #include "PCA9547.h"
okano 0:662ab6a5aa97 19
okano 5:f4f72501148a 20 PCA9547::PCA9547( PinName sda, PinName scl, char i2c_address )
okano 5:f4f72501148a 21 : i2c_p( new I2C( sda, scl ) ), i2c( *i2c_p ), i2c_addr( i2c_address )
okano 0:662ab6a5aa97 22 {
okano 0:662ab6a5aa97 23 // do nothing.
okano 0:662ab6a5aa97 24 // leave it in default state.
okano 5:f4f72501148a 25 }
okano 5:f4f72501148a 26
okano 5:f4f72501148a 27 PCA9547::PCA9547( I2C &i2c_, char i2c_address )
okano 5:f4f72501148a 28 : i2c_p( NULL ), i2c( i2c_ ), i2c_addr( i2c_address )
okano 0:662ab6a5aa97 29 {
okano 0:662ab6a5aa97 30 // do nothing.
okano 0:662ab6a5aa97 31 // leave it in default state.
okano 0:662ab6a5aa97 32 }
okano 0:662ab6a5aa97 33
okano 0:662ab6a5aa97 34 PCA9547::~PCA9547()
okano 0:662ab6a5aa97 35 {
okano 5:f4f72501148a 36 if ( NULL != i2c_p )
okano 5:f4f72501148a 37 delete i2c_p;
okano 0:662ab6a5aa97 38 }
okano 0:662ab6a5aa97 39
okano 0:662ab6a5aa97 40 void PCA9547::select( char channel )
okano 0:662ab6a5aa97 41 {
okano 0:662ab6a5aa97 42 char data = 0x08 | channel;
okano 0:662ab6a5aa97 43
okano 5:f4f72501148a 44 i2c.write( i2c_addr, &data, 1 );
okano 0:662ab6a5aa97 45 }
okano 2:c3459a955c8c 46
okano 2:c3459a955c8c 47 void PCA9547::disable( void )
okano 2:c3459a955c8c 48 {
okano 2:c3459a955c8c 49 char data = 0x00;
okano 2:c3459a955c8c 50
okano 5:f4f72501148a 51 i2c.write( i2c_addr, &data, 1 );
okano 2:c3459a955c8c 52 }