imu_serial initial commit

Dependencies:   MadgwickAHRS mpu9250 mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers TCA9548.h Source File

TCA9548.h

00001 #ifndef TCA9548_H
00002 #define TCA9548_H
00003 
00004 // Includes
00005 #include "mbed.h"
00006 
00007  
00008 //Constants
00009 
00010  
00011  
00012 class TCA9548 
00013 {
00014     //data members
00015     protected:
00016      
00017     public:
00018      
00019      
00020     private:
00021     uint8_t addr;
00022      
00023     //functions
00024     protected:
00025      
00026     public:
00027      
00028     TCA9548(uint8_t address = 0x70)
00029     {
00030          //MBED uses 8 bit address, most devices use 7 bit address, so need to shift
00031          addr = address << 1;         
00032     } // end of constructor    
00033      
00034     void setAddr(uint8_t address)
00035     {
00036          addr = address;
00037     } // end of setAddr
00038      
00039     void addrSelect(uint8_t ch)
00040     {
00041         //address range is 0-7
00042         if (ch > 7) return;
00043         char ch_s[1];
00044         ch_s[0] = 1 << ch;
00045         
00046         i2c.write(addr, ch_s, 1);
00047      
00048     } // end of addrSelect
00049      
00050     private:
00051      
00052 };// end of class
00053 
00054 
00055 
00056 
00057 
00058 #endif