Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of libTCS34725 by
TCA9548 Class Reference
TCA9548 control class. More...
#include <TCA9548.h>
Public Member Functions | |
| TCA9548 () | |
| Initialize object with default i2c pins. | |
| TCA9548 (PinName i2c_sda, PinName i2c_scl) | |
| Initialize object with specific i2c pins. | |
| bool | init (uint8_t iCh) |
| Boot up the mux and change to initial channel (defaults to 0) | |
| void | ch (uint8_t newCh) |
| Changes the i2c channel. | |
Detailed Description
TCA9548 control class.
Example:
//Perform readings on two i2c devices with the same address #include "TCA9548.h" #include "mbed.h" #include "VL6180.h" TCA9548 i2cMux(SDA, SCL); VL6180 laser1(SDA, SCL); // on SD0 and SC0 VL6180 laser2(SDA, SCL); // on SD1 and SC1 Serial pc(USBTX, USBRX); //USB serial int main() { float reading; i2cMux.ch(CH0); reading = laser1.read(); pc.printf("Laser 1: %f\n", reading); i2cMux.ch(CH1); //for two channels: i2cMux.ch(CH1 | CH5); pc.printf("Laser 2: %f\n", reading); reading = laser2.read(); while(1) { } }
Definition at line 51 of file TCA9548.h.
Constructor & Destructor Documentation
| TCA9548 | ( | ) |
Initialize object with default i2c pins.
Definition at line 3 of file TCA9548.cpp.
| TCA9548 | ( | PinName | i2c_sda, |
| PinName | i2c_scl | ||
| ) |
Initialize object with specific i2c pins.
- Parameters:
-
i2c_sda SDA pin i2c_scl SCL pin
Definition at line 4 of file TCA9548.cpp.
Member Function Documentation
| void ch | ( | uint8_t | newCh ) |
Changes the i2c channel.
- Parameters:
-
newCh New channel for mux
Definition at line 27 of file TCA9548.cpp.
| bool init | ( | uint8_t | iCh ) |
Boot up the mux and change to initial channel (defaults to 0)
- Parameters:
-
iCh Initial Channel
- Returns:
- 1 if failed ` 0 if successful
Definition at line 12 of file TCA9548.cpp.
Generated on Fri Jul 15 2022 20:40:20 by
1.7.2
