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.
Demo hardware block diagram
Connection between mbed and PCA9547
Information
For more information, please visit component page.
main.cpp@2:63d9012f8c01, 2014-07-01 (annotated)
- Committer:
- okano
- Date:
- Tue Jul 01 00:28:38 2014 +0000
- Revision:
- 2:63d9012f8c01
- Parent:
- 1:63d8f8d68f61
disable function test
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
okano | 0:fb906b7b1452 | 1 | #include "mbed.h" |
okano | 0:fb906b7b1452 | 2 | #include "LM75B.h" |
okano | 1:63d8f8d68f61 | 3 | #include "PCA9547.h" |
okano | 0:fb906b7b1452 | 4 | |
okano | 0:fb906b7b1452 | 5 | int main() |
okano | 0:fb906b7b1452 | 6 | { |
okano | 1:63d8f8d68f61 | 7 | PCA9547 mux( p28, p27, 0xE0 ); |
okano | 1:63d8f8d68f61 | 8 | |
okano | 1:63d8f8d68f61 | 9 | mux.select( 0 ); |
okano | 2:63d9012f8c01 | 10 | mux.disable( ); |
okano | 1:63d8f8d68f61 | 11 | |
okano | 0:fb906b7b1452 | 12 | LM75B tmp0( p28, p27 ); // making instance after a branch of I2C bus (which is connecting the LM75B) enabled |
okano | 0:fb906b7b1452 | 13 | |
okano | 0:fb906b7b1452 | 14 | while(1) { |
okano | 0:fb906b7b1452 | 15 | printf( "%.3f\r\n", tmp0.read() ); |
okano | 0:fb906b7b1452 | 16 | wait( 1.0 ); |
okano | 0:fb906b7b1452 | 17 | } |
okano | 0:fb906b7b1452 | 18 | } |