Tedd OKANO / Mbed 2 deprecated PCA9546A_Hello

Dependencies:   LM75B PCA9546A mbed

Files at this revision

API Documentation at this revision

Comitter:
okano
Date:
Mon Feb 23 06:07:56 2015 +0000
Commit message:
initial version

Changed in this revision

LM75B.lib Show annotated file Show diff for this revision Revisions of this file
PCA9546A.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LM75B.lib	Mon Feb 23 06:07:56 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/chris/code/LM75B/#6a70c9303bbe
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/PCA9546A.lib	Mon Feb 23 06:07:56 2015 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/okano/code/PCA9546A/#2d50d8bba33e
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Feb 23 06:07:56 2015 +0000
@@ -0,0 +1,52 @@
+/**
+ *  PCA9546A library "Hello world" sample
+ *
+ *  @author  Tedd OKANO
+ *  @version 0.1
+ *  @date    Feb-2015
+ *
+ *  PCA9546A: an I2C bus switch control library
+ *
+ *  The PCA9546A is a quad bidirectional translating switch controlled
+ *  via the I2C-bus. The SCL/SDA upstream pair fans out to four downstream
+ *  pairs, or channels. Any individual SCx/SDx channel or combination of
+ *  channels can be selected, determined by the contents of the programmable
+ *  control register.
+ *
+ *  For more information about PCA9546A:
+ *    http://www.nxp.com/documents/data_sheet/PCA9546A.pdf
+ *
+ */
+
+#include "mbed.h"
+#include "LM75B.h"
+#include "PCA9546A.h"
+
+PCA9546A    i2c_sw( p28, p27, 0xE0 );
+
+int main()
+{
+    //  all PCA9546A's downstream ports are OFF after power-up and hardware-reset
+    
+    i2c_sw.on( 0 );     //  turn-ON  the channel 0
+
+    LM75B   tmp0( p28, p27 );   //  making instance after a branch of I2C bus (which is connecting the LM75B) enabled
+
+    i2c_sw.off( 0 );    //  turn-OFF the channel 0
+    i2c_sw.on( 1 );     //  turn-ON  the channel 1
+
+    LM75B   tmp1( p28, p27 );   //  making instance after a branch of I2C bus (which is connecting the LM75B) enabled
+
+    while(1) {
+        
+        i2c_sw.off( 1 );    //  turn-OFF the channel 1
+        i2c_sw.on( 0 );     //  turn-ON  the channel 0
+        printf( "%.3f\r\n", tmp0.read() );
+
+        i2c_sw.off( 0 );    //  turn-OFF the channel 0
+        i2c_sw.on( 1 );     //  turn-ON  the channel 1
+        printf( "%.3f\r\n", tmp1.read() );
+
+        wait( 1.0 );
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Feb 23 06:07:56 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/9ad691361fac
\ No newline at end of file