i2cmux5  2.0.0.0
Main Page

I2C MUX 5 click

I2C MUX 5 Click is a compact add-on board with translating I2C and SMBus switch intended for applications with I2C slave address conflicts.

click Product page


Click library

  • Author : Nenad Filipovic
  • Date : Nov 2020.
  • Type : I2C type

Software Support

We provide a library for the I2cMux5 Click as well as a demo application (example), developed using MikroElektronika compilers. The demo can run on all the main MikroElektronika development boards.

Package can be downloaded/installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on mikroE github account.

Library Description

This library contains API for I2cMux5 Click driver.

Standard key functions :

Example key functions :

  • i2cmux5_generic_write I2C MUX 5 I2C writing function.
    err_t i2cmux5_generic_write ( i2cmux5_t *ctx, uint8_t reg, uint8_t *tx_buf, uint8_t tx_len );
  • i2cmux5_generic_read I2C MUX 5 I2C reading function.
    err_t i2cmux5_generic_read ( i2cmux5_t *ctx, uint8_t reg, uint8_t *rx_buf, uint8_t rx_len );
  • i2cmux5_channel_read_byte I2C MUX 5 I2C channel reading function.
    uint8_t i2cmux5_channel_read_byte ( i2cmux5_t *ctx, uint8_t sel_ch, uint8_t ch_slave_addr, uint8_t reg );

Examples Description

This app reads "Who am I" and "Status" register of the connected click boards to the I2C MUX 5 click.

The demo application is composed of two sections :

Application Init

Initializes I2C driver, set the default configuration and start to write log.

void application_init ( void ) {
log_cfg_t log_cfg;
i2cmux5_cfg_t i2cmux5_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_printf( &logger, "\r\n" );
log_info( &logger, " Application Init " );
// Click initialization.
i2cmux5_cfg_setup( &i2cmux5_cfg );
I2CMUX5_MAP_MIKROBUS( i2cmux5_cfg, MIKROBUS_1 );
err_t init_flag = i2cmux5_init( &i2cmux5, &i2cmux5_cfg );
if ( init_flag == I2C_MASTER_ERROR ) {
log_error( &logger, " Application Init Error. " );
log_info( &logger, " Please, run program again... " );
for ( ; ; );
}
i2cmux5_default_cfg ( &i2cmux5 );
log_info( &logger, " Application Task \r\n" );
Delay_ms( 100 );
log_printf( &logger, "-------------------------------\r\n" );
log_printf( &logger, " I2C MUX 5 click \r\n" );
log_printf( &logger, "-------------------------------\r\n" );
}

Application Task

This is an example that demonstrates the use of the I2C MUX 5 click board. In this example, we read "Who am I" ( or "Status" ) register of the connected click boards to the I2C MUX 5 click. Channel 1 : 6DOF IMU 9 click [slave address: 0x69; reg: 0x75; ID val.: 0xA9], Channel 2 : 6DOF IMU 11 click [slave address: 0x0E; reg: 0x00; ID val.: 0x2D], Channel 3 : RTC 10 click [slave address: 0x68; reg: 0x0F; St val.: 0x88], Channel 4 : Accel 10 click [slave address: 0x18; reg: 0x0F; ID val.: 0x44]. Results are being sent to the Usart Terminal where you can track their changes.

void application_task ( void ) {
Delay_ms( 1000 );
log_printf( &logger, " CH-1 6DOF IMU 9 click : 0x%X \r\n", ( uint16_t )rx_data );
Delay_ms( 1000 );
log_printf( &logger, " CH-2 6DOF IMU 11 click : 0x%X \r\n", ( uint16_t )rx_data );
Delay_ms( 1000 );
log_printf( &logger, " CH-3 RTC 10 click : 0x%X \r\n", ( uint16_t )rx_data );
Delay_ms( 1000 );
log_printf( &logger, " CH-4 Accel 10 click : 0x%X \r\n", ( uint16_t )rx_data );
log_printf( &logger, "-------------------------------\r\n" );
i2cmux5_hw_reset( &i2cmux5 );
Delay_ms( 2000 );
}

The full application code, and ready to use projects can be installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on mikroE github account.

Other mikroE Libraries used in the example:

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.I2cMux5

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. UART terminal is available in all Mikroelektronika compilers.


i2cmux5_generic_write
err_t i2cmux5_generic_write(i2cmux5_t *ctx, uint8_t reg, uint8_t *tx_buf, uint8_t tx_len)
I2C MUX 5 I2C writing function.
I2CMUX5_SET_RTC_10_ADDR
#define I2CMUX5_SET_RTC_10_ADDR
Definition: i2cmux5.h:170
I2CMUX5_CH_1
#define I2CMUX5_CH_1
I2C MUX 5 channel selection setting.
Definition: i2cmux5.h:190
i2cmux5_hw_reset
void i2cmux5_hw_reset(i2cmux5_t *ctx)
I2C MUX 5 HW reset function.
i2cmux5_channel_read_byte
uint8_t i2cmux5_channel_read_byte(i2cmux5_t *ctx, uint8_t sel_ch, uint8_t ch_slave_addr, uint8_t reg)
I2C MUX 5 I2C channel reading function.
i2cmux5_generic_read
err_t i2cmux5_generic_read(i2cmux5_t *ctx, uint8_t reg, uint8_t *rx_buf, uint8_t rx_len)
I2C MUX 5 I2C reading function.
I2CMUX5_SET_6DOF_IMU_9_ADDR
#define I2CMUX5_SET_6DOF_IMU_9_ADDR
I2C MUX 5 channel slave address setting.
Definition: i2cmux5.h:168
I2CMUX5_SET_6DOF_IMU_11_ADDR
#define I2CMUX5_SET_6DOF_IMU_11_ADDR
Definition: i2cmux5.h:169
application_task
void application_task(void)
Definition: main.c:76
i2cmux5_cfg_setup
void i2cmux5_cfg_setup(i2cmux5_cfg_t *cfg)
I2C MUX 5 configuration object setup function.
I2CMUX5_CH_2
#define I2CMUX5_CH_2
Definition: i2cmux5.h:191
I2CMUX5_MAP_MIKROBUS
#define I2CMUX5_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition: i2cmux5.h:222
i2cmux5_t
I2C MUX 5 Click context object.
Definition: i2cmux5.h:237
application_init
void application_init(void)
Definition: main.c:37
I2CMUX5_SET_ACCEL_10_ADDR
#define I2CMUX5_SET_ACCEL_10_ADDR
Definition: i2cmux5.h:171
I2CMUX5_CH_4
#define I2CMUX5_CH_4
Definition: i2cmux5.h:193
i2cmux5_default_cfg
void i2cmux5_default_cfg(i2cmux5_t *ctx)
I2C MUX 5 default configuration function.
i2cmux5_cfg_t
I2C MUX 5 Click configuration object.
Definition: i2cmux5.h:262
i2cmux5_init
err_t i2cmux5_init(i2cmux5_t *ctx, i2cmux5_cfg_t *cfg)
I2C MUX 5 initialization function.
I2CMUX5_CH_3
#define I2CMUX5_CH_3
Definition: i2cmux5.h:192