i2c1wire  2.0.0.0
Main Page

I2C 1 Wire click

I2C 1-Wire click carries DS2482-800, a bridge device that performs bidirectional conversions between I2C masters and 1-Wire slave devices. These can be EEPROM chips, temperature sensors and similar devices that have momentary high source current modes.

click Product page


Click library

  • Author : MikroE Team
  • Date : May 2020.
  • Type : I2C type

Software Support

We provide a library for the I2C1Wire 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 form compilers IDE(recommended way), or downloaded from our LibStock, or found on mikroE github account.

Library Description

This library contains API for I2C1Wire Click driver.

Standard key functions :

Example key functions :

Examples Description

This example showcases how to initialize, confiure and use the I2C 1-Wire click. The click

is a I2C (host) to 1-Wire interface (slave). In order for the example to work one or more 1-Wire (GPIO) click modules are required. Gnd goes to gnd, power goes to power and the cha- nnels are there to read data from connected modules.

The demo application is composed of two sections :

Application Init

This function initializes and configures the logger and click modules.

void application_init ( void )
{
log_cfg_t log_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, "---- Application Init ----" );
// Click initialization.
I2C1WIRE_MAP_MIKROBUS( cfg, MIKROBUS_1 );
i2c1wire_init( &i2c1wire, &cfg );
Delay_1sec( );
}

Application Task

This function reads all of the channels on the click module and displays any data it acqu-

ires from them with a 100 millisecond delay.

void application_task ( void )
{
uint8_t chan_state = 0;
uint8_t cnt_chan = 0;
uint8_t cnt_val = 0;
uint8_t id_code[ 9 ] = { 0 };
chan_state = 1;
i2c1wire_soft_reset( &i2c1wire );
Delay_10ms( );
Delay_10ms( );
for ( cnt_chan = 0; cnt_chan < 8; cnt_chan++ )
{
i2c1wire_set_channel( &i2c1wire, cnt_chan );
Delay_10ms( );
Delay_10ms();
for ( cnt_val = 8; cnt_val > 0; cnt_val-- )
{
id_code[ cnt_val ] = i2c1wire_read_byte_one_wire( &i2c1wire );
if ( id_code[ cnt_val ] == I2C1WIRE_WIRE_RESULT_OK )
{
log_printf( &logger, "\r\n Channel %d : No device on the channel\r\n", ( uint16_t ) cnt_chan );
Delay_100ms( );
break;
}
else if ( chan_state )
{
log_printf( &logger, " Channel %d : ID = 0x", ( uint16_t ) cnt_chan );
chan_state = 0;
}
log_printf( &logger, "%d", ( uint16_t ) id_code[ cnt_val ] );
Delay_10ms( );
}
log_printf( &logger, "\r\n---------------------------------------\r\n" );
}
log_printf( &logger, "***\r\n" );
}

The full application code, and ready to use projects can be installed directly form compilers IDE(recommneded) or found on LibStock page or mikroE GitHub accaunt.

Other mikroE Libraries used in the example:

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.I2C1Wire

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.


application_init
void application_init()
Definition: main.c:37
I2C1WIRE_WIRE_COMMAND_READ_ROM
#define I2C1WIRE_WIRE_COMMAND_READ_ROM
Definition: i2c1wire.h:109
I2C1WIRE_CONFIG_SPU_HIGH
#define I2C1WIRE_CONFIG_SPU_HIGH
Definition: i2c1wire.h:97
i2c1wire_set_channel
uint8_t i2c1wire_set_channel(i2c1wire_t *ctx, uint8_t chan)
Set channel function.
i2c1wire_cfg_setup
void i2c1wire_cfg_setup(i2c1wire_cfg_t *cfg)
Config Object Initialization function.
i2c1wire_one_wire_reset
void i2c1wire_one_wire_reset(i2c1wire_t *ctx)
Reset function.
i2c1wire_cfg_t
Click configuration structure definition.
Definition: i2c1wire.h:157
i2c1wire_soft_reset
void i2c1wire_soft_reset(i2c1wire_t *ctx)
Software reset function.
I2C1WIRE_WIRE_RESULT_OK
#define I2C1WIRE_WIRE_RESULT_OK
Definition: i2c1wire.h:71
i2c1wire_t
Click ctx object definition.
Definition: i2c1wire.h:144
i2c1wire_write_byte_one_wire
void i2c1wire_write_byte_one_wire(i2c1wire_t *ctx, uint8_t input)
Write byte function.
i2c1wire_read_byte_one_wire
uint8_t i2c1wire_read_byte_one_wire(i2c1wire_t *ctx)
Read byte function.
application_task
void application_task()
Definition: main.c:62
I2C1WIRE_MAP_MIKROBUS
#define I2C1WIRE_MAP_MIKROBUS(cfg, mikrobus)
Definition: i2c1wire.h:52
i2c1wire_set_config
uint8_t i2c1wire_set_config(i2c1wire_t *ctx, uint8_t cfg)
Set configuration function.
i2c1wire_init
err_t i2c1wire_init(i2c1wire_t *ctx, i2c1wire_cfg_t *cfg)
Initialization function.
I2C1WIRE_CONFIG_1WS_HIGH
#define I2C1WIRE_CONFIG_1WS_HIGH
Definition: i2c1wire.h:99
I2C1WIRE_CONFIG_APU_LOW
#define I2C1WIRE_CONFIG_APU_LOW
Definition: i2c1wire.h:96