Sarah Marsh / TCA9548A

Fork of TCA9548A by Akash Vibhute

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers tca9548a.cpp Source File

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) : i2c_(sda, scl), reset_pin(resetPin)
00013 {
00014     i2c_addr = i2c_address;
00015 }
00016 
00017  
00018 void TCA9548A::select( uint8_t channel )
00019 {
00020     if(channel >= 8) return;
00021     char data[1];
00022     data[0] = 1 << channel;
00023     int err = i2c_.write(0xE0, data, 1);
00024 }
00025 
00026 char TCA9548A::check_set_channel()
00027 {
00028     char data[1];
00029     int err = i2c_.read(0xE1, data, 1);
00030     return data[0];
00031 }
00032  
00033 void TCA9548A::reset( )
00034 {
00035     reset_pin = 0;
00036     wait_ms(1);
00037     reset_pin = 1;
00038 }
00039