HelloWorld program for 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

Dependencies:   LM75B PCA9547 mbed

What is this?

This is a sample code to demonstrate the PCA9547. The PCA9547 is a 8 channel multiplexer for I2C bus.
The code shows how the bed can access the I2C device (LM75B) through PCA9547.

PCA9547_and_LM75B
Demo hardware block diagram

/media/uploads/okano/pca9547_connections.png
Connection between mbed and PCA9547

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.

Committer:
okano
Date:
Tue Jul 01 00:37:05 2014 +0000
Revision:
3:e8697f8b6da5
Parent:
1:63d8f8d68f61
Child:
5:c6450501913e
correction: typo in comment

Who changed what in which revision?

UserRevisionLine numberNew contents of line
okano 3:e8697f8b6da5 1 /**
okano 3:e8697f8b6da5 2 * PCA9547 library "Hello world" sample
okano 3:e8697f8b6da5 3 *
okano 3:e8697f8b6da5 4 * @author Tedd OKANO
okano 3:e8697f8b6da5 5 * @version 0.1
okano 3:e8697f8b6da5 6 * @date July-2014
okano 3:e8697f8b6da5 7 *
okano 3:e8697f8b6da5 8 * PCA9547: an I2C bus multiplexer control library
okano 3:e8697f8b6da5 9 *
okano 3:e8697f8b6da5 10 * PCA9547 is an I2C multiplexer which enables to select 1:8 multiplexed I2C bus.
okano 3:e8697f8b6da5 11 * The multiplexer is useful for deviding I2C bus to avoiding slave address conflict and separating capacitive loads.
okano 3:e8697f8b6da5 12 *
okano 3:e8697f8b6da5 13 * For more information about PCA9547:
okano 3:e8697f8b6da5 14 * http://www.nxp.com/documents/data_sheet/PCA9547.pdf
okano 3:e8697f8b6da5 15 *
okano 3:e8697f8b6da5 16 */
okano 3:e8697f8b6da5 17
okano 0:fb906b7b1452 18 #include "mbed.h"
okano 0:fb906b7b1452 19 #include "LM75B.h"
okano 1:63d8f8d68f61 20 #include "PCA9547.h"
okano 0:fb906b7b1452 21
okano 0:fb906b7b1452 22 int main()
okano 0:fb906b7b1452 23 {
okano 1:63d8f8d68f61 24 PCA9547 mux( p28, p27, 0xE0 );
okano 1:63d8f8d68f61 25
okano 1:63d8f8d68f61 26 mux.select( 0 );
okano 1:63d8f8d68f61 27
okano 0:fb906b7b1452 28 LM75B tmp0( p28, p27 ); // making instance after a branch of I2C bus (which is connecting the LM75B) enabled
okano 0:fb906b7b1452 29
okano 0:fb906b7b1452 30 while(1) {
okano 0:fb906b7b1452 31 printf( "%.3f\r\n", tmp0.read() );
okano 0:fb906b7b1452 32 wait( 1.0 );
okano 0:fb906b7b1452 33 }
okano 0:fb906b7b1452 34 }