TOP Contributors

  1. MIKROE (2658 codes)
  2. Alcides Ramos (355 codes)
  3. Shawon Shahryiar (307 codes)
  4. jm_palomino (112 codes)
  5. Chisanga Mumba (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 (136920 times)
  2. FAT32 Library (70042 times)
  3. Network Ethernet Library (56011 times)
  4. USB Device Library (46310 times)
  5. Network WiFi Library (41935 times)
  6. FT800 Library (41240 times)
  7. GSM click (29026 times)
  8. PID Library (26435 times)
  9. mikroSDK (26411 times)
  10. microSD click (25389 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 click

Rating:

0

Author: MIKROE

Last Updated: 2024-04-03

Package Version: 2.1.0.12

mikroSDK Library: 2.0.0.0

Category: 1-Wire

Downloaded: 191 times

Not followed.

License: MIT license  

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.

No Abuse Reported

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

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

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

  • mikroSDK Library 1.0.0.0
  • Comments (0)

mikroSDK Library Blog


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.

i2c1wire_click.png

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 :

  • i2c1wire_cfg_setup Config Object Initialization function.

    void i2c1wire_cfg_setup ( i2c1wire_cfg_t *cfg ); 
  • i2c1wire_init Initialization function.

    err_t i2c1wire_init ( i2c1wire_t *ctx, i2c1wire_cfg_t *cfg );

Example key functions :

  • i2c1wire_write_byte_one_wire This function writes one byte to the click module.

    void i2c1wire_write_byte_one_wire ( i2c1wire_t *ctx, uint8_t input );
  • i2c1wire_read_byte_one_wire This function reads one byte from the click module.

    uint8_t i2c1wire_read_byte_one_wire ( i2c1wire_t *ctx );
  • i2c1wire_one_wire_reset This function does a hardware reset of the click module.

    void i2c1wire_one_wire_reset ( i2c1wire_t *ctx );

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;
    i2c1wire_cfg_t cfg;

    /** 
     * 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.
    i2c1wire_cfg_setup( &cfg );
    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( );
    i2c1wire_set_config( &i2c1wire, I2C1WIRE_CONFIG_1WS_HIGH |
                                    I2C1WIRE_CONFIG_SPU_HIGH |
                                    I2C1WIRE_CONFIG_APU_LOW );
    Delay_10ms( );

    for ( cnt_chan = 0; cnt_chan < 8; cnt_chan++ )
    {
        i2c1wire_set_channel( &i2c1wire, cnt_chan );
        i2c1wire_one_wire_reset( &i2c1wire );
        Delay_10ms( );

        i2c1wire_write_byte_one_wire( &i2c1wire, I2C1WIRE_WIRE_COMMAND_READ_ROM );
        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.


ALSO FROM THIS AUTHOR

I2C Isolator 6 click

0

I2C Isolator 6 Click is a compact add-on board that offers completely isolated bidirectional communication. This board features the ADUM2250, a two-channel, 5kVRMS I2C digital isolator from Analog Devices. The ADUM2250 provides two bidirectional channels, supporting a completely isolated I2C interface that eliminates the need for splitting I2C signals into separate transmit and receive signals for use with standalone optocouplers. It supports data rates from DC up to 1MHz and has a hot swap circuitry to prevent data glitches.

[Learn More]

Matrix R click

0

Matrix R click is a mikroBUS add-on board with two red 5x7 matrices driven by two MAX7219 8-bit LED Display Drivers. The active area of each matrix is 7.62mm high and 5.08 mm wide. 7x5 is a standard resolution for displaying ASCII characters, so the click is essentially a dual-character display capable of showing letters in more readable typefaces compared to a 14-segment display. The click communicates with the target MCU through the mikroBUS:tm: SPI interface with two separate Chip Select lines for each matrix (CSL for the left, CSR for the right). This board is designed to use a 5V power supply.

[Learn More]

DRAM click

0

DRAM Click is a compact add-on board representing a dynamic random-access memory solution. This board features the APS6404L-3SQR, 64Mb high-performance SPI/QPI PSRAM memory organized as 8M x 8 bits each from AP Memory. This Pseudo-SRAM device features a high speed, low pin count interface and incorporates a seamless self-managed refresh mechanism to maximize the performance of memory read operation. It has 4 SDR I/O pins and operates in SPI or QPI (quad peripheral interface) mode with frequencies up to 133 MHz.

[Learn More]