We strongly encourage users to use Package manager for sharing their code on Libstock website, because it boosts your efficiency and leaves the end user with no room for error. [more info]
Rating:
Author: MIKROE
Last Updated: 2020-09-16
Package Version: 1.0.0.0
mikroSDK Library: 1.0.0.0
Category: I2C
Downloaded: 1898 times
Not followed.
License: MIT license
I2C MUX 3 Click is a compact add-on board that contains eight bidirectional translating switches dedicated for applications with I2C slave address conflicts. This board features the TCA9548APWR, a low voltage 8-channel I2C bus switch with an active-low reset input from Texas Instruments.
Do you want to subscribe in order to receive notifications regarding "I2C MUX 3 click" changes.
Do you want to unsubscribe in order to stop receiving notifications regarding "I2C MUX 3 click" changes.
Do you want to report abuse regarding "I2C MUX 3 click".
Library Description
The library covers all the necessary functions that enables the usage of the I2C MUX 3 click board. User can set one of 8 channels by writing to devices control register and check it by reading, or use the function to set it directly. User can also use sequential read and write function to comunicate with the devices sonnected to the selected channel.
Key functions:
uint8_t n_bytes );
- Function is used to write a sequential data starting from the targeted 8-bit register address of the device connected to the desired channel of the I2C MUX 4 click board.uint8_t n_bytes )
- Function is used to read a sequential data starting from the targeted 8-bit register address of the device connected to the desired channel of the I2C MUX 4 click board.void i2cmux3_ch_sel ( uint8_t sel_ch );
- Function is used to select communication channel.Examples description
The application is composed of three sections :
void application_task ( )
{
mikrobus_logWrite( "-------------------------", _LOG_LINE );
mikrobus_logWrite( "ID values by click board:", _LOG_LINE );
mikrobus_logWrite( "-------------------------", _LOG_LINE );
mikrobus_logWrite( "", _LOG_LINE );
i2cmux3_ch_sel( 0 );
i2cmux3_rd_slv ( 0x68, 0x00, &id_val, 1 );
ByteToHex( id_val, log_txt );
Ltrim( log_txt );
mikrobus_logWrite( " 6DOF IMU 12 : 0x", _LOG_TEXT );
mikrobus_logWrite( log_txt, _LOG_LINE );
mikrobus_logWrite( "-------------------------", _LOG_LINE );
Delay_ms( 100 );
i2cmux3_ch_sel( 1 );
i2cmux3_rd_slv ( 0x68, 0x0F, &id_val, 1 );
ByteToHex( id_val, log_txt );
Ltrim( log_txt );
mikrobus_logWrite( " RTC 10 : 0x", _LOG_TEXT );
mikrobus_logWrite( log_txt, _LOG_LINE );
mikrobus_logWrite( "-------------------------", _LOG_LINE );
Delay_ms( 100 );
i2cmux3_ch_sel( 2 );
i2cmux3_rd_slv ( 0x48, 0x0B, &id_val, 1 );
ByteToHex( id_val, log_txt );
Ltrim( log_txt );
mikrobus_logWrite( " Surface Temp : 0x", _LOG_TEXT );
mikrobus_logWrite( log_txt, _LOG_LINE );
mikrobus_logWrite( "-------------------------", _LOG_LINE );
Delay_ms( 100 );
i2cmux3_ch_sel( 3 );
i2cmux3_rd_slv ( 0x39, 0x92, &id_val, 1 );
ByteToHex( id_val, log_txt );
Ltrim( log_txt );
mikrobus_logWrite( " Spectrometer : 0x", _LOG_TEXT );
mikrobus_logWrite( log_txt, _LOG_LINE );
mikrobus_logWrite( "-------------------------", _LOG_LINE );
Delay_ms( 100 );
i2cmux3_ch_sel( 4 );
i2cmux3_rd_slv ( 0x30, 0x2F, &id_val, 1 );
ByteToHex( id_val, log_txt );
Ltrim( log_txt );
mikrobus_logWrite( " Compass 3 : 0x", _LOG_TEXT );
mikrobus_logWrite( log_txt, _LOG_LINE );
mikrobus_logWrite( "-------------------------", _LOG_LINE );
Delay_ms( 100 );
i2cmux3_ch_sel( 5 );
i2cmux3_rd_slv ( 0x29, 0x12, &id_val, 1 );
ByteToHex( id_val, log_txt );
Ltrim( log_txt );
mikrobus_logWrite( " Color 3 : 0x", _LOG_TEXT );
mikrobus_logWrite( log_txt, _LOG_LINE );
mikrobus_logWrite( "-------------------------", _LOG_LINE );
Delay_ms( 100 );
i2cmux3_ch_sel( 6 );
i2cmux3_rd_slv ( 0x0E, 0x00, &id_val, 1 );
ByteToHex( id_val, log_txt );
Ltrim( log_txt );
mikrobus_logWrite( " 6DOF IMU 11 : 0x", _LOG_TEXT );
mikrobus_logWrite( log_txt, _LOG_LINE );
mikrobus_logWrite( "-------------------------", _LOG_LINE );
Delay_ms( 100 );
i2cmux3_ch_sel( 7 );
i2cmux3_rd_slv ( 0x57, 0xFF, &id_val, 1 );
ByteToHex( id_val, log_txt );
Ltrim( log_txt );
mikrobus_logWrite( " Heart Rate 4 : 0x", _LOG_TEXT );
mikrobus_logWrite( log_txt, _LOG_LINE );
mikrobus_logWrite( "-------------------------", _LOG_LINE );
Delay_ms( 100 );
mikrobus_logWrite( "", _LOG_LINE );
mikrobus_logWrite( "-------------------------", _LOG_LINE );
Delay_ms( 3000 );
}
Other mikroE Libraries used in the example:
Additional notes and informations
Depending on the development board you are using, you may need USB UART click, USB UART 2 click or RS232 click to connect to your PC, for development systems with no UART to USB interface available on the board. The terminal available in all MikroElektronika compilers, or any other terminal application of your choice, can be used to read the message.