Dependents: 4012Code PWM SBra_Programme_Mbed
tca9548a.cpp
00001 /** 00002 * TCA9548A library 00003 * 00004 * @author Akash Vibhute 00005 * @author < akash . roboticist [at] gmail . com > 00006 * @version 0.1 00007 * @date May/24/2016 00008 */ 00009 00010 #include "tca9548a.h" 00011 00012 TCA9548A::TCA9548A( PinName sda, PinName scl, uint8_t i2c_address, PinName resetPin, uint32_t hz ) : i2c_(sda, scl), reset_pin(resetPin) 00013 { 00014 i2c_addr = i2c_address; 00015 i2c_.frequency(hz); 00016 } 00017 00018 00019 void TCA9548A::select( uint8_t channel ) 00020 { 00021 char data; //create temporary char buffer 00022 00023 if(channel >= 8) return; 00024 00025 data = 1 << channel; 00026 i2c_.write( i2c_addr << 1, &data, 1); 00027 } 00028 00029 void TCA9548A::reset( ) 00030 { 00031 reset_pin = 0; 00032 wait_ms(1); 00033 reset_pin = 1; 00034 } 00035
Generated on Fri Jul 15 2022 12:20:07 by
