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:
Tue Jul 01 00:24:32 2014 +0000
Revision:
1:47f2cf4c6619
Parent:
0:662ab6a5aa97
Child:
2:c3459a955c8c
API document (doxygen format) added

Who changed what in which revision?

UserRevisionLine numberNew contents of line
okano 1:47f2cf4c6619 1 /**
okano 1:47f2cf4c6619 2 * PCA9547 library
okano 1:47f2cf4c6619 3 *
okano 1:47f2cf4c6619 4 * @author Tedd OKANO
okano 1:47f2cf4c6619 5 * @version 0.1
okano 1:47f2cf4c6619 6 * @date July-2014
okano 1:47f2cf4c6619 7 *
okano 1:47f2cf4c6619 8 * PCA9547: an I2C bus multiplexer control library
okano 1:47f2cf4c6619 9 *
okano 1:47f2cf4c6619 10 * PCA9547 is an I2C multiplexer which enables to select 1:8 multiplexed I2C bus.
okano 1:47f2cf4c6619 11 * The multiplexer is useful for deviding I2C bus to avoiding slave address conflict and separating capacitive loads.
okano 1:47f2cf4c6619 12 *
okano 1:47f2cf4c6619 13 * For more informatioj about PCA9547:
okano 1:47f2cf4c6619 14 * http://www.nxp.com/documents/data_sheet/PCA9547.pdf
okano 1:47f2cf4c6619 15 *
okano 1:47f2cf4c6619 16 */
okano 1:47f2cf4c6619 17
okano 0:662ab6a5aa97 18 #ifndef MBED_PCA9547_H
okano 0:662ab6a5aa97 19 #define MBED_PCA9547_H
okano 0:662ab6a5aa97 20
okano 0:662ab6a5aa97 21 #include "mbed.h"
okano 0:662ab6a5aa97 22
okano 1:47f2cf4c6619 23 /** PCA9547 class
okano 1:47f2cf4c6619 24 *
okano 1:47f2cf4c6619 25 * PCA9547: an I2C bus multiplexer control library
okano 1:47f2cf4c6619 26 *
okano 1:47f2cf4c6619 27 * PCA9547 is an I2C multiplexer which enables to select 1:8 multiplexed I2C bus.
okano 1:47f2cf4c6619 28 * The multiplexer is useful for deviding I2C bus to avoiding slave address conflict and separating capacitive loads.
okano 1:47f2cf4c6619 29 *
okano 1:47f2cf4c6619 30 * For more informatioj about PCA9547:
okano 1:47f2cf4c6619 31 * http://www.nxp.com/documents/data_sheet/PCA9547.pdf
okano 1:47f2cf4c6619 32 *
okano 1:47f2cf4c6619 33 * Example:
okano 1:47f2cf4c6619 34 * @code
okano 1:47f2cf4c6619 35 * #include "mbed.h"
okano 1:47f2cf4c6619 36 * #include "LM75B.h"
okano 1:47f2cf4c6619 37 * #include "PCA9547.h"
okano 1:47f2cf4c6619 38 *
okano 1:47f2cf4c6619 39 * int main()
okano 1:47f2cf4c6619 40 * {
okano 1:47f2cf4c6619 41 * PCA9547 mux( p28, p27, 0xE0 );
okano 1:47f2cf4c6619 42 *
okano 1:47f2cf4c6619 43 * mux.select( 0 );
okano 1:47f2cf4c6619 44 *
okano 1:47f2cf4c6619 45 * LM75B tmp0( p28, p27 ); // making instance after a branch of I2C bus (which is connecting the LM75B) enabled
okano 1:47f2cf4c6619 46 *
okano 1:47f2cf4c6619 47 * while(1) {
okano 1:47f2cf4c6619 48 * printf( "%.3f\r\n", tmp0.read() );
okano 1:47f2cf4c6619 49 * wait( 1.0 );
okano 1:47f2cf4c6619 50 * }
okano 1:47f2cf4c6619 51 * }
okano 1:47f2cf4c6619 52 * @endcode
okano 1:47f2cf4c6619 53 */
okano 1:47f2cf4c6619 54
okano 0:662ab6a5aa97 55 class PCA9547
okano 0:662ab6a5aa97 56 {
okano 0:662ab6a5aa97 57 public:
okano 1:47f2cf4c6619 58
okano 1:47f2cf4c6619 59 /** Create a PCA9547 instance connected to specified I2C pins with specified address
okano 1:47f2cf4c6619 60 *
okano 1:47f2cf4c6619 61 * @param sda I2C-bus SDA pin
okano 1:47f2cf4c6619 62 * @param scl I2C-bus SCL pin
okano 1:47f2cf4c6619 63 * @param i2c_address I2C-bus address (default: 0xE0)
okano 1:47f2cf4c6619 64 */
okano 0:662ab6a5aa97 65 PCA9547( PinName sda, PinName scl, char i2c_address = 0xE0 );
okano 0:662ab6a5aa97 66
okano 1:47f2cf4c6619 67 /** Destructor of PCA9547
okano 1:47f2cf4c6619 68 */
okano 0:662ab6a5aa97 69 ~PCA9547();
okano 0:662ab6a5aa97 70
okano 1:47f2cf4c6619 71 /** Channel select
okano 1:47f2cf4c6619 72 *
okano 1:47f2cf4c6619 73 * Enable and selecting a channel
okano 1:47f2cf4c6619 74 *
okano 1:47f2cf4c6619 75 * @param channel channel number
okano 1:47f2cf4c6619 76 */
okano 0:662ab6a5aa97 77 void select( char channel );
okano 0:662ab6a5aa97 78
okano 0:662ab6a5aa97 79 private:
okano 0:662ab6a5aa97 80 I2C i2c;
okano 0:662ab6a5aa97 81 char _i2c_addr;
okano 0:662ab6a5aa97 82 };
okano 0:662ab6a5aa97 83
okano 0:662ab6a5aa97 84 #endif // MBED_PCA9547_H