TOP Contributors

  1. MIKROE (2762 codes)
  2. Alcides Ramos (374 codes)
  3. Shawon Shahryiar (307 codes)
  4. jm_palomino (118 codes)
  5. Bugz Bensce (90 codes)
  6. S P (73 codes)
  7. dany (71 codes)
  8. MikroBUS.NET Team (35 codes)
  9. NART SCHINACKOW (34 codes)
  10. Armstrong Subero (27 codes)

Most Downloaded

  1. Timer Calculator (139248 times)
  2. FAT32 Library (71743 times)
  3. Network Ethernet Library (57115 times)
  4. USB Device Library (47428 times)
  5. Network WiFi Library (43082 times)
  6. FT800 Library (42403 times)
  7. GSM click (29835 times)
  8. mikroSDK (28073 times)
  9. PID Library (26885 times)
  10. microSD click (26198 times)
Libstock prefers package manager

Package Manager

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]

< Back
mikroSDK Library

I2C 1-Wire 2 Click

Rating:

0

Author: MIKROE

Last Updated: 2024-10-31

Package Version: 2.1.0.4

mikroSDK Library: 2.0.0.0

Category: 1-Wire

Downloaded: 74 times

Not followed.

License: MIT license  

I2C 1-Wire 2 Click is a compact add-on board bridging I2C master interfaces with 1-Wire slave devices, ideal for simplifying complex communication protocols. This board features the DS2485, an advanced 1-Wire master with memory from Analog Devices. It features adjustable internal timers for precise 1-Wire signal management, relieving the host processor of timing-sensitive operations, and supports standard and overdrive communication speeds.

No Abuse Reported

Do you want to subscribe in order to receive notifications regarding "I2C 1-Wire 2 Click" changes.

Do you want to unsubscribe in order to stop receiving notifications regarding "I2C 1-Wire 2 Click" changes.

Do you want to report abuse regarding "I2C 1-Wire 2 Click".

  • Information
  • Comments (0)

mikroSDK Library Blog


I2C 1-Wire 2 Click

I2C 1-Wire 2 Click is a compact add-on board bridging I2C master interfaces with 1-Wire slave devices, ideal for simplifying complex communication protocols. This board features the DS2485, an advanced 1-Wire master with memory from Analog Devices. It features adjustable internal timers for precise 1-Wire signal management, relieving the host processor of timing-sensitive operations, and supports standard and overdrive communication speeds.

i2c1wire2_click.png

Click Product page


Click library

  • Author : Stefan Ilic
  • Date : Dec 2023.
  • Type : I2C type

Software Support

We provide a library for the I2C 1-Wire 2 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 I2C 1-Wire 2 Click driver.

Standard key functions :

  • i2c1wire2_cfg_setup Config Object Initialization function.

    void i2c1wire2_cfg_setup ( i2c1wire2_cfg_t *cfg );
  • i2c1wire2_init Initialization function.

    err_t i2c1wire2_init ( i2c1wire2_t *ctx, i2c1wire2_cfg_t *cfg );
  • i2c1wire2_default_cfg Click Default Configuration function.

    err_t i2c1wire2_default_cfg ( i2c1wire2_t *ctx );

Example key functions :

  • i2c1wire2_master_reset This function is used to reset device, and return all configuration registers to the default values.

    err_t i2c1wire2_master_reset ( i2c1wire2_t *ctx );
  • i2c1wire2_write_port_cfg This function is used to write a 1-Wire configuration register.

    err_t i2c1wire2_write_port_cfg ( i2c1wire2_t *ctx, uint8_t reg, uint8_t *data_in );
  • i2c1wire2_search This function is used to perform 1-Wire Search algorithm and return one device ROMID.

    err_t i2c1wire2_search ( i2c1wire2_t *ctx, uint8_t *flag, uint8_t *rom_id, uint8_t *last_flag, uint8_t param_data, uint8_t command_code );

Example Description

This example demonstrates the use of the I2C 1-Wire 2 Click board by searching if a device is connected and reading its ROMID.

The demo application is composed of two sections :

Application Init

Initialization of I2C module, log UART and perform Click default configuration.


