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 (139263 times)
  2. FAT32 Library (71752 times)
  3. Network Ethernet Library (57128 times)
  4. USB Device Library (47431 times)
  5. Network WiFi Library (43092 times)
  6. FT800 Library (42407 times)
  7. GSM click (29835 times)
  8. mikroSDK (28080 times)
  9. PID Library (26886 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

Expand 3 Click

Rating:

0

Author: MIKROE

Last Updated: 2024-10-31

Package Version: 2.1.0.4

mikroSDK Library: 2.0.0.0

Category: Port expander

Downloaded: 40 times

Not followed.

License: MIT license  

Expand 3 Click is a compact add-on board providing general-purpose I/O expansion. This board features the DS2408, an 8-channel programmable I/O expander from Analog Devices. The DS2408 has a factory-lasered 64-bit registration number, enabling multiple Expand 3 Click boards™ to be connected on the same data line, communicating with the host MCU through a standard Dallas Semiconductor 1-Wire interface (15.3kbps or 100kbps). PIO outputs are configured as open-drain and provide a maximum on-resistance of 100Ω.

No Abuse Reported

Do you want to subscribe in order to receive notifications regarding "Expand 3 Click" changes.

Do you want to unsubscribe in order to stop receiving notifications regarding "Expand 3 Click" changes.

Do you want to report abuse regarding "Expand 3 Click".

  • mikroSDK Library 1.0.0.0
  • Comments (0)

mikroSDK Library Blog


Expand 3 Click

Expand 3 Click is a compact add-on board providing general-purpose I/O expansion. This board features the DS2408, an 8-channel programmable I/O expander from Analog Devices. The DS2408 has a factory-lasered 64-bit registration number, enabling multiple Expand 3 Click boards™ to be connected on the same data line, communicating with the host MCU through a standard Dallas Semiconductor 1-Wire interface (15.3kbps or 100kbps). PIO outputs are configured as open-drain and provide a maximum on-resistance of 100Ω.

expand3_click.png

Click Product page


Click library

  • Author : Stefan Filipovic
  • Date : Feb 2024.
  • Type : One Wire type

Software Support

We provide a library for the Expand 3 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 Expand 3 Click driver.

Standard key functions :

  • expand3_cfg_setup Config Object Initialization function.

    void expand3_cfg_setup ( expand3_cfg_t *cfg );
  • expand3_init Initialization function.

    err_t expand3_init ( expand3_t *ctx, expand3_cfg_t *cfg );
  • expand3_default_cfg Click Default Configuration function.

    err_t expand3_default_cfg ( expand3_t *ctx );

Example key functions :

  • expand3_write_state This function writes data to the PIO output-latch state register which controls the open-drain output transistors of the PIO channels.

    err_t expand3_write_state ( expand3_t *ctx, uint8_t state );
  • expand3_read_last_state This function reads the latest data written to the PIO using

    err_t expand3_read_last_state ( expand3_t *ctx, uint8_t *last_state );
  • expand3_read_current_state This function reads the current logic state of the PIO pins.

    err_t expand3_read_current_state ( expand3_t *ctx, uint8_t *curr_state );

Example Description

This example demonstrates the use of Expand 3 Click board by setting and reading the port state.

The demo application is composed of two sections :

Application Init

Initializes the driver and performs the Click default configuration.


void application_init ( void )
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    expand3_cfg_t expand3_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.
    expand3_cfg_setup( &expand3_cfg );
    EXPAND3_MAP_MIKROBUS( expand3_cfg, MIKROBUS_1 );
    if ( ONE_WIRE_ERROR == expand3_init( &expand3, &expand3_cfg ) ) 
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }

    if ( EXPAND3_ERROR == expand3_default_cfg ( &expand3 ) )
    {
        log_error( &logger, " Default configuration." );
        for ( ; ; );
    }

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

Application Task

Writes a counter data to the port output pins and reads the status of the same port input pins approximately every 500ms. All data are displayed on the USB UART.

void application_task ( void )
{
    static uint8_t out_state = 0;
    static uint8_t in_state = 0;
    if ( ( EXPAND3_OK == expand3_write_state ( &expand3, out_state ) ) && 
         ( EXPAND3_OK == expand3_read_last_state ( &expand3, &out_state ) ) )
    {
        log_printf( &logger, " Output state: 0x%.2X\r\n\n", out_state++ );
    }
    if ( EXPAND3_OK == expand3_read_current_state ( &expand3, &in_state ) )
    {
        log_printf( &logger, " Input state: 0x%.2X\r\n\n", in_state );
    }
    Delay_ms ( 500 );
}

Note

The PIO pins are in the open-drain mode, therefore a pull-up resistor must be added to each pin. This Click board can be used in a combination with an EasyLED [MIKROE-571] and EasyPULL [MIKROE-575] boards.

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

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

Buck-Boost 4 Click

0

Buck-Boost 4 Click is a compact add-on board that contains a buck-boost DC/DC converter with four integrated MOSFETs. This board features the TPS55289, a buck-boost converter from Texas Instruments. It can deliver on its output voltages from 0.8 up to 22V, from the input voltage in a range of 3 up to 30V. The output voltage can be programmed in 10mV steps.

[Learn More]

Hall Current 14 Click

0

Hall Current 14 Click is a compact add-on board that contains a precise solution for AC/DC current sensing. This board features the MCS1801, a fully integrated Hall-effect-based isolated linear current sensor designed for the current range of ±25A from Monolithic Power Systems (MPS). The galvanic isolation between the pins of the primary copper conductive path and the sensor leads allows the MCS1801 to replace optoisolators or other isolation devices. Applied current flowing through this copper conduction path generates a magnetic field that the differential Hall sensors convert into a proportional voltage, where after that, the user is given the option to process the output voltage as an analog or digital value.

[Learn More]

TempHum 22 Click

0

Temp&Hum 22 Click is a compact add-on board representing temperature and humidity sensing solution. This board features the SHT41A, a 4th generation automotive-grade relative humidity and temperature sensor from Sensirion. The SHT41A is characterized by its high accuracy (±2% RH and ±0.3°C over a wide operating temperature range) and high resolution providing 16-bit data to the host controller with a configurable I2C interface. Also, it is designed for reliable operation in harsh conditions such as condensing environments.

[Learn More]