TCA9548A 8 channel I2C switch with reset

Dependents:   4012Code PWM SBra_Programme_Mbed

Revision:
0:5bd73cede544
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tca9548a.cpp	Tue May 24 06:07:37 2016 +0000
@@ -0,0 +1,35 @@
+/**
+ *  TCA9548A library
+ *
+ *  @author Akash Vibhute
+ *  @author < akash . roboticist [at] gmail . com >
+ *  @version 0.1
+ *  @date May/24/2016
+ */
+ 
+#include "tca9548a.h"
+ 
+TCA9548A::TCA9548A( PinName sda, PinName scl, uint8_t i2c_address, PinName resetPin, uint32_t hz ) : i2c_(sda, scl), reset_pin(resetPin)
+{
+    i2c_addr = i2c_address;
+    i2c_.frequency(hz);
+}
+
+ 
+void TCA9548A::select( uint8_t channel )
+{
+    char data; //create temporary char buffer
+    
+    if(channel >= 8) return;
+    
+    data = 1 << channel;
+    i2c_.write( i2c_addr << 1, &data, 1);
+}
+ 
+void TCA9548A::reset( )
+{
+    reset_pin = 0;
+    wait_ms(1);
+    reset_pin = 1;
+}
+ 
\ No newline at end of file