void application_init ( void ) 
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    i2c1wire2_cfg_t i2c1wire2_cfg;  /**< Click config object. */

    /** 
     * Logger initialization.
     * Default baud rate: 115200
     * Default log level: LOG_LEVEL_DEBUG
     * @note If USB_UART_RX and USB_UART_TX 
     * are defined as HAL_PIN_NC, you will 
     * need to define them manually for log to work. 
     * See @b LOG_MAP_USB_UART macro definition for detailed explanation.
     */
    LOG_MAP_USB_UART( log_cfg );
    log_init( &logger, &log_cfg );
    log_info( &logger, " Application Init " );

    // Click initialization.
    i2c1wire2_cfg_setup( &i2c1wire2_cfg );
    I2C1WIRE2_MAP_MIKROBUS( i2c1wire2_cfg, MIKROBUS_1 );
    if ( I2C_MASTER_ERROR == i2c1wire2_init( &i2c1wire2, &i2c1wire2_cfg ) ) 
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }

    if ( I2C1WIRE2_ERROR == i2c1wire2_default_cfg ( &i2c1wire2 ) )
    {
        log_error( &logger, " Default configuration." );
        for ( ; ; );
    }

    log_info( &logger, " Application Task " );
}

Application Task

Performing 1-Wire Search algorithm to find if any device is connected. If a device is connected and detected, its ROMID will be read and displayed.

void application_task ( void ) 
{
    err_t error_flag;
    uint8_t flag;
    uint8_t last_flag;
    uint8_t rom_id[ 8 ] = { 0 };
    #define I2C1WIRE2_DEVICE_SEARCH_CODE            0xF0

    error_flag = i2c1wire2_search ( &i2c1wire2, &flag, rom_id, &last_flag, I2C1WIRE2_SEARCH_RESET | 
                                    I2C1WIRE2_SEARCH_1WIRE_RESET, I2C1WIRE2_DEVICE_SEARCH_CODE );
    if ( I2C1WIRE2_OK == error_flag )
    {   
        if ( I2C1WIRE2_RESULT_BYTE_OK == flag )
        {
            log_printf( &logger, " Device found: \r\n" );
            log_printf( &logger, " Device ROMID: 0x" );
            for ( uint8_t n_cnt = 0; n_cnt < 8; n_cnt++ )
            {
                log_printf( &logger, "%.2X", ( uint16_t ) rom_id[ n_cnt ] );
            }
            log_printf( &logger, " \r\n" );
            log_printf( &logger, " Last device flag %d \r\n", last_flag );
        }
        else if ( I2C1WIRE2_NO_DEVICE_DETECTED == flag )
        {
            log_printf( &logger, " No device detected \r\n" );
        }
        else if ( I2C1WIRE2_NO_PRESENCE_PULS == flag )
        {
            log_printf( &logger, " No presence puls \r\n" );
        }
    }
    else 
    {
        log_printf( &logger, " ERROR \r\n" );
    }
    Delay_ms ( 1000 );
}

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.I2C1Wire2

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.


ALSO FROM THIS AUTHOR

GNSS 2 Click

5

GNSS2 click carries Quectel’s L76 module and an SMA antenna connector. L76 can acquire both GPS and GLONASS signals.

[Learn More]

DAC 19 Click

0

DAC 19 Click is a compact add-on board designed for high-performance voltage-output applications. This board features the DAC53701-Q1, a 10-bit automotive-grade DAC from Texas Instruments, offering smart functionality through force-sense output, GPI function trigger, PWM output, and integrated nonvolatile memory (NVM). The board supports an internal or power supply reference, provides a full-scale output range, and communicates efficiently with microcontrollers using an I2C interface with up to 1MHz clock speed.

[Learn More]

DIGI IN 2 Click

0

DIGI IN 2 Click is a compact add-on board designed for converting high-voltage industrial signals into logic-level outputs, ideal for enhancing industrial control systems. This board features the MAX22196, a high-performance octal industrial sink/source digital input IC from Analog Devices. This Click board™ stands out for its ability to interface eight industrial inputs (8V-24V) via SPI, configurable as either sinking or sourcing with built-in current limiters, ensuring adherence to IEC 61131-2 standards.

[Learn More]