I2C-bus switch with reset

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
wataaki
Date:
Wed Feb 04 06:04:27 2015 +0000
Commit message:
Initial version

Changed in this revision

PCA9546A.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
diff -r 000000000000 -r afc432dbba61 PCA9546A.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/PCA9546A.cpp	Wed Feb 04 06:04:27 2015 +0000
@@ -0,0 +1,23 @@
+#include "mbed.h"
+ 
+I2C i2c(p28,p27);        // sda, scl
+Serial pc(USBTX, USBRX); // tx, rx
+char cmd[32];
+int i, j, k;
+int sw;
+ 
+int main ()
+{
+    i2c.frequency(100000);
+    pc.printf("PCA9546A Sample Program\r\n");
+    
+  // PCA9546A
+    while(1)
+    {
+        pc.printf("選択チャネルは? 0 0 0 0 CH3 CH2 CH1 CH0 16進数で入力 \r\n");
+        pc.scanf("%x", &sw);
+        pc.printf("CH3=%d, CH2=%d, CH1=%d, CH0=%d\r\n\r\n", (sw & 0x8)>>3, (sw & 0x4)>>2, (sw & 0x2)>>1, (sw & 0x1));
+        cmd[0] = sw;                 // PCA9546 Cont Reg Ch1 enabled
+        i2c.write(0xe8, cmd, 1); // Send command string
+    }
+}
diff -r 000000000000 -r afc432dbba61 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Feb 04 06:04:27 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/4fc01daae5a5
\ No newline at end of